Ejemplo n.º 1
0
 /// <summary>
 /// Registers the events that display a message to the user.
 /// </summary>
 /// <param name="entity">Game entity that triggers the event.</param>
 private void registerEntityEvents(IGameEntity entity)
 {
     if (entity.info.isBuilding)
     {
         if (entity.info.isBarrack)
         {
             Barrack barrack = (Barrack)entity;
             barrack.register(Barrack.Actions.DAMAGED, events.DisplayUnderAttack);
             barrack.register(Barrack.Actions.DESTROYED, events.DisplayBuildingDestroyed);
             barrack.register(Barrack.Actions.CREATE_UNIT, OnUnitCreated);
             barrack.register(Barrack.Actions.BUILDING_FINISHED, events.DisplayBuildingCreated);
         }
         else
         {
             Resource resourcesBuilding = (Resource)entity;
             resourcesBuilding.register(Resource.Actions.DAMAGED, events.DisplayUnderAttack);
             resourcesBuilding.register(Resource.Actions.DESTROYED, events.DisplayBuildingDestroyed);
             resourcesBuilding.register(Resource.Actions.BUILDING_FINISHED, events.DisplayBuildingCreated);
             resourcesBuilding.register(Resource.Actions.CREATE_UNIT, OnUnitCreated);
         }
     }
     else if (entity.info.isUnit)
     {
         Unit unit = (Unit)entity;
         unit.register(Unit.Actions.DAMAGED, events.DisplayUnderAttack);
         unit.register(Unit.Actions.DIED, events.DisplayUnitDead);
         unit.register(Unit.Actions.TARGET_TERMINATED, signalMissionUpdate);
         unit.register(Unit.Actions.EAT, onUnitEats);
     }
 }
Ejemplo n.º 2
0
 // REGISTER METHODS
 public void registerBuildingToEvents(IGameEntity entity)
 {
     if (entity.info.isResource)
     {
         Resource resource = (Resource)entity;
         resource.register(Resource.Actions.NEW_HARVEST, OnNewHarvest);
         resource.register(Resource.Actions.NEW_EXPLORER, OnNewExplorer);
         resource.register(Resource.Actions.COLLECTION, OnCollection);
         resource.register(Resource.Actions.CREATED, OnCreated);
         resource.register(Resource.Actions.EXTERMINATED, OnDestroyed);
     }
     else if (entity.info.isBarrack)
     {
         Barrack barrack = (Barrack)entity;
         barrack.register(Barrack.Actions.CREATED, OnCreated);
     }
 }