Пример #1
0
    // Update is called once per frame
    void Update()
    {
        //if (map_ctr.CheckIfWin())
        //{
        //    WinScene.SetActive(true);
        //    map_ctr.reset();
        //}

        //else if (map_ctr.CheckIfLose())
        //{
        //    LoseScene.SetActive(true);
        //    map_ctr.reset();
        //}

        //Player round
        if (gameRound == "Player")
        {
            map_ctr.Character_Click();
        }

        if (map_ctr.character_moving)
        {
            endTurnButton.GetComponent <Button>().interactable = false;
        }
        else
        {
            endTurnButton.GetComponent <Button>().interactable = true;
        }

        if (roundUI_showing)
        {
            Image round_UI;
            if (gameRound == "Player")
            {
                round_UI = UI.GetComponent <InGameUI>().Player_roundUI;
            }
            else if (gameRound == "AI")
            {
                round_UI = UI.GetComponent <InGameUI>().Enemy_roundUI;
            }
            else
            {
                round_UI        = null;
                roundUI_showing = false;
            }


            if (round_UI != null)
            {
                round_UI.gameObject.SetActive(true);
                float screen_width = UI.GetComponent <RectTransform>().rect.width;
                float speed;
                float mid_1 = screen_width * 9 / 20;
                float mid_2 = screen_width * 11 / 20;
                if (round_UI.rectTransform.anchoredPosition.x > mid_1 &&
                    round_UI.rectTransform.anchoredPosition.x < mid_2)
                {
                    speed = 200;
                }
                else
                {
                    speed = 2500;
                }

                round_UI.rectTransform.anchoredPosition = new Vector2(round_UI.rectTransform.anchoredPosition.x
                                                                      + speed * Time.deltaTime, 0);

                if (round_UI.rectTransform.anchoredPosition.x > screen_width)
                {
                    roundUI_showing = false;
                    round_UI.rectTransform.anchoredPosition = new Vector2(0, 0);
                    round_UI.gameObject.SetActive(false);
                }
            }
        }
    }