internal GameObject CreatePlayer(PlayerCreate create) { //get a random point in the arena Vector3 potentialStartPoint = RandomArenaPosition(); //already exists. Ignore. if (FindTankObject(create.Token) != null) { return(null); } GameObject t = null; //team game. if (ConfigValueStore.GetBoolValue("team_mode")) { if (create.Name.Contains(":")) { //get the team name. string teamName = GetTeamName(create.Name); //add the team to the list of teams if it isn't in there already. //Assign the team a tank type if this is the first time we've seen the team. if (!teams.Keys.Contains(teamName)) { teams.Add(teamName, new List <TankController>()); teamNameToModelMap.Add(teamName, currentModel); currentModel += 2; } t = tankFactory.CreateTank(create.Color, create.Name, create.Token, potentialStartPoint, teamNameToModelMap[teamName]); teams[teamName].Add(t.GetComponent <TankController>()); } else { //don't create player, this is a team game and they've not conformed to the naming needs (i.e. teamname:playername). } } else { t = tankFactory.CreateTank(create.Color, create.Name, create.Token, potentialStartPoint, -1); } //randomly rotate the tank t.GetComponent <TankController>().transform.Rotate(Vector3.up, UnityEngine.Random.Range(0, 360)); t.GetComponent <TankController>().Sim = this; tankControllers.Add(t.GetComponent <TankController>()); return(t); }
private void InitializeTanks() { _tanks = new Tanks(); foreach (var component in SingletonConfiguration.Instance.Components) { _tanks.Add(TankFactory.CreateTank(component)); } }
public string ManufactureTank(string name, double attackPoints, double defensePoints) { if (this.machines.Any(m => m.Name == name)) { return($"{string.Format(OutputMessages.MachineExists, name)}"); } var tank = (ITank)TankFactory.CreateTank(name, attackPoints, defensePoints); //tank.ToggleDefenseMode(); this.machines.Add(tank); return($"{string.Format(OutputMessages.TankManufactured, name, tank.AttackPoints, tank.DefensePoints)}"); }
public string ManufactureTank(string name, double attackPoints, double defensePoints) { var tank = tankFactory.CreateTank(name, attackPoints, defensePoints); if (!machineName.Contains(name)) { machineName.Add(name); machines.Add(tank); return(string.Format(OutputMessages.TankManufactured, name, tank.AttackPoints, tank.DefensePoints)); } else { return(string.Format(OutputMessages.MachineExists, name)); } }
public void CreateContainer_IngridientWithUnknownType_NotImplementedException() { Assert.Throws <NotImplementedException>(() => TankFactory.CreateTank(new Component("abc", CoffeeMake.Interfaces.ComponentType.OTHER, false))); }
public void CreateContainer_NullArgument_ArgumentNullException() { Assert.Throws <ArgumentNullException>(() => TankFactory.CreateTank(null)); }