Inheritance: MonoBehaviour
コード例 #1
0
    static void UpdateAnimals()
    {
        //load the animal container from resources
        AnimalContainer container = Resources.Load <AnimalContainer>("AnimalContainer");

        //load the revelant spreadsheet
        SpreadSheetManager manager   = new SpreadSheetManager();
        GS2U_Worksheet     worksheet = manager.LoadSpreadSheet("Animal Stats").LoadWorkSheet("Stats");
        WorksheetData      data      = worksheet.LoadAllWorksheetInformation();

        //loop through all the animals on the spreadsheet, if an animal is found then update their stats
        for (int i = 0; i < data.rows.Count; i++)
        {
            Animal animal = container.allAnimals.Find(x => x.name == data.rows[i].rowTitle);

            //if an animal can not be found then create an asset for that animal
            if (animal == null)
            {
                animal      = new Animal();
                animal.name = data.rows[i].rowTitle;
                AssetDatabase.CreateAsset(animal, "Assets/Animal Example/Animal Stats/" + animal.name + ".asset");
                container.allAnimals.Add(animal);

                Debug.Log("Creating animal asset for " + animal.name);
            }

            //update the animals stats
            animal.UpdateStats(data.rows[i]);
            Debug.Log("Updating Stats for " + animal.name);
        }
    }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: DaanSnoeijen/CircusTrein
        public void TestAnimalAdd()
        {
            //arrange
            AnimalContainer animalContainer = new AnimalContainer();

            //act
            animalContainer.CreateAnimal(diet.Meat, size.Large);

            //assert
            Assert.IsTrue(animalContainer.animalList.Count == 1);
        }
コード例 #3
0
        public IActionResult Get()
        {
            var animais = database.Animais.ToList();
            List <AnimalContainer> animaisHATEOAS = new List <AnimalContainer>();

            foreach (var animal in animais)
            {
                AnimalContainer animalHATEOAS = new AnimalContainer();
                animalHATEOAS.animal = animal;
                animalHATEOAS.links  = HATEOAS.GetActions(animal.Id.ToString());
                animaisHATEOAS.Add(animalHATEOAS);
            }
            return(Ok(new { result = "success", animaisHATEOAS }));
        }
コード例 #4
0
 public IActionResult Get(int id)
 {
     try
     {
         var             animal        = database.Animais.First(a => a.Id == id);
         AnimalContainer animalHATEOAS = new AnimalContainer();
         animalHATEOAS.animal = animal;
         animalHATEOAS.links  = HATEOAS.GetActions(animal.Id.ToString());
         return(Ok(new { result = "success", animalHATEOAS }));
     }
     catch (System.Exception)
     {
         Response.StatusCode = 404;
         return(new ObjectResult(new{ result = "error", msg = "Animal não encontrado" }));
     }
 }
コード例 #5
0
        static void Main(string[] args)
        {
            AnimalContainer ac = new AnimalContainer();

            foreach (Animal animal in ac)
            {
                System.Console.WriteLine(animal.Name);
            }

            List <ComparableClass> list = new List <ComparableClass>();
            Random r = new Random();

            for (int i = 0; i < 10; i++)
            {
                list.Add(new ComparableClass(r.Next(1000)));
            }

            foreach (ComparableClass c in list)
            {
                System.Console.WriteLine("{0}", c.Value);
            }

            System.Console.WriteLine("\n Sorted list:");

            list.Sort();

            foreach (ComparableClass c in list)
            {
                System.Console.WriteLine("{0}", c.Value);
            }

            Matrix matrix1 = new Matrix(2, 2);
            Matrix matrix2 = new Matrix(2, 2);

            for (int i = 0; i < matrix1.N; i++)
            {
                for (int j = 0; j < matrix1.M; j++)
                {
                    matrix1[i, j] = r.Next(10);
                    matrix2[i, j] = r.Next(10);
                }
            }
            System.Console.WriteLine(matrix1.ToString());
            System.Console.WriteLine(matrix2.ToString());

            System.Console.WriteLine(matrix1 + matrix2);
        }