public bool CreatePlayer(PlayerDTO playerDTO) { // It might have already been created. if (activePlayers.ContainsKey(PlayerId(playerDTO.id))) { return(true); } GameObject player = PlayerGenerator.GeneratePlayer(playerDTO, parentPlayerFolder); if (player == null) { return(false); } player.tag = PLAYER_TAG; player.name = PlayerId(playerDTO.id); player.AddComponent <PlayerController>(); if (playersCurrentAvatarID == playerDTO.id) { Debug.Log("Setting marker to id: " + playersCurrentAvatarID); PlayerGenerator.AppendMarker(player); } activePlayers.Add(PlayerId(playerDTO.id), player); return(true); }
public VoteScannerTests() { var players = new Player[] { PlayerGenerator.GeneratePlayer(name: "John0", aliases: new string[] { "John" }), PlayerGenerator.GeneratePlayer(name: "Xevious", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "snowbind", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "GMass", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "Liamness", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "spork", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "Alask", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "PaulM", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "Danster", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "gospvg", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "Strategos", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "bennette98", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "Don Wiskerando", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "The Grand Pursuivant", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "Mr. Blonde", aliases: new string[0]), PlayerGenerator.GeneratePlayer(name: "Mr. Violet", aliases: new string[] { "Mr Violet", "Violet", "Mr.Violet", "MrViolet" }), PlayerGenerator.GeneratePlayer(name: "Mr. Viridian", aliases: new string[] { "Mr.Viridian", "Mr Viridian", "Viridian", "MrViridian" }), PlayerGenerator.GeneratePlayer(name: "Moderator", aliases: new string[0], participating: false), PlayerGenerator.GeneratePlayer(name: "Player With Aliases", aliases: new string[] { "PlayerWithAliases", "PWA" }), }; var mockRepo = new Mock <IRepository>(); mockRepo.Setup(m => m.FindAllPlayers()) .Returns(players); this.voteScanner = new VoteScanner(mockRepo.Object, 8); }
public void TestGeneratePlayerByPrefab() { GameObject playersFolder = GameObject.Find("Players"); GameObject deePrefab = Resources.Load <GameObject>("Prefabs/Players/player_dee"); GameObject generatedPlayer = PlayerGenerator.GeneratePlayer(deePrefab, playersFolder); Assert.AreEqual(0, generatedPlayer.transform.localPosition.x); Assert.AreEqual(0, generatedPlayer.transform.localPosition.y); Assert.AreEqual(0, generatedPlayer.transform.localPosition.z); Assert.AreEqual(generatedPlayer.transform.parent.name, "Players"); }
public void SetUpPlayerManager() { parentStub = new GameObject("ParentStub"); playersFolder = new GameObject("PlayersFolder"); playerManager = parentStub.AddComponent <PlayerManager>(); playerManager.parentPlayerFolder = playersFolder; player = PlayerGenerator.GeneratePlayer(new PlayerDTO { id = 0, location = new Location(5, 5), orientation = "north" }, playersFolder); player.AddComponent <PlayerController>(); }
public void GenerateLevel(Transform root = null) { this.root = root; if (this.root == null) { this.root = CreateEmptyLevelFolder(); } SetupCamera(); SetupLighting(); CreateTerrainFolder(); CreateTerrain(); CreateGrid(); CreatePickupsFolder(); CreateObstaclesFolder(); CreatePlayerFolder(); GameObject defaultPlayerPrefab = Resources.Load <GameObject>("Prefabs/Players/player_dee"); PlayerGenerator.GeneratePlayer(defaultPlayerPrefab, avatarFolder); }
public void TestGeneratePlayerByDTO() { PlayerDTO playerDTO = new PlayerDTO(); Location playerLocation = new Location(10, 20); GameObject playersFolder = GameObject.Find("Players"); playerDTO.location = playerLocation; playerDTO.id = 1; GameObject generatedPlayer = PlayerGenerator.GeneratePlayer(playerDTO, playersFolder); Assert.AreEqual(playerLocation.x, generatedPlayer.transform.localPosition.x); Assert.AreEqual(0, generatedPlayer.transform.localPosition.y); Assert.AreEqual(playerLocation.y, generatedPlayer.transform.localPosition.z); int noOfSkins = PlayerGenerator.numberOfSkins; Material expectedSkin = PlayerGenerator.materials[playerDTO.id % noOfSkins]; Material returnedSkin = generatedPlayer.transform.Find("Dee").GetComponent <Renderer>().sharedMaterial; Assert.IsInstanceOf <Material>(returnedSkin); Assert.AreEqual(expectedSkin, returnedSkin); Assert.AreEqual(generatedPlayer.transform.parent.name, "Players"); }