2017-09-13 12:40:42 -05:00
|
|
|
|
using UnityEngine;
|
2017-09-13 17:29:22 -05:00
|
|
|
|
using System.Collections;
|
2017-09-13 12:40:42 -05:00
|
|
|
|
|
|
|
|
|
public class PlayerController : MonoBehaviour
|
|
|
|
|
{
|
2017-09-13 17:29:22 -05:00
|
|
|
|
public GameObject particle;
|
2017-09-21 04:59:13 -05:00
|
|
|
|
public GameObject cameraRigPrefab;
|
|
|
|
|
private GameObject cameraRig;
|
|
|
|
|
public Transform cameraTarget;
|
|
|
|
|
private Vector3 target;
|
|
|
|
|
private Spy spy;
|
|
|
|
|
private int mask;
|
2017-09-13 17:29:22 -05:00
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2017-09-21 04:59:13 -05:00
|
|
|
|
int layerMask = LayerMask.NameToLayer("Floor");
|
|
|
|
|
mask = 1 << layerMask;
|
|
|
|
|
spy = GetComponent<Spy>();
|
|
|
|
|
cameraRig = Instantiate(cameraRigPrefab, Vector3.zero, Quaternion.identity);
|
|
|
|
|
cameraRig.GetComponentInChildren<ThirdPersonCameraController>().SetTarget(cameraTarget);
|
2017-09-13 17:29:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-13 12:40:42 -05:00
|
|
|
|
void Update()
|
|
|
|
|
{
|
2017-09-13 17:29:22 -05:00
|
|
|
|
RaycastHit hit;
|
|
|
|
|
if (Input.GetButtonDown("Fire1")) {
|
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
2017-09-21 04:59:13 -05:00
|
|
|
|
|
|
|
|
|
if (Physics.Raycast(ray, out hit, 100.0f, mask)) {
|
2017-09-13 17:29:22 -05:00
|
|
|
|
Vector3 wantedPos = hit.point;
|
2017-09-21 04:59:13 -05:00
|
|
|
|
Instantiate(particle, wantedPos, Quaternion.Euler(-90,0,0));
|
|
|
|
|
wantedPos.y = 0.5f;
|
|
|
|
|
spy.UpdateTarget(wantedPos);
|
2017-09-13 17:29:22 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-21 04:59:13 -05:00
|
|
|
|
|
|
|
|
|
if (Input.GetKeyDown("space"))
|
|
|
|
|
{
|
|
|
|
|
spy.HandShake();
|
|
|
|
|
}
|
2017-09-13 12:40:42 -05:00
|
|
|
|
}
|
|
|
|
|
}
|