Example #1
0
        public void UpdatePanelOnMouse()
        {
            Vector2 p   = Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y));
            NVector pos = new NVector((int)p.x, (int)p.y, GameMgmt.Get().newMap.view.ActiveLevel);

            Debug.Log($"Click on {pos}");

            if (!pos.Valid())
            {
                NAudio.PlayBuzzer();
                return;
            }

            //active action?
            if (_action != null)
            {
                _action.Click(pos);
            }
            else
            {
                UpdatePanel(pos);
            }

            //center mouse?
            if (LSys.tem.options["centermouse"].Bool())
            {
                S.CameraMove().MoveTo(pos);
            }
        }
Example #2
0
        public void Call(Player player)
        {
            GameButton b = L.b.gameButtons[id];

            if (!b.req.Check(player))
            {
                NAudio.PlayBuzzer();
                UIHelper.ShowOk(b.Name(), b.req.Desc(player));
                return;
            }
            Run(player);
        }
Example #3
0
        public virtual void ShowPanelMessageError(string text)
        {
            if (text == null)
            {
                ShowPanelMessage("");
                return;
            }

            infoText.color = Color.magenta;
            infoText.text  = text;
            NAudio.PlayBuzzer();
        }
Example #4
0
        protected override void ClickFirst()
        {
            Debug.Log("Click first on " + LastClickPos);

            UnitInfo      unit    = (UnitInfo)mapElementInfo;
            string        moveTyp = unit.dataUnit.movement;
            var           path    = GameMgmt.Get().newMap.PathFinding(mapElementInfo.Pos().level);
            List <PPoint> way     = path.Path(player, moveTyp, mapElementInfo.Pos(), new NVector(LastClickPos.x, LastClickPos.y, mapElementInfo.Pos().level));

            if (way.Count == 0)
            {
                OnMapUI.Get().unitUI.ShowPanelMessage($"Can not move to this field. No path found.");
                NAudio.PlayBuzzer();
                return;
            }

            //show way
            Remove();
            int round = 0;
            int cost  = 0;

            Color(LastClickPos, 0);

            foreach (var p in way)
            {
                NVector pos = new NVector(p.x, p.y, LastClickPos.level);
                cost += path.CostNode(player, moveTyp, pos);
                if (cost > unit.data.ap + round * unit.data.apMax * round)
                {
                    round++;
                }
                Color(pos, round % 4);
            }

            OnMapUI.Get().unitUI.ShowPanelMessage($"You want to move to this field for {cost} AP? Click again!");
        }
Example #5
0
 public void ShowPanelMessageError(string text)
 {
     OnMapUI.Get().bottomButtonText.color = Color.magenta;
     OnMapUI.Get().bottomButtonText.text = text;
     NAudio.PlayBuzzer();
 }
Example #6
0
        // Update is called once per frame
        void Update()
        {
            //find key?
            if (findKey != null)
            {
                if (Input.anyKey)
                {
                    foreach (var key in keyValues)
                    {
                        if (key.ToString().StartsWith("mouse"))
                        {
                            continue;
                        }

                        if (Input.GetKeyDown((KeyCode)key))
                        {
                            findKey((KeyCode)key);
                        }
                    }
                }
                return;
            }

            if (LSys.tem == null || LSys.tem.inputs == null)
            {
                Debug.Log($"LSys.tem is not loaded, can not perform key check. LSys.tem:${LSys.tem != null} LSys.tem.inputs:${LSys.tem != null && LSys.tem.inputs != null}");
                return;
            }

            //check all buttons
            foreach (InputKey key in LSys.tem.inputs.Values())
            {
                //active?
                if (key.Hidden)
                {
                    continue;
                }

                //pressed?
                if (!Input.GetKeyDown(key.KeyCode()))
                {
                    continue;
                }

                //req fullfilled?
                if (!key.req.Check(ActPlayer(), active, active?.Pos()))
                {
                    if (S.IsGame())
                    {
                        OnMapUI.Get().ShowPanelMessageError(key.req.Desc(ActPlayer(), active, active?.Pos()));
                    }
                    else
                    {
                        //TODO show error
                        NAudio.PlayBuzzer();
                    }
                    continue;
                }

                try
                {
                    if (key.IsGameButton())
                    {
                        PressGameButton(key);
                        return;
                    }

                    if (key.IsAction())
                    {
                        PressAction(key);
                        return;
                    }

                    PressHidden(key);
                    return;
                }
                catch (Exception e)
                {
                    ExceptionHelper.ShowException(e);
                }
            }

            MouseMoveMap();
        }
Example #7
0
 public void ShowPanelMessageError(string text)
 {
     menuButtonText.color = Color.magenta;
     menuButtonText.text  = text;
     NAudio.PlayBuzzer();
 }