Exemplo n.º 1
0
    private void EndTurn()
    {
        if (OnTurnEnd != null)
        {
            OnTurnEnd(m_currentPlayer, m_playerCounter);
        }

        m_playerCounter = m_playerCounter == PlayerNum.Player1 ? PlayerNum.Player2 : PlayerNum.Player1;

        turn_active = false;
        //TODO: unregister EndTurn from current player
        m_currentPlayer.OnTurnEnd -= this.EndTurn;

        PlayerNum winner = PlayerNum.Player1;

        if (GameDone(out winner))
        {
            game_done = true;
            EndGame(winner);
        }
        else
        {
            if (GameObject.ReferenceEquals(m_p1.GetCurrentTile(), m_p2.GetCurrentTile()))
            {
                minigame_in_progress = true;
                ModalPanel.Instance().Activate();
            }

            this.GetComponent <Animator>().SetTrigger("TurnWait");
            //Activate waiting camera
            //StartTurn();
        }
    }
Exemplo n.º 2
0
    public void Init(PlayerNum owner, GameManager gameManager)
    {
        this.owner = owner;
        SetColor(PlayerMethods.GetPlayerColor(owner), gameManager);
        healthRemaining = startingHealth; // Need to do this here instead of start so that if someone hits us as we spawn we don't insta-die

        // Ugly hack - could be cleaned up
        if (owner == PlayerNum.One)
        {
            targetingLayerMask = PlayerMethods.allButP1;
            gameObject.layer   = LayerMask.NameToLayer("Pawn1");
        }
        else if (owner == PlayerNum.Two)
        {
            targetingLayerMask = PlayerMethods.allButP2;
            gameObject.layer   = LayerMask.NameToLayer("Pawn2");
        }
        else if (owner == PlayerNum.Three)
        {
            targetingLayerMask = PlayerMethods.allButP3;
            gameObject.layer   = LayerMask.NameToLayer("Pawn3");
        }
        else if (owner == PlayerNum.Four)
        {
            targetingLayerMask = PlayerMethods.allButP4;
            gameObject.layer   = LayerMask.NameToLayer("Pawn4");
        }

        _height = 100;
    }
Exemplo n.º 3
0
 /// <summary>
 /// A playable character.
 /// </summary>
 /// <param name="sprite">Character's sprite.</param>
 /// <param name="playerNum">Player one or player two.</param>
 /// <param name="boundingBox">The bounding box of the player.</param>
 /// <param name="hitboxWidth">The width of the player's hitbox.</param>
 /// <param name="hitboxHeight">The height of the player's hitbox.</param>
 public Player(Sprite sprite, PlayerNum playerNum, Rectangle boundingBox, int hitboxWidth, int hitboxHeight)
 {
     this.sprite      = sprite;
     this.pos         = new Vector2(boundingBox.X, boundingBox.Y);
     this.boundingBox = boundingBox;
     this.playerNum   = playerNum;
 }
Exemplo n.º 4
0
        public void applyScore(int score, PlayerNum player)
        {
            int currentScore = getScore(player);
            int remaining    = currentScore - score;

            if (remaining < 0 || remaining == 1)    //No score
            {
                return;
            }

            if (remaining == 0)     //TODO Should we check if it's a double?
            {
                winner = player;
            }

            if (player == PlayerNum.PlayerOne)
            {
                player1.Score -= score;
            }
            if (player == PlayerNum.PlayerTwo)
            {
                player2.Score -= score;
            }

            ScoreChanged?.Invoke(this, new ScoreChangedEventArgs());
        }
Exemplo n.º 5
0
    private void SetWinText(PlayerNum winner, Color color)
    {
        var colorHex = ColorHex(color);

        Debug.Log($"Converting color ({color} -> {colorHex}");
        _text.text = $"<color={colorHex}>{winner}</color> WINS!";
    }
Exemplo n.º 6
0
    private bool SpawnPlayers()
    {
        TurnCount = 1;

        if (player1Prefab && player2Prefab && startTile)
        {
            //Instantiate objects
            m_p1 = Instantiate <GameObject>(player1Prefab.gameObject).GetComponent <Player>();
            m_p2 = Instantiate <GameObject>(player2Prefab.gameObject).GetComponent <Player>();

            //TODO Initialize GPA of objects
            m_p1.SetGPA(gpaStart);
            m_p2.SetGPA(gpaStart);

            //Position objects
            m_p1.transform.position = startTile.transform.position;
            m_p2.transform.position = startTile.transform.position;

            m_p1.InitPlayer(startTile);
            m_p2.InitPlayer(startTile);

            //Current player is player 1
            m_playerCounter = PlayerNum.Player1;
            m_currentPlayer = m_p1;

            return(true);
        }

        return(false);
    }
Exemplo n.º 7
0
 public void reset()
 {
     player1.reset(StartValue);
     player2.reset(StartValue);
     winner = PlayerNum.Nobody;
     ScoreChanged?.Invoke(this, new ScoreChangedEventArgs());
 }
Exemplo n.º 8
0
 /// <summary>
 /// A playable character.
 /// </summary>
 /// <param name="sprite">Character's sprite.</param>
 /// <param name="playerNum">Player one or player two.</param>
 /// <param name="boundingBox">The bounding box of the player.</param>
 public Player(Sprite sprite, PlayerNum playerNum, Rectangle boundingBox)
 {
     this.sprite      = sprite;
     this.pos         = new Vector2(boundingBox.X, boundingBox.Y);
     this.boundingBox = boundingBox;
     this.playerNum   = playerNum;
     objType          = 'P';
 }
Exemplo n.º 9
0
    private void OnLastManStanding(PlayerNum winner)
    {
        var color = PlayerConfig.GetConfig(winner).PlayerColor;

        SetWinText(winner, color);

        _uiRoot.SetActive(true);
    }
Exemplo n.º 10
0
        private uint PossiblePoints(PlayerNum playerNum)
        {
            String guessLetters = GuessLetters[playerNum];
            Word   guess        = Word.Construct(guessLetters);
            bool   validGuess   = Vocabulary.Contains(guess);

            return(validGuess ? (uint)guess.Letters.Length : 0);
        }
Exemplo n.º 11
0
 private void OnPlayerEnteredGame(PlayerNum playerNum)
 {
     if (playerNum != _playerNum)
     {
         return;
     }
     StartCoroutine(WaitThenInstantiate());
 }
Exemplo n.º 12
0
 private void OnPlayerEneteredGame(PlayerNum playerNum)
 {
     if (playerNum != _playerNum)
     {
         return;
     }
     _pressAnykey.gameObject.SetActive(false);
     _playerHudRoot.SetActive(true);
 }
Exemplo n.º 13
0
 /// <summary>
 /// A playable character.
 /// </summary>
 /// <param name="sprite">Character's sprite.</param>
 /// <param name="playerNum">Player one or player two.</param>
 /// <param name="pos">Player's position.</param>
 /// <param name="hitboxWidth">Width of the player's hitbox.</param>
 /// <param name="hitboxHeight">Height of the player's hitbox.</param>
 public Player(Sprite sprite, PlayerNum playerNum, Vector2 pos, int hitboxWidth, int hitboxHeight)
 {
     this.sprite      = sprite;
     this.pos         = pos;
     this.boundingBox = new Rectangle((int)pos.X, (int)pos.Y, sprite.Width, sprite.Height);
     this.playerNum   = playerNum;
     startingPos      = pos;
     bombs            = 3;
 }
Exemplo n.º 14
0
 /// <summary>
 /// A playable character.
 /// </summary>
 /// <param name="sprite">Character's sprite.</param>
 /// <param name="playerNum">Player one or player two.</param>
 /// <param name="pos">Player's position.</param>
 public Player(Sprite sprite, PlayerNum playerNum, Vector2 pos)
 {
     this.sprite      = sprite;
     this.pos         = pos;
     this.boundingBox = new Rectangle((int)pos.X, (int)pos.Y, sprite.Width, sprite.Height);
     this.playerNum   = playerNum;
     objType          = 'P';
     startingPos      = pos;
 }
Exemplo n.º 15
0
 public Node(GameGrid gameGrid, List <Node> children, float score, int depth, List <Vector3Int> moves, Vector3Int activePlayerPos, Vector3Int opponentPos, PlayerNum nextMovesBelongsTo)
 {
     this.gameGrid           = gameGrid;
     this.children           = children;
     this.score              = score;
     this.depth              = depth;
     this.moves              = moves;
     this.activePlayerPos    = activePlayerPos;
     this.opponentPos        = opponentPos;
     this.nextMovesBelongsTo = nextMovesBelongsTo;
 }
Exemplo n.º 16
0
        public void UpdateDisplay()
        {
            this.PlayerGrid.Background  = (this.textBlockMessage.Text.Contains("Winner")) ? new SolidColorBrush(Colors.LightGreen) : new SolidColorBrush(Colors.White);
            this.textBlockScore.Text    = "Score: " + aPlayer.p1.score.ToString();
            this.textBlockRight.Text    = "Right: " + aPlayer.p1.correct.ToString();
            this.textBlockWrong.Text    = "Wrong: " + aPlayer.p1.incorrect.ToString();
            this.textBlockTimer.Text    = "This Time: " + aPlayer.p1.timer.ToString();
            this.textBlockBestTime.Text = "Best Time:" + ((aPlayer.p1.besttime == 99999) ? "" : aPlayer.p1.besttime.ToString());
            this.textBlockMessage.Text  = aPlayer.p1.message;

            this.textBlockQuestion.Text = aPlayer.p1.x.ToString() + " x " + aPlayer.p1.y.ToString();

            this.buttonA.Content = aPlayer.p1.suggestion1.ToString();
            this.buttonB.Content = aPlayer.p1.suggestion2.ToString();
            this.buttonX.Content = aPlayer.p1.suggestion3.ToString();
            this.buttonY.Content = aPlayer.p1.suggestion4.ToString();

            this.buttonA.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.buttonB.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.buttonX.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.buttonY.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.textBlockPlayer.Text = PlayerNum.ToString();

            this.ProgBar.Value = ((aPlayer.p1.score <= 0) ? 0 : aPlayer.p1.score) * 100 / 7;
            //this.ProgBar.MaxWidth = aPlayer.AnswersToWin;
            //this.ProgBar.MinWidth = 0;


            double dscore = (((aPlayer.p1.correct * 100.0) / (aPlayer.p1.incorrect + aPlayer.p1.correct)));

            dscore = (dscore > 0) ? dscore: 0;
            this.textBlockPercent.Text     = "Score: " + (dscore).ToString("N2") + " %";
            this.textBlockScore.Foreground = aPlayer.AnswerColor;

            if ((aPlayer.WrongAnswers.Count() > 0) && (this.listBox.Items.Count != aPlayer.WrongAnswers.Count))
            {
                this.listBox.Items.Add(aPlayer.WrongAnswers[aPlayer.WrongAnswers.Count - 1]);
            }

            if (aPlayer.WrongAnswers.Count() == 0)
            {
                this.listBox.Items.Clear();
            }

            if ((aPlayer.p1.showresults) && (this.myWebView.Visibility == Visibility.Collapsed))
            {
                this.myWebView.Visibility = Visibility.Visible;
                this.myWebView.NavigateToString(aPlayer.MakeResultsPage());
            }
            else if (!(aPlayer.p1.showresults) && (this.myWebView.Visibility == Visibility.Visible))
            {
                this.myWebView.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 17
0
 public bool Search(string str)
 {
     if (ID.ToString().Contains(str) || IDType.ToString().Contains(str) ||
         Range.ToString().Contains(str) || PlayerNum.ToString().Contains(str))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 18
0
        public Player(PlayerNum type = PlayerNum.One)
        {
            batchMan = new SpriteBatchManager(9, 1);
            gameObjMan = new GameObjectManager(11, 1);
            timeMan = new TimeEventManager(4, 2);
            colPairMan = new CollisionPairManager(13, 1);
            hookupManagers();
            initialPlayerSetup();

            playerType = type;
            currNumLives = maxLives;
        }
Exemplo n.º 19
0
    private bool GameDone(out PlayerNum winningPlayer)
    {
        float p1Score = m_p1.GetGPA();
        float p2Score = m_p2.GetGPA();

        bool p1Won = p2Score < gpaMin || p1Score >= gpaGoal;
        bool p2Won = p1Score < gpaMin || p2Score >= gpaGoal;

        winningPlayer = p1Won ? PlayerNum.Player1 : PlayerNum.Player2;

        return(p1Won || p2Won);
    }
Exemplo n.º 20
0
    public BeatInput.Command GetCommand(PlayerNum player)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            return(p1Command);

        case PlayerNum.Player2:
            return(p2Command);
        }
        return(p1Command);
    }
Exemplo n.º 21
0
 public float getAverage(PlayerNum player)
 {
     if (player == PlayerNum.PlayerOne)
     {
         return(player1.Average);
     }
     if (player == PlayerNum.PlayerTwo)
     {
         return(player2.Average);
     }
     throw new System.ArgumentException("Invalid player");
 }
Exemplo n.º 22
0
    public double GetOffset(PlayerNum player)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            return(p1Offset);

        case PlayerNum.Player2:
            return(p2Offset);
        }
        return(p1Offset);
    }
Exemplo n.º 23
0
 public int getScore(PlayerNum player)
 {
     if (player == PlayerNum.PlayerOne)
     {
         return(player1.Score);
     }
     if (player == PlayerNum.PlayerTwo)
     {
         return(player2.Score);
     }
     throw new System.ArgumentException("Invalid player");
 }
Exemplo n.º 24
0
 private GameObject FindKeep(PlayerNum thePlayerNumber) // ONLY WORKS WITH TWO PLAYERS
 {
     Keep[] keeps = GameObject.FindObjectsOfType <Keep>();
     foreach (Keep theKeep in keeps)
     {
         print("Hello");
         if (theKeep.GetComponent <Character_Stats>().GetPlayerNum() != playerNum)
         {
             return(theKeep.gameObject);
         }
     }
     return(null);
 }
Exemplo n.º 25
0
    public void AddNote(PlayerNum player, NoteType noteType)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            p1Notes.Add(noteType);
            break;

        case PlayerNum.Player2:
            p2Notes.Add(noteType);
            break;
        }
    }
Exemplo n.º 26
0
    public void SetOffset(PlayerNum player, double offset)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            p1Offset = offset;
            break;

        case PlayerNum.Player2:
            p2Offset = offset;
            break;
        }
    }
Exemplo n.º 27
0
    public void SetCommand(PlayerNum player, BeatInput.Command Command)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            p1Command = Command;
            break;

        case PlayerNum.Player2:
            p2Command = Command;
            break;
        }
    }
Exemplo n.º 28
0
 public WinerReferee(PlayerNum winner)
 {
     if (winner == PlayerNum.None)
     {
         foreach (var item in winnerCounters)
         {
             item.count++;
         }
     }
     else
     {
         winnerCounters.Find(n => n.playerNum == winner).count++;
     }
 }
Exemplo n.º 29
0
 void Update()
 {
     if (isServer)
     {
         client = GameObject.Find("Client");
         if (client != null)
         {
             clientNum++;
             playerNum             = client.GetComponent <PlayerNum>();
             playerNum.Num         = clientNum;
             client.transform.name = clientNum.ToString();
             client = null;
         }
     }
 }
Exemplo n.º 30
0
    private void EndGame(PlayerNum winningPlayer)
    {
        Player winner = winningPlayer != PlayerNum.Player1 ? m_p2 : m_p1;
        Player loser  = winningPlayer == PlayerNum.Player1 ? m_p2 : m_p1;

        m_playerCounter = winningPlayer;
        //Activate End Game Camera
        this.GetComponent <Animator>().SetBool("GameDone", true);
        if (OnGameEnd != null)
        {
            OnGameEnd(winner, winningPlayer);
        }
        winner.PlayerWon();
        loser.gameObject.SetActive(false);
        //Display winner
    }
Exemplo n.º 31
0
        private void WinnerDisplay(PlayerNum winner)
        {
            winerReferee = new WinerReferee(winner);

            string res;

            if (winner == PlayerNum.None)
            {
                res = "Draw";
            }
            else
            {
                res = "Winner-" + winner;
            }
            CountDisply();
            centerMesseage.Display(res);
        }