Exemplo n.º 1
0
        public static VLifecycle Increment(VLifecycle v)
        {
            switch (v)
            {
            case VLifecycle.EnemySetupStart:
                return(VLifecycle.EnemySetupExecute);

            case VLifecycle.EnemySetupExecute:
                return(VLifecycle.PlayerTurnStart);

            case VLifecycle.PlayerTurnStart:
                return(VLifecycle.PlayerTurnExecute);

            case VLifecycle.PlayerTurnExecute:
                return(VLifecycle.PlayerTurnEnd);

            case VLifecycle.PlayerTurnEnd:
                return(VLifecycle.EnemyActionsStart);

            case VLifecycle.EnemyActionsStart:
                return(VLifecycle.EnemyActionsResolve);

            case VLifecycle.EnemyActionsResolve:
                return(VLifecycle.EnemyActionsEnd);

            case VLifecycle.EnemyActionsEnd:
                return(VLifecycle.EnemySetupStart);

            default:
                throw new Exception("Trying to increment non-incrementable lifecycle");
            }
        }
Exemplo n.º 2
0
        public void OnLifecycle(VEntity entity, VLifecycle lifecycle)
        {
            switch (lifecycle)
            {
            case VLifecycle.EnemySetupStart:
                OnEnemySetupStart(entity);
                break;

            case VLifecycle.EnemySetupExecute:
                OnEnemySetupExecute(entity);
                break;

            case VLifecycle.PlayerTurnStart:
                OnPlayerTurnStart(entity);
                break;

            case VLifecycle.PlayerTurnExecute:
                OnPlayerTurnExecute(entity);
                break;

            case VLifecycle.PlayerTurnEnd:
                OnPlayerTurnEnd(entity);
                break;

            case VLifecycle.EnemyActionsStart:
                OnEnemyActionsStart(entity);
                break;

            case VLifecycle.EnemyActionsResolve:
                OnEnemyActionsResolve(entity);
                break;

            case VLifecycle.EnemyActionsEnd:
                OnEnemyActionsEnd(entity);
                break;

            case VLifecycle.OnBeforeEvent:
                OnBeforeEvent(entity);
                break;

            case VLifecycle.OnExecuteEvent:
                OnExecuteEvent(entity);
                break;

            case VLifecycle.OnAfterEvent:
                OnAfterEvent(entity);
                break;

            default:
                throw new Exception("Unhandled lifecycle");
            }
        }
        public void RunSystems(VLifecycle lifecycle, bool shouldFlush, IEnumerable <VEntity> entities = null)
        {
            if (entities == null)
            {
                entities = gameEntities;
            }
            foreach (VEntity entity in entities)
            {
                foreach (VSystem system in gameSystems)
                {
                    if (system.ShouldOperate(entity))
                    {
                        system.OnLifecycle(entity, lifecycle);
                    }

                    if (shouldFlush)
                    {
                        gameplayEventQueue.Flush();
                    }
                }
            }
        }