Esempio n. 1
0
    private void AiThink()
    {
        if (MatchManager.Instance.PlayerTurn)
        {
            return;
        }

        var attackPair = GetAttackPair();

        if (attackPair != null)
        {
            Panel.Fight(attackPair.Attacker.Id, attackPair.Defender.Id);
            MatchManager.Instance.NextTurn();
            return;
        }

        var hiddenCells = MatchManager.Instance.GetAll().FindAll(cell => cell.IsHide && cell.Side > 0);

        if (hiddenCells.Count > 10)//todo temp code
        {
            var openTarget = hiddenCells[MathTool.GetRandom(hiddenCells.Count)];
            Panel.Open(openTarget.Id);
            MatchManager.Instance.NextTurn();
            return;
        }
    }
Esempio n. 2
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();
                }
            }
        }
    }