コード例 #1
0
        protected virtual void Shoot()
        {
            if (_numberOfShoots < 1)
            {
                Instantiate(soundEffect);
                GetComponentInParent <Character>().MovementState.ChangeState(CharacterStates.MovementStates.Attacking);
                StartCoroutine("endAnimation");

                Vector3 target = new Vector3(_brain.Target.position.x + UnityEngine.Random.Range(-1f, 1f), _brain.Target.position.y + UnityEngine.Random.Range(-1f, 1f), _brain.Target.position.z);
                Instantiate(aoeProjectile, target, Quaternion.identity, StaticManager.ObjectPool.transform);
                StaticManager.addObjectToPool();
                _numberOfShoots++;
            }
        }
コード例 #2
0
        public virtual IEnumerator waitBeforeShooting(float x)
        {
            yield return(new WaitForSecondsRealtime(x));

            //play animation
            GetComponentInParent <Character>().MovementState.ChangeState(CharacterStates.MovementStates.Attacking);
            StartCoroutine("endAnimation");

            explosions      = 0;
            currentLocation = transform.position;


            float mult = (10 / (_brain.Target.position - currentLocation).magnitude);

            targetLocation = currentLocation + (_brain.Target.position - currentLocation) * mult;

            distanceBetweenExplosions = (targetLocation - transform.position) / totalExplosions;
            StartCoroutine("chainExplosion");

            StaticManager.addObjectToPool();
        }