示例#1
0
 public void StartGame()
 {
     if (TurnStart != null)
     {
         TurnStart.Invoke();
     }
     turnPlayer.Turn();
 }
示例#2
0
 public void NextTurn()
 {
     if (TurnEnd != null)
     {
         TurnEnd.Invoke();
     }
     turn++;
     Debug.Log(turnPlayer);
     if (TurnStart != null)
     {
         TurnStart.Invoke();
     }
     turnPlayer.Turn();
 }
示例#3
0
        public void OnTurnStart(TurnStart turn)
        {
            MyBoard         = turn.MeColoredBoard;
            EnemyBoard      = turn.EnemyColoredBoard;
            MyAgent1        = turn.MeAgent1;
            MyAgent2        = turn.MeAgent2;
            EnemyAgent1     = turn.EnemyAgent1;
            EnemyAgent2     = turn.EnemyAgent2;
            CurrentTurn     = turn.Turn;
            SendingFinished = false;

            Log("[IPC] Receive TurnStart turn = {0}", turn.Turn);
            DumpBoard(turn.MeColoredBoard, turn.EnemyColoredBoard, MyAgent1, MyAgent1, EnemyAgent1, EnemyAgent2);

            StartSolve();
            timer.Interval = CalculateTimerMiliSconds(turn.WaitMiliSeconds);
            timer.Enabled  = true;
        }
示例#4
0
        public void OnTurnStart(TurnStart turn)
        {
            MyBoard         = turn.MeColoredBoard;
            EnemyBoard      = turn.EnemyColoredBoard;
            MyAgents        = turn.MyAgents;
            EnemyAgents     = turn.EnemyAgents;
            IsAgentsMoved   = turn.IsAgentsMoved;
            CurrentTurn     = turn.Turn;
            SendingFinished = false;

            Log("[IPC] Receive TurnStart turn = {0}", turn.Turn);
            DumpBoard(turn.MeColoredBoard, turn.EnemyColoredBoard, AgentsCount, MyAgents, EnemyAgents);

            StartSolve();
            if (IsEnableTimer)
            {
                timer.Interval = CalculateTimerMiliSconds(turn.WaitMiliSeconds);
                timer.Enabled  = true;
            }
        }
示例#5
0
 public OrdinalModel(FieldParameters fieldParameters)
 {
     Field            = new Field(fieldParameters);
     turns.TurnStart += Field.NextTurn;
     turns.TurnStart += () => TurnStart?.Invoke();
 }
示例#6
0
        public override void Update()
        {
            // Pre-battle

            ShowText("Beginning battle between " + battlers[0].Name + " and " + battlers[1].Name + ". ");
            foreach (Battler b in battlers)
            {
                if (!(b is Player))
                {
                    NPC n = (NPC)b;
                    ShowText(n.Name + ": " + n.Text[0]);
                }
            }

            // Main battle loop
            while (battlers[0].Mana > 0 && battlers[1].Mana > 0)
            {
                // Main turn loop
                foreach (Battler b in battlers)
                {
                    // Pre-turn
                    cursorLocation[0] = 2;
                    cursorLocation[1] = 0;
                    if (b.Mana <= 0)
                    {
                        break;
                    }
                    if (b.Mana > b.MaxManaAllotment)
                    {
                        b.Mana         -= b.MaxManaAllotment;
                        b.ManaAllotment = b.MaxManaAllotment;
                    }
                    else
                    {
                        b.ManaAllotment = b.Mana - 1;
                        b.Mana          = 1;
                    }
                    ShowText(b.Name + "'s turn.", !(b is NPC));
                    b.HasMoved = false;
                    if (b.PlayDeck.Count > 0)
                    {
                        if ((turn > 0 || Array.IndexOf(battlers, b) > 0) && b.Hand.Count < 9)
                        {
                            b.Draw();
                        }
                    }
                    else
                    {
                        b.Mana -= b.MaxManaAllotment;
                        ShowText(b.Name + "'s deck is empty! " + b.Name + " takes " + b.MaxManaAllotment + " damage as punishment!");
                        if (b.Mana <= 0)
                        {
                            break;
                        }
                    }

                    for (int i = 0; i < b.Field.Length; i++)
                    {
                        if (b.Field.Monsters[i] != null)
                        {
                            ((Monster)b.Field.Monsters[i]).CanAttack = true;
                        }
                    }

                    TurnStart?.Invoke(this, new BattleEventArgs(b, GetOpponent(b)));

                    // Turn processing
                    if (b is NPC)
                    {
                        AITurn(b);
                    }
                    else if (b is Player)
                    {
                        UpdateSprites();
                        PlayerTurn(b);
                    }

                    // End of turn
                    UpdateSprites("End of " + b.Name + "'s turn.");

                    if (!b.HasMoved && b.MaxManaAllotment < 10)
                    {
                        b.MaxManaAllotment += 2;
                        if (b.MaxManaAllotment > 10)
                        {
                            b.MaxManaAllotment = 10;
                        }
                        ShowText(b.Name + " forfeited their turn to boost Mana consumption. Max Mana allotment for next turn is " + b.MaxManaAllotment + ".");
                    }

                    TurnEnd?.Invoke(this, new BattleEventArgs(b, GetOpponent(b)));

                    if (b.ManaAllotment > 0)
                    {
                        b.Mana += b.ManaAllotment;
                    }
                    else
                    {
                        b.MaxManaAllotment++;
                    }
                    b.ManaAllotment = 0;
                    turn++;
                }
            }

            //End battle
            //TODO: Tie handling
            if (battlers[0].Mana <= 0)
            {
                winner = battlers[1];
            }
            else if (battlers[1].Mana <= 0)
            {
                winner = battlers[0];
            }
            ShowText(winner.Name + " wins!");

            if (winner is Player)
            {
                PlayerVictory();
            }
            else
            {
                PlayerLoss();
            }
            UpdateSprites();
            EndScene();
        }
示例#7
0
 public void NextTurn()
 {
     TurnStart?.Invoke();
     Turn++;
     TurnEnd?.Invoke();
 }