コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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);
                    }
                }
            }
        }
コード例 #3
0
ファイル: CoffeeMaker.cs プロジェクト: smietanka/CoffeeMaker
 private void InitializeTanks()
 {
     _tanks = new Tanks();
     foreach (var component in SingletonConfiguration.Instance.Components)
     {
         _tanks.Add(TankFactory.CreateTank(component));
     }
 }
コード例 #4
0
ファイル: Team.cs プロジェクト: ajshiff/ApiTanks
        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);
        }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        /// <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);
            }
        }
コード例 #8
0
ファイル: GameScreen.cs プロジェクト: LSViana/diep-project
 public virtual void AddTank(Tank tank)
 {
     Tanks.Add(tank);
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: dkinvoker/BotFactory
 public void RegisterTank(Tank tank)
 {
     Tanks.Add(tank);
 }
コード例 #10
0
ファイル: TanksTest.cs プロジェクト: smietanka/CoffeeMaker
        public void Should_AddComponent_WhenAddCorrectParameter()
        {
            var tanks = new Tanks();

            Assert.DoesNotThrow(() => tanks.Add(new DryTank(new Component("asd", ComponentType.DRY, false))));
        }
コード例 #11
0
ファイル: TanksTest.cs プロジェクト: smietanka/CoffeeMaker
        public void Should_ThrowArgumentNullException_WhenAddNullParameter()
        {
            var tanks = new Tanks();

            Assert.Throws <ArgumentNullException>(() => tanks.Add(null));
        }