public override void OnUpdate()
        {
            //	Debug.Log(asyncOperation.isDone);

            if (asyncOperation ==null || asyncOperation.isDone )
            {
                Debug.Log(state);

                if (state == loadState.LoadBase)
                {
                    LogDebug("UnloadUnusedAssets");
                    state = loadState.UnloadUnusedResources;
                    asyncOperation = null;
                    asyncOperation =  Resources.UnloadUnusedAssets();

                }else if (state == loadState.UnloadUnusedResources)
                {
                    LogDebug("loading level :"+levelName.Value);
                    state = loadState.LoadLevel;
                    asyncOperation = null;
                    asyncOperation = Application.LoadLevelAdditiveAsync(levelName.Value);

                }else if (state == loadState.LoadLevel)
                {
                    LogDebug("loading done");

                    Fsm.Event(loadedEvent);
                    Finish();
                }
            }
        }
Example #2
0
        public void Toggle()
        {
            CrestronConsole.PrintLine("Toggle is called");

            var _ison = this.IsOn();

            currentState         = loadState.Toggle;
            expectedMessageCount = 2;

            if (!_ison)
            {
                FullOn();
            }
            else if (_ison)
            {
                Off();
            }

            var hub = MessageHub.Instance;
            LoadToggleOnEvent message = new LoadToggleOnEvent(this);

            message.IsOn = !_ison;

            hub.Publish <LoadToggleOnEvent>(message);
        }
        public override void OnUpdate()
        {
            //	Debug.Log(asyncOperation.isDone);

            if (asyncOperation == null || asyncOperation.isDone)
            {
                Debug.Log(state);

                if (state == loadState.LoadBase)
                {
                    LogDebug("UnloadUnusedAssets");
                    state          = loadState.UnloadUnusedResources;
                    asyncOperation = null;
                    asyncOperation = Resources.UnloadUnusedAssets();
                }
                else if (state == loadState.UnloadUnusedResources)
                {
                    LogDebug("loading level :" + levelName.Value);
                    state          = loadState.LoadLevel;
                    asyncOperation = null;
                    asyncOperation = Application.LoadLevelAdditiveAsync(levelName.Value);
                }
                else if (state == loadState.LoadLevel)
                {
                    LogDebug("loading done");

                    Fsm.Event(loadedEvent);
                    Finish();
                }
            }
        }
Example #4
0
        public void StopLower()
        {
            if (_crestronLoad.Type == eLoadType.Dimmer)
            {
                currentState = loadState.StopLower;

                var            messageHub   = MessageHub.Instance;
                LoadLowerEvent lowerMessage = new LoadLowerEvent(this);
                messageHub.Publish <LoadLowerEvent>(lowerMessage);

                ((BasicDimmingLoad)_crestronLoad).Lower.BoolValue = false;
            }
        }
Example #5
0
        public void StopRaise()
        {
            if (_crestronLoad.Type == eLoadType.Dimmer)
            {
                currentState = loadState.StopRaise;

                var            messageHub   = MessageHub.Instance;
                LoadRaiseEvent raiseMessage = new LoadRaiseEvent(this);
                messageHub.Publish <LoadRaiseEvent>(raiseMessage);

                ((BasicDimmingLoad)_crestronLoad).Raise.BoolValue = false;
            }
        }
        public override void OnEnter()
        {
            Object.DontDestroyOnLoad(Owner.transform.root.gameObject);

            LogDebug("Loading base level :"+BaselevelName.Value);

            Application.LoadLevel(BaselevelName.Value);

            Debug.Log("done");

            state = loadState.LoadBase;
            //	LogDebug("Loading base level :"+BaselevelName.Value);
            //asyncOperation = Application.LoadLevelAsync(levelName.Value);
        }
        public override void OnEnter()
        {
            Object.DontDestroyOnLoad(Owner.transform.root.gameObject);

            LogDebug("Loading base level :" + BaselevelName.Value);

            Application.LoadLevel(BaselevelName.Value);

            Debug.Log("done");

            state = loadState.LoadBase;
            //	LogDebug("Loading base level :"+BaselevelName.Value);
            //asyncOperation = Application.LoadLevelAsync(levelName.Value);
        }
        public void loadInitialRoom(int difficulty)
        {
            XNACS1Base.World.SetWorldCoordinate
                (new Vector2(initialRoom.X * 100f, initialRoom.Y * (9f / 16f) * 100f), 100f);
            //XNACS1Base.World.SetBackgroundTexture("bg1");

            hero = new Hero(new Vector2(rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().X
                                        + 50f, rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().Y + (9f / 16f) * 50f), difficulty);
            rooms[(int)initialRoom.X, (int)initialRoom.Y].loadRoom();
            currentRoom      = initialRoom;
            lastVisitedRoom  = currentRoom;
            currentOrigin    = new Vector2(currentRoom.X * 100f, currentRoom.Y * (9f / 16f) * 100f);
            loads            = loadState.notLoading;
            currentDirection = loadDirection.noDirection;
        }
Example #9
0
        public void loadInitialRoom(int difficulty, Hero hero)
        {
            XNACS1Base.World.SetWorldCoordinate
                (new Vector2(initialRoom.X * 100f, initialRoom.Y * (9f / 16f) * 100f), 100f);


            hero.Center = new Vector2(rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().X
                                      + 50f, rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().Y + (9f / 16f) * 50f);

            rooms[(int)initialRoom.X, (int)initialRoom.Y].loadRoom(hero, levelNum);
            roomMap[(int)initialRoom.X, (int)initialRoom.Y] = roomState.visited; // betania added
            currentRoom      = initialRoom;
            lastVisitedRoom  = currentRoom;
            currentOrigin    = new Vector2(currentRoom.X * 100f, currentRoom.Y * (9f / 16f) * 100f);
            loads            = loadState.notLoading;
            currentDirection = loadDirection.noDirection;
            hero.TopOfAutoDrawSet();
        }
Example #10
0
    public bool LoadIFN()
    {
        if (this.state != loadState.loaded)
        {
            if (this.ResolveDependencies())
            {
                this.Load();
                UnityEngine.Debug.Assert(this.state == loadState.loaded);
            }
            else
            {
                this.state = loadState.waitingForDependencies;
                this.StartCoroutine(this.WaitForDependencies());
            }
        }

        return(this.state == loadState.loaded);
    }
Example #11
0
        public LightingLoad(int LoadID, LightLoad Load, String Name)
        {
            this.LoadID   = LoadID;
            _crestronLoad = Load;
            _name         = Name;
            currentState  = loadState.Steady;

            if (_crestronLoad.Type == eLoadType.Dimmer)
            {
                ((AdvDimmer)Load.DeviceLoadIsOn).LoadStateChange += new LoadEventHandler(load_LoadEventHandler);
            }

            else
            {
                Load.DeviceLoadIsOn.LoadStateChange += new LoadEventHandler(load_LoadEventHandler);
            }

            // Load.DeviceLoadIsOn.
        }
Example #12
0
        public void Lower()
        {
            if (_crestronLoad.Type == eLoadType.Switch)
            {
                if (this.Level > 0)
                {
                    Off();
                }
            }
            else if (_crestronLoad.Type == eLoadType.Dimmer)
            {
                currentState         = loadState.Lower;
                expectedMessageCount = 3;

                var            messageHub   = MessageHub.Instance;
                LoadLowerEvent lowerMessage = new LoadLowerEvent(this);
                messageHub.Publish <LoadLowerEvent>(lowerMessage);

                ((BasicDimmingLoad)_crestronLoad).Lower.BoolValue = true;
            }
        }
Example #13
0
        public void Raise()
        {
            if (_crestronLoad.Type == eLoadType.Switch)
            {
                if (this.Level == 0)
                {
                    FullOn();
                }
            }
            else if (_crestronLoad.Type == eLoadType.Dimmer)
            {
                currentState         = loadState.Raise;
                expectedMessageCount = 3;

                var            messageHub   = MessageHub.Instance;
                LoadRaiseEvent raiseMessage = new LoadRaiseEvent(this);
                messageHub.Publish <LoadRaiseEvent>(raiseMessage);

                ((BasicDimmingLoad)_crestronLoad).Raise.BoolValue = true;
            }
        }
Example #14
0
        public void loadInitialRoom(int difficulty, Hero hero)
        {
            XNACS1Base.World.SetWorldCoordinate
                (new Vector2(initialRoom.X * 100f, initialRoom.Y * (9f/16f)*100f), 100f);

            hero.Center = new Vector2(rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().X
                + 50f, rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().Y + (9f / 16f) * 50f);

            rooms[(int)initialRoom.X, (int)initialRoom.Y].loadRoom(hero, levelNum);
            roomMap[(int)initialRoom.X, (int)initialRoom.Y] = roomState.visited; // betania added
            currentRoom = initialRoom;
            lastVisitedRoom = currentRoom;
            currentOrigin = new Vector2(currentRoom.X * 100f, currentRoom.Y * (9f / 16f) * 100f);
            loads = loadState.notLoading;
            currentDirection = loadDirection.noDirection;
            hero.TopOfAutoDrawSet();
        }
        public bool updateLevel(XNACS1Lib.XNACS1Lib.GamePadSupport.AllButtonsOnGamePad pad, 
			XNACS1Lib.XNACS1Lib.GamePadSupport.ThumbSticksOnGamePad thumbs)
        {
            Vector2 newRoom = new Vector2(-1, -1);
            if(loads == loadState.notLoading){
                hero.UpdateHero(thumbs.Left);
                newRoom = rooms[(int)currentRoom.X, (int)currentRoom.Y].updateRoom(hero);

            }

            if (newRoom.X > -1) {
                loads = loadState.loading;
                if (newRoom.X > currentRoom.X)
                    currentDirection = loadDirection.right;

                else if (newRoom.X < currentRoom.X)
                    currentDirection = loadDirection.left;

                else if (newRoom.Y > currentRoom.Y)
                    currentDirection = loadDirection.top;

                else
                    currentDirection = loadDirection.bottom;

                lastVisitedRoom = currentRoom;
                currentRoom = newRoom;
                loadRoom();

                expectedOrigin = new Vector2(currentRoom.X * 100f, currentRoom.Y * ((9f/16f)* 100f));

            }

            if (loads == loadState.loading) {
                hero.Visible = false;
                moveRoom();
            }

            if(loads == loadState.finished){
                hero.Visible = true;
                unLoadRoom();
                loads = loadState.notLoading;
                currentDirection = loadDirection.noDirection;
                currentOrigin = expectedOrigin;

            }

            //XNACS1Rectangle Screen;
            //if (hero.NumTimesCaught == 0)
            //{
            //    Screen = new XNACS1Rectangle(new Vector2(currentOrigin.X + 50f, currentOrigin.Y +25f), 100f, 54f);
            //    Screen.Label = "GAME OVER";
            //    Screen.LabelColor = Color.White;
            //    }
            //XNACS1Base.EchoToTopStatus("Hero has " + hero.NumTimesCaught + " live(s)");

            if(rooms[(int)currentRoom.X, (int)currentRoom.Y].stairsInRoom()){
                if (hero.Collided(rooms[(int)currentRoom.X, (int)currentRoom.Y].stairs))
                    return true;
            }
            return false;
        }
        public bool updateLevel(XNACS1Lib.XNACS1Lib.GamePadSupport.AllButtonsOnGamePad pad,
                                XNACS1Lib.XNACS1Lib.GamePadSupport.ThumbSticksOnGamePad thumbs)
        {
            Vector2 newRoom = new Vector2(-1, -1);

            if (loads == loadState.notLoading)
            {
                hero.UpdateHero(thumbs.Left);
                newRoom = rooms[(int)currentRoom.X, (int)currentRoom.Y].updateRoom(hero);
            }

            if (newRoom.X > -1)
            {
                loads = loadState.loading;
                if (newRoom.X > currentRoom.X)
                {
                    currentDirection = loadDirection.right;
                }

                else if (newRoom.X < currentRoom.X)
                {
                    currentDirection = loadDirection.left;
                }

                else if (newRoom.Y > currentRoom.Y)
                {
                    currentDirection = loadDirection.top;
                }

                else
                {
                    currentDirection = loadDirection.bottom;
                }

                lastVisitedRoom = currentRoom;
                currentRoom     = newRoom;
                loadRoom();

                expectedOrigin = new Vector2(currentRoom.X * 100f, currentRoom.Y * ((9f / 16f) * 100f));
            }

            if (loads == loadState.loading)
            {
                hero.Visible = false;
                moveRoom();
            }

            if (loads == loadState.finished)
            {
                hero.Visible = true;
                unLoadRoom();
                loads            = loadState.notLoading;
                currentDirection = loadDirection.noDirection;
                currentOrigin    = expectedOrigin;
            }


            //XNACS1Rectangle Screen;
            //if (hero.NumTimesCaught == 0)
            //{
            //    Screen = new XNACS1Rectangle(new Vector2(currentOrigin.X + 50f, currentOrigin.Y +25f), 100f, 54f);
            //    Screen.Label = "GAME OVER";
            //    Screen.LabelColor = Color.White;
            //    }
            //XNACS1Base.EchoToTopStatus("Hero has " + hero.NumTimesCaught + " live(s)");

            if (rooms[(int)currentRoom.X, (int)currentRoom.Y].stairsInRoom())
            {
                if (hero.Collided(rooms[(int)currentRoom.X, (int)currentRoom.Y].stairs))
                {
                    return(true);
                }
            }
            return(false);
        }
        public void moveRoom()
        {
            switch (currentDirection)
            {
            case loadDirection.right:
                if (currentOrigin.X < expectedOrigin.X - .5f)
                {
                    currentOrigin.X += .75f;
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);
                }
                else
                {
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                    loads = loadState.finished;
                }

                break;

            case loadDirection.left:
                if (currentOrigin.X > expectedOrigin.X + .5f)
                {
                    currentOrigin.X -= .75f;
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);
                }

                else
                {
                    loads = loadState.finished;
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                }

                break;

            case loadDirection.top:
                if (currentOrigin.Y < expectedOrigin.Y - .5f)
                {
                    currentOrigin.Y += .75f;
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);
                }

                else
                {
                    loads = loadState.finished;
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                }

                break;

            case loadDirection.bottom:
                if (currentOrigin.Y > expectedOrigin.Y + .5f)
                {
                    currentOrigin.Y -= .75f;
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);
                }

                else
                {
                    loads = loadState.finished;
                    XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                }

                break;

            default:
                loads = loadState.finished;
                break;
            }
        }
Example #18
0
        public bool updateLevel(XNACS1Lib.XNACS1Lib.GamePadSupport.AllButtonsOnGamePad pad,
                                XNACS1Lib.XNACS1Lib.GamePadSupport.ThumbSticksOnGamePad thumbs, Hero hero)
        {
            Vector2 newRoom = new Vector2(-1, -1);

            if (rooms[(int)currentRoom.X, (int)currentRoom.Y].heroCaught || paused)
            {
                if (ticker > 0)
                {
                    paused = true;
                    ticker--;
                }

                else
                {
                    paused = false;
                    rooms[(int)currentRoom.X, (int)currentRoom.Y].heroCaught = false;
                    ticker = 80;
                }
            }

            else if (loads == loadState.notLoading)
            {
                hero.UpdateHero(thumbs.Left);



                newRoom = rooms[(int)currentRoom.X, (int)currentRoom.Y].updateRoom(hero, levelNum);
                if (newRoom.X > -1)
                {
                    loads = loadState.loading;
                    if (newRoom.X > currentRoom.X)
                    {
                        currentDirection = loadDirection.right;
                    }

                    else if (newRoom.X < currentRoom.X)
                    {
                        currentDirection = loadDirection.left;
                    }

                    else if (newRoom.Y > currentRoom.Y)
                    {
                        currentDirection = loadDirection.top;
                    }

                    else
                    {
                        currentDirection = loadDirection.bottom;
                    }

                    lastVisitedRoom = currentRoom;
                    currentRoom     = newRoom;
                    loadRoom(hero);

                    expectedOrigin = new Vector2(currentRoom.X * 100f, currentRoom.Y * ((9f / 16f) * 100f));
                }
            }
            if (loads == loadState.loading)
            {
                hero.Visible = false;
                moveRoom();
            }

            if (loads == loadState.finished)
            {
                hero.Visible = true;
                unLoadRoom();
                loads            = loadState.notLoading;
                currentDirection = loadDirection.noDirection;
                currentOrigin    = expectedOrigin;
            }

            if (rooms[(int)currentRoom.X, (int)currentRoom.Y].stairsInRoom())
            {
                if (hero.Collided(rooms[(int)currentRoom.X, (int)currentRoom.Y].stairs) && rooms[(int)currentRoom.X, (int)currentRoom.Y].stairs.available)
                {
                    return(true);
                }
            }
            return(false);
        }
        public void loadInitialRoom(int difficulty)
        {
            XNACS1Base.World.SetWorldCoordinate
                (new Vector2(initialRoom.X * 100f, initialRoom.Y * (9f/16f)*100f), 100f);
            //XNACS1Base.World.SetBackgroundTexture("bg1");

            hero = new Hero(new Vector2(rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().X
                + 50f, rooms[(int)initialRoom.X, (int)initialRoom.Y].roomOrig().Y + (9f / 16f) * 50f), difficulty);
            rooms[(int)initialRoom.X, (int)initialRoom.Y].loadRoom();
            currentRoom = initialRoom;
            lastVisitedRoom = currentRoom;
            currentOrigin = new Vector2(currentRoom.X * 100f, currentRoom.Y * (9f / 16f) * 100f);
            loads = loadState.notLoading;
            currentDirection = loadDirection.noDirection;
        }
Example #20
0
 protected virtual void Load()
 {
     this.state = loadState.loaded;
 }
Example #21
0
        void load_LoadEventHandler(LightingBase currentDevice, LoadEventArgs args)
        {
            var hub = MessageHub.Instance;

            if (EventIds.ContainsKey(args.EventId))
            {
                CrestronConsole.PrintLine("MessgeID: {0} Device {1}: {2}", sequence++, currentDevice.ID, EventIds[args.EventId]);
            }

            // use this structure to react to the different events
            switch (args.EventId)
            {
            case LoadEventIds.IsOnEventId:
                if (args.Load is SwitchedLoad)
                {
                    // this._ison = ((SwitchedLoad)(args.Load)).IsOn;

                    LoadOnEvent message = new LoadOnEvent(this);
                    message.IsOn = this.IsOn();

                    hub.Publish <LoadOnEvent>(message);
                }
                else if (args.Load is BasicDimmingLoad)
                {
                    LoadOnEvent mess = new LoadOnEvent(this);
                    mess.IsOn = this.IsOn();

                    hub.Publish <LoadOnEvent>(mess);
                    break;
                }

                break;

            case LoadEventIds.LevelChangeEventId:

                var dimmer = ((ClwDimmingLoad)(args.Load));
                _levelFB = dimmer.LevelFeedback.UShortValue;

                CrestronConsole.PrintLine("Processing Ramp Level Event: {0}", _levelFB);

                if (currentState == loadState.Raise || currentState == loadState.Lower ||
                    currentState == loadState.StopLower || currentState == loadState.StopRaise)
                {
                    if (expectedMessageCount == 3)
                    {
                        CrestronConsole.PrintLine("Start Ramp Level: {0}", _levelFB);
                        //Swallow the initial Level Message (for now);
                        expectedMessageCount--;
                        break;
                    }
                    else if (expectedMessageCount == 2)
                    {
                        expectedMessageCount--;
                        break;
                        //Next to last message (pulse)
                    }
                    else if (expectedMessageCount == 1)
                    {
                        //Final state (store in Level);
                        CrestronConsole.PrintLine("End Ramp Level: {0}", _levelFB);
                        expectedMessageCount--;
                        _level = dimmer.LevelFeedback.UShortValue;
                        SetLevelFB(_level);
                        currentState = loadState.Steady;
                        break;
                    }
                }
                else if (currentState == loadState.Toggle)
                {
                    if (expectedMessageCount == 2)
                    {
                        //Swallow first level
                        expectedMessageCount--;
                        break;
                    }
                    else if (expectedMessageCount == 1)
                    {
                        CrestronConsole.PrintLine("End State based on Toggle: {0}", _levelFB);
                        expectedMessageCount--;
                        _level = dimmer.LevelFeedback.UShortValue;
                        SetLevelFB(_level);
                        currentState = loadState.Steady;
                        break;
                    }
                }
                else
                {
                    if (currentState == loadState.Steady)
                    {
                        CrestronConsole.PrintLine("Toggle state encountered: {0}", _levelFB);
                        currentState         = loadState.Toggle;
                        expectedMessageCount = 1;
                        break;
                    }
                }

                break;

            case LoadEventIds.LevelInputChangedEventId:

                break;

            case LoadEventIds.PresetLoadIsAtEventId:

                break;

            case LoadEventIds.LastPresetCalledEventId:

                var dimmer2    = ((ClwDimmingLoad)(args.Load));
                var lastPreset = dimmer2.LastPresetCalled();


                if (lastPreset != null)
                {
                    LoadPresetCalledEvent presetMessage = new LoadPresetCalledEvent(this);
                    presetMessage.PresetNumber = lastPreset.Number;

                    hub.Publish <LoadPresetCalledEvent>(presetMessage);
                }
                else
                {
                }

                break;

            case LoadEventIds.LowerEventId:

                if (currentState == loadState.Lower)
                {
                    CrestronConsole.PrintLine("I was lowering, stopping lower");
                    currentState = loadState.StopLower;
                }
                else
                {
                    CrestronConsole.PrintLine("In default Lower block");
                    currentState         = loadState.Lower;
                    expectedMessageCount = 3;
                }

                LoadLowerEvent lowerMessage = new LoadLowerEvent(this);
                hub.Publish <LoadLowerEvent>(lowerMessage);

                break;

            case LoadEventIds.RaiseEventId:

                if (currentState == loadState.Raise)
                {
                    CrestronConsole.PrintLine("I was raising, stopping raise");
                    currentState = loadState.StopRaise;
                }
                else
                {
                    CrestronConsole.PrintLine("In default Raise block");
                    currentState         = loadState.Raise;
                    expectedMessageCount = 3;
                }

                LoadRaiseEvent raiseMessage = new LoadRaiseEvent(this);
                hub.Publish <LoadRaiseEvent>(raiseMessage);

                break;

            case LoadEventIds.OffReleaseEventId:

                currentState         = loadState.Toggle;
                expectedMessageCount = 2;

                LoadButtonOffReleaseEvent offReleaseMessage = new LoadButtonOffReleaseEvent(this);
                hub.Publish <LoadButtonOffReleaseEvent>(offReleaseMessage);
                break;

            default:
                break;
            }
        }
Example #22
0
        public void moveRoom()
        {
            switch (currentDirection) {
                case loadDirection.right:
                    if (currentOrigin.X < expectedOrigin.X -.5f) {
                        currentOrigin.X += .85f;
                        XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);

                    }
                    else {
                        XNACS1Base.World.SetWorldCoordinate
                        (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                        loads = loadState.finished;

                    }

                    break;

                case loadDirection.left:
                    if (currentOrigin.X > expectedOrigin.X + .5f) {
                        currentOrigin.X -= .85f;
                        XNACS1Base.World.SetWorldCoordinate
                            (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);
                    }

                    else {
                        loads = loadState.finished;
                        XNACS1Base.World.SetWorldCoordinate
                            (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                    }

                    break;

                case loadDirection.top:
                    if (currentOrigin.Y < expectedOrigin.Y - .5f) {
                        currentOrigin.Y += .85f;
                        XNACS1Base.World.SetWorldCoordinate
                            (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);
                    }

                    else {
                        loads = loadState.finished;
                        XNACS1Base.World.SetWorldCoordinate
                            (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                    }

                    break;

                case loadDirection.bottom:
                    if (currentOrigin.Y > expectedOrigin.Y + .5f) {
                        currentOrigin.Y -= .85f;
                        XNACS1Base.World.SetWorldCoordinate
                            (new Vector2(currentOrigin.X, currentOrigin.Y), 100f);
                    }

                    else {
                        loads = loadState.finished;
                        XNACS1Base.World.SetWorldCoordinate
                            (new Vector2(expectedOrigin.X, expectedOrigin.Y), 100f);
                    }

                    break;

                default:
                    loads = loadState.finished;
                    break;
            }
        }
Example #23
0
        public bool updateLevel(XNACS1Lib.XNACS1Lib.GamePadSupport.AllButtonsOnGamePad pad, 
			XNACS1Lib.XNACS1Lib.GamePadSupport.ThumbSticksOnGamePad thumbs, Hero hero)
        {
            Vector2 newRoom = new Vector2(-1, -1);
                if (rooms[(int)currentRoom.X, (int)currentRoom.Y].heroCaught || paused) {

                    if (ticker > 0) {
                        paused = true;
                        ticker--;
                    }

                    else {
                        paused = false;
                        rooms[(int)currentRoom.X, (int)currentRoom.Y].heroCaught = false;
                        ticker = 80;
                    }

                }

                else if (loads == loadState.notLoading) {
                    hero.UpdateHero(thumbs.Left);

                    newRoom = rooms[(int)currentRoom.X, (int)currentRoom.Y].updateRoom(hero, levelNum);
                    if (newRoom.X > -1) {
                        loads = loadState.loading;
                        if (newRoom.X > currentRoom.X)
                            currentDirection = loadDirection.right;

                        else if (newRoom.X < currentRoom.X)
                            currentDirection = loadDirection.left;

                        else if (newRoom.Y > currentRoom.Y)
                            currentDirection = loadDirection.top;

                        else
                            currentDirection = loadDirection.bottom;

                        lastVisitedRoom = currentRoom;
                        currentRoom = newRoom;
                        loadRoom(hero);

                        expectedOrigin = new Vector2(currentRoom.X * 100f, currentRoom.Y * ((9f / 16f) * 100f));

                    }
                }
            if (loads == loadState.loading) {
                hero.Visible = false;
                moveRoom();
            }

            if(loads == loadState.finished){
                hero.Visible = true;
                unLoadRoom();
                loads = loadState.notLoading;
                currentDirection = loadDirection.noDirection;
                currentOrigin = expectedOrigin;

            }

            if(rooms[(int)currentRoom.X, (int)currentRoom.Y].stairsInRoom()){
                if (hero.Collided(rooms[(int)currentRoom.X, (int)currentRoom.Y].stairs) && rooms[(int)currentRoom.X, (int)currentRoom.Y].stairs.available)
                    return true;
            }
            return false;
        }
Example #24
0
 protected virtual void Unload()
 {
     this.state = loadState.notLoaded;
 }