Example #1
0
    /// <summary>
    /// Assign the specified action to the enemy.
    /// </summary>
    /// <param name="action">Action to assign.</param>
    protected void AssignValidAction(EnemyAction.Actions action)
    {
        switch (action)
        {
        case EnemyAction.Actions.EnemyMoveAction:
            m_ActiveAction = GetComponentInChildren <EnemyMoveAction>();
            break;

        case EnemyAction.Actions.EnemyPlayerDetection:
            m_ActiveAction = GetComponentInChildren <EnemyPlayerDetection>();
            break;

        case EnemyAction.Actions.EnemyMoveToPlayer:
            m_ActiveAction = GetComponentInChildren <EnemyMoveToPlayerAction>();
            break;

        case EnemyAction.Actions.EnemyMeleeAttack:
            m_ActiveAction = GetComponentInChildren <EnemyMeleeAttack>();
            break;

        case EnemyAction.Actions.EnemyPatrol:
            m_ActiveAction = GetComponentInChildren <EnemyPatrolAction>();
            break;

        case EnemyAction.Actions.EnemyRangedAttack:
            m_ActiveAction = GetComponentInChildren <EnemyRangedAttack>();
            break;
        }
        m_ActiveAction.InitialiseAction();
    }
Example #2
0
 /// <summary>
 /// Check that this enemy can use the specified action.
 /// </summary>
 /// <param name="action">The action to check.</param>
 /// <returns>True if the action is valid, false if not.</returns>
 protected bool CheckValidAction(EnemyAction.Actions action)
 {
     foreach (EnemyAction.Actions act in m_AvailableActions)
     {
         if (action == act)
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
 /// <summary>
 /// Set the action to the specified action.
 /// </summary>
 /// <param name="action">The desired action.</param>
 public void SetActiveAction(EnemyAction.Actions action)
 {
     if (CheckValidAction(action))
     {
         AssignValidAction(action);
     }
     else
     {
         Debug.LogError("Invalid Enemy Action");
     }
 }