Ejemplo n.º 1
0
        public void MakeTheRoverMove_RoversPlateauConsiderBoundaryAndCrashGiven_ReturnsTrue_2()
        {
            //Arrange
            Plateau plateau = new Plateau()
            {
                UpperRightX = 5,
                UpperRightY = 5
            };
            Rover rover = new Rover()
            {
                CoordinateX  = 1,
                CoordinateY  = 2,
                Direction    = Direction.North,
                MovementList = Helpers.Helpers.GetMovementEnumList("LMLMLMLMM")
            };
            Rover rover2 = new Rover()
            {
                CoordinateX  = 3,
                CoordinateY  = 3,
                Direction    = Direction.East,
                MovementList = Helpers.Helpers.GetMovementEnumList("MMM")
            };
            Squad squad = new Squad();

            squad.Add(rover);
            squad.Add(rover2);

            //Act
            var    result         = rover2.MakeTheRoverMove(squad, plateau, false);
            Result expectedResult = new Result();

            //Assert
            Assert.AreEqual(expectedResult.Success, result.Success);
            Assert.AreEqual(expectedResult.ErrorMessage, result.ErrorMessage);
        }
Ejemplo n.º 2
0
        async Task ExecuteLoadSquadCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Squad.Clear();
                var teams = await DataStore.GetFireTeamsAsync(true);

                foreach (var team in teams)
                {
                    Squad.Add(team);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        Assert.IsNotNull(AIPresets, "Please assign GameAIPresets");

        squads = new List <Squad>();
        var   ground_units = GameObject.FindGameObjectsWithTag("GroundUnit");
        Squad squad        = new Squad(AIPresets);

        foreach (var unit in ground_units)
        {
            squad.Add(unit);
        }
        squads.Add(squad);
        // for (int id = 0; id < ground_units.Length; id += Squad.MaxUnits) {
        //   Squad squad = new Squad();
        //   int end = Mathf.Min(id + Squad.MaxUnits, ground_units.Length);
        //   for (int i = id; i < end; i++)
        //     squad.Add(ground_units[i]);
        //   squads.Add(squad);
        // }
        //var flying_units = GameObject.FindGameObjectsWithTag("FlyingUnit");
        inputSystem = GetComponent <InputSystem>();

        Assert.IsNotNull(TargetReticle, "Bah!");
    }
Ejemplo n.º 4
0
        public void Move_PlateauConsiderBoundaryAndCrashTrueGiven_ReturnsFalse()
        {
            //Arrange
            Plateau plateau = new Plateau()
            {
                UpperRightX = 5,
                UpperRightY = 5
            };
            Rover rover = new Rover()
            {
                CoordinateX  = 1,
                CoordinateY  = 2,
                Direction    = Helpers.Direction.North,
                MovementList = Helpers.Helpers.GetMovementEnumList("LMLMLMLMM")
            };
            Rover rover2 = new Rover()
            {
                CoordinateX  = 3,
                CoordinateY  = 3,
                Direction    = Helpers.Direction.East,
                MovementList = Helpers.Helpers.GetMovementEnumList("MMRMMRMRRM")
            };
            Rover rover3 = new Rover()
            {
                CoordinateX  = 3,
                CoordinateY  = 5,
                Direction    = Helpers.Direction.West,
                MovementList = Helpers.Helpers.GetMovementEnumList("MMLMM")
            };
            Squad squad = new Squad();

            squad.Add(rover);
            squad.Add(rover2);
            squad.Add(rover3);

            //Act
            var    result         = squad.Move(plateau, true);
            Result expectedResult = new Result()
            {
                Success      = false,
                ErrorMessage = "The rover will crash with another rover with this route. Please change the route!"
            };

            //Assert
            Assert.AreEqual(expectedResult.Success, result.Success);
            Assert.AreEqual(expectedResult.ErrorMessage, result.ErrorMessage);
        }
Ejemplo n.º 5
0
        private void Move(object sender, RoutedEventArgs e)
        {
            switch ((sender as Button).Content)
            {
            case "Move unit":
                _myObject.MoveTo(1, 1);
                break;

            case "Move squad":
                var squad = new Squad(ExampleBlock);
                squad.Add(new MyObject(ExampleBlock));
                squad.Add(new MyObject(ExampleBlock));
                ISelectableObject obj = new ISecondbjectToISelectableAdapter(new MySecondObject(ExampleBlock));
                squad.Add(obj);
                squad.MoveTo(10, 10);
                break;
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var squad = new Squad();

            squad.Add(new Unit(10));
            squad.Add(new Unit(10));
            squad.Add(new Unit(15));
            squad.Add(new Squad(new List <ISelectableEntity>()
            {
                new Unit(10)
            }));

            ISelectableEntity entity = squad;

            squad.MoveTo(10, 10);

            var health = new GetHealth();

            entity.Accept(health);
            Console.WriteLine(health.Result);
        }
Ejemplo n.º 7
0
 public void MakeSquad()
 {
     if (IsSquadLeader)
     {
         return;
     }
     gameObject.AddComponent <Squad>();
     Squad        = GetComponent <Squad>();
     Squad.Leader = this;
     Squad.Add(this);
     IsSquadLeader = true;
     squadMarker   = (GameObject)Instantiate(faction == Faction.Police ? pfMarkerPolice : pfMarkerRebels);
     squadMarker.transform.parent        = this.transform;
     squadMarker.transform.localPosition = Vector3.zero;
     squadMarker.transform.localRotation = Quaternion.identity;
     squadMarker.transform.localScale    = new Vector3(0.3f, 0.3f, 0.3f);
 }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            //Taking plateau's upper-right co-ordinates
            var plateau = getUpperRightCoordinates();
            var squad   = new Squad();

            while (true)
            {
                //Taking a rover information from the user
                var rover = getRover(plateau, squad);
                //Adding rover to the squad
                squad.Add(rover);
                ConsoleKey response;
                do
                {
                    Console.Write("Do you want to enter another rover information?(Y/N): ");
                    response = Console.ReadKey(true).Key;
                    if (response != ConsoleKey.Enter)
                    {
                        Console.WriteLine();
                    }
                } while (response != ConsoleKey.Y && response != ConsoleKey.N);
                if (response == ConsoleKey.Y)
                {
                    continue;
                }
                else
                {
                    Result result = squad.Move(plateau, false);
                    if (result.Success == true)
                    {
                        foreach (var item in squad.rovers)
                        {
                            Console.WriteLine(item.CoordinateX + " " + item.CoordinateY + " " + Helpers.Helpers.GetDescription(item.Direction));
                        }
                    }
                    else
                    {
                        Console.WriteLine(result.ErrorMessage);
                    }
                    break;
                }
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Archer archer1 = new Archer("Вася");
            Archer archer2 = new Archer("Петя");
            Archer archer3 = new Archer("Саша");
            Archer archer4 = new Archer("Ваня");
            Archer archer5 = new Archer("Митя");

            Cavalryman cavalryman1 = new Cavalryman("Дима");
            Cavalryman cavalryman2 = new Cavalryman("Паша");
            Cavalryman cavalryman3 = new Cavalryman("Гена");
            Cavalryman cavalryman4 = new Cavalryman("Вова");

            Infantryman infantryman1 = new Infantryman("Даня");
            Infantryman infantryman2 = new Infantryman("Тима");
            Infantryman infantryman3 = new Infantryman("Егор");
            Infantryman infantryman4 = new Infantryman("Витя");
            Infantryman infantryman5 = new Infantryman("Женя");
            Infantryman infantryman6 = new Infantryman("Олег");

            Squad      army    = new Squad("Армия");
            Cavalryman general = new Cavalryman("Генерал");

            Squad  division1  = new Squad("Первый дивизион");
            Archer commander1 = new Archer("Командир");
            Squad  division2  = new Squad("Второй дивизион");
            Archer commander2 = new Archer("Командир");

            Squad       company1 = new Squad("Первая рота");
            Infantryman officer1 = new Infantryman("Офицер");

            Squad       company2 = new Squad("Вторая рота");
            Infantryman officer2 = new Infantryman("Офицер");

            Squad       company3 = new Squad("Первая рота");
            Infantryman officer3 = new Infantryman("Офицер");

            army.Add(general);
            army.Add(division1); army.Add(division2);

            division1.Add(commander1);
            division1.Add(company1);

            division2.Add(commander2);
            division2.Add(company3); division2.Add(company2);

            company1.Add(officer1);
            company1.Add(infantryman1); company1.Add(infantryman2);
            company1.Add(archer1); company1.Add(archer2);
            company1.Add(cavalryman1);

            company2.Add(officer2);
            company2.Add(infantryman3); company2.Add(infantryman4);
            company2.Add(archer3); company2.Add(archer4);
            company2.Add(cavalryman2);

            company3.Add(officer3);
            company3.Add(infantryman5); company3.Add(infantryman6);
            company3.Add(archer5);
            company3.Add(cavalryman3); company3.Add(cavalryman4);

            army.Print(0);

            Console.WriteLine();
            Console.WriteLine("Удаляем часть компонентов");
            Console.WriteLine();

            army.Remove(division1);
            division2.Remove(company2);
            company3.Remove(archer5);
            company3.Remove(officer3);

            army.Print(0);
        }
Ejemplo n.º 10
0
        static public void Run()
        {
            int  armyQuantity = 0;
            Army army         = new Army();

            Squad   elfSquad      = new Squad(Race.elf);
            Squad   minotaurSquad = new Squad(Race.minotaur);
            Squad   centaurSquad  = new Squad(Race.centaur);
            Squad   knightSquad   = new Squad(Race.knight);
            Squad   orcSquad      = new Squad(Race.orc);
            Squad   cyclopsSquad  = new Squad(Race.cyclops);
            Squad   cyclopsSquad2 = new Squad(Race.cyclops);
            Squad   elfSquad2     = new Squad(Race.elf);
            Soldier hydra         = new Soldier(Race.hydra);
            Soldier dragon        = new Soldier(Race.dragon);

            //Создание войс и добавление количества воинов каждой расы в состав армии
            var orcSoldiers = Enumerable.Range(1, 4).Select(x => new Soldier(Race.orc));

            orcSquad.AddAll(orcSoldiers);
            armyQuantity += Enumerable.Range(1, 4).Select(x => new Soldier(Race.orc)).Count();


            var elfSoldiers = Enumerable.Range(1, 12).Select(x => new Soldier(Race.elf));

            elfSquad.AddAll(elfSoldiers);
            armyQuantity += Enumerable.Range(1, 12).Select(x => new Soldier(Race.elf)).Count();

            var elfSoldiers2 = Enumerable.Range(1, 6).Select(x => new Soldier(Race.elf));

            elfSquad2.AddAll(elfSoldiers2);
            elfSquad.Add(elfSquad2);
            armyQuantity += Enumerable.Range(1, 6).Select(x => new Soldier(Race.elf)).Count();


            var minotaurSoldiers = Enumerable.Range(1, 5).Select(x => new Soldier(Race.minotaur));

            minotaurSquad.AddAll(minotaurSoldiers);
            armyQuantity += Enumerable.Range(1, 5).Select(x => new Soldier(Race.minotaur)).Count();

            var centaurSoldiers = Enumerable.Range(1, 5).Select(x => new Soldier(Race.centaur));

            centaurSquad.AddAll(centaurSoldiers);
            armyQuantity += Enumerable.Range(1, 5).Select(x => new Soldier(Race.centaur)).Count();

            var knightSoldiers = Enumerable.Range(1, 20).Select(x => new Soldier(Race.knight));

            knightSquad.AddAll(knightSoldiers);
            armyQuantity += Enumerable.Range(1, 10).Select(x => new Soldier(Race.knight)).Count();

            var cyclopsSoldiers = Enumerable.Range(1, 8).Select(x => new Soldier(Race.cyclops));

            cyclopsSquad.AddAll(cyclopsSoldiers);
            armyQuantity += Enumerable.Range(1, 8).Select(x => new Soldier(Race.cyclops)).Count();

            var cyclopsSoldiers2 = Enumerable.Range(1, 4).Select(x => new Soldier(Race.cyclops));

            cyclopsSquad2.AddAll(cyclopsSoldiers2);
            cyclopsSquad.Add(cyclopsSquad2);
            armyQuantity += Enumerable.Range(1, 4).Select(x => new Soldier(Race.cyclops)).Count();


            army.Add(hydra);
            army.Add(dragon);
            army.Add(elfSquad);
            army.Add(minotaurSquad);
            army.Add(centaurSquad);
            army.Add(knightSquad);
            army.Add(orcSquad);
            army.Add(cyclopsSquad);
            army.Display();
            Console.WriteLine("\n\n\tОбщее количество войск : {0} ", armyQuantity);
        }
Ejemplo n.º 11
0
 public void SignPlayer(Player player)
 {
     player.Teams.Add(this);
     Squad.Add(player);
 }
Ejemplo n.º 12
0
        public override Task DivideLine(string line)
        {
            Console.WriteLine($"{DateTime.Now} Thread {Thread.CurrentThread.ManagedThreadId} started job.");
            if (line.Length < 5)
            {
                Console.WriteLine($"{DateTime.Now} Line too small, skipped.");
            }
            else if (line.Contains(" TC: "))
            {
                Team.Add(line);
            }
            else if (line.Contains(" MC LS:"))
            {
                Main.Add(line);
            }
            else if (line.Contains(" MC LV:"))
            {
                Main.Add(line);
            }
            else if (line.Contains(" MC SF:"))
            {
                Main.Add(line);
            }
            else if (line.Contains(" (ADVERT) "))
            {
                Advert.Add(line);
            }
            else if (line.Contains(" (MYC "))
            {
                Country.Add(line);
            }

            else if (line.Contains(" (sup) "))
            {
                Support.Add(line);
            }
            else if (line.Contains(" (cad) "))
            {
                Cad.Add(line);
            }

            else if (line.Contains(" KILL: "))
            {
                KillDeaths.Add(line);
            }
            else if (line.Contains(" DEATH: "))
            {
                KillDeaths.Add(line);
            }
            else if (line.Contains(" killed themselves via command"))
            {
                KillDeaths.Add(line);
            }

            else if (line.Contains(" GrC ("))
            {
                Group.Add(line);
            }
            else if (line.Contains(" SC ("))
            {
                Squad.Add(line);
            }
            else if (line.Contains(" UC ("))
            {
                Unit.Add(line);
            }
            else if (line.Contains(" (alliance) "))
            {
                Group.Add(line);
            }

            else if (line.Contains(" SMS from "))
            {
                Sms.Add(line);
            }
            else if (line.Contains(" SMS to "))
            {
                Sms.Add(line);
            }

            else if (line.Contains(" T$ "))
            {
                TTransactions.Add(line);
                if (line.Contains("(CITphoneTran"))
                {
                    PlayerTransactions.Add(line);
                }
                else if (line.Contains("CIThit"))
                {
                    Hit.Add(line);
                }
            }
            else if (line.Contains(" G$ "))
            {
                GTransactions.Add(line);
                if (line.Contains("(CITphoneTran"))
                {
                    PlayerTransactions.Add(line);
                }
                else if (line.Contains("CIThit"))
                {
                    Hit.Add(line);
                }
            }
            else if (line.Contains(" BT: "))
            {
                PlayerTransactions.Add(line);
            }

            else if (line.Contains(" (FMSG) "))
            {
                Fmsg.Add(line);
            }
            else if (line.Contains(" (LOCF)["))
            {
                Fmsg.Add(line);
            }

            else if (line.Contains(" (LOC)["))
            {
                Local.Add(line);
            }
            else if (line.Contains(" (LOC)["))
            {
                Local.Add(line);
            }
            else if (line.Contains(" (LOC)["))
            {
                Local.Add(line);
            }

            else if (line.Contains(" LC "))
            {
                Emergency.Add(line);
            }

            else if (line.Contains(" GroupPromotion: "))
            {
                Group.Add(line);
            }

            else if (line.Contains(" modify "))
            {
                Inventory.Add(line);
            }
            else if (line.Contains(" Crafting "))
            {
                Inventory.Add(line);
            }
            else if (line.Contains(") sold "))
            {
                Trading.Add(line);
            }
            else if (line.Contains(" (Bought "))
            {
                Trading.Add(line);
            }

            else if (line.Contains(" NC "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" LOGIN MISC: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" LOGIN: "******" LOGIN WEPS: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT MISC: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT WEPS: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT WEPS: "))
            {
                JoinQuit.Add(line);
            }

            else
            {
                Other.Add(line);
            }

            Console.WriteLine($"{DateTime.Now} Thread {Thread.CurrentThread.ManagedThreadId} ended job.");
            return(Task.CompletedTask);
        }
Ejemplo n.º 13
0
        private void HUD_Tick(object sender, EventArgs e)
        {
            // Make the inventory visible based on the button pressed
            if (menu.Inventory.Checked)
            {
                Game.DisableControlThisFrame(Control.SelectWeapon);
                if (Game.IsControlJustPressed(Control.SelectWeapon))
                {
                    inventory.Visible = !inventory.Visible;
                }
            }

            // If a Ped update is required and we are not in a cutscene
            if ((nextSquadUpdate <= Game.GameTime || nextSquadUpdate == 0) && !Game.IsCutsceneActive)
            {
                // Iterate over the peds in the whole game world
                foreach (Ped ped in World.GetAllPeds())
                {
                    bool isFriend    = Game.Player.Character.GetRelationshipWithPed(ped) <= Relationship.Like && ped.GetRelationshipWithPed(Game.Player.Character) <= Relationship.Like;
                    bool sameGroup   = Game.Player.Character.PedGroup == ped.PedGroup;
                    bool groupLeader = ped.PedGroup?.Leader == Game.Player.Character;

                    // If the ped is a friend or is part of the player's group, is not the player, and is not part of the squad, add it
                    if ((isFriend || sameGroup || groupLeader) && ped != Game.Player.Character && !Squad.Contains(ped))
                    {
                        Squad.Add(new PedHealth(ped));
                    }
                }

                // Finally, set the new update time
                nextSquadUpdate = Game.GameTime + 1000;
            }

            // If the user entered ggohudconfig in the cheat input, open the menu
            if (Game.WasCheatStringJustEntered("ggo"))
            {
                menu.Visible = true;
            }

            // If the current weapon used by the player is not the primary or secondary and is not unarmed
            WeaponHash current = Game.Player.Character.Weapons.Current.Hash;

            if ((current != weaponPrimary || current != weaponSecondary) && current != WeaponHash.Unarmed)
            {
                // Check for the group and switch it if required
                switch (Tools.GetWeaponType(current))
                {
                case WeaponType.Primary:
                    weaponPrimary = current;
                    inventory.UpdateWeapons();
                    Player.PrimaryWeapon.ShiftImage(false, true);
                    break;

                case WeaponType.Secondary:
                    weaponSecondary = current;
                    inventory.UpdateWeapons();
                    Player.SecondaryWeapon.ShiftImage(false, true);
                    break;

                case WeaponType.Melee:
                    weaponSecondary = current;
                    inventory.UpdateWeapons();
                    Player.SecondaryWeapon.ShiftImage(true, true);
                    break;
                }
            }

            // If the player does not has either the primary or secondary weapons, clear them out
            if (!Function.Call <bool>(Hash.HAS_PED_GOT_WEAPON, Game.Player.Character, weaponPrimary, false))
            {
                weaponPrimary = 0;
            }
            if (!Function.Call <bool>(Hash.HAS_PED_GOT_WEAPON, Game.Player.Character, weaponSecondary, false))
            {
                weaponSecondary = 0;
            }

            // Work on the Death markers
            if (menu.DeathMarkers.Checked)
            {
                UpdateMarkers();
            }

            // Just process the HUD Elements
            pool.Process();

            // If the user pressed 1, 2 or 3 with the equip mode enabled, change the weapon
            if (menu.EquipWeapons.Checked)
            {
                if (Game.IsControlJustPressed(Control.SelectWeaponUnarmed))
                {
                    Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character, weaponPrimary, false);
                }
                if (Game.IsControlJustPressed(Control.SelectWeaponMelee))
                {
                    Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character, weaponSecondary, false);
                }
                if (Game.IsControlJustPressed(Control.SelectWeaponShotgun))
                {
                    Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character, WeaponHash.Unarmed, false);
                }
            }
        }