Exemple #1
0
        public void UpdateHUD(KeyboardState newState)
        {
            // Update X cordinate
            HUD_X = Convert.ToInt32(HUD_IsHiddenAnimation_Value);


            // Update IsHidden Animation
            if (HUD_IsHiddenToggle && !HUD_IsHiddenAnimation_Enabled)
            {
                HUD_IsHiddenToggle            = false;
                HUD_IsHiddenAnimation_Enabled = true;
            }

            if (HUD_IsHiddenAnimation_Enabled)
            {
                HUD_IsHiddenAnimation_ValueMultiplier += 1f;

                if (HUD_IsHiddenAnimationMode == 0)
                {
                    HUD_IsHiddenAnimation_Value -= HUD_IsHiddenAnimation_ValueMultiplier;

                    if (HUD_IsHiddenAnimation_Value <= -HUD_Width + 10)
                    {
                        HUD_IsHiddenAnimation_Value           = -HUD_Width + 10;
                        HUD_IsHiddenAnimation_Enabled         = false;
                        HUD_IsHiddenAnimationMode             = 1;
                        HUD_IsHiddenAnimation_ValueMultiplier = 0.5f;
                        HUD_IsHidden = true;
                    }
                }
                else if (HUD_IsHiddenAnimationMode == 1)
                {
                    HUD_IsHiddenAnimation_Value += HUD_IsHiddenAnimation_ValueMultiplier;

                    if (HUD_IsHiddenAnimation_Value >= 0)
                    {
                        HUD_IsHiddenAnimation_Value           = 0;
                        HUD_IsHiddenAnimation_Enabled         = false;
                        HUD_IsHiddenAnimationMode             = 0;
                        HUD_IsHiddenAnimation_ValueMultiplier = 0.5f;
                        HUD_IsHidden = false;
                    }
                }
            }

            // Hides/Unhides HUD
            if (Utils.CheckKeyUp(oldState, newState, Keys.J))
            {
                HUD_IsHiddenToggle = true;
            }


            if (HUD_IsHidden)
            {
                return;
            }

            // Next TileSprite
            if (Utils.CheckKeyUp(oldState, newState, Keys.Up))
            {
                HUD_SelectedTileIndex += 1;

                UpdateTileIndex();
            }

            // Previuos Map Tile
            if (Utils.CheckKeyUp(oldState, newState, Keys.Down))
            {
                HUD_SelectedTileIndex -= 1;

                if (HUD_SelectedTileIndex <= -2)
                {
                    HUD_SelectedTileIndex = 0;
                }

                UpdateTileIndex();
            }

            // Next Map Layer
            if (Utils.CheckKeyUp(oldState, newState, Keys.F10))
            {
                if (HUD_SelectedLayer == Convert.ToInt32(Registry.ReadKeyValue("/editor/map_max_layers")))
                {
                    HUD_SelectedTileIndex = Convert.ToInt32(Registry.ReadKeyValue("/editor/map_max_layers"));
                }
                else
                {
                    HUD_SelectedLayer += 1;
                }
            }

            // Previus Map Layer
            if (Utils.CheckKeyUp(oldState, newState, Keys.F9))
            {
                HUD_SelectedLayer -= 1;

                if (HUD_SelectedLayer <= -1)
                {
                    HUD_SelectedLayer = -1;
                }
            }

            // Clear custom atributes
            if (Utils.CheckKeyUp(oldState, newState, Keys.F12))
            {
                UpdateTileAtribute();
            }

            // Call dialog for setting custom atributes
            if (Utils.CheckKeyUp(oldState, newState, Keys.F11))
            {
                if (HUD_SelectedLayer == 1)
                {
                    DialogAction(4);
                }
                else
                {
                    DialogMessage("Re");
                }
            }


            // Toggle Help
            if (Utils.CheckKeyUp(oldState, newState, Keys.H))
            {
                DialogMessage(Registry.ReadKeyValue("/editor/help_screen"));
            }

            // Set IsColideable Parameter
            if (Utils.CheckKeyUp(oldState, newState, Keys.F5))
            {
                if (HUD_SelectedLayer != 0)
                {
                    DialogMessage(Registry.ReadKeyValue("/editor/editor_layer_not_supports_colision_flag"));
                }
                else
                {
                    if (!HUD_SelectedTileAtribute_Colideable)
                    {
                        HUD_SelectedTileAtribute_Colideable = true;
                    }
                    else
                    {
                        HUD_SelectedTileAtribute_Colideable = false;
                    }
                }
            }

            // Decrease InterationID
            if (Utils.CheckKeyUp(oldState, newState, Keys.F6))
            {
                if (HUD_SelectedLayer != 1)
                {
                    DialogMessage(Registry.ReadKeyValue("/editor/editor_layer_not_supports_action_id"));
                }
                else
                {
                    HUD_SelectedTileAtribute_ObjectTileInterationID -= 1;

                    if (HUD_SelectedTileAtribute_ObjectTileInterationID <= -1)
                    {
                        HUD_SelectedTileAtribute_ObjectTileInterationID = 0;
                    }
                }
            }

            // Increase InteractionID
            if (Utils.CheckKeyUp(oldState, newState, Keys.F7))
            {
                if (HUD_SelectedLayer != 1)
                {
                    DialogMessage(Registry.ReadKeyValue("/editor/editor_layer_not_supports_action_id"));
                }
                else
                {
                    HUD_SelectedTileAtribute_ObjectTileInterationID += 1;
                }
            }

            // Run Test the Map
            if (Utils.CheckKeyUp(oldState, newState, Keys.F4))
            {
                SaveCurrentMap();

                Global.CurrentMapName = Global.MAP_SourceFolder + "/" + Global.MapEditor_CurrentMapName + ".map";
                Global.ForceReloadMap = true;


                ScreenSelector.SetCurrentScreen(0);
            }

            // Save Dialog
            if (Utils.CheckKeyUp(oldState, newState, Keys.F1))
            {
                if (!MapHasBeenLoaded)
                {
                    DialogMessage(Registry.ReadKeyValue("/editor/cannot_save_without_map"));
                }
                else
                {
                    DialogAction(1);
                }
            }

            // Load Dialog
            if (Utils.CheckKeyUp(oldState, newState, Keys.F2))
            {
                DialogAction(2);
            }

            // NewMap Dialog
            if (Utils.CheckKeyUp(oldState, newState, Keys.F3))
            {
                DialogAction(3);
            }

            // Map Properties Dialog
            if (Utils.CheckKeyUp(oldState, newState, Keys.P))
            {
                DialogAction(5);
            }


            // Update selected tile
            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                UpdateSelectedTile();
            }
        }
Exemple #2
0
        public override void Update()
        {
            base.Update();

            KeyboardState newState = Keyboard.GetState();

            // Reload Map Key
            ReloadMapKey(newState);

            // Change to Map Editor Screen
            if (Utils.CheckKeyDown(oldState, newState, Keys.F5))
            {
                MapObjects.Clear();
                Taiyou.Global.Reload();
                ScreenSelector.SetCurrentScreen(1);
            }

            if (Utils.CheckKeyDown(oldState, newState, Keys.H))
            {
                DebugTestVar += 0.01f;
                Console.WriteLine("DEBUG VARIABLE VALUE:" + DebugTestVar);
            }
            if (Utils.CheckKeyUp(oldState, newState, Keys.N))
            {
                DebugTestVar += 0.01f;
                Console.WriteLine("DEBUG VARIABLE VALUE:" + DebugTestVar);
            }
            if (Utils.CheckKeyDown(oldState, newState, Keys.J))
            {
                DebugTestVar -= 0.01f;
                Console.WriteLine("DEBUG VARIABLE VALUE:" + DebugTestVar);
            }
            if (Utils.CheckKeyUp(oldState, newState, Keys.M))
            {
                DebugTestVar -= 0.05f;
                Console.WriteLine("DEBUG VARIABLE VALUE:" + DebugTestVar);
            }
            if (Utils.CheckKeyUp(oldState, newState, Keys.K))
            {
                DebugTestVar = 1.0f;
                Console.WriteLine("DEBUG VARIABLE VALUE:" + DebugTestVar);
            }
            if (Utils.CheckKeyUp(oldState, newState, Keys.L))
            {
                DebugTestVar = 0;
                Console.WriteLine("DEBUG VARIABLE VALUE:" + DebugTestVar);
            }


            // If map failed to load, return
            if (MapLoadingError)
            {
                oldState = newState;
                return;
            }

            // Set this game instance
            TaiyouGlobal.CurrentGameInstance = this;

            // If map needs to be reloaded
            if (Global.ForceReloadMap)
            {
                Initialize();
                return;
            }

            UpdateCamera();

            foreach (var obj in MapObjects)
            {
                obj.CameraX            = CameraX;
                obj.CameraY            = CameraY;
                obj.CurrentMapRenderer = MapView;


                obj.Update();
            }

            MapView.CameraX = CameraX;
            MapView.CameraY = CameraY;

            oldState = newState;

            // Update Player
            if (!Initialized)
            {
                return;
            }
            CurrentPlayer.Update();
        }