Beispiel #1
0
    public void OnMouseDown()
    {
        // 当前选中的武将准备移动,那么不能点击其他武将
        if (msCurrentWujiang)
        {
            if (msCurrentWujiang.GetWujiangState() == WujiangState.WujiangState_Prepare_Expedition ||
                msCurrentWujiang.GetWujiangState() == WujiangState.WujiangState_Prepare_Move ||
                msCurrentWujiang.GetWujiangState() == WujiangState.WujiangState_Prepare_Attack
                )
            {
                return;
            }
        }
        // 防止移动过程中点击武将
        if (Pathfinding.GetInstance().IsShowingPath())
        {
            return;
        }
        // 选中武将
        mSelected = !mSelected;
        Seclet(mSelected);

        if (mSelected)
        {
            ShowPath();
            SetWujiangState(WujiangState.WujiangState_Prepare_Move);
            BattleGameManager.msIgnoreRaycast = true;
        }
    }
Beispiel #2
0
    // 骑兵:2
    public static void Skill_Qibing02(Wujiang wujiang, Coordinates target)
    {
        Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions();
        Wujiang targetWujiang = wujiangExpeditions[target];

        // 1.伤害
        targetWujiang.OnDamage(3000);
        // 2.移动
        Coordinates c1 = wujiang.GetCoordinates();
        Coordinates c2 = targetWujiang.GetCoordinates();
        int         dx = (c2.HexX - c1.HexX);
        int         dy = (c2.HexY - c1.HexY);

        Coordinates myCoordinates = new Coordinates();

        myCoordinates.SetHexXY(c2.HexX + dx, c2.HexY + dy);
        if (!Skills.CanMoveIn(myCoordinates))
        {
            if (targetWujiang.GetWujiangState() == WujiangState.WujiangState_Dead)
            {
                wujiang.Move(c2);
                return;
            }
            return;
        }
        wujiang.Move(myCoordinates);
    }
Beispiel #3
0
    void Update()
    {
        if (IsPointerOverGameObject(Input.mousePosition))
        {
            if (mMobileTouchCamera.enabled)
            {
                mMobileTouchCamera.enabled = false;
            }
            return;
        }
        if (!mMobileTouchCamera.enabled)
        {
            mMobileTouchCamera.enabled = true;
        }
        RaycastHit hit;
        // 从鼠标所在的位置发射
        Vector2 screenPosition = Input.mousePosition;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(screenPosition), out hit))
        {
            // 1.点击格子,主要用于行军
            Vector3 pointCubePosition = MapManager.GetInstance().TerrainPositionToCenterPosition(hit.point);
            pointCubePosition.y           = mOriginalPosition.y;
            mPointCube.transform.position = pointCubePosition;
            if (Input.GetMouseButtonUp(0))
            {
                // 这个主要是因为防止刚刚点击武将,战斗菜单就显示出来了
                if (msIgnoreRaycast)
                {
                    msIgnoreRaycast = false;
                    return;
                }
                Wujiang currentWujiang = Wujiang.GetCurrentWujiang();
                if (currentWujiang != null)
                {
                    // 1.当前处于要攻击状态
                    // 这个主要是因为防止刚刚点击武将,战斗菜单就显示出来了
                    if (currentWujiang.GetWujiangState() == WujiangState.WujiangState_Prepare_Attack)
                    {
                        // 释放技能
                        mCanvasBattleMenu.MoveAndStartSkill(MapManager.GetInstance().TerrainPositionToCorrdinate(pointCubePosition));
                        return;
                    }
                    // 2.显示战斗菜单
                    currentWujiang.ShowBattleMeun(new Vector3(mPointCube.transform.position.x, currentWujiang.transform.position.y, mPointCube.transform.position.z));
                    return;
                }
                // 2.点击城市
                if (hit.collider.CompareTag("City"))
                {
                    if (currentWujiang != null || Pathfinding.GetInstance().IsShowingPath())
                    {
                        return;
                    }
                    if (Input.GetMouseButtonUp(0))
                    {
                        GameObject city;
                        if (hit.collider.gameObject.name.Equals("Model"))
                        {
                            // 关隘
                            city = hit.collider.transform.parent.gameObject;
                        }
                        else
                        {
                            // 港口
                            city = hit.collider.transform.gameObject;
                        }
                        // 显示小菜单
                        mCanvasGameMenu.SetCity(city.GetComponent <City>());
                        mCanvasGameMenu.ShowCanvasGameMenu(screenPosition);
                    }
                }
            }
        }
        // 3.点击空白
        if (Input.GetMouseButtonDown(0))
        {
            mCanvasGameMenu.gameObject.SetActive(false);
            mCanvasBattleMenu.gameObject.SetActive(false);
        }
    }