Пример #1
0
	// player left the game
	private void PlayerLeave(PsObject psobj)
	{
		string name = psobj.GetString(ServerConstants.PLAYER_NAME);

		Player player = FindPlayer(name);
		if (player == null)
			return;

		// update chat a player left
		_chat.UserAction(name, ChatAction.Leave);

		GameObject.Destroy(player.gameObject);
	}
Пример #2
0
	// another player moved
	private void PlayerMove(PsObject psobj)
	{
		string name = psobj.GetString(ServerConstants.PLAYER_NAME);

		Player player = FindPlayer(name);
		if (player == null)
            return;

		List<int> position = psobj.GetIntArray(ServerConstants.PLAYER_POSITION);
		player.MoveTo(Utility.ListToVector2(position));
	}
Пример #3
0
	// another player shot
	private void PlayerShoot(PsObject psobj)
	{
		string name = psobj.GetString(ServerConstants.PLAYER_NAME);
		
		Player player = FindPlayer(name);
		if (player == null)
            return;

		List<int> position = psobj.GetIntArray(ServerConstants.PLAYER_POSITION);
		List<int> heading = psobj.GetIntArray(ServerConstants.PLAYER_HEADING);
		Shot.Create(player, Utility.ListToVector2(position), Utility.ListToVector2(heading));
	}
Пример #4
0
	// add a single player.  generally when somebody new joins after the game has started
	private void AddPlayer(PsObject psobj, bool updateStatus)
	{
		string name = psobj.GetString(ServerConstants.PLAYER_NAME);
		if (_otherPlayers.ContainsKey(name))
			return;

		int type = psobj.GetInt(ServerConstants.PLAYER_TYPE);
		List<int> position = psobj.GetIntArray(ServerConstants.PLAYER_POSITION);

		Player player = CreateCharacter(type, Utility.ListToVector2(position), OthersLayer);
		player.Face(PlayerDirection.Down);
		_otherPlayers.Add(name, player);

		// update chat a player entered
		if (updateStatus)
			_chat.UserAction(name, ChatAction.Enter);
	}