public bool BackwardAction(TimeMachine timeMachine, GameState.GameState state) { if (_isTie) { // TODO: Handle tie. return(false); } if (_loser is Sub) { // Undo the sub cleanup if (_loser.GetComponent <SpecialistManager>().GetSpecialistCount() > 0) { _loser.GetComponent <SpecialistManager>().UncaptureAll(); ((Sub)_loser).GetComponent <DrillerCarrier>().SetCaptured(false); } else { // Put the sub back state.AddSub((Sub)_loser); } } if (_loser is Outpost) { // Transfer Ownership and give drillers. _loser.GetComponent <DrillerCarrier>().SetOwner(_losingPlayer); _loser.GetComponent <DrillerCarrier>().SetDrillerCount(_initialLoserDrillerCount); // Put the winner's specialists back _winner.GetComponent <SpecialistManager>().AddSpecialists(_loser.GetComponent <SpecialistManager>().GetPlayerSpecialists(_winner.GetComponent <DrillerCarrier>().GetOwner())); // Uncapture the losing player's specialists _loser.GetComponent <SpecialistManager>().UncaptureAll(); // Put the incoming sub back state.AddSub((Sub)_winner); } this._isSuccess = true; return(_isSuccess); }
/// <summary> /// Undoes the sub's arrival /// </summary> /// <returns>If the event was undone</returns> public override bool BackwardAction(TimeMachine timeMachine, GameState.GameState state) { if (EventSuccess) { _outpost.GetComponent <DrillerCarrier>().RemoveDrillers(_arrivingSub.GetComponent <DrillerCarrier>().GetDrillerCount()); _outpost.GetComponent <SpecialistManager>() .RemoveSpecialists(_arrivingSub.GetComponent <SpecialistManager>().GetSpecialists()); state.AddSub(this._arrivingSub); return(true); } return(false); }