Exemplo n.º 1
0
    void OnMouseOver()
    {
        if (Input.GetMouseButtonUp(0))
        {
            panel.SetShine(Id); //先给选中框
        }
        if (Input.GetMouseButtonUp(1))
        {
            if (MatchManager.Instance.PlayerTurn)
            {
                var target = panel.GetShine();
                if (target == null) //无法空操作
                {
                    return;
                }

                if (target != gameObject)
                {
                    var targetCell  = target.GetComponent <BattleCell>();
                    var nowCellInfo = MatchManager.Instance.GetCell(Id);
                    //   Debug.Log(string.Format("state id={0} side={1} hide={2}", nowCellInfo.Id, nowCellInfo.Side, nowCellInfo.IsHide));
                    if (!nowCellInfo.IsHide && nowCellInfo.Side == 2)
                    {
                        panel.Fight(targetCell, this);
                        MatchManager.Instance.NextTurn();
                    }
                    else //交换位置
                    {
                        panel.ExchangePos(this, targetCell);
                        MatchManager.Instance.NextTurn();
                    }
                }
                else
                {
                    Open();
                    MatchManager.Instance.NextTurn();
                }
            }
        }
    }