Ejemplo n.º 1
0
    //初期化処理
    public void Init()
    {
        //ルームに遷移したの時の初期化
        if (GameStateManager.Instance.CurrentScene == 1)
        {
            ASetting = GameObject.FindGameObjectWithTag("AnimalSetting").GetComponent <AnimalSetting>();

            if (ALoader == null)
            {
                ALoader = new AnimalLoader();
                // ALoader = GameObject.FindGameObjectWithTag("AnimalSetting").GetComponent<AnimalLoader>();
                Datas       = ALoader.LoadData();
                maxPage     = (int)Mathf.Ceil(Datas.Count / panelNum);
                currentPage = 1;
                ASetting.SetDataList(Datas, currentPage);
            }
            UseCategory = "100";
            UseID       = "1";
            // UseData = ASetting.ChooseData ;
            // Datatest();
        }
        //おでかけ先に遷移した時の初期化
        else if (GameStateManager.Instance.CurrentScene == 2)
        {
            ACreator = GameObject.FindGameObjectWithTag("ObjectSpawner").GetComponent <AnimalCreator>();
            FCreator = GameObject.FindGameObjectWithTag("ObjectSpawner").GetComponent <FoodCreator>();
            AnimalCreate();
        }
    }
Ejemplo n.º 2
0
        public void OptimalSort()
        {
            List <IAnimal> animals = new List <IAnimal>();

            animals.Add(AnimalCreator.CreateCarnivore(Sizes.Large));
            animals.Add(AnimalCreator.CreateCarnivore(Sizes.Small));
            animals.Add(AnimalCreator.CreateCarnivore(Sizes.Small));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Large));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));

            sorter = new Sorter(animals);
            List <Wagon> wagons = sorter.Sort();

            //Wagon 1
            Assert.IsTrue(wagons[0].Animals[0] is Carnivore);
            Assert.AreEqual(wagons[0].Animals[0].Size, Sizes.Large);

            //Wagon 2
            Assert.IsTrue(wagons[1].Animals[0] is Carnivore);
            Assert.AreEqual(wagons[1].Animals[0].Size, Sizes.Small);
            Assert.IsTrue(wagons[1].Animals[1] is Herbivore);
            Assert.AreEqual(wagons[1].Animals[1].Size, Sizes.Large);
            Assert.IsTrue(wagons[1].Animals[2] is Herbivore);
            Assert.AreEqual(wagons[1].Animals[2].Size, Sizes.Middle);

            //Wagon 4
            Assert.IsTrue(wagons[2].Animals[0] is Carnivore);
            Assert.AreEqual(wagons[2].Animals[0].Size, Sizes.Small);
            Assert.IsTrue(wagons[2].Animals[1] is Herbivore);
            Assert.AreEqual(wagons[2].Animals[1].Size, Sizes.Middle);
        }
Ejemplo n.º 3
0
        public void CapacityLowers()
        {
            int capacity = wagon.Capacity;

            wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Large));

            Assert.IsTrue(wagon.Capacity < capacity);
        }
Ejemplo n.º 4
0
        public void CanAddAnimal()
        {
            Carnivore animal = AnimalCreator.CreateCarnivore(Sizes.Large);

            wagon.AddAnimal(animal);

            Assert.IsTrue(wagon.Animals.Contains(animal));
        }
Ejemplo n.º 5
0
        public void ConctructorAddsAnimal()
        {
            Carnivore animal = AnimalCreator.CreateCarnivore(Sizes.Large);

            wagon = new Wagon(animal);

            Assert.IsTrue(wagon.Animals.Contains(animal));
        }
Ejemplo n.º 6
0
        public void IsWagonListCreated()
        {
            List <IAnimal> animals = new List <IAnimal>();

            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));
            sorter = new Sorter(animals);

            Assert.IsNotNull(sorter.wagons);
        }
Ejemplo n.º 7
0
        public void MaxCapacity()
        {
            double capacity        = (double)wagon.Capacity;
            int    amountOfAnimals = Convert.ToInt32(Math.Floor(capacity / (double)Sizes.Small));

            for (int i = 0; i < amountOfAnimals; i++)
            {
                wagon.AddAnimal(AnimalCreator.CreateHerbivore(Sizes.Small));
            }

            Assert.IsFalse(wagon.AddAnimal(AnimalCreator.CreateHerbivore(Sizes.Small)));
        }
Ejemplo n.º 8
0
        public void AddsAnimalsToList()
        {
            List <IAnimal> animals = new List <IAnimal>();

            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));

            sorter = new Sorter(animals);

            foreach (IAnimal animal in animals)
            {
                Assert.IsTrue(sorter.Animals.Contains(animal));
            }
        }
Ejemplo n.º 9
0
        public void AnimalCreate()
        {
            AnimalCreator ac = new AnimalCreator();

            Animal animal;

            Type[] expected = { typeof(Bear), typeof(Wolf), typeof(Giraffe) };

            animal = ac.Create();

            foreach (var type in expected)
            {
                if (type == animal.GetType())
                {
                    Assert.AreEqual(type, animal.GetType());
                }
            }
        }
Ejemplo n.º 10
0
        public void NoCarnivoresTogether()
        {
            wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Large));

            Assert.IsFalse(wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Middle)));
        }
Ejemplo n.º 11
0
        public void NoSmallerHerbivoreWithCarnivore()
        {
            wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Large));

            Assert.IsFalse(wagon.AddAnimal(AnimalCreator.CreateHerbivore(Sizes.Middle)));
        }
Ejemplo n.º 12
0
 public Zoo()
 {
     Animals        = new List <Animal>();
     _animalCreator = new AnimalCreator();
     InitZooHardCode();
 }