コード例 #1
0
ファイル: GameManager.cs プロジェクト: xd00258/mcgill_party
    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();
        }
    }
コード例 #2
0
ファイル: Pawn.cs プロジェクト: VN0/LD38-Factions
    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;
    }
コード例 #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;
 }
コード例 #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());
        }
コード例 #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!";
    }
コード例 #6
0
ファイル: GameManager.cs プロジェクト: xd00258/mcgill_party
    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);
    }
コード例 #7
0
 public void reset()
 {
     player1.reset(StartValue);
     player2.reset(StartValue);
     winner = PlayerNum.Nobody;
     ScoreChanged?.Invoke(this, new ScoreChangedEventArgs());
 }
コード例 #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';
 }
コード例 #9
0
    private void OnLastManStanding(PlayerNum winner)
    {
        var color = PlayerConfig.GetConfig(winner).PlayerColor;

        SetWinText(winner, color);

        _uiRoot.SetActive(true);
    }
コード例 #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);
        }
コード例 #11
0
 private void OnPlayerEnteredGame(PlayerNum playerNum)
 {
     if (playerNum != _playerNum)
     {
         return;
     }
     StartCoroutine(WaitThenInstantiate());
 }
コード例 #12
0
 private void OnPlayerEneteredGame(PlayerNum playerNum)
 {
     if (playerNum != _playerNum)
     {
         return;
     }
     _pressAnykey.gameObject.SetActive(false);
     _playerHudRoot.SetActive(true);
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #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;
            }
        }
コード例 #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);
     }
 }
コード例 #18
0
ファイル: Player.cs プロジェクト: frobro98/School-Projects
        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;
        }
コード例 #19
0
ファイル: GameManager.cs プロジェクト: xd00258/mcgill_party
    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);
    }
コード例 #20
0
    public BeatInput.Command GetCommand(PlayerNum player)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            return(p1Command);

        case PlayerNum.Player2:
            return(p2Command);
        }
        return(p1Command);
    }
コード例 #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");
 }
コード例 #22
0
    public double GetOffset(PlayerNum player)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            return(p1Offset);

        case PlayerNum.Player2:
            return(p2Offset);
        }
        return(p1Offset);
    }
コード例 #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");
 }
コード例 #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);
 }
コード例 #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;
        }
    }
コード例 #26
0
    public void SetOffset(PlayerNum player, double offset)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            p1Offset = offset;
            break;

        case PlayerNum.Player2:
            p2Offset = offset;
            break;
        }
    }
コード例 #27
0
    public void SetCommand(PlayerNum player, BeatInput.Command Command)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            p1Command = Command;
            break;

        case PlayerNum.Player2:
            p2Command = Command;
            break;
        }
    }
コード例 #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++;
     }
 }
コード例 #29
0
ファイル: PlayerNum.cs プロジェクト: stupic999/RpcCmdTest
 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;
         }
     }
 }
コード例 #30
0
ファイル: GameManager.cs プロジェクト: xd00258/mcgill_party
    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
    }
コード例 #31
0
ファイル: BattleManager.cs プロジェクト: KMC319/yurukyara
        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);
        }