コード例 #1
0
 protected virtual void OnAttack()
 {
     if (OnAttackEvent != null)
     {
         OnAttackEvent.Invoke();
     }
 }
コード例 #2
0
    /// <summary>
    /// Attacks Player (if he is in PolygonCollider range)
    /// Killes player if he is also inside distance
    /// </summary>
    /// <returns></returns>
    IEnumerator Attack()
    {
        if (_state != States.Attack)
        {
            if (_toAttack.Count > 0)
            {
                _state              = States.Attack;
                Behaviour.enabled   = false;
                FaceForward.enabled = false;
                yield return(_waitCheckAttack);

                float distance = Vector3.Distance(Behaviour.target.transform.position, transform.position);
                if (distance > AttackDistance)
                {
                    foreach (Transform t in _toAttack)
                    {
                        Entity e = t.GetComponent <Entity>();
                        if (e)
                        {
                            e.ApplyDamage(1);
                            Debug.Log("Attacked " + e);
                        }
                    }
                    Debug.Log("Attacked");
                }
                OnAttackEvent.Invoke();

                yield return(_waitAttack);
            }
            yield return(Pursue());
        }
        yield break;
    }
コード例 #3
0
ファイル: EnemyShooter.cs プロジェクト: qipa/NordeusGameJam
    IEnumerator Shot()
    {
        OnAttackEvent.Invoke();
        yield return(_waitDelay);

        yield return(Shot());
    }
コード例 #4
0
        public void Attack()
        {
            OnAttackEvent?.Invoke();
            ProjectileBase arrow = Instantiate(arrowPrefab);

            arrow.Reset();
            arrow.transform.localEulerAngles = projectileRotation[(int)facing];
            Vector2 dir;

            switch (facing)
            {
            case Facing.Front:
                dir = Vector2.down;
                break;

            case Facing.Back:
                dir = Vector2.up;
                break;

            case Facing.Left:
                dir = Vector2.left;
                break;

            case Facing.Right:
                dir = Vector2.right;
                break;

            default:
                dir = Vector2.down;
                break;
            }

            arrow.Launch(dir, attackPoint.position);
        }
コード例 #5
0
 void Awake()
 {
     m_Instance = this;
     OnDamaged  = new OnDamageEvent();
     OnAttack   = new OnAttackEvent();
     OnDeath    = new UnityEvent();
     DoAction   = DoActionNormal;
 }
コード例 #6
0
ファイル: UnitModel.cs プロジェクト: defacto2k15/PolySpear
 public void OnAttack() => OnAttackEvent?.Invoke();
コード例 #7
0
 private void ShootAnimation(bool playAnim)
 {
     // Method that controls the shooting animation.
     OnAttackEvent.Invoke(playAnim);
 }