Ejemplo n.º 1
0
 /// <summary>
 /// Validates a sub
 /// </summary>
 /// <param name="state">The game state</param>
 /// <param name="sub">The sub to validate</param>
 /// <returns>If the sub is valid</returns>
 public static bool ValidateSub(GameState.GameState state, Sub sub)
 {
     if (sub == null)
     {
         return(false);
     }
     if (!state.SubExists(sub))
     {
         return(false);
     }
     if (sub.GetComponent <DrillerCarrier>().GetDrillerCount() < 0)
     {
         return(false);
     }
     if (sub.GetComponent <SpecialistManager>() == null)
     {
         return(false);
     }
     if (sub.GetComponent <SpecialistManager>().GetSpecialistCount() < 0)
     {
         return(false);
     }
     if (sub.GetComponent <SpecialistManager>().GetSpecialistCount() > sub.GetComponent <SpecialistManager>().GetCapacity())
     {
         return(false);
     }
     if (sub.GetComponent <DrillerCarrier>().GetOwner() != null && !state.PlayerExists(sub.GetComponent <DrillerCarrier>().GetOwner()))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Perfoms a friendly sub arrival
 /// </summary>
 /// <returns>If the event was successful</returns>
 public override bool ForwardAction(TimeMachine timeMachine, GameState.GameState state)
 {
     if (state.SubExists(_arrivingSub) && state.OutpostExists(_outpost))
     {
         _outpost.GetComponent <DrillerCarrier>().AddDrillers(_arrivingSub.GetComponent <DrillerCarrier>().GetDrillerCount());
         _outpost.GetComponent <SpecialistManager>().AddSpecialists(_arrivingSub.GetComponent <SpecialistManager>().GetSpecialists());
         state.RemoveSub(_arrivingSub);
         EventSuccess = true;
     }
     else
     {
         EventSuccess = false;
     }
     return(EventSuccess);
 }