public void runBehaviours(GameLoopPhase phase) { foreach (IBehaviour behaviour in behaviours .Where(x => x.Key == phase) .SelectMany(x => x.Value)) { behaviour.doBehaviour(this); } }
public void run(GameLoopPhase phase) { // Linq skillz ;) foreach (IEntity entity in scenes .Where(x => x.Key == game.currentState) .SelectMany(x => x.Value)) { entity.runBehaviours(phase); } }
public void addBehaviour(GameLoopPhase phase, IBehaviour behaviourToAdd) { Debug.Assert(verifyAttributes(behaviourToAdd), getMissingAttributes(behaviourToAdd)); List <IBehaviour> entityBehaviours; if (behaviours.TryGetValue(phase, out entityBehaviours)) { entityBehaviours.Add(behaviourToAdd); } else { entityBehaviours = new List <IBehaviour>(); entityBehaviours.Add(behaviourToAdd); behaviours.Add(phase, entityBehaviours); } }
public void PlayerHasEscaped() { phase = GameLoopPhase.escapedPhase; //Pause game, show post game menu, save high score }
public void ActivateAlarm() { phase = GameLoopPhase.alarmedPhase; }
public void Init() { phase = GameLoopPhase.preAlarmPhase; }