Пример #1
0
        private IEnumerator SpawnProjectilesCoroutine(SpriteAnimationBehaviour animated, SpriteFrame frame, bool isHoming)
        {
            BaseActor actor = animated.GetComponent <BaseActor>();
            int       c     = timeouts != null ? timeouts.Length : 0;

            for (int i = 0; i < count; i++)
            {
                float timeout = 0f;

                if (i == 0)
                {
                    if (soundOnFirstProjectile != null)
                    {
                        var src = animated.GetComponent <AudioSource>();
                        if (src != null)
                        {
                            src.pitch = Engine.RandomFloat(0.9f, 1.1f);
                            src.PlayOneShot(soundOnFirstProjectile);
                            src.pitch = 1.0f;
                        }
                    }
                }

                if (c != 0)
                {
                    timeout = timeouts[i % c];
                }

                bool isActor = prefab.GetComponent <BaseActor>();


                if (timeout > 0f)
                {
                    yield return(new WaitForSeconds(timeout));
                }

                Vector3 pos = animated.transform.position + (Vector3)actor.TransformDirection(offset);

                if (isActor)
                {
                    var go = Instantiate(prefab, pos, Quaternion.identity);
                    var ac = go.GetComponent <BaseActor>();
                    ac.Move(actor.movementDirection);
                    ac.transform.right = Vector3.right;
                }
                else if (isHoming)
                {
                    HomingProjectileBehaviour.Fire(prefab, animated.gameObject, pos, actor.movementDirection, Mathf.FloorToInt(frame.damage.value * actor.GetDamageDealt()), animated.GetComponent <AI.DefaultEnemyAI>().Target.transform);
                }
                else
                {
                    ProjectileBehaviour.Fire(prefab, animated.gameObject, pos, actor.movementDirection, Mathf.FloorToInt(frame.damage.value * actor.GetDamageDealt()));
                }
            }
        }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Q))
     {
         // fire projectile
         if (!pB.IsFiring())
         {
             print("Fire");
             pB.Fire(Camera.main.ScreenToWorldPoint(Input.mousePosition));
         }
     }
 }
Пример #3
0
 protected void FireAtTarget(Transform _target, float _damage)
 {
     if (_target && !GameManager.GameEnded)
     {
         if (Team.BLUE_TEAM == _target.gameObject.GetComponent <Info>().team)
         {
             weapon.transform.LookAt(_target, _target.up);
         }
         p = (Instantiate(projectile, weapon.transform.position, weapon.transform.rotation) as
              GameObject).GetComponent <ProjectileBehaviour>();
         p.speed  = 120.0f;
         p.damage = _damage;
         p.target = _target;
         p.Fire();
     }
 }
Пример #4
0
    protected override void AbilityActivate()
    {
        base.AbilityActivate();
        originalSpeed = targNm.speed;
        targNm.speed  = 0.0f;
        activeIcon    = Instantiate(Icon, target.transform.position, target.transform.rotation) as
                        GameObject;
        activeIconSpriteRenderer         = activeIcon.GetComponent <SpriteRenderer>();
        activeIcon.transform.parent      = target.transform;
        activeIconSpriteRenderer.enabled = true;
        ProjectileBehaviour p = (Instantiate(projectile, arrowSpawn.transform.position, arrowSpawn
                                             .transform.rotation) as GameObject).GetComponent <ProjectileBehaviour>();

        p.speed  = speed;
        p.damage = damage;
        p.target = hit.transform;
        p.Fire();
    }
Пример #5
0
 private void Fire()
 {
     if (Physics.SphereCast(new Ray(transform.position, transform.forward), 5.0f, out hit,
                            range, 9, QueryTriggerInteraction.Collide))
     {
         if (hit.collider.GetComponent <Info>() && hit.collider.GetComponent <Info>().team !=
             heroInfo.team)
         {
             ProjectileBehaviour p = (Instantiate(projectile, arrowSpawn.transform.position,
                                                  arrowSpawn.transform.rotation) as GameObject).GetComponent <ProjectileBehaviour
                                                                                                              >();
             p.speed  = speed;
             p.damage = heroInfo.Damage + abilityAdditionalDamage;
             p.target = hit.transform;
             p.Fire();
             TryCast();
         }
     }
 }
    private void FixedUpdate()
    {
        for (int i = 0; i < enemyGOs.Count; i++)
        {
            if (enemyGOs[i] == null)
            {
                enemyGOs.Remove(enemyGOs[i]);
            }
        }
        for (int i = 0; i < enemies.Count; i++)
        {
            if (enemies[i] == null)
            {
                enemies.Remove(enemies[i]);
            }
        }

        if (/*enemyGOs[0] != null &&*/ enemyGOs.Count != 0)
        {
            RotateToTarget(enemyGOs[0].transform.position);


            utility.Attack(turretBehaviour, enemies[0]);
            projectileBehaviour.Fire(enemyGOs[0].transform.position);
            if (enemies[0].currentHealth <= 0)
            {
                currentExperience = currentExperience + enemies[0].experience;

                if (currentExperience >= maxExperience)
                {
                    LevelUp(enemies[0].experience);
                }

                killCount++;
                enemies.Remove(enemies[0]);
                enemyGOs.Remove(enemyGOs[0]);
            }
        }
    }