Пример #1
0
        /// <summary>
        /// Make a new player.
        /// </summary>
        /// <param name="playerNumber">The player's number(i.e. player one, or player two)</param>
        /// <param name="position">The starting position of the player.</param>
        public Player(PlayerNumber playerNumber, Vector2 position)
            : base(position, Vector2.Zero, Vector2.Zero, new Vector2(MAX_VELOCITY_X, MAX_VELOCITY_Y), 
            new Vector2(ACCELERATION_X, ACCELERATION_Y), new Vector2(DECELERATION_X, DECELERATION_Y),
            playerNumber == PlayerNumber.One ? 
                TextureManager.GetTexture(TextureNames.PLAYER_ONE_IDLE) :
                TextureManager.GetTexture(TextureNames.PLAYER_TWO_IDLE))
        {
            this.PlayerNumber = playerNumber;
            this.origin = new Vector2(Texture.Width / 2, Texture.Height / 2);

            if (PlayerNumber == PlayerNumber.One)
            {
                Up = Keys.Up;
                Down = Keys.Down;
                Right = Keys.Right;
                Left = Keys.Left;
                Fire = Keys.RightControl;
            }
            else
            {
                Up = Keys.W;
                Down = Keys.S;
                Right = Keys.D;
                Left = Keys.A;
                Fire = Keys.LeftControl;
            }
        }
Пример #2
0
        public bool TryEngage(IPlayer playerOne, IPlayer playerTwo, out PlayerNumber number)
        {
            number = PlayerNumber.None;
            if (playerOne.GType != GestureType.Rock) return false;

            switch (playerTwo.GType)
            {
                case GestureType.Scissor:
                    number = PlayerNumber.PlayerOne;
                    return true;
                case GestureType.Paper:
                    number = PlayerNumber.PlayerTwo;
                    return true;
                case GestureType.Rock:
                    return true;
                case GestureType.Lizard:
                    number = PlayerNumber.PlayerOne;
                    return true;
                case GestureType.Spock:
                    number = PlayerNumber.PlayerTwo;
                    return true;
                default:
                    throw new NotImplementedException();
            }
        }
Пример #3
0
 public Scissor(PlayerNumber number)
 {
     Number = number;
     GType = GestureType.Scissor;
     WinTo = new List<GestureType>
     {
         GestureType.Paper, GestureType.Lizard
     };
 }
Пример #4
0
 public Lizard(PlayerNumber number)
 {
     Number = number;
     GType = GestureType.Lizard;
         WinTo = new List<GestureType>
         {
             GestureType.Spock, GestureType.Paper
         };
 }
Пример #5
0
 public Paper(PlayerNumber number)
 {
     Number = number;
     GType = GestureType.Paper;
     WinTo = new List<GestureType>
     {
         GestureType.Rock, GestureType.Spock
     };
 }
Пример #6
0
    public static RTSPlayer GetPlayer(PlayerNumber number)
    {
        foreach (RTSPlayer player in Players) {
            if ((int)number == player.Number) {
                return player;
            }
        }

        return null;
    }
Пример #7
0
        internal void Bind(int touchPointId, PlayerNumber player)
        {
            var playersTouchPoints = _boundTouchPoints.Where(btp => btp.Value == player).ToList();
            foreach (var touchPointBinding in playersTouchPoints)
            {
                _boundTouchPoints.Remove(touchPointBinding.Key);
            }

            _boundTouchPoints.Add(touchPointId, player);
        }
Пример #8
0
 /// <summary>
 /// Returns whether or not the given player owns this continent.
 /// </summary>
 /// <param name="game">The game that this continent is a part of.</param>
 /// <param name="playerName">The name of the player who may own this country.</param>
 /// <returns>Whether or not the given player owns this continent.</returns>
 public bool OwnedByName(Game game, PlayerNumber playerName)
 {
     foreach(Country country in Countries(game))
     {
         if(country.OwnedBy != playerName)
         {
             return false;
         }
     }
     return true;
 }
Пример #9
0
	public override void SetPeripheralString(PlayerNumber aPlayerNumber)
	{
		if (aPlayerNumber != PlayerNumber.God)
		{
			PeripheralString = "Joystick" + aPlayerNumber.ToString();
		}
		else
		{
			PeripheralString = "Joystick";
		}
	}
Пример #10
0
 /// <summary>
 /// Method to check if a touch point is bound to a specific player.
 /// </summary>
 /// <param name="touchPointId">The touch point Id to check.</param>
 /// <param name="player">The player to check.</param>
 /// <returns>Flag indicating if the touch point specified is bound to the player specified.</returns>
 public bool IsTouchPointBoundToPlayer(int touchPointId, PlayerNumber player)
 {
     PlayerNumber boundPlayer;
     if (_boundTouchPoints.TryGetValue(touchPointId, out boundPlayer))
     {
         return boundPlayer == player;
     }
     else
     {
         return false;
     }
 }
Пример #11
0
        public PongPaddle(PlayerNumber pNumber, Sprite sprite, Vector2 startPosition, Vector2 direction, float speed, ContentManager contMan, Rectangle collision, SoundEffect soundEffect)
            : base(sprite, startPosition, direction, speed, contMan, collision, soundEffect)
        {
            this.score = 0;
            playerNumber = pNumber;
            if (playerNumber == Pong.PlayerNumber.player2)
                canDoAnything = false;

            if (canDoAnything)
            {
                Thread t = new Thread(UpdatePosition);
                t.Start();
            }
        }
Пример #12
0
        // 勝利条件系

        public void FinishBattle(PlayerNumber _winner)
        {
            this.Winner           = _winner;
            this.isFinishedBattle = true;
            this.ChageState(State.Result);
        }
Пример #13
0
 public float GetPlayerHitPoint(PlayerNumber _playerNumber)
 {
     return(this.GetPlayer(_playerNumber).HitPoint);
 }
Пример #14
0
 protected void AddPlayer(PlayerNumber playerNumber, IPlayer player)
 {
     Players[playerNumber] = player;
 }
Пример #15
0
 public bool BelongsTo(PlayerNumber player)
 {
     return(PawnPlayerNumber == player);
 }
Пример #16
0
 public Player GetPlayerByNumber(PlayerNumber _targetPlayer)
 {
     return(playerByNumber[_targetPlayer]);
 }
Пример #17
0
 public void SelectPlayer(PlayerNumber newPlayerNumber, Player_asset newPlayerAsset)
 {
     Debug.Log("new player:" + newPlayerNumber + " (" + newPlayerAsset.GetPlayerName() + ")");
 }
Пример #18
0
 public void SelectPlayer1()
 {
     playerNumber = PlayerNumber.one;
     Debug.Log("player 1 selected");
 }
Пример #19
0
 public override void SetPeripheralString(PlayerNumber aPlayerNumber)
 {
     PeripheralString = "Keyboard";
 }
Пример #20
0
 public abstract void SetPeripheralString(PlayerNumber aPlayerNumber);
Пример #21
0
 public GameState(PlayerNumber winner, byte[] winningLine)
 {
     Winner      = winner;
     WinningLine = winningLine;
 }
Пример #22
0
 void Player(PlayerNumber number, Action <Grid> action)
 => action(number switch
Пример #23
0
 protected override void BeforeMove()
 {
     currentPlayer = Game.CurrentPlayer;
 }
Пример #24
0
 public Line GetBaseline(PlayerNumber playerNumber, int totalPlayers)
 {
     return(baselines[totalPlayers == 2 ? (playerNumber == PlayerNumber.Player1 ? 0 : 2) : ((int)playerNumber)]);
 }
Пример #25
0
 public Round Defeated(PlayerNumber defeated)
 => new Round(Number, MatchedOther, Defeateds.Append(defeated).ToArray());
Пример #26
0
 public void Score(PlayerNumber whoScored)
 {
     ballCount--;
     switch (whoScored)
     {
         case PlayerNumber.player1:
             hasJustScored = true;
             p1Pad.Score++;
             break;
         case PlayerNumber.player2:
             hasJustScored = true;
             p2Pad.Score++;
             break;
         default:
             break;
     }
 }
Пример #27
0
 public void SelectPlayer2()
 {
     playerNumber = PlayerNumber.two;
     Debug.Log("player 2 selected");
 }
Пример #28
0
 public void GameOver(PlayerNumber winner)
 {
     winnerTxt.text = winner + " gagne la partie !";
     gameObject.SetActive(true);
 }
Пример #29
0
 public Player(PlayerNumber playerNumber)
 {
     this.playerNumber = playerNumber;
 }
Пример #30
0
 /// <summary>
 /// Updates the background color (=owner player)
 /// </summary>
 /// <param name="player"></param>
 public void UpdateOwnerPlayer(PlayerNumber player)
 {
     Button.Background = player.Color();
 }
Пример #31
0
 static public bool HasKeyboard(PlayerNumber player = PlayerNumber.Player1)
 {
     return(instance.players [(int)player].keyboard);
 }
 public void Init(PlayerNumber _playerNumber)
 {
     this.PlayerNumber            = _playerNumber;
     this.imgLiveColor.fillAmount = 1.0f;
     this.HitPointMax             = GameManager.Instance.GetPlayerHitPointMax(this.PlayerNumber);
 }
Пример #33
0
 static public ControllerNumber GetControllerNumber(PlayerNumber player = PlayerNumber.Player1)
 {
     return(instance.players [(int)player].controller);
 }
Пример #34
0
 public Domain.Action Execute(IList <RoundResult> previousRoundResults, PlayerNumber playerNumber)
 {
     return(Domain.Action.Cooperate);
 }
Пример #35
0
 public Player(Game game, PlayerNumber playerNumber, PlayerTouchBinder touchBinder)
     : base(game)
 {
     _playerNumber = playerNumber;
     _touchBinder = touchBinder;
 }
Пример #36
0
 public GameEngine()
 {
     lastPlayerTurn = PlayerNumber.FirstPlayer;
     RegisterNewGameState(new GameState());
 }
Пример #37
0
 public bool EventPlayerNumber(PlayerNumber ev)
 {
     return(EventRedirect(OnPlayerNumber, ev));
 }
Пример #38
0
 public float GetPlayerHitPointMax(PlayerNumber _playerNumber)
 {
     return(((RiaPlayerScript)this.GetPlayer(_playerNumber).Actor.CharacterScript).HitPointMax);
 }
Пример #39
0
 public void SubtractResource(PlayerNumber PlayerNumber, Resource Resource, int Amount)
 {
     Resources[(int)PlayerNumber, (int)Resource] -= Amount;
 }
Пример #40
0
 private void YoureWinner(PlayerNumber playerNo)
 {
     winnerText.text = "게임종료!\n플레이어" + ((int)playerNo + 1) + "의 승리";
     ActiveRestartButton();
 }
Пример #41
0
 public Round NextMatch(PlayerNumber matchedOther)
 => new Round(Number + 1, matchedOther, Array.Empty <PlayerNumber>());
Пример #42
0
 /// <summary>
 /// Create a new instance of the Pallet class using the game reference and a player number.
 /// </summary>
 /// <param name="game">Reference to the game class.</param>
 /// <param name="playerNumber">Player number.</param>
 public Pallet(PungGame game, PlayerNumber playerNumber)
     : base(game)
 {
     playerIndex = playerNumber; // Associate the pallet to a player using it's player number.
 }
Пример #43
0
	public abstract void SetPeripheralString(PlayerNumber aPlayerNumber);
Пример #44
0
 public int GetResource(PlayerNumber PlayerNumber, Resource Resource)
 {
     return Resources[(int)PlayerNumber, (int)Resource];
 }
Пример #45
0
	public override void SetPeripheralString(PlayerNumber aPlayerNumber)
	{
		PeripheralString = "Keyboard";
	}
Пример #46
0
 public void AddResource(PlayerNumber PlayerNumber, Resource Resource, int Amount)
 {
     Resources[(int)PlayerNumber, (int)Resource] += Amount;
 }
Пример #47
0
 public void ButtonPressedMessage(ButtonPressed btnPrs, PlayerNumber playnum)
 {
     Enqueue(new LogMsg
     {
         ReportedAt = DateTime.UtcNow,
         ButtonPressed = btnPrs,
         Player = playnum,
         Seriousness = Severity.Info,
         LogType = LogType.InputPressed
     });
 }
Пример #48
0
        public bool IsPlayerTurnRight(PlayerNumber number)
        {
            switch(number)
            {
                case PlayerNumber.One:
                    return IsKeyPress(Keys.Q, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadRight, PlayerIndex.One);
                case PlayerNumber.Two:
                    return IsKeyPress(Keys.LeftAlt, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadRight, PlayerIndex.Two);
                case PlayerNumber.Three:
                    return IsKeyPress(Keys.OemComma, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadRight, PlayerIndex.Three);
                case PlayerNumber.Four:
                    return IsKeyPress(Keys.Down, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadRight, PlayerIndex.Four);
                case PlayerNumber.Five:
                    return IsKeyPress(Keys.Subtract, PlayerIndex.One) ||
                            IsButtonPress(Buttons.B, PlayerIndex.One);
                case PlayerNumber.Six:
                    return IsKeyPress(Keys.B, PlayerIndex.One) ||
                            IsButtonPress(Buttons.B, PlayerIndex.Two);
            }

            return false;
        }
Пример #49
0
        void Start()
        {
            var go = gameObject.GetComponent<GameEntity>() as GameEntity;
            if (go == null) throw new UnityException("attack script is not attached to a GameEntity.");
            owner = go.owner;

            projectileBase.transform.position = transform.position;
        }
Пример #50
0
        /// <summary>
        /// Ends current player's turn and transitions to the next player.
        /// </summary>
        public void EndCurrentPlayerTurn()
        {
            if (CurrentPlayerNumber == PlayerNumber.P1)
            {
                CurrentPlayerNumber = PlayerNumber.P2;
                if (!Players[CurrentPlayerNumber].IsActive)
                {
                    EndCurrentPlayerTurn();
                    return;
                }
            }
            else if (CurrentPlayerNumber == PlayerNumber.P2 && Players.Count > 2)
            {

                CurrentPlayerNumber = PlayerNumber.P3;
                if (!Players[CurrentPlayerNumber].IsActive)
                {
                    EndCurrentPlayerTurn();
                    return;
                }
            }
            else if (CurrentPlayerNumber == PlayerNumber.P3 && Players.Count > 3)
            {
                CurrentPlayerNumber = PlayerNumber.P4;
                if (!Players[CurrentPlayerNumber].IsActive)
                {
                    EndCurrentPlayerTurn();
                    return;
                }
            }
            else if (CurrentPlayerNumber == PlayerNumber.P4 && Players.Count > 4)
            {
                CurrentPlayerNumber = PlayerNumber.P5;
                if (!Players[CurrentPlayerNumber].IsActive)
                {
                    EndCurrentPlayerTurn();
                    return;
                }
            }
            else if (CurrentPlayerNumber == PlayerNumber.P5 && Players.Count > 5)
            {
                CurrentPlayerNumber = PlayerNumber.P6;
                if (!Players[CurrentPlayerNumber].IsActive)
                {
                    EndCurrentPlayerTurn();
                    return;
                }
            }
            else
            {
                CurrentPlayerNumber = PlayerNumber.P1;
                if (!Players[CurrentPlayerNumber].IsActive)
                {
                    EndCurrentPlayerTurn();
                    return;
                }
            }
            Players[CurrentPlayerNumber].SetReinforcments();
            GameLog.AddEvent(Players[CurrentPlayerNumber].Name + " has begun their turn with " +
                Players[CurrentPlayerNumber].UnitsToPlace.ToString() + " reinforcements");
        }
Пример #51
0
 private void WindowLoaded(object sender, RoutedEventArgs e)
 {
     currentPlayer = PlayerNumber.First;
     MakeGameBoard();
 }
Пример #52
0
	public InputConfig(InputPeripheral aPeripheral, PlayerNumber aNumber = PlayerNumber.God, int aJoystickNumber = 0)
	{
		Peripheral = aPeripheral;
		Number = aNumber;
		JoystickNumber = aJoystickNumber;
		InputObjects = new Dictionary<string, InputObj>();

		Peripheral.SetPeripheralString(Number);
		Debug.Log(aNumber);
		//SetInputObjs();
	}
Пример #53
0
    // Update is called once per frame
    void Update()
    {
        if (State == GameState.STARTING)
        {
            GameStartTimer -= Time.deltaTime;
            if (GameStartTimer <= 0)
            {
                State = GameState.PLAYING;
                PlayerNumber playerToStart = PlayerNumber.ONE;

                if (IsRestart)
                {
                    IsRestart = false;
                    if (LastStartingPlayer != PlayerNumber.UNKNOWN)
                    {
                        playerToStart = LastStartingPlayer;
                    }
                    else
                    {
                        if (Random.Range(0f, 1f) < 0.5f)
                        {
                            playerToStart = PlayerNumber.ONE;
                        }
                        else
                        {
                            playerToStart = PlayerNumber.TWO;
                        }
                    }
                }
                else
                {
                    switch (FirstPlayer)
                    {
                    case StartingPlayer.ONE:
                        playerToStart = PlayerNumber.ONE;
                        break;

                    case StartingPlayer.TWO:
                        playerToStart = PlayerNumber.TWO;
                        break;

                    case StartingPlayer.RANDOM:
                        if (Random.Range(0f, 1f) < 0.5f)
                        {
                            playerToStart = PlayerNumber.ONE;
                        }
                        else
                        {
                            playerToStart = PlayerNumber.TWO;
                        }
                        break;

                    case StartingPlayer.ALTERNATING:
                        if (LastStartingPlayer == PlayerNumber.UNKNOWN)
                        {
                            if (Random.Range(0f, 1f) < 0.5f)
                            {
                                playerToStart = PlayerNumber.ONE;
                            }
                            else
                            {
                                playerToStart = PlayerNumber.TWO;
                            }
                        }
                        else
                        {
                            switch (LastStartingPlayer)
                            {
                            case PlayerNumber.ONE:
                                playerToStart = PlayerNumber.TWO;
                                break;

                            case PlayerNumber.TWO:
                                playerToStart = PlayerNumber.ONE;
                                break;
                            }
                        }
                        break;
                    }
                }
                LastStartingPlayer = playerToStart;
                StartTurn(playerToStart);
            }
        }

        //DEBUG remove
        if (Input.GetKeyDown(KeyCode.A))
        {
            Win(PlayerNumber.ONE);
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            INPUT_PlayAgain();
        }
    }
Пример #54
0
 public void ShowMessage(PlayerNumber recipientPlayer, string message)
 {
     NotificationText.gameObject.SetActive(true);
     NotificationText.ShowMessage(recipientPlayer, message);
 }
Пример #55
0
 // Start is called before the first frame update
 void Start()
 {
     fartAudio    = GetComponent <AudioSource>();
     mPlayerNumer = gameObject.CompareTag("Player") ? PlayerNumber.Player1 : PlayerNumber.Player2;
 }
Пример #56
0
 public void TotalDamageTaken(int dmgtk, PlayerNumber playnum)
 {
     Enqueue(new LogMsg
     {
         ReportedAt = DateTime.UtcNow,
         Player = playnum,
         DamageTaken = dmgtk,
         Seriousness = Severity.Info,
         LogType = LogType.DamageTaken
     });
 }
Пример #57
0
        public bool IsPlayerTurnLeft(PlayerNumber number)
        {
            switch (number)
            {
                case PlayerNumber.One:
                    return IsKeyPress(Keys.D1, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadLeft, PlayerIndex.One);
                case PlayerNumber.Two:
                    return IsKeyPress(Keys.LeftControl, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadLeft, PlayerIndex.Two);
                case PlayerNumber.Three:
                    return IsKeyPress(Keys.M, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadLeft, PlayerIndex.Three);
                case PlayerNumber.Four:
                    return IsKeyPress(Keys.Left, PlayerIndex.One) ||
                            IsButtonPress(Buttons.DPadLeft, PlayerIndex.Four);
                case PlayerNumber.Five:
                    return IsKeyPress(Keys.Multiply, PlayerIndex.One) ||
                            IsButtonPress(Buttons.X, PlayerIndex.One);
                case PlayerNumber.Six:
                    return IsKeyPress(Keys.V, PlayerIndex.One) ||
                            IsButtonPress(Buttons.X, PlayerIndex.Two);
            }

            return false;
        }