예제 #1
0
        public static string GetPetEffectDescription(this AnimalType animalType)
        {
            switch (animalType)
            {
            case AnimalType.Any:
                return($"Pet any animal by touching it");

            case AnimalType.Chicken:
            case AnimalType.Duck:
            case AnimalType.Rabbit:
            case AnimalType.Dinosaur:
            case AnimalType.Cow:
            case AnimalType.Goat:
            case AnimalType.Pig:
            case AnimalType.Hog:
                return($"Pet {animalType.ToString().ToLower()}s by touching them");

            case AnimalType.Sheep:
                return($"Pet sheep by touching them");

            case AnimalType.Ostrich:
                return($"Pet ostriches by touching them");

            default:
                return("");
            }
        }
예제 #2
0
        /// <summary>
        /// The type of animal being read.
        /// </summary>
        /// <returns> The type of animal.</returns>
        public static AnimalType ReadAnimalType()
        {
            AnimalType result = AnimalType.Dingo;

            string stringValue = result.ToString();

            bool found = false;

            while (!found)
            {
                stringValue = ConsoleUtil.ReadAlphabeticValue("AnimalType");

                stringValue = ConsoleUtil.InitialUpper(stringValue);

                // If a matching enumerated value can be found...
                if (Enum.TryParse <AnimalType>(stringValue, out result))
                {
                    found = true;
                }
                else
                {
                    Console.WriteLine("Invalid animal type.");
                }
            }

            return(result);
        }
예제 #3
0
        public Animal GetAnimal(AnimalType animalType)
        {
            var ns       = typeof(AnimalType).Namespace; //or your classes namespace if different
            var typeName = ns + "." + animalType.ToString();

            return((Animal)Activator.CreateInstance(Type.GetType(typeName)));
        }
예제 #4
0
 public AnimalModel(int id, string name, AnimalType type, string description, int age, string gender)
 {
     this.Id          = id;
     this.Name        = name;
     this.Description = description;
     this.Type        = type.ToString();
     this.Age         = age;
     this.Gender      = gender;
 }
예제 #5
0
    void OnMouseDown()
    {
        Debug.Log("Animal is clicked: " + AnimalKind.ToString());
        if (ScorePrefab && !ScorePrefab.activeInHierarchy)
        {
            ScorePrefab.SetActive(true);
        }

        GameManager.instance.AddScore(AnimalKind);
        StopAllCoroutines();
        AudioSource.PlayClipAtPoint(KillClip, transform.position);
        gameObject.SetActive(false);
    }
예제 #6
0
 public static IAnimal CreateAnimal(AnimalType type, string name)
 {
     switch (type)
     {
         case AnimalType.Dog:
             return new Dog(name);
         case AnimalType.Lion:
             return new Lion(name);
         case AnimalType.Ostrich:
             return new Ostrich(name);
         default:
             throw new ArgumentException("The animal " + type.ToString() + " can not be created because is not part of our animal.");
     }
 }
예제 #7
0
        static void Main(string[] args)
        {
            AnimalType animal  = AnimalType.Dog;
            Visibility visible = Visibility.Hidden;

            // ... Use Console.WriteLine to print out heir values.
            Console.WriteLine(animal);
            Console.WriteLine(visible);
            Console.WriteLine((int)animal);
            Console.WriteLine((int)visible);
            if (AnimalType.Cat == animal)
            {
                Console.WriteLine("Tak");
            }
            animal = (AnimalType)10;
            Console.WriteLine(animal.ToString());
        }
예제 #8
0
        private string AddAnimal(AnimalType type, string id)
        {
            Console.Write("name: ");
            var name = Console.ReadLine();

            Console.Write("gender(male/female): ");

            GenderType gender = (GenderType)Enum.Parse(typeof(GenderType), Console.ReadLine().ToLower());

            Animal x = null;//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Implement fill info method for each animal

            if (type == AnimalType.Dog)
            {
                Console.Write("age: ");
                int age = int.Parse(Console.ReadLine());
                Console.Write("breed: ");
                string breed = Console.ReadLine();
                x = new Dog(name, gender, age, breed);
            }
            else if (type == AnimalType.Cat)
            {
                Console.Write("age: ");
                int age = int.Parse(Console.ReadLine());
                x = new Cat(name, gender, age);
            }
            else if (type == AnimalType.Hamster)
            {
                x = new Hamster(name, gender);
            }


            DataBaseForOwners.data[id].AddPet(x);
            Owner y = DataBaseForOwners.data[id];



            return(string.Format(AnimalAddedSuccessfully, type.ToString(), name, x.ID, y.FirstName, y.ID));
        }
예제 #9
0
 public override void Introduce()
 {
     base.Introduce();
     Console.WriteLine("And im wild " + AnimalType.ToString() + " because im wild animal; my name is " + Name);
 }
예제 #10
0
    public void BeginModifyingAnimal()
    {
        suppressUpdateRules = true;
//		// commented Debug.Log("modifying;"+button.gameObject.name);
        if (!LevelBuilder.inst.currentPiece || !LevelBuilder.inst.currentPiece.GetComponentInChildren <Animal>())
        {
            // commented Debug.LogError("No animal selected during animal rules dialogue begin");
            return;
        }

        preference.options.Clear();
        int i             = 0;
        int selectedIndex = -1;

        SetCurrentAnimalType(LevelBuilder.inst.currentPiece.GetComponentInChildren <Animal>().type);
        bool cannibalism = false;

        optsList.Clear();
        optsListWithSpaces.Clear();
//		string debug_optslist = "";

        foreach (AnimalTargetPreference atp in AnimalType.GetValues(typeof(AnimalTargetPreference)))
        {
            string val = atp.ToString();
            optsList.Add(val);
//			debug_optslist += val;
            val = Utils.AddSpacesToSentence(val);
            optsListWithSpaces.Add(val);

            foreach (AnimalTargetPreferenceRel atpr in AnimalBehaviorManager.inst.preferences)
            {
                if (atpr.type == currentAnimalType && atpr.preference == atp)
                {
                    cannibalism = atpr.cannibalize;
                    if (atpr.preferenceInt.ToString().Length > 0)
                    {
                        preferenceInt.text = atpr.preferenceInt.ToString();                                                               // This line causes OnValueChanged to fire on Preference Int, which we want to suppress.
                    }
                    // Suppress by boolean!
//					// commented Debug.Log("atpr int;"+atpr.preferenceInt+", for:"+atpr.type);
                    selectedIndex = i;
//					selectedPreference = atpr;
//					// commented Debug.Log("?");
                }
                else
                {
//					// commented Debug.Log("atpr type:"+atpr.type.ToString()+", curantype;"+currentAnimalType+",pref:"+atpr.preference+", atp"+atp.ToString());
                }
            }
//			// commented Debug.Log("val;"+val);
            i++;
        }

//		// commented Debug.Log("Finished optslits for:"+button.levelPiecePrefab.name+": list: "+debug_optslist);
        preference.AddOptions(optsListWithSpaces);
        preference.value = selectedIndex;
        SetPreferenceIntActive();
//		// commented Debug.Log("set int:"+preferenceInt.text);
        if (sliderToggle.GetSliderValue() != cannibalism)
        {
            sliderToggle.ToggleSlider();
        }


        animalName.text = currentAnimalType.ToString();
        foreach (Transform t in animalImages)
        {
            t.GetComponent <Image>().sprite = LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>().icon;
        }


//		// commented Debug.Log("finished;"+button.gameObject.name);
//		// commented Debug.Log(" updating rules from enabled");
        suppressUpdateRules = false;
        UpdateRules();
    }
        public string AnimalCount(AnimalType animalType)
        {
            if (animals == null)
            {
                // connect to db and fetch the records
                //animals = Database.Data.AnimalDictionary();
                animals = Database.Data.Animals;
            }

            //return $"There are a total of: {animals[animalType].Count()} {animalType.ToString()}";
            return($"There are a total of: {animals.Where(Database.Data.GetAnimalByTypeFunc(animalType)).Count()} {animalType.ToString()}");
        }
예제 #12
0
 public static Func <Animal, bool> GetAnimalByTypeFunc(AnimalType animalType)
 {
     return(x => x.GetType().Name.Equals(animalType.ToString(), StringComparison.InvariantCultureIgnoreCase));
 }