Пример #1
0
            public void AssertBrothersOfIshAreCorrect()
            {
                Ape ish  = _apeService.GetElement("Ish");
                Ape chit = _apeService.GetElement("Chit");
                Ape vich = _apeService.GetElement("Vich");

                Assert.That(ish.GetSiblings(GenderType.Male, _apeFamilyAssociationService), Is.EqualTo(new List <Ape>()
                {
                    chit, vich
                }));
            }
Пример #2
0
 public static void PrintName(Ape ape, RelationshipType type)
 {
     if (ape != null)
     {
         Console.WriteLine($"\t " + ape.GetName());
     }
     else
     {
         Console.WriteLine($"" +
                           $"\t Oops no member found! with relation {type.ToString()}");
     }
 }
Пример #3
0
            public void AssertAbilityToFindAllMothersWithMaxGirlChildren()
            {
                Ape jaya  = _apeService.GetElement("Jaya");
                Ape jnki  = _apeService.GetElement("Jnki");
                Ape satya = _apeService.GetElement("Satya");
                Ape lika  = _apeService.GetElement("Lika");

                Assert.That(new List <Ape>()
                {
                    satya, lika, jaya, jnki
                }, Is.EqualTo(_apeFamilyService.GetMothersWithMaximumGirlApes()));
            }
Пример #4
0
        public void Start()
        {
            DontDestroyOnLoad(gameObject);

            var logger = new DefaultLogger();

            _ape = new Ape(new IApeAction[]
            {
                new RandomButtonClick(),
                new KeyInputAction(),
                new StopWhenError(logger),
            }, logger);
        }
Пример #5
0
            public void AssertPaternalUncleOfKriyaisSaayan()
            {
                Ape kriya  = _apeService.GetElement("Kriya");
                Ape saayan = _apeService.GetElement("Saayan");
                Ape asva   = _apeService.GetElement("Asva");

                List <Ape> parent = kriya.GetParent(GenderType.Male, _apeFamilyAssociationService);

                Assert.That(new List <Ape>()
                {
                    saayan, asva
                }, Is.EqualTo(kriya.GetUncleOrAuntOnMaternalOrPaternalSide(GenderType.Male, _apeFamilyAssociationService, parent.ElementAt(0))));

                Assert.That(RelationshipType.PaternalUncle,
                            Is.EqualTo(_apeFamilyAssociationService.GetRelationshipBetweenApes(kriya, saayan)));
            }
Пример #6
0
        protected override void AliveUpdate()
        {
            if (_time < 0)
            {
                _time = MathExt.Random(0, 0.7f);
                var value = MathExt.Random(0, 10);
                for (int i = 0; i < Player.Stat.DnaClass; i++)
                {
                    var _speed = 0f;
                    switch (value)
                    {
                    case 0:
                        _speed = MathExt.Random(8.0f, 8.5f);
                        break;

                    default:
                        _speed = MathExt.Random(0.4f, 0.5f);
                        break;
                    }
                    var unit = new Ape(Data, new DogInput(), new AccMovement(_speed));
                    AddUnit(unit);
                    if (value == 0)
                    {
                        unit.Skin.SetColor(Microsoft.Xna.Framework.Color.Red);
                        unit.Stat.SetAttack(30, 0);
                        unit.Collision.Body.Mass        = 40;
                        unit.Collision.Body.Restitution = 1.2f;
                    }
                    unit.SetPosition(Player.Position + new Microsoft.Xna.Framework.Vector2(MathExt.Random(-500, 500), MathExt.Random(-500, 500)));
                }
            }
            _time -= TimeExt.ElapsedGameTime;

            for (int i = 0; i < _Units.Count; i++)
            {
                _Units[i].Update();
            }

            base.AliveUpdate();
        }
Пример #7
0
    IEnumerator secondScene()
    {
        ++othercounter;
        Debug.Log("A");
        yield return(new WaitForSeconds(.5f));

        topBar.GetComponent <Animator>().enabled = true;
        botBar.GetComponent <Animator>().enabled = true;
        sign.GetComponent <Animator>().enabled   = true;
        house.GetComponent <Animator>().enabled  = true;
        ground.GetComponent <Animator>().enabled = true;
        Ape.GetComponent <Animator>().SetTrigger("zoom");
        thunder.SetActive(true);
        yield return(new WaitForSeconds(.6f));

        // yield return new WaitForSeconds(.2f);
        GetComponent <Text>().text = " ";
        Lightning.SetActive(true);
        yield return(new WaitForSeconds(.12f));

        Eyes.SetActive(true);
        ++othercounter;
    }
Пример #8
0
        static void Main(string[] args)
        {
            ApeService                  apeService                  = new ApeService();
            ApeFamilyService            apeFamilyService            = new ApeFamilyService(apeService);
            ApeFamilyAssociationService apeFamilyAssociationService = new ApeFamilyAssociationService(apeFamilyService);

            int userInput = 0;

            do
            {
                userInput = DisplayMenu(apeService);
                switch (userInput)
                {
                case 1:
                    try
                    {
                        Console.WriteLine("Please enter the name of the Ape you want to find relationship for:");
                        string apeName = Console.ReadLine();
                        Console.WriteLine("Enter RelationShip Type");
                        string relationShipType = Console.ReadLine();

                        Ape ape = apeService.GetElement(apeName);

                        Models.RelationshipType relationship;

                        if (!Enum.TryParse(relationShipType, true, out relationship))
                        {
                            throw new Exception("Invalid Relationship");
                        }

                        List <Ape> apes = ape.CalculateRelationship(relationship, apeFamilyAssociationService, apeFamilyService);

                        Utility.PrintName(apes);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        Console.WriteLine("We should start from all over");
                    }

                    break;

                case 2:

                    try
                    {
                        Console.WriteLine("Please enter the name of the parent you want add the family under");
                        string parent = Console.ReadLine();
                        Console.WriteLine("Enter child name:");
                        string child = Console.ReadLine();
                        Console.WriteLine("Enter child gender:");
                        string genderType = Console.ReadLine();

                        Ape parentApe = apeService.GetElement(parent);
                        Models.GenderType gender;
                        if (!Enum.TryParse(genderType, true, out gender))
                        {
                            throw new Exception("We are not aware of such a gender!!");
                        }

                        ApeFamily apeFamily = apeFamilyService.GetAll().SingleOrDefault(p => p.Partners.Contains(parentApe));

                        if (apeFamily == null)
                        {
                            throw new Exception("That would be incorrect. Apes are not Godzillas.");
                        }

                        Ape newBorn = apeFamily.AddNewBorn(child, parentApe.GetDepthLevel() + 1, gender);
                        apeFamilyAssociationService.AddElement(child, apeFamily);
                        apeService.AddElement(newBorn.GetName(), newBorn);

                        Console.WriteLine($"New born {newBorn.GetName()} successfully added to family");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        Console.WriteLine("We should start from all over");
                    }

                    break;

                case 3:

                    Utility.PrintName(apeFamilyService.GetMothersWithMaximumGirlApes());

                    break;

                case 4:

                    try
                    {
                        Console.WriteLine("Please enter the name of the ape1");
                        string ape1Name = Console.ReadLine();
                        Console.WriteLine("Please enter the name of the ape1");
                        string ape2Name = Console.ReadLine();

                        Ape ape1 = apeService.GetElement(ape1Name);
                        Ape ape2 = apeService.GetElement(ape2Name);

                        Utility.PrintName(apeFamilyAssociationService.GetRelationshipBetweenApes(ape1, ape2));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        Console.WriteLine("We should start from all over");
                    }
                    break;
                }
            } while (userInput != 5);

            Console.WriteLine();
        }
Пример #9
0
        private void TagTestWithSave(ref Ape.Tag tag,
		                              TagTestFunc testFunc)
        {
            testFunc (tag, "Before Save");
            tag = new Ape.Tag (tag.Render ());
            testFunc (tag, "After Save");
        }