示例#1
0
        public void DoCombat(bool retreat)
        {
            Round++;
            Enemies[0].Combat(Party.ToArray(), retreat);
            var dead       = new List <Puppet>();
            int deathCount = 0;

            for (int i = 0; i < Party.Count; i++)
            {
                if (Party[i].State == PuppetState.Dead && !knownDead[i])
                {
                    dead.Add(Party[i]);
                    knownDead[i] = true;
                }
                if (knownDead[i])
                {
                    deathCount++;
                }
            }

            if (dead.Count > 0)
            {
                OnPuppetDies?.Invoke(this, new BattleEventArgs(Enemies, dead.ToArray(), Round));
            }
            if (deathCount == Party.Count)
            {
                OnBattleLost?.Invoke(this, new BattleEventArgs(Enemies, Party.ToArray(), Round));
                Ended = true;
            }
            else if (Enemies[0].State == PuppetState.Dead)
            {
                GenerateRelics();
                OnEnemyDies?.Invoke(this, new BattleEventArgs(Enemies, Party.ToArray(), Round));
                Ended = true;
            }
            else if (retreat)
            {
                OnRetreated?.Invoke(this, new BattleEventArgs(Enemies, Party.ToArray(), Round));
                Ended = true;
            }
            else
            {
                OnNextRound?.Invoke(this, new BattleEventArgs(Enemies, Party.ToArray(), Round));
            }
        }
示例#2
0
        void TryMoveChess(Check fromCheck, Check toCheck)
        {
            //Debug.Log($"[Game] TryMoveChess {fromCheck.Pos}, {toCheck.Pos}");
            if (fromCheck == null || toCheck == null)
            {
                return;
            }

            // 沒有可以移動的棋,或者對面有棋導致無法移動過去
            if (fromCheck.CurrentChess == null || toCheck.CurrentChess != null)
            {
                return;
            }

            if (!IsMoveValid(fromCheck, toCheck, out var moveTimes))
            {
                return;
            }

            void MoveAndEndRound()
            {
                MoveChess(fromCheck, toCheck);
                RoundEnd();
                OnNextRound?.Invoke();
            }

            // 可以連跳
            if (GameSetting.Instance.ShowHint && mCurMaxMove > moveTimes)
            {
                Notify.Instance.InitNotify(new NotifyData
                {
                    Content      = Notify.kBetterChoice,
                    ConfirmText  = "I'm sure.",
                    ConfirmEvent = MoveAndEndRound,
                    CancelText   = "Wait!",
                    CancelEvent  = null,
                });
                Notify.Instance.Show();
                return;
            }

            MoveAndEndRound();
            return;
        }
示例#3
0
        void ChessRemove(Chess chess)
        {
            //Debug.Log($"[Game] ChessRemove {chess.Pos}");
            OnChessSelect?.Invoke(chess.Pos);

            if (mCurSelectFrom == null ||
                mCurSelectFrom.Pos != chess.Pos)
            {
                var check = mCheckArray[chess.XPos, chess.YPos];
                mCurSelectFrom = check;
                return;
            }

            // Remove first chess
            RemoveChess(chess.Pos);

            RoundEnd();
            OnNextRound?.Invoke();
        }
示例#4
0
 public void NextRoundButton()
 {
     OnNextRound?.Invoke();
 }
示例#5
0
 /// <summary>
 /// This is the funciton to call the OnNextRound event
 /// </summary>
 public void InvokeOnNextRound()
 {
     OnNextRound?.Invoke();
 }