private void CreateTanks() { int x, y; //единоразовое создание охотника под индеком 0 if (Tanks.Count == 0) { Tanks.Add(new Hunter(size, r.Next(7) * 40, r.Next(7) * 40)); } while (Tanks.Count < tanksAmount) { x = r.Next(7) * 40; y = r.Next(7) * 40; bool quit = false; foreach (Tank t in Tanks) { if (x == t.X && y == t.Y || Pl.X == x && Pl.Y == y) { quit = true; } } if (quit) { continue; } Tanks.Add(new Tank(size, x, y)); } }
private void CreateTank(int percent) { if (Tanks.Count < tankCount && rnd.Next(100) <= percent) { int x = rnd.Next(view.MapWidth - BlockSize); int y = rnd.Next(view.MapHeight - BlockSize); var tank = new TankViewModel(x, y, 16, 16, (Direction)rnd.Next(4)); if (Player != null) { if (Walls.Find(wall => IsCollision(wall, tank)) == null && IsCollision(Player, tank) == false && Tanks.Find(tnk => tnk != tank ? IsCollision(tnk, tank) : false) == null) { Tanks.Add(tank); } } else { if (Walls.Find(wall => IsCollision(wall, tank)) == null && IsCollision(reservePlayer, tank) == false && Tanks.Find(tnk => tnk != tank ? IsCollision(tnk, tank) : false) == null) { Tanks.Add(tank); } } } }
private void InitializeTanks() { _tanks = new Tanks(); foreach (var component in SingletonConfiguration.Instance.Components) { _tanks.Add(TankFactory.CreateTank(component)); } }
public Tank SpawnTank(string tankName) { if (Tanks.Count > MaxTanks || Tanks.ContainsKey(tankName)) { return(null); } tankName = $"{Id}_{tankName}"; var newTank = new Tank(this, tankName); Tanks.Add(tankName, newTank); return(newTank); }
public void SetNewGameTanksParameters(int players) { Tanks.Clear(); Tanks.Add(P1Tank); AliveTanks = 1; if (players == 2) { Tanks.Add(P2Tank); AliveTanks = 2; } foreach (var tank in Tanks) { tank.SetNewGameParameters(); } }
public FluidTank AddTank(String id, int transmitPin, int receivePin, int capacity, int minDistance = JSN_SR04T.MIN_DISTANCE, int maxDistance = JSN_SR04T.MAX_DISTANCE) { FluidTank ft = new FluidTank(transmitPin, receivePin, id); ft.Capacity = capacity; ft.MinDistance = minDistance; ft.MaxDistance = maxDistance; ft.Offset = 3; ft.SampleInterval = SampleInterval; ft.SampleSize = SampleSize; Tanks.Add(ft); AddDevice(ft); return(ft); }
/// <summary> /// Add Tank has slightly different logic where it is the only object that can be /// "Disconnected". And if so, we remove it from our world. /// </summary> /// <param name="obj"></param> /// <param name="message"></param> public void AddTank(JObject obj, string message) { int id = (int)obj.First; Tank tank = JsonConvert.DeserializeObject <Tank>(message); // Adding new tanks if (!Tanks.ContainsKey(id)) { Tanks.Add(id, tank); TankColors.Add(id, GetTankColor(id)); } // If this tank is disconnected, remove it. else if (tank.disconnected) { Tanks.Remove(id); } // Update the tank else { Tanks[id] = Tanks[id].Update(tank); } }
public virtual void AddTank(Tank tank) { Tanks.Add(tank); }
public void RegisterTank(Tank tank) { Tanks.Add(tank); }
public void Should_AddComponent_WhenAddCorrectParameter() { var tanks = new Tanks(); Assert.DoesNotThrow(() => tanks.Add(new DryTank(new Component("asd", ComponentType.DRY, false)))); }
public void Should_ThrowArgumentNullException_WhenAddNullParameter() { var tanks = new Tanks(); Assert.Throws <ArgumentNullException>(() => tanks.Add(null)); }