示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     rb   = GetComponent <Rigidbody>();
     anim = gameObject.GetComponentInChildren <Animator>();
     //Fills the camScript variable with the script attached to the camera game object.
     camScript = currentCam.GetComponent <PlayerCam>();
 }
示例#2
0
    /// <summary>
    /// Handles the player's firing logic and setting raycasts.
    /// </summary>
    protected void Fire()
    {
        if (_reloading)
        {
            return;
        }

        waitTime = Time.time + _attackTime;

        RaycastHit hitInfo;

        // Sets the middle of the players view as our start point
        Vector3 rayStart = PlayerCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0));

        Debug.DrawRay(rayStart, PlayerCam.transform.forward * 5000f, Color.red);

        if (Physics.Raycast(rayStart, PlayerCam.transform.forward, out hitInfo, 5000f))
        {
            Transform go = hitInfo.transform;

            if (go.tag.Equals("Enemy"))
            {
                go.GetComponent <PhotonView>().RPC("TakeDamage", PhotonTargets.MasterClient, _damage);
            }
        }

        numberOfBulletsInGun--;
        UpdateGunAmmo();

        // Plays the muzzle flash
        _muzzleFlash.Play();

        // Plays the weapon sound
        _weaponSound.PlayShotSound();
    }
示例#3
0
    //public bool reloaded = true;
    public override void Shoot()
    {
        if (reloaded == true)
        {
            ShotAudio.Play();
            LazerBeam.enabled = true;
            Ray ray = PlayerCam.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2) /*new Vector3(0.5f, 0, 0.5f)*/);
            //ray.origin = PlayerCam.transform.position;
            LazerBeam.SetPosition(0, Vector3.zero);
            Invoke(nameof(LazerOff), 0.2f);
            Invoke(nameof(Reload), 2.5f);
            reloaded = false;

            if (Physics.Raycast(ray, out RaycastHit hit))
            {
                LazerBeam.SetPosition(1, transform.InverseTransformPoint(hit.point));
                PlayerScript.DrawShotLine(1, hit.point);
                if (hit.collider.gameObject.GetComponent <PlayerController>() != null)
                {
                    hit.collider.gameObject.GetComponent <PlayerController>().TakeDamage(damage);
                    //PlayerScript.TakeDamage();
                }
                Debug.Log("We hit" + hit.collider.name);
            }
            else
            {
                LazerBeam.SetPosition(1, new Vector3(580, -4547, 40));
                PlayerScript.DrawShotLine(1, new Vector3(580, -4547, 40));
            }
        }
    }
    void Update()
    {
        if (!PlayerLook.instance.isDisabled)
        {
            PlayerCam cachedPCamInstance = PlayerCam.instance;
            if (cachedPCamInstance && cachedPCamInstance.cam && Input.GetMouseButtonDown(0))
            {
                if (Physics.Raycast(
                        cachedPCamInstance.cam.transform.position,
                        cachedPCamInstance.cam.transform.forward,
                        out RaycastHit hit,
                        range,
                        itemMask
                        ))
                {
                    if (hit.transform.gameObject.GetComponent <Interactable>())
                    {
                        hit.transform.gameObject.GetComponent <Interactable>().Interact();
                    }
                }
            }

            //if (Physics.Raycast(
            //        cachedPCamInstance.cam.transform.position,
            //        cachedPCamInstance.cam.transform.forward,
            //        out RaycastHit hit2,
            //        range,
            //        itemMask
            //    ))
            //{
            //    hit2.transform.gameObject.GetComponent<Renderer>().material.SetFloat("_SecondOutlineWidth", hit2.transform.gameObject.GetComponent<Interactable>().hoveringOutlineWidth);
            //}
        }
    }
示例#5
0
    // Use this for initialization
    void Start()
    {
        m_HitManger.OnHitAction += PlayerHitAction;
        m_HitManger.OnDragAction += FixPlayerCam;
        m_MoveManger.OnMove += PlayerMove;

        mLocalPlayer = UIManager.LocalPlayer;

        mLocalPlayerCam = UIManager.LocalPlayerCam;
    }
示例#6
0
    public void Exit()
    {
        gameObject.SetActive(false);
        ButtonsAnimator.SetTrigger("Close");
        minimap.SetActive(true);
        Movement.isPaused = false;

        PlayerCam.SetActive(true);
        ShopCam.SetActive(false);

        ShopCam.GetComponent <CinemachineVirtualCamera>().LookAt = null;
    }
示例#7
0
    public void Activate()
    {
        gameObject.SetActive(true);
        minimap.SetActive(false);
        ButtonsAnimator.SetTrigger("Open");

        ShopCam.SetActive(true);
        PlayerCam = GameObject.Find("Player").transform.GetChild(6).gameObject;
        PlayerCam.SetActive(false);

        ShopCam.GetComponent <CinemachineVirtualCamera>().LookAt = Merchant.transform;

        Movement.isPaused = true;
    }
    // Use this for initialization
    void Start()
    {
        firstPersonCam = transform.Find("FirstPersonCharacter");
        thirdPersonCam = transform.Find("ThirdPersonCharacter");

        thirdPerson = thirdPersonCam.GetComponent<Camera>();
        firstPerson = firstPersonCam.GetComponent<Camera>();

        firstPersonAudio = firstPersonCam.GetComponent<AudioListener>();
        thirdPersonAudio = thirdPersonCam.GetComponent<AudioListener>();

        firstPersonCameraScript = firstPersonCam.GetComponent<PlayerCam>();
        thirdPersonCameraScript = thirdPersonCam.GetComponent<PlayerCam>();
    }
示例#9
0
    public override void OnStartLocalPlayer()
    {
        enabled = isLocalPlayer;

        Debug.LogFormat(name + " : " + isLocalPlayer);

        if (isLocalPlayer)
        {
            mPlayerCam = PlayerCam.Instance;
            mPlayerCam.SetTarget(RoleFixedPoint.BodyTs);

            UIManager.Instance.SetLocalPlayer(mPlayerController, mPlayerCam);
            /*
            mPlayerController.uiSet();
            mPlayerController.Listencontroll = true;
            */

            //GameManager.SetLocalPlayer(gameObject, netId);

            //GameManager.SetLocalParam(netId);
        }
    }
示例#10
0
 public override void Shoot()
 {
     if (reloaded == true && Time.time >= nextfire)
     {
         if (WorkingParticleSystem == false)
         {
             flash.Play();
             WorkingParticleSystem = true;
             PlayerScript.ShowMachineGunShooting(true);
         }
         ShotAudio.Play();
         nextfire = Time.time + 1f / fireRate;
         RaycastHit hit;
         if (Physics.Raycast(PlayerCam.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2)), out hit))
         {
             if (hit.collider.gameObject.GetComponent <PlayerController>() != null)
             {
                 hit.collider.gameObject.GetComponent <PlayerController>().TakeDamage(damage);
             }
             Debug.Log("We hit" + hit.collider.name);
         }
     }
 }
示例#11
0
 void Awake()
 {
     mInstance = this;
     mTs = transform;
 }
示例#12
0
	void Start ()
    {
        cam = transform.FindChild("Camera").GetComponent<Camera>();
        playerCam = GameObject.FindWithTag("Player").GetComponent<PlayerCam>();
    }
示例#13
0
 public void SetLocalPlayer(PlayerController player, PlayerCam cam)
 {
     mLocalPlayerControler = player;
     mLocalPlayerCam = cam;
 }
 public void UpdateSens(float val)
 {
     PlayerPrefs.SetFloat("sens", val);
     PlayerCam.SetSensitivity(val);
 }
示例#15
0
 private void Awake()
 {
     instance = this;
 }
示例#16
0
 void Awake()
 {
     instance = this;
 }
示例#17
0
 void Awake()
 {
     _player = GetComponent <Player>();
     _cam    = GetComponent <PlayerCam>();
 }
示例#18
0
 void OnDestroy()
 {
     mInstance = null;
 }
示例#19
0
 // Use this for initialization
 void Awake()
 {
     _cam         = cam.GetComponent <PlayerCam>();
     cc           = GetComponent <CharacterController>();
     currentSpeed = 7;
 }
示例#20
0
 private void Start()
 {
     playCamTf = GameObject.Find("Main Camera").GetComponent <Transform>();
     playCam   = playCamTf.GetComponent <PlayerCam>();
 }