/// <summary> /// Validates an outpost /// </summary> /// <param name="state">The game state</param> /// <param name="outpost">The outpost to validate</param> /// <returns>If the outpost is valid</returns> public static bool ValidateOutpost(GameState.GameState state, Outpost outpost) { if (outpost == null) { return(false); } if (!state.OutpostExists(outpost)) { return(false); } if (outpost.GetComponent <DrillerCarrier>().GetDrillerCount() < 0) { return(false); } if (outpost.GetComponent <SpecialistManager>() == null) { return(false); } if (outpost.GetComponent <SpecialistManager>().GetSpecialistCount() < 0) { return(false); } if (outpost.GetComponent <SpecialistManager>().GetSpecialistCount() > outpost.GetComponent <SpecialistManager>().GetCapacity()) { return(false); } if (outpost.GetComponent <DrillerCarrier>().GetOwner() != null && !state.PlayerExists(outpost.GetComponent <DrillerCarrier>().GetOwner())) { return(false); } return(true); }
/// <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); }
public override bool ForwardAction(TimeMachine timemachine, GameState.GameState state) { _productionAmount = this._producingFactory.GetDrillerProduction(state); if (state.OutpostExists(_producingFactory) && this._productionAmount > 0 && !this._producingFactory.GetComponent <DrillerCarrier>().IsDestroyed()) { _producingFactory.GetComponent <DrillerCarrier>().AddDrillers(this._productionAmount); EventSuccess = true; if (_nextProduction == null) { _nextProduction = new FactoryProduction(_producingFactory, base.GetOccursAt().Advance(this._producingFactory.GetTicksPerProduction())); timemachine.AddEvent(this._nextProduction); } } else { EventSuccess = false; } return(EventSuccess); }