Esempio n. 1
0
    void UseItem()
    {
        if (Action.itemIndex == -1 || itemList.GetItem(Action.itemIndex) == null)
        {
            return;
        }

        //Debug.Log("使用 " + Action.itemIndex);
        int targetIndex;

        if (Input.GetMouseButtonUp(0))
        {
            targetIndex = HexMapEditor.GetPointedIndex();

            //Debug.Log("1" + targetIndex);
            int range = itemList.GetItem(Action.itemIndex).range;
            //Debug.Log("2");
            if (hexGrid.GetRoleID(targetIndex) == -1)
            {
                if (range != 0)
                {
                    //Debug.Log("3" + hexGrid.GetRoleID(targetIndex));
                    return;
                }
            }

            //Debug.Log("4");

            Action.targetIndex = targetIndex;
            //Debug.Log("5");
            int myIndex = hexGrid.GetCellIndex(transform.position);
            //Debug.Log("6");

            if (!hexGrid.CheckInRange(myIndex, targetIndex, range))
            {
                if (range != 0)
                {
                    //Debug.Log("7");
                    return;
                }
            }
            //Debug.Log("8");

            itemList.UseItem(id, hexGrid.GetRoleID(targetIndex), Action.itemIndex);
            //Debug.Log("9");
        }
    }
Esempio n. 2
0
    void Move()
    {
        if (!EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonUp(0))
        {
            int index   = hexGrid.GetCellIndex(transform.position); //当前人物位置
            int pointed = HexMapEditor.GetPointedIndex();           //当前光标位置

            //检测是否在移动范围,是否有其他人,是否有充足能量
            if (hexGrid.CheckInRange(index, pointed, 10) && hexGrid.GetRoleID(pointed) == -1 && UseEnergy(1))
            {
                hexGrid.SetRoleID(index, -1);
                hexGrid.SetRoleID(pointed, id);
                AddEXP(1);
                transform.position = HexMapEditor.GetPointedVec();
            }
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(hexGrid.PointedTag());
        switch (hexGrid.GetRoleID(HexMapEditor.GetPointedIndex()))
        {
        case 0:
            ShowRoleInfo(0);
            break;

        case 1:
            ShowRoleInfo(1);
            break;

        case 2:
            ShowRoleInfo(2);
            break;

        case 3:
            ShowRoleInfo(3);
            break;

        default: break;
        }
    }