Esempio n. 1
0
    public void Grunt()
    {
        // If the leader is dead
        if (m_shipScript.leader == null)
        {
            // and the player is not close, wander
            if (m_shipScript.DistanceTo(m_shipScript.Target.position) > 20.0f)
            {
                m_shipScript.Wander();
            }
            // if the player is close, run away
            else
            {
                m_shipScript.MoveAwayFrom(m_shipScript.player);
            }
        }
        else if (chaseTime > 3.0f)
        {
            chaseTime += Time.deltaTime;

            if (m_shipScript.DistanceTo(m_shipScript.Target.position) < 10.0f)
            {
                m_shipScript.MoveAwayFrom(m_shipScript.Target);
            }
            else
            {
                m_shipScript.MoveToward(m_shipScript.Target);
            }

            if (chaseTime > 0.0f)
            {
                chaseTime = 0.0f;
            }
        }
        // If the leader is alive and the player is less than 10 units away, move toward it
        else if (m_shipScript.CheckAggro())
        {
            if (m_shipScript.DistanceTo(m_shipScript.Target.position) < 5.0)
            {
                if (m_shipScript.AngleToTarget() < 10.0f && m_shipScript.CanSeeTarget())
                {
                    m_shipScript.FireWeapon(0);
                }
                m_shipScript.ChaseTarget(5.0f, 3.0f);
                chaseTime += Time.deltaTime;
            }
            else
            {
                m_shipScript.MoveToward(m_shipScript.Target);
            }
        }
        // If the leader is alive, and the player is not near
        else
        {
            m_shipScript.aggro = false;
            m_shipScript.Flock();
        }
    }
Esempio n. 2
0
 public void Grunt()
 {
     m_shipScript.Go();
     // If the player is less than 15 units away, move toward it
     if (m_shipScript.CheckAggro(20.0f, enemies))
     {
         if (m_shipScript.Obstacle)
         {
             m_shipScript.Stop();
             if (m_shipScript.AngleToTarget(m_shipScript.obstacleTrans.position) < 45.0f && m_shipScript.CanSeeTarget(m_shipScript.obstacleTrans, friends))
             {
                 m_shipScript.FireWeapon();
             }
         }
         if (m_shipScript.DistanceTo(m_shipScript.Target.position) < 20.0)
         {
             m_shipScript.AttackTarget(7.5f, friends);
         }
         else
         {
             m_shipScript.MoveToward(m_shipScript.Target);
         }
     }
     // If the player is not near
     else
     {
         if (m_shipScript.Obstacle)
         {
             m_shipScript.Stop();
             m_shipScript.FaceTarget(m_shipScript.obstacleTrans.position);
             if (m_shipScript.AngleToTarget(m_shipScript.obstacleTrans.position) < 15.0f && m_shipScript.CanSeeTarget(m_shipScript.obstacleTrans, friends))
             {
                 m_shipScript.FireWeapon();
             }
         }
         else if (m_shipScript.objective != null && m_shipScript.DistanceTo(m_shipScript.ObjectiveStartPos) > 25.0f)
         {
             if (m_shipScript.objective != null)
             {
                 m_shipScript.MoveToward(m_shipScript.objective);
             }
         }
         else
         {
             m_shipScript.Flock();
         }
         m_shipScript.aggro = false;
     }
 }