예제 #1
0
        string ShowSelector()
        {
            List <string> screens = new List <string>();

            for (int i = 0; i < grid.RowCount; i++)
            {
                screens.Add(grid.Rows[i].Cells[1].Value + "," + grid.Rows[i].Cells[2].Value + "," + grid.Rows[i].Tag.ToString());
            }
            ScreenSelector ss = new ScreenSelector(screens);

            ss.ShowDialog(this);
            if (ss.Tag == null)
            {
                return(null);
            }
            string ret = (string)ss.Tag;

            return(ret);
        }
예제 #2
0
 public bool TryFindNearestEdge(Vector2 mouseUv)
 {
     return(ScreenSelector.TryFindNearestEdge(mouseUv, BlendingData.Screens, BlendingData.Trapeziums,
                                              out selectedScreen, out selectedEdge));
 }
예제 #3
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();
        }
예제 #4
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();
            }
        }
예제 #5
0
        public EdgeControl(BlendingController bcon, Blending blending,
                           MouseTracker mouseTracker, BlendingController.MousePosition mouseCurr)
            : base(bcon, blending, mouseTracker, mouseCurr)
        {
            fsmOperation = new FSM <OperationEnum>();

            FsmActivity.State(ActivityEnum.Inactive);
            FsmActivity.State(ActivityEnum.Active).Enter(fsm => {
                mouseTracker.OnSelectionDown += (mt, f) => {
                    switch (f)
                    {
                    case MouseTracker.ButtonFlag.Left:
                        if (mouseCurr.TryInitEdgeMode())
                        {
                            fsmOperation.Goto(OperationEnum.MoveEdge);
                        }
                        break;

                    case MouseTracker.ButtonFlag.Right:
                        break;
                    }
                };
                mouseTracker.OnSelection += (mt, f) => {
                    fsmOperation.Update();
                };
                mouseTracker.OnSelectionUp += (mt, f) => {
                    fsmOperation.Goto(OperationEnum.None);
                };
            }).Update(fsm => {
                fsmOperation.Update();
            }).Exit(fsm => {
                fsmOperation.Goto(OperationEnum.None);
                mouseTracker.Clear();
            });
            FsmActivity.Init();

            fsmOperation.State(OperationEnum.None);
            fsmOperation.State(OperationEnum.MoveEdge).Update(fsm => {
                if (bcon.IsOverGUI)
                {
                    return;
                }

                mouseCurr.Update();

                var duv       = mouseCurr.WorldDuv;
                var screen    = mouseCurr.selectedScreen;
                var data      = blending.BlendingData;
                var iscreen   = screen.x + screen.y * data.Screens.x;
                var trap      = data.Trapeziums[iscreen];
                var iv0       = ScreenSelector.PAIR_EDGES[2 * mouseCurr.selectedEdge];
                var iv1       = ScreenSelector.PAIR_EDGES[2 * mouseCurr.selectedEdge + 1];
                var dx        = ScreenSelector.ScreenSize(data.Screens);
                var worldTrap = ScreenSelector.LocalToWorld(screen.x, screen.y, trap, dx);
                var tan       = (worldTrap[iv1] - worldTrap[iv0]).normalized;
                duv          -= Vector2.Dot(duv, tan) * tan;
                trap[iv0]    += duv;
                trap[iv1]    += duv;
                trap.Clamp01();
                data.Trapeziums[iscreen] = trap;
                data.Invalidate();
            });
            fsmOperation.Init();
        }