Пример #1
0
        /// <summary>
        /// The basic outline of the updateEntity method is as follows:
        /// 1, Have the entity perform the current action at the top of it's action queue (if any)
        /// 2, Check for changes in the entity's stats. (ex: check for death.)
        /// 3, Have the Entity react to any Events that occur within it's visibility range.
        /// (Events that either occur to the Entity or events that the Entity can "see")
        /// 4, Check if the Entity should be removed from the game. (When it's primary state is set to Remove.)
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="entitiesToRemove"></param>
        private void updateEntity(Entity entity, List <Entity> entitiesToRemove)
        {
            /*** Have entity perform it's current action (if any) ***/
            ActionController.Instance.update(entity, locController);

            Entity.EntityType type = entity.getEntityType();
            /*** Update stats of Entity ***/
            if (type == Entity.EntityType.Unit)
            {
                UnitStatsLogic.updateUnit((Unit)entity, curTick);
            }
            else
            {
                // Only Stats update occurs upon death of any StaticEntity right?
                if (entity.health <= 0)
                {
                    entity.getState().setPrimaryState(State.PrimaryState.Dead);
                }
            }

            /*** Have Entity react to any Events ***/
            if (type == Entity.EntityType.Unit)             // Only Units really need to react to Events.
            {
            }

            /*** Remove Entity if it needs to be removed. ***/
            if (entity.getState().getPrimaryState() == State.PrimaryState.Dead)             // Should be remove. Changed for demo.
            {
                entitiesToRemove.Add(entity);
            }
        }
        /// <summary>
        /// The basic outline of the updateEntity method is as follows:
        /// 1, Have the entity perform the current action at the top of it's action queue (if any)
        /// 2, Check for changes in the entity's stats. (ex: check for death.)
        /// 3, Have the Entity react to any Events that occur within it's visibility range.
        /// (Events that either occur to the Entity or events that the Entity can "see")
        /// 4, Check if the Entity should be removed from the game. (When it's primary state is set to Remove.)
        /// </summary>
        /// <param name="entity">Entity being updated.</param>
        /// <param name="entitiesToRemove">List of Entities to be removed.</param>
        private void updateEntity(Entity entity, List <Entity> entitiesToRemove)
        {
            /*** Have entity perform it's current action (if any) ***/
            ActionController.Instance.update(entity, locController);

            Entity.EntityType type  = entity.getEntityType();                   // Enity's type (Unit, Building, Object or Resource)
            State             state = entity.getState();                        // Entity's State.

            /*** Update stats of Entity ***/
            if (type == Entity.EntityType.Unit)
            {
                UnitStatsLogic.updateUnit((Unit)entity, curTick);
            }
            else
            {
                // Only Stats update occurs upon death of any StaticEntity right?
                if (entity.health <= 0)
                {
                    state.setPrimaryState(State.PrimaryState.Dead);
                    entity.tickKilled = curTick;
                }
            }

            /*** Have Entity react to any Events ***/
            if (type == Entity.EntityType.Unit)             // Only Units really need to react to Events.
            {
                GameEventLogic.processEvents((Unit)entity, scenario.getGameWorld());
            }


            /*** Remove Entity if it needs to be removed. ***/
            if (state.getPrimaryState() == State.PrimaryState.Dead)
            {
                entitiesToRemove.Add(entity);
            }
        }