Beispiel #1
0
        public void SpawnPet(UnturnedPlayer player, PlayerPet pet)
        {
            foreach (var activePet in GetPlayerActivePets(player.Id).ToArray())
            {
                InvokeKillPet(activePet);
            }

            var point = player.Position;

            AnimalManager.spawnAnimal(pet.AnimalId, point, player.Player.transform.rotation);

            // remove animal spawn
            AnimalManager.packs.RemoveAll(x => x.spawns.Exists(y => y.point == point));


            // I know it's crap and but that's the simplest way atm, please pr if you know better
            var animals = new List <Animal>();

            AnimalManager.getAnimalsInRadius(player.Position, 1, animals);

            pet.Animal = animals.FirstOrDefault(x => x.asset.id == pet.AnimalId);
            pet.Player = player.Player;

            ActivePets.Add(pet);
            OnPetSpawned.TryInvoke(pet);
        }
Beispiel #2
0
        private static void TestReflectionAndGenerycs()
        {
            Console.WriteLine(Guid.NewGuid().ToString().Length);
            var animalManager = new AnimalManager <Dog> {
                Id = Guid.NewGuid()
            };
            var animals = new List <Dog>
            {
                new Dog(Guid.NewGuid(), "Firulais", "Golden", 43),
                new Dog(Guid.NewGuid(), "Paco", "Caniche", 12),
                new Dog(Guid.NewGuid(), "Paco", "Caniche", 2),
                new Dog(Guid.NewGuid(), "Paco", "Caniche", 13),
                new Dog(Guid.NewGuid(), "Paco", "Caniche", 1),
                new Dog(Guid.NewGuid(), "Paco", "Caniche", 14),
            };

            animalManager.Animals = animals;
            Dictionary <string, object> animalsReflecion = animalManager.DecodeObject();
            var anonimousObj = new { animals.First().Name, animals.First().Age };

            foreach (var property in animalsReflecion)
            {
                Console.ForegroundColor = property.Value is string?ConsoleColor.Red : ConsoleColor.Yellow;
                Console.WriteLine($"{property.Key}: {property.Value}");
            }
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length < 1)
            {
                UnturnedChat.Say(caller, Syntax);
                return;
            }

            UnturnedPlayer untPlayer = (UnturnedPlayer)caller;
            ushort         type      = Utils.GetAnimalType(command[0].ToLower());

            if (type == 0)
            {
                UnturnedChat.Say(caller, Main.Instance.Translate("not_type"));
                return;
            }

            Vector3?eyePos = Utils.GetEyePosition(Mathf.Infinity, untPlayer);

            Vector3 spawnPoint = new Vector3();

            if (eyePos.HasValue)
            {
                spawnPoint = eyePos.Value;
            }
            else
            {
                spawnPoint = untPlayer.Position;
            }

            AnimalManager.spawnAnimal(type, spawnPoint, new Quaternion());
        }
 // Start is called before the first frame update
 void Start()
 {
     itemSlots     = GetComponentsInChildren <itemSlot>();
     spawnManager  = GameObject.Find("SpawnManager").GetComponent <SpawnManager>();
     animalManager = GameObject.Find("AnimalManager").GetComponent <AnimalManager>();
     initializeItemSlotAssignments();
 }
Beispiel #5
0
    void Start()
    {
        this.StageManager  = GameObject.Find("StageManager").GetComponent <StageManager>();
        this.AnimalManager = GameObject.Find("AnimalManager").GetComponent <AnimalManager>();
        talk_w             = GameObject.Find("Canvas").transform.Find("bubble_talk_w").gameObject;
        game_w             = GameObject.Find("Canvas").transform.Find("bubble_game_w").gameObject;
        food_w             = GameObject.Find("Canvas").transform.Find("bubble_food_w").gameObject;
        talk_d             = GameObject.Find("Canvas").transform.Find("bubble_talk_d").gameObject;
        game_d             = GameObject.Find("Canvas").transform.Find("bubble_game_d").gameObject;
        food_d             = GameObject.Find("Canvas").transform.Find("bubble_food_d").gameObject;
        talk_s             = GameObject.Find("Canvas").transform.Find("bubble_talk_s").gameObject;
        game_s             = GameObject.Find("Canvas").transform.Find("bubble_game_s").gameObject;
        food_s             = GameObject.Find("Canvas").transform.Find("bubble_food_s").gameObject;
        talk_f             = GameObject.Find("Canvas").transform.Find("bubble_talk_f").gameObject;
        game_f             = GameObject.Find("Canvas").transform.Find("bubble_game_f").gameObject;
        food_f             = GameObject.Find("Canvas").transform.Find("bubble_food_f").gameObject;
        talk_p             = GameObject.Find("Canvas").transform.Find("bubble_talk_p").gameObject;
        game_p             = GameObject.Find("Canvas").transform.Find("bubble_game_p").gameObject;
        food_p             = GameObject.Find("Canvas").transform.Find("bubble_food_p").gameObject;
        talk_l             = GameObject.Find("Canvas").transform.Find("bubble_talk_l").gameObject;
        game_l             = GameObject.Find("Canvas").transform.Find("bubble_game_l").gameObject;
        food_l             = GameObject.Find("Canvas").transform.Find("bubble_food_l").gameObject;
        talk_t             = GameObject.Find("Canvas").transform.Find("bubble_talk_t").gameObject;
        game_t             = GameObject.Find("Canvas").transform.Find("bubble_game_t").gameObject;
        food_t             = GameObject.Find("Canvas").transform.Find("bubble_food_t").gameObject;

        rand1 = Random.Range(0, 50);
        rand2 = Random.Range(0, 23);
        rand3 = Random.Range(0, 101);
        rand4 = Random.Range(0, 48);
    }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #7
0
        public void TestAnimalManagerAddNewAnimal()
        {
            // arrange
            bool           isValidAnimal = false;
            IAnimalManager animalManager = new AnimalManager(_animalAccessor);

            // act
            Animal animal1 = new Animal()
            {
                AnimalID        = 4,
                AnimalName      = "D",
                Dob             = DateTime.Now.Date,
                AnimalBreed     = "D",
                ArrivalDate     = DateTime.Now.Date,
                CurrentlyHoused = true,
                Adoptable       = true,
                Active          = true,
                AnimalSpeciesID = "D"
            };

            isValidAnimal = animalManager.AddNewAnimal(animal1);

            // assert
            Assert.IsTrue(isValidAnimal);
        }
    private void Start()
    {
        animalManager = GameObject.Find("Director").GetComponent <AnimalManager>();

        rigidBody      = GetComponent <Rigidbody>();
        sphereCollider = GetComponent <SphereCollider>();
    }
        public void PenTesting()
        {
            Pen             pen       = new Pen("MY FARM");
            DatabaseManager manager   = new DatabaseManager();
            EventManager    eManager  = new EventManager();
            AnimalManager   aManager  = new AnimalManager();
            CDChicken       cdChicken = new CDChicken();

            //Assert.AreEqual(3, pen.GetAnimals().Count);
            pen.KillAllAnimals();
            eManager.DeleteAllEvents(manager);
            pen.AddChicken();
            pen.AddChicken();
            pen.AddCow();
            pen.AddCow();
            pen.AddPig();
            pen.AddPig();
            //pen.RemoveAnimal(pen.GetAnimal(0));
            //Assert.AreEqual(5, pen.GetAnimals().Count);
            //aManager.DeleteAnimals(cdChicken, manager);
            //eManager.DeleteAllEvents(manager);
            //Assert.IsTrue(pen.Copulate(pen.GetAnimal(3), pen.GetAnimal(5)));
            Assert.IsFalse(pen.Copulate(pen.GetAnimal(0), pen.GetAnimal(5)));
            Assert.IsTrue(pen.Copulate(pen.GetAnimal(0), pen.GetAnimal(1)));
        }
Beispiel #10
0
        /// <summary>
        /// Checks if the fence data is valid.
        /// </summary>
        /// <param name="player">The player building the fences</param>
        /// <param name="data">Data defining the fences to be built</param>
        /// <param name="pastures">A list of pastures resulting from the fences built</param>
        /// <param name="costs">The costs of the requested fences</param>
        /// <returns>True if the fence data is valid</returns>
        public static bool CanBuildFences(AgricolaPlayer player, int actionId, BuildFencesActionData data, out List <int[]> pastures, out ResourceCache[] costs)
        {
            var fenceData = (BuildFencesActionData)data;

            pastures = null;
            if (!Curator.CanAffordFences(player, actionId, fenceData.Fences.Length, out costs))
            {
                return(false);
            }

            var fenceValidator = new FencePlacementValidator(fenceData.Fences, player.Farmyard, out pastures);

            if (!fenceValidator.Valid || !player.Farmyard.IsValidPastureLocations(pastures))
            {
                return(false);
            }

            var tempAnimalManager = new AnimalManager();

            tempAnimalManager = tempAnimalManager.Update(player.Farmyard.Grid, pastures.ToImmutableArray(), data.AnimalData.Assignments);
            if (!ActionService.CanAssignAnimals(player, (AnimalCacheActionData)fenceData.AnimalData, tempAnimalManager, null))
            {
                return(false);
            }

            return(true);
        }
Beispiel #11
0
        public override void Initialize()
        {
            // create and add any components that belong to this scene
            this.AddComponent(new Background(Game));

            this.AddComponent(new Score(Game, "fonts\\hudFont", HudLocation.TopRight));

            this.AddComponent(new AnimalsDead(Game, "fonts\\hudFont", HudLocation.TopLeft));


            AnimalManager animalManager = new AnimalManager(Game);

            this.AddComponent(animalManager);
            Game.Services.AddService <AnimalManager>(animalManager);

            TrashManager trashManager = new TrashManager(Game);

            this.AddComponent(trashManager);
            Game.Services.AddService <TrashManager>(trashManager);

            Hunter hunter = new Hunter(Game);

            this.AddComponent(hunter);
            Game.Services.AddService <Hunter>(hunter);

            base.Initialize();
        }
    void Start()
    {
        this.AnimalManager = GameObject.Find("AnimalManager").GetComponent <AnimalManager>();
        int rand = Random.Range(1, 7);

        Animal_Random(rand);
    }
Beispiel #13
0
        static void Main(string[] args)
        {
            //================================================================
            // Test polymorphic objects

            var animalManager = new AnimalManager();

            animalManager.Animals = new IAnimal[]
            {
                new Dog {
                    Name = "Pochi", DogProperty = "Wan wan"
                },
                new Cat {
                    Name = "Tama", CatProperty = "Nya nya"
                }
            };

            // Serializer.
            var serializer = new JsonSerializerAdapter(typeof(AnimalManager));

            serializer.JsonSerializer.Formatting = Formatting.Indented;

            // Output file path.
            var path = Path.Combine(Directory.GetCurrentDirectory(), "AnimalManager.json");

            // Serialize.
            using (var stream = File.Create(path))
            {
                serializer.Serialize(stream, animalManager);
            }
            Console.WriteLine("Serialize:");
            Console.WriteLine(path);

            using (var stream = File.Open(path, FileMode.Open))
                using (var reader = new StreamReader(stream))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        Console.WriteLine(line);
                    }
                }
            Console.WriteLine();

            // Deserialize.
            AnimalManager loadedObject;

            using (var stream = File.Open(path, FileMode.Open))
            {
                loadedObject = serializer.Deserialize(stream, null) as AnimalManager;
            }
            Console.WriteLine("Deserialize:");
            Console.WriteLine(loadedObject);
            Console.WriteLine();

            // Exit.
            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }
        public void DoesNotTigerlAnimalsFixture()
        {
            AnimalManager <AnimalBase> animalManager = new AnimalManager <AnimalBase>();

            string getallAnimals = animalManager.GetAnimals();

            Assert.IsFalse(getallAnimals.Contains("tiger"));
        }
Beispiel #15
0
 public override void Execute(PointBlankPlayer executor, string[] args)
 {
     AnimalManager.animals.ForEach((animal) =>
     {
         AnimalManager.sendAnimalDead(animal, Vector3.zero);
     });
     UnturnedChat.SendMessage(executor, Translate("KillAnimals_Success"), ConsoleColor.Green);
 }
Beispiel #16
0
        public void TestCowObjectConstuction()
        {
            _cow = new Cow();
            this.animalManager = new AnimalManager <AnimalBase>();

            Assert.That(AnimalTypeEnum.Cow, Is.EqualTo(_cow.Type));
            Assert.That("cow", Is.EqualTo(_cow.AnimalName));
            Assert.That("moo", Is.EqualTo(_cow.AnimalSound));
            Assert.That(this.animalManager.GetAnimals(), Contains.Substring(_cow.GetGetAnimalNameAndSound()));
        }
Beispiel #17
0
        public void Creat()
        {
            AnimalManager animalManager = new AnimalManager();

            animalManager.InitialAuto();

            IAnimal animal = animalManager.GetT <Dog>();

            animal.Property();
        }
Beispiel #18
0
        public void TigerShouldNotBelongToAnimals()
        {
            AnimalManager <AnimalBase> animalManager = new AnimalManager <AnimalBase>();

            this._originalVerseMOQ.Setup(p => p.GetAnimals()).Returns(this._originalVerse);

            string getallAnimals = this._originalVerseMOQ.Object.GetAnimals();

            Assert.That(getallAnimals, !Contains.Substring("tiger"));
        }
        private AnimalManager manager = null; // MainGUI "har en" AnimalManager
        /// <summary>
        /// Default konstruktor som instansierar ett objekt av AnimalManager samt fyller i alla nödvändiga värden
        /// </summary>
        public MainGUI()
        {
            InitializeComponent();

            manager = new AnimalManager(); // Instansiera AnimalManagern

            InitializeGUI(); // Börjar med att fylla i alla nödvändiga värden

            foodManager = new RecipeManager();
        }
Beispiel #20
0
        public void AssertCowObjectConstuctionFixture()
        {
            this._cow          = new Cow();
            this.animalManager = new AnimalManager <AnimalBase>();

            Assert.AreEqual(AnimalTypeEnum.Cow, this._cow.Type);
            Assert.AreEqual("cow", this._cow.AnimalName);
            Assert.AreEqual("moo", this._cow.AnimalSound);
            Assert.IsTrue(this.animalManager.GetAnimals().Contains(this._cow.GetGetAnimalNameAndSound()));
        }
Beispiel #21
0
        public AnimalController()
        {
            _animalManager = new AnimalManager();

            var config = new MapperConfiguration(x =>
            {
                x.CreateMap <AnimalModel, Models.AnimalViewModel>();
            });

            _mapper = new Mapper(config);
        }
Beispiel #22
0
        public void TestRetrieveAnimalByAnimalID()
        {
            // arrange
            List <Animal>  testAnimals;
            IAnimalManager animalManager = new AnimalManager(_animalAccessor);

            // act
            testAnimals = animalManager.RetrieveAnimalByAnimalID(1);

            // assert
            Assert.IsNotNull(testAnimals);
        }
Beispiel #23
0
        public void TestAnimalManagerSelectAnimalSpecies()
        {
            // arrange
            List <string>  testSpecies;
            IAnimalManager animalManager = new AnimalManager(_animalAccessor);

            // act
            testSpecies = animalManager.RetrieveAnimalSpecies();

            // assert
            Assert.IsNotNull(testSpecies);
        }
Beispiel #24
0
        public void TestAnimalManagerSelectAllAnimalProfiles()
        {
            // arrange
            List <Animal>  testAnimals;
            IAnimalManager animalManager = new AnimalManager(_animalAccessor);

            // act
            testAnimals = animalManager.RetrieveAllAnimalProfiles();

            // assert
            Assert.IsNotNull(testAnimals);
        }
Beispiel #25
0
        public void TestRetrieveOneAnimalByAnimalID()
        {
            // arrange
            Animal         testAnimal;
            IAnimalManager animalManager = new AnimalManager(_animalAccessor);

            // act
            testAnimal = animalManager.RetrieveOneAnimalByAnimalID(1);

            // assert
            Assert.IsNotNull(testAnimal);
        }
Beispiel #26
0
        public void TestDeactivateHousedGoodValue()
        {
            //arrange
            IAnimalManager animalManager  = new AnimalManager(_animalAccessor);
            const bool     expectedResult = true;

            //act
            bool actualResult = animalManager.SetAnimalHousedState(false, 1);

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #27
0
        public void TestActivateAdoptableGoodValue()
        {
            //arrange
            IAnimalManager animalManager  = new AnimalManager(_animalAccessor);
            const bool     expectedResult = true;

            //act
            bool actualResult = animalManager.SetAnimalAdoptableState(true, 1);

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #28
0
        public void TestDeactivateAdoptableBadValue()
        {
            //arrange
            IAnimalManager animalManager  = new AnimalManager(_animalAccessor);
            const bool     expectedResult = false;

            //act
            bool actualResult = animalManager.SetAnimalAdoptableState(false, 0);

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #29
0
    //protected int getWorldSize()    // Is there a nicer way to make a variable public to unity but not editable by child classes...? { get; } etc.
    //{
    //    return worldSize;
    //}

    // Start is called before the first frame update
    void Start()
    {
        nodeManagerPrefab   = (NodeManager)Resources.Load("Prefabs/Node/Node Manager", typeof(NodeManager));
        grassManagerPrefab  = (GrassManager)Resources.Load("Prefabs/Grass/Grass Manager", typeof(GrassManager));
        animalManagerPrefab = (AnimalManager)Resources.Load("Prefabs/Animal/Animal Manager", typeof(AnimalManager));
        worldPrefab         = (World)Resources.Load("Prefabs/World/World", typeof(World));

        Instantiate(worldPrefab, transform);            // Do i have to create instances of classes with "Instantiate" and a prefab...?
        Instantiate(nodeManagerPrefab, transform);
        Instantiate(grassManagerPrefab, transform);
        Instantiate(animalManagerPrefab, transform);
    }
Beispiel #30
0
 private void Awake()
 {
     if (Instans == null)
     {
         Instans = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
        public void GetAllAnimalsFixture()
        {
            this.animalManager = new AnimalManager <AnimalBase>();

            string getAllAnimals = this.animalManager.GetAnimals();

            Assert.IsTrue(getAllAnimals.Contains(new Cat().GetGetAnimalNameAndSound()));
            Assert.IsTrue(getAllAnimals.Contains(new Dog().GetGetAnimalNameAndSound()));
            Assert.IsTrue(getAllAnimals.Contains(new Cow().GetGetAnimalNameAndSound()));
            Assert.IsTrue(getAllAnimals.Contains(new Duck().GetGetAnimalNameAndSound()));
            Assert.IsTrue(getAllAnimals.Contains(new Pig().GetGetAnimalNameAndSound()));
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            //================================================================
            // Test polymorphic objects

            var animalManager = new AnimalManager();
            animalManager.Animals = new IAnimal[]
            {
                new Dog { Name = "Pochi", DogProperty = "Wan wan" },
                new Cat { Name = "Tama", CatProperty = "Nya nya" }
            };

            // Serializer.
            var serializer = new JsonSerializerAdapter(typeof(AnimalManager));
            serializer.JsonSerializer.Formatting = Formatting.Indented;

            // Output file path.
            var path = Path.Combine(Directory.GetCurrentDirectory(), "AnimalManager.json");

            // Serialize.
            using (var stream = File.Create(path))
            {
                serializer.Serialize(stream, animalManager);
            }
            Console.WriteLine("Serialize:");
            Console.WriteLine(path);

            using (var stream = File.Open(path, FileMode.Open))
            using (var reader = new StreamReader(stream))
            {
                string line;
                while ((line = reader.ReadLine()) != null) Console.WriteLine(line);
            }
            Console.WriteLine();

            // Deserialize.
            AnimalManager loadedObject;
            using (var stream = File.Open(path, FileMode.Open))
            {
                loadedObject = serializer.Deserialize(stream, null) as AnimalManager;
            }
            Console.WriteLine("Deserialize:");
            Console.WriteLine(loadedObject);
            Console.WriteLine();

            // Exit.
            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }
Beispiel #33
0
 void Awake()
 {
     instance = this;
 }
Beispiel #34
0
        private AnimalManager animalMngr = null; //ref variable declared

        #endregion Fields

        #region Constructors

        public Form1()
        {
            InitializeComponent();

            //Initializations
            InitializeGUI();

            //rcpMngr = new RecipeManager();
            //AnimalManager
            animalMngr = new AnimalManager();
            //instanceFoodSchedule = new FoodSchedule();
            //animalMngr = new ListManager<AnimalManager>();
        }