예제 #1
0
        public override int Execute(LogicLevel level)
        {
            if (level != null)
            {
                LogicGameObject gameObject;

                if (level.GetState() == 5)
                {
                    gameObject = LogicGameObjectFactory.CreateGameObject(this.m_data, level, level.GetVillageType());
                    gameObject.Load(this.m_json);
                    level.GetGameObjectManager().AddGameObject(gameObject, -1);
                }
                else
                {
                    gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_id);
                }

                if (gameObject != null)
                {
                    if (gameObject.GetGameObjectType() == LogicGameObjectType.TRAP)
                    {
                        LogicTrap trap = (LogicTrap)gameObject;
                        LogicGameObjectManagerListener listener = level.GetGameObjectManager().GetListener();

                        listener.AddGameObject(gameObject);

                        gameObject.LoadingFinished();
                        gameObject.GetListener().RefreshState();

                        LogicTriggerComponent triggerComponent = trap.GetTriggerComponent();

                        if (triggerComponent != null)
                        {
                            triggerComponent.SetTriggered();
                        }
                    }

                    return(0);
                }

                Debugger.Warning("PGO == NULL in LogicTriggerComponentTriggeredCommand");
                return(-2);
            }

            return(-1);
        }
        public override int Execute(LogicLevel level)
        {
            if (level != null)
            {
                LogicGameObject gameObject;

                if (level.GetState() == 5)
                {
                    gameObject = LogicGameObjectFactory.CreateGameObject(this.m_data, level, level.GetVillageType());
                    gameObject.Load(this.m_json);
                    level.GetGameObjectManager().AddGameObject(gameObject, -1);
                }
                else
                {
                    gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_id);
                }

                if (gameObject != null && gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING)
                {
                    if (gameObject.IsHidden())
                    {
                        LogicBuilding building = (LogicBuilding)gameObject;
                        LogicGameObjectManagerListener listener = level.GetGameObjectManager().GetListener();

                        listener.AddGameObject(gameObject);

                        gameObject.LoadingFinished();
                        gameObject.GetListener().RefreshState();

                        building.Trigger();

                        return(0);
                    }

                    Debugger.Warning("PGO building not hidden");
                    return(-3);
                }

                Debugger.Warning("PGO == NULL in LogicTriggerTeslaCommand");
                return(-2);
            }

            return(-1);
        }