// Use this for initialization void Start() { observer = new EventObserver((eventID_, params_) => { GameInterface.Events id = (GameInterface.Events)eventID_; switch (id) { case GameInterface.Events.Attack: break; case GameInterface.Events.MaxDefenders: break; case GameInterface.Events.MaxPopulation: break; case GameInterface.Events.Reinforce: break; default: break; } }); }
// Use this for initialization void Start() { observer = new EventObserver((eventID_, params_) => { GameInterface.Events id = (GameInterface.Events)eventID_; switch (id) { case GameInterface.Events.Attack: { Town originatingTown = (Town)params_[0]; // params 0 should be the originating town Town targetTown = (Town)params_[1]; // params 0 should be the originating town // if we sent the attack, ignore it // if we are not the target, ignore it if (originatingTown.GetPlayer() == this || targetTown.GetPlayer() != this) { return; } ReinforceTown(originatingTown); break; } case GameInterface.Events.MaxDefenders: { break; } case GameInterface.Events.MaxPopulation: { Town originatingTown = (Town)params_[0]; // params 0 should be the originating town AttackSomethingAlready(originatingTown); break; } case GameInterface.Events.Reinforce: { break; } case GameInterface.Events.OverPopulated: { Town originatingTown = (Town)params_[0]; // params 0 should be the originating town AttackSomethingAlready(originatingTown); break; } case GameInterface.Events.AttackerPopulationIncreased: { Town originatingTown = (Town)params_[0]; // params 0 should be the originating town AttackSmaller(originatingTown); break; } default: { break; } } }); EventManager.instance.AddObserver(observer); }