Exemplo n.º 1
0
    public void Render(MatchPhase mp)
    {
        switch (mp)
        {
        case MatchPhase.FirstHalf:
        {
            stateText.text = "First Half";
            break;
        }

        case MatchPhase.SecondHalf:
        {
            stateText.text = "Second Half";
            break;
        }

        case MatchPhase.OverTime:
        {
            stateText.text = "Over Time";
            break;
        }

        case MatchPhase.Penalty:
        {
            stateText.text = "Penalty Shootout";
            break;
        }
        }
    }
Exemplo n.º 2
0
 public TeamCompetitive()
 {
     Team1        = new List <Player>();
     Team2        = new List <Player>();
     this.running = true;
     this.Phase   = MatchPhase.RUNNING;
 }
Exemplo n.º 3
0
 private void matchWon()
 {
     ActivateScreen(gameEndScreen);
     currentPhase = MatchPhase.END;
     MusicManagerScript.Instance.ChangeMusicType(MusicType.Theme);
     MatchEndScript.Instance.ResolveEnd(matchState);
 }
    public void Notify(MatchPhase current)
    {
        string str;

        switch (current)
        {
        case MatchPhase.FirstHalf:
            str = "<b>First Half Start</b>";
            break;

        case MatchPhase.SecondHalf:
            str = "<b>Second Half Start</b>\n<size=70%>Switch Role";
            break;

        case MatchPhase.OverTime:
            str = "<b>Over Time Start</b>";
            break;

        // case MatchPhase.Penalty:
        default:
            str = "<b>Penalty War Start</b>";
            break;
        }
        text.text = str;
        animator.SetBool("show", true);

        IEnumerator func()
        {
            yield return(new WaitForSecondsRealtime(1));

            animator.SetBool("show", false);
        }

        StartCoroutine(func());
    }
Exemplo n.º 5
0
    public void StartMatch(VisualPlayer v_player = null, VisualMinion v_minion = null, int visualBoardHeight = 0, MatchUI matchUI = null)
    {
        V_Player          = v_player;
        V_Minion          = v_minion;
        VisualBoardHeight = visualBoardHeight;

        if (Visual)
        {
            // UI
            MatchUI       = matchUI;
            MatchUI.Match = this;
            MatchUI.UpdatePlayerBar();
            MatchUI.UpdateTurnText();
            if (MatchType == MatchType.AI_vs_AI)
            {
                MatchUI.UpdatePlayerGenomes();
            }

            // Summon Players
            Player1.Visual = GameObject.Instantiate(V_Player, new Vector3(0, 0, -(VisualBoardHeight / 2)), Quaternion.identity);
            Player2.Visual = GameObject.Instantiate(V_Player, new Vector3(0, 0, VisualBoardHeight / 2), Quaternion.identity);
            Player1.Color  = PlayerColor;
            Player2.Color  = PlayerColor;
            VisualActions.Add(new VA_SummonPlayer(Player1.Visual, PlayerColor));
            VisualActions.Add(new VA_SummonPlayer(Player2.Visual, PlayerColor));
        }

        // Let's go
        Phase = MatchPhase.GameReady;
    }
Exemplo n.º 6
0
    /// <summary>
    /// Checks if a player is dead and if yets updates the player stats and ends the game.
    /// </summary>
    private bool CheckGameOver()
    {
        if (Player1.Health <= 0)
        {
            Winner = Player2;
            Loser  = Player1;
            if (MatchType == MatchType.AI_vs_AI)
            {
                ((AIPlayer)Player2).Brain.Wins++;
                ((AIPlayer)Player1).Brain.Losses++;
            }
            Phase = MatchPhase.GameEnded;
        }
        else if (Player2.Health <= 0)
        {
            Winner = Player1;
            Loser  = Player2;
            if (MatchType == MatchType.AI_vs_AI)
            {
                ((AIPlayer)Player1).Brain.Wins++;
                ((AIPlayer)Player2).Brain.Losses++;
            }
            Phase = MatchPhase.GameEnded;
        }
        if (Phase == MatchPhase.GameEnded)
        {
            //if (Player1.Name == "0.0" || Player2.Name == "0-0") Debug.Log("0-0 finished a game " + Player1.Name + "," + Player2.Name); // test if one player finished one match per round

            if (MatchType == MatchType.AI_vs_AI)
            {
                ((AIPlayer)Player1).Brain.DamageDealt    = StartHealth - Player2.Health;
                ((AIPlayer)Player2).Brain.DamageReceived = StartHealth - Player2.Health;

                ((AIPlayer)Player1).Brain.DamageReceived = StartHealth - Player1.Health;
                ((AIPlayer)Player2).Brain.DamageDealt    = StartHealth - Player1.Health;
            }

            if (Visual)
            {
                MatchUI.UpdatePlayerBar();
                GameObject.Destroy(Player1.Visual.gameObject);
                GameObject.Destroy(Player2.Visual.gameObject);
                foreach (Minion m in Minions)
                {
                    GameObject.Destroy(m.Visual.gameObject);
                }
            }
            if (Log)
            {
                Debug.Log(Winner.Name + " won against " + Loser.Name + " after " + Turn + " turns.");
            }
            return(true);
        }
        return(false);
    }
Exemplo n.º 7
0
        /// <summary>
        /// 更新MatchInfo中的所有信息
        /// </summary>
        /// <param name="matchInfo"></param>
        public void UpdateFrom(MatchInfo matchInfo)
        {
            BlueRobots   = (Robot[])matchInfo.BlueRobots.Clone();
            YellowRobots = (Robot[])matchInfo.YellowRobots.Clone();
            Ball         = matchInfo.Ball;

            Score      = matchInfo.Score;
            TickMatch  = matchInfo.TickMatch;
            MatchPhase = matchInfo.MatchPhase;
            Referee    = (Referee)matchInfo.Referee.Clone();
        }
Exemplo n.º 8
0
 private void StartPhaseCommands(MatchPhase phase)
 {
     if (!PhaseCommands.ContainsKey(phase))
     {
         return;
     }
     foreach (var command in PhaseCommands[phase])
     {
         command.Start();
     }
 }
Exemplo n.º 9
0
        public static MatchPhase NextPhase(this MatchPhase phase)
        {
            switch (phase)
            {
            case MatchPhase.FirstHalf:
                return(MatchPhase.SecondHalf);

            case MatchPhase.SecondHalf:
                return(MatchPhase.OverTime);

            case MatchPhase.OverTime:
                return(MatchPhase.Penalty);

            default:
                throw new ArgumentException("Penalty don't have next phase");
            }
        }
Exemplo n.º 10
0
    public void StartMatch()
    {
        // Cleanup
        ChatManagerScript.Instance.EmptyChat();
        // Prepare new
        matchState = new MatchState();
        Hero.state = matchState;
        ActivateScreen(heroPickScreen);
        HeroPickManagerScript.Instance.StartNewHeroPick();
        MusicManagerScript.Instance.ChangeMusicType(MusicType.Battle);
        currentPhase = MatchPhase.HERO_PICK;

        ChatMessage startMessage = new ChatMessage();

        startMessage.messageType = ChatMessageType.SYSTEM;
        startMessage.message     = "Joined game. Pick your hero!";
        ChatManagerScript.Instance.AddMessage(startMessage);
    }
Exemplo n.º 11
0
    private void CompleteWholeMatch()
    {
        while (Phase != MatchPhase.GameEnded)
        {
            switch (Phase)
            {
            case MatchPhase.GameReady:
                Phase = MatchPhase.TurnStart;
                break;

            case MatchPhase.TurnStart:
                StartTurn();
                Phase = MatchPhase.CardPick;
                break;

            case MatchPhase.CardPick:
                GetCardOptions();
                InitializeCardEffects();
                ApplyFatigueDamage();
                Phase = MatchPhase.CardEffect;
                break;

            case MatchPhase.CardEffect:
                DequeueEffect();
                if (Phase != MatchPhase.GameEnded)
                {
                    RemoveSummonProtection();
                    QueueMinionEffects();
                    Phase = MatchPhase.MinionEffect;
                }
                break;

            case MatchPhase.MinionEffect:
                DequeueEffect();
                if (Phase != MatchPhase.GameEnded)
                {
                    DestroyDestabilizedMinions();
                    Phase = MatchPhase.TurnStart;
                }
                break;
            }
        }
    }
Exemplo n.º 12
0
    private float MinionYStartAction = 0.1f;  // The higher this value is, the closer the minions are to the player (0 < x < 0.5)

    public void InitGame(Player player1, Player player2, int health, int options, int minOptions, int maxOptions, int maxMinions, int maxMinionsPerType, int fatigueStart, bool visual, bool log)
    {
        // Set rules
        StartHealth            = health;
        StartCardOptions       = options;
        MinCardOptions         = minOptions;
        MaxCardOptions         = maxOptions;
        MaxMinions             = maxMinions;
        MaxMinionsPerType      = maxMinionsPerType;
        FatigueDamageStartTurn = fatigueStart;

        // Set players
        Player1 = player1;
        Player2 = player2;
        Player1.Initialize(Player2, StartHealth, StartCardOptions);
        Player2.Initialize(Player1, StartHealth, StartCardOptions);

        // Set match type
        if (Player1.GetType() == typeof(AIPlayer) && Player2.GetType() == typeof(AIPlayer))
        {
            MatchType = MatchType.AI_vs_AI;
        }
        else if (Player1.GetType() == typeof(HumanPlayer) && Player2.GetType() == typeof(AIPlayer))
        {
            MatchType = MatchType.Human_vs_AI;
        }
        else
        {
            throw new Exception("Invalid Match Type. Only AI vs AI and Human vs AI allowed!");
        }

        // Init game values
        Visual        = visual;
        Log           = log;
        Minions       = new List <Minion>();
        Effects       = new Queue <Action>();
        VisualActions = new List <VisualAction>();
        Turn          = 0;
        SummonOrder   = 0;

        Phase = MatchPhase.GameInitialized;
    }
Exemplo n.º 13
0
    public void HeroPickReady()
    {
        ActivateScreen(gameScreen);
        // Reset fight manager (animations) has to be after activate to update animations
        FightManagerScript.Instance.Reset();
        List <string> names = new List <string>();

        for (int i = 0; i < matchState.matchHeroes.Count; i++)
        {
            if (i == 0)
            {
                names.Add("You");
            }
            else
            {
                names.Add(matchState.matchHeroes[i].name);
            }
        }
        FightAnimatorScript.Instance.SetTexts(names);

        currentPhase = MatchPhase.GAME;
    }
Exemplo n.º 14
0
    public void Update()
    {
        // During game phases (only visual)
        switch (Phase)
        {
        case MatchPhase.GameReady:
            if (Visual)
            {
                foreach (VisualAction va in VisualActions)
                {
                    va.Update();
                }
                VisualActions = VisualActions.Where(x => !x.Done).ToList();
                if (VisualActions.Count == 0)
                {
                    NextPhaseReady = true;
                }
            }
            else
            {
                CompleteWholeMatch();
            }
            break;

        case MatchPhase.TurnStart:
            DequeueEffect();
            break;

        case MatchPhase.CardPick:
            if (!MatchUI.HideCardsButton.gameObject.activeSelf)
            {
                MatchUI.SetHideCardsButtonVisible(true);
            }

            if (Player1.ChosenCard != null && Player2.ChosenCard != null)
            {
                NextPhaseReady = true;
            }
            break;

        case MatchPhase.CardEffect:
            DequeueEffect();
            break;

        case MatchPhase.MinionsToAction:
            VisualUpdate();
            break;

        case MatchPhase.MinionEffect:
            DequeueEffect();
            break;

        case MatchPhase.MinionDeaths:
            VisualUpdate();
            break;

        case MatchPhase.MinionsToPlan:
            VisualUpdate();
            break;

        case MatchPhase.GameEnded:
            break;
        }

        // Changing game phases (only visual)
        if (NextPhaseReady && Input.GetKeyDown(KeyCode.Space))
        {
            NextPhaseReady = false;

            switch (Phase)
            {
            case MatchPhase.GameReady:
                StartTurn();
                Phase = MatchPhase.TurnStart;
                break;

            case MatchPhase.TurnStart:
                GetCardOptions();
                Phase = MatchPhase.CardPick;
                break;

            case MatchPhase.CardPick:
                // Hide cards
                MatchUI.UnshowAllCards();
                MatchUI.SetHideCardsButtonVisible(false);
                InitializeCardEffects();
                ApplyFatigueDamage();
                Phase = MatchPhase.CardEffect;
                break;

            case MatchPhase.CardEffect:
                RemoveSummonProtection();
                if (Minions.Count > 0)
                {
                    InitializeMoveMinionsEffect(toAction: true);
                    Phase = MatchPhase.MinionsToAction;
                }
                else     // Skip MoveMinion Phase if no minions
                {
                    QueueMinionEffects();
                    Phase = MatchPhase.MinionEffect;
                }
                break;

            case MatchPhase.MinionsToAction:
                // Queue minion effects
                QueueMinionEffects();
                Phase = MatchPhase.MinionEffect;
                break;

            case MatchPhase.MinionEffect:
                if (Minions.Where(x => x.Destabilized).Count() > 0)
                {
                    DestroyDestabilizedMinions();
                    Phase = MatchPhase.MinionDeaths;
                }
                else if (Minions.Count > 0)     // Skip MinionDeaths if no destabilized minions
                {
                    InitializeMoveMinionsEffect(toAction: false);
                    Phase = MatchPhase.MinionsToPlan;
                }
                else     // Skip to next turn if there are no minions
                {
                    StartTurn();
                    Phase = MatchPhase.TurnStart;
                }
                break;

            case MatchPhase.MinionDeaths:
                if (Minions.Count > 0)
                {
                    InitializeMoveMinionsEffect(toAction: false);
                    Phase = MatchPhase.MinionsToPlan;
                }
                else     // Skip to next turn if there are no minions
                {
                    StartTurn();
                    Phase = MatchPhase.TurnStart;
                }
                break;

            case MatchPhase.MinionsToPlan:
                StartTurn();
                Phase = MatchPhase.TurnStart;
                break;

            case MatchPhase.GameEnded:
                break;
            }
        }
    }
Exemplo n.º 15
0
 /// <summary>
 /// Apply this attribute to a command to have it started when the respective match phase starts.
 /// </summary>
 /// <param name="phase">The match phase to start the command.</param>
 public RunCommandAtPhaseStartAttribute(MatchPhase phase)
 {
     Phase = phase;
 }
 /// <summary>
 /// Apply this attribute to a command to have it started when the respective match phase starts.
 /// </summary>
 /// <param name="phase">The match phase to start the command.</param>
 public RunCommandAtPhaseStartAttribute(MatchPhase phase)
 {
     Phase = phase;
 }
Exemplo n.º 17
0
 private void StartPhaseCommands(MatchPhase phase)
 {
     if (!PhaseCommands.ContainsKey(phase)) return;
     foreach (var command in PhaseCommands[phase])
     {
         command.Start();
     }
 }