public void Setup(PlayerBattleModel player) { _playerColor.color = player.PlayerModel.Color; _playerScore.text = player.Score.ToString(); var playerIndex = ApplicationModels.GetModel <BattleModel>().Players.FindIndex(player); _playerName.text = string.Format(PlayerNameFormat, playerIndex + 1); SetPlayerReady(false); }
private void AddRankingItem(PlayerBattleModel player) { var item = Instantiate(_rankingItemPrefab, transform); item.Setup(player); var statusPair = new ReadyStatusPair { Widget = item, IsReady = false }; _rankingItems.Add(player.PlayerModel, statusPair); }
private void SpawnPlayer(PlayerController controller, PlayerBattleModel model, int spawnIndex) { var isIndexValid = spawnIndex >= 0 && spawnIndex < _spawnPoints.Length; var spawn = isIndexValid ? _spawnPoints[spawnIndex] : _spawnPoints.RandomElement(); var position = spawn.Position; position.y += 0.5f * controller.CharacterController.height * controller.transform.localScale.y; controller.transform.position = position; controller.Coords = spawn.Tile.Coords; spawn.Tile.Content.Add(controller); model.IsSpawned = true; controller.Status = PlayerController.InputStatus.Playing; }
public void Initialize(PlayerBattleModel playerBattleModel) { if (_battleModel != null) { Deinitialize(); } _battleModel = playerBattleModel; _battleModel.Events.ScoreChanged.Connect(SetScore); _battleModel.Events.Eliminated.Connect(OnEliminated); SetScore(_battleModel.Score); _playerColor.color = _battleModel.PlayerModel.Color; GameFacade.RoundStart.Connect(OnRoundStart); }
private void SpawnPlayer(PlayerBattleModel model) { var controller = _players.Find(p => p.Owner == model.PlayerModel); // We don't want to spawn several players at the same place var emptySpawnPoints = new List <int>(); for (int i = 0, count = _spawnPoints.Length; i < count; ++i) { if (!_spawnPoints[i].Tile.HasPlayer) { emptySpawnPoints.Add(i); } } var spawnIndex = emptySpawnPoints.Count > 0 ? emptySpawnPoints.RandomElement() : _spawnPoints.RandomIndex(); SpawnPlayer(controller, model, spawnIndex); }
public void OnPlayerHit(PlayerBattleModel victim, PlayerBattleModel attacker) { attacker.Score += victim == attacker ? -1 : 1; _playersToRespawn.Add(victim); }
public static int CompareScores(PlayerBattleModel player, PlayerBattleModel otherPlayer) { return(otherPlayer.Score - player.Score); }
public void OnPlayerHit(PlayerBattleModel victim, PlayerBattleModel attacker) { victim.Events.Eliminated.Invoke(); }