예제 #1
0
        public override IEnumerator Activate()
        {
            if (!CanCast())
            {
                yield break;
            }

            IsActive = true;

            Vector3?        clickLocation   = null;
            MouseController mouseController = GameObject.Find("GameManager").GetComponent <MouseController>();

            yield return(_playerMono.StartCoroutine(mouseController.WaitForMouseClickLocation((_clickLocation) => clickLocation = _clickLocation)));

            if (clickLocation.HasValue)
            {
                float height = 1f;
                // Spawn in front
                Vector3 spawnLocation = _player.transform.position + _player.transform.forward;
                spawnLocation.y += height;
                GameObject projectile = PhotonNetwork.Instantiate("ReviveProjectile", spawnLocation, _player.transform.rotation);
                Vector3    target     = clickLocation.Value;
                // Allow projectile to go up slopes
                target.y += height;
                projectile.GetComponent <ReviveProjectile.ReviveProjectile>().TurnTowardPosition(target);
                SpendAbilityCharge();
            }

            IsActive = false;
        }