public bool ForwardAction(TimeMachine timeMachine, GameState.GameState state)
        {
            if (_isTie)
            {
                // TODO: Handle tie.
                return(false);
            }

            if (_loser is Sub)
            {
                // Cleanup the sub.
                if (_loser.GetComponent <SpecialistManager>().GetSpecialistCount() > 0)
                {
                    _loser.GetComponent <SpecialistManager>().CaptureAll();
                    ((Sub)_loser).GetComponent <DrillerCarrier>().SetCaptured(true);
                }
                else
                {
                    // Remove the sub
                    state.RemoveSub((Sub)_loser);
                }
            }

            if (_loser is Outpost)
            {
                // Transfer Ownership and give drillers.
                _loser.GetComponent <DrillerCarrier>().SetOwner(_winner.GetComponent <DrillerCarrier>().GetOwner());

                // Remove the winning sub and make it arrive at the outpost.
                _loser.GetComponent <DrillerCarrier>().SetDrillerCount(0);
                _loser.GetComponent <DrillerCarrier>().AddDrillers(_winner.GetComponent <DrillerCarrier>().GetDrillerCount());

                // Transfer any specialists to the outpost.
                _loser.GetComponent <SpecialistManager>().CaptureAll();
                _winner.GetComponent <SpecialistManager>().TransferSpecialistsTo(_loser.GetComponent <SpecialistManager>());

                // Remove the incoming sub.
                state.RemoveSub((Sub)_winner);
            }

            this._isSuccess = true;
            return(_isSuccess);
        }
Exemplo 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);
 }