コード例 #1
0
ファイル: Combat.cs プロジェクト: R1G/War-Is-Heck
    void Update()
    {
        // Can only attack when the timer is greater than attack speed, hence;
        // Greater attack speed value actually means more time between attacks
        attackTimer += 0.5f * Time.deltaTime;

        // If there is no target to attack, then find a target in range
        if (target == null)
        {
            SetTarget(tc.AcquireTarget());
            // Else if there is a target, attack if in range or move to it if not in range
        }
        else
        {
            if (ProgUtils.InRange(gameObject, target, attackRange))
            {
                if (ProgUtils.InLineOfSight(gameObject, target))
                {
                    tc.Stop();
                    Attack();
                }
                else if (tc.IsStopped())
                {
                    tc.Move(target.transform.position);
                }
            }
            else
            {
                tc.Move(ProgUtils.GetNearestWithinRange(gameObject, target, attackRange - 2f));
            }
        }
    }
コード例 #2
0
 //Delegated helper function for MoveTroops
 static void MoveTroop(TroopClass troop)
 {
     if (target == null)
     {
         troop.ClearCombatTarget();
     }
     troop.Move(pointSelected);
 }
コード例 #3
0
 //Delegated helper function for MoveTroops
 void MoveTroop(TroopClass troop)
 {
     troop.Move(pointSelected, true);
 }