Exemple #1
0
    public void OnClick(Vec2 pt, Vector3 wp)
    {
        if (MapUnit.inReplay)
        {
            return;
        }

        if (UUIs.CurUnitType == null)
        {
            return;
        }

#if UNITY_EDITOR
        if (EventLayerHandler.CurrentClickBtn == UnityEngine.EventSystems.PointerEventData.InputButton.Right)
        {
            OnRightClick(pt, wp);
            return;
        }
#endif

        this.pt = pt;
        this.wp = wp;

        var cp = new Vec2(wp.x, wp.z);

        var adaptWp = wp;
        var adaptCp = cp;

        var us = Room.GetUnitsInArea(cp, 1, (u) => PlaceBuildingLst.Contains(u));

        if (IsSpecificAreaUnit)
        {
            if (us.Length <= 0)
            {
                AddTip("该区域不可建造");
                UPSUI.Hide();
                return;
            }
            else
            {
                adaptCp = us[0].Pos;
                adaptWp = new Vector3((float)adaptCp.x, 0.0f, (float)adaptCp.y);
            }
        }

        if (UnitConfiguration.GetDefaultConfig(UUIs.CurUnitType).IsBuilding)
        {
            if (adaptCp.y > 70 && GameCore.Instance.MePlayer == 1)
            {
                AddTip("只能在自己一侧建造");
                UPSUI.Hide();
                return;
            }
            else if (adaptCp.y < room.MapSize.y - 70 && GameCore.Instance.MePlayer == 2)
            {
                AddTip("只能在自己一侧建造");
                UPSUI.Hide();
                return;
            }

            UC.ShowExampleUnit(UUIs.CurUnitType, adaptWp);
            UPSUI.Show();
            UPSUI.ReSetPos(pt, adaptCp);
        }
        else
        {
            // 只能在各自那边建造,除了伞兵和雷达
            if (UUIs.CurUnitType != "SoldierCarrier" && UUIs.CurUnitType != "RobotCarrier" && UUIs.CurUnitType != "Radar")
            {
                if (adaptCp.y > 70 && GameCore.Instance.MePlayer == 1)
                {
                    adaptCp.y = 70;
                }
                else if (adaptCp.y < room.MapSize.y - 70 && GameCore.Instance.MePlayer == 2)
                {
                    adaptCp.y = room.MapSize.y - 70;
                }
            }

            OnClickMap(pt, adaptCp);

            //UUIs.CancelSelUnit();
        }
    }