コード例 #1
0
    void moveMenuCursor()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            openMenu = false;
            unitMenu = false;
            //mc.removeZone ();
            for (int i = 0; i < menuOptions.Length; i++)
            {
                DestroyObject(menuOptions [i]);
            }
            actionOption = -1;
        }

        else if (Input.GetKeyDown(KeyCode.D) && menuOptions.Length > 1)
        {
            int previousOption = currentMenuOption;
            currentMenuOption = (currentMenuOption + 1) % menuOptions.Length;
            menuOptions[currentMenuOption].color = menuCursorColor;
            menuOptions[previousOption].color    = new Color(1f, 1f, 1f);
        }

        else if (Input.GetKeyDown(KeyCode.A) && menuOptions.Length > 1)
        {
            int previousOption = currentMenuOption;
            currentMenuOption -= 1;
            if (currentMenuOption < 0)
            {
                currentMenuOption = menuOptions.Length - 1;
            }
            menuOptions[currentMenuOption].color = menuCursorColor;
            menuOptions[previousOption].color    = new Color(1f, 1f, 1f);
        }

        else if (Input.GetKeyDown(KeyCode.Space))
        {
            actionOption = currentMenuOption;

            if (unitMenu)
            {
                unitMenu           = false;
                unitActionSelected = true;
                changeCursorColor(MyColor.green);
                Vector3 pos = cursor.transform.position;

                selectedGO = tms.getUnitAtTile((int)pos.z, (int)pos.x);
                UnitBehaviour ub = selectedGO.GetComponent <UnitBehaviour> ();
                //if(actionOption == 0)
                //mc.markZone ((int) pos.x, (int) pos.z, ub.attackRange);
                //else if(actionOption == 1)
                //mc.markZone ((int) pos.x, (int) pos.z, ub.stepLength);
            }
            else
            {
                if (actionOption == 0)
                {
                    endTurn();
                    actionOption = -1;
                    changeCursorColor(MyColor.cyan);
                }
                else
                {
                    generalActionSelected = true;
                    changeCursorColor(MyColor.green);
                }
            }
            openMenu = false;
            for (int i = 0; i < menuOptions.Length; i++)
            {
                DestroyObject(menuOptions [i]);
            }
        }
    }