Inheritance: MonoBehaviour
        protected override void AddObjectToFarm(string[] inputCommands)
        {
            string type = inputCommands[1];
            string id = inputCommands[2];

            switch (type)
            {
                case "Grain":
                    var food = new Food(id, ProductType.Grain, FoodType.Organic, 10, 2);
                    this.farm.AddProduct(food);
                    break;
                case "CherryTree":
                    var cherryTree = new CherryTree(id);
                    this.farm.Plants.Add(cherryTree);
                    break;
                case "TobaccoPlant":
                    var tobaccoPlant = new TobaccoPlant(id);
                    this.farm.Plants.Add(tobaccoPlant);
                    break;
                case "Cow":
                    var cow = new Cow(id);
                    this.farm.Animals.Add(cow);
                    break;
                case "Swine":
                    var swine = new Swine(id);
                    this.farm.Animals.Add(swine);
                    break;
                default:
                    break;
            }
        }
 static void Main()
 {
     Animal A;
     //A=new Animal();
     A = new Dog(); A.Sound();
     A = new Cow(); A.Sound();
     A = new Cat(); A.Sound();
 }
Esempio n. 3
0
 public void removeCow(Cow c)
 {
     for (int i = 0; i <m_catched_array.Count; i++) {
         Cow lCow = (Cow)m_catched_array [i];
         if(lCow.getId()==c.getId()) {
             m_catched_array.RemoveAt (i);
         }
     }
 }
Esempio n. 4
0
 public bool isCowInBeam(Cow c)
 {
     for (int i = 0; i <m_catched_array.Count; i++) {
         Cow lCow = (Cow)m_catched_array [i];
         if(lCow.getId()==c.getId()) {
             return true;
         }
     }
     return false;
 }
Esempio n. 5
0
        public void AddThingWithAnyAnimal()
        {
            var cow = new Cow {Name = "Bessie"};
             var thing = new ThingWithAnyAnimal { Name = "Thing 1", Pet = cow};

             using (ISession session = GetSession())
             {
            session.SaveOrUpdate(thing);

            session.Flush();
             }
        }
 void OnTriggerEnter2D(Collider2D other)
 {
     Cow cow = other.GetComponent<Cow> ();
     if (isBorderTop) {
         if (cow!=null && !cow.getIsUFOCatched() && parent.isCowInBeam(cow)) {
             liftCow = cow;
             liftCow.setCowState(CowState.Lifted);
             //Debug.Log ("Lifted");
             liftCow.hideAndFreeze();
             //particuleCaptureFeedback.SetActive(true);
             Invoke("releaseCow",1);
         }
     }
 }
 // Executes when the user navigates to this page.
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     Cow cow = null;
     if (MainPage.mobs != null && MainPage.mobs.mob_pool != null)
     {
         foreach (Mob m in MainPage.mobs.mob_pool) if (m is Cow) cow = (Cow)m;
     }
     if (cow == null) cow = new Cow();
     LayoutRoot.DataContext = cow;
        // Cow cow2 = new Cow();
        // cow2.condition_groups = new ObservableCollection<Condition_group>();
       //  test.ItemsSource = cow2.condition_groups;
     //if (MainPage.mobs == null) MainPage.mobs = new Models.Mobs();
        // if (MainPage.mobs.creatures == null) MainPage.mobs.creatures = new List<Mob>();
 }
Esempio n. 8
0
 private static IEnumerable<Cow> GetCows(string line, out int weightLimit)
 {
     string[] args = line.Split(' ');
     int numberOfCows = Int32.Parse(args[0]);
     weightLimit = Int32.Parse(args[1]);
     string[] weightStrs = args[2].Split(',');
     string[] milkProdStr = args[3].Split(',');
     Cow[] cows = new Cow[numberOfCows];
     for (int i = 0; i < numberOfCows; i++)
     {
         cows[i].Weight = Int32.Parse(weightStrs[i]);
         cows[i].MilkProd = Int32.Parse(milkProdStr[i]);
         cows[i].MilkProdPerKg = cows[i].MilkProd/(float)cows[i].Weight;
     }
     return cows;
 }
        protected override void AddObjectToFarm(string[] inputCommands)
        {
            string type = inputCommands[1];
            string id = inputCommands[2];

            switch (type)
            {
                case "CherryTree":
                    {
                        var cherryTree = new CherryTree(id);
                        this.farm.Plants.Add(cherryTree);
                    }

                    break;
                case "Swine":
                    {
                        var swine = new Swine(id);
                        this.farm.Animals.Add(swine);
                    }

                    break;
                case "Cow":
                    {
                        var cow = new Cow(id);
                        this.farm.Animals.Add(cow);
                    }

                    break;
                case "TobaccoPlant":
                    {
                        var tobacco = new TobaccoPlant(id);
                        this.farm.Plants.Add(tobacco);
                    }

                    break;
                default:
                    base.AddObjectToFarm(inputCommands);
                    break;
            }
        }
Esempio n. 10
0
 public static Animal ProduceAnimal(string id, string type)
 {
     switch (type)
     {
         case "Cow":
             {
                 Animal currentAnimal = new Cow(id);
                 LoadCowValues(currentAnimal);
                 return currentAnimal;
             }
         case "Swine":
             {
                 Animal currentAnimal = new Swine(id);
                 LoadSwineValues(currentAnimal);
                 return currentAnimal;
             }
         default:
             {
                 throw new NotImplementedException("Unknown animal type " + type);
             }
     }
 }
Esempio n. 11
0
        static void Main(string[] args)
        {
            Cow myCow = new Cow("Geronimo");

             IMethaneProducer<Cow> cowMethaneProducer = myCow;
             IMethaneProducer<Animal> animalMethaneProducer = cowMethaneProducer;

             IGrassMuncher<Cow> cowGrassMuncher = myCow;
             IGrassMuncher<SuperCow> superCowGrassMuncher = cowGrassMuncher;

             List<Cow> cows = new List<Cow>();
             cows.Add(myCow);
             cows.Add(new SuperCow("Tonto"));
             cows.Add(new Cow("Gerald"));
             cows.Add(new Cow("Phil"));

             cows.Sort(new AnimalNameLengthComparer());

             ListAnimals(cows);

             Console.ReadKey();
        }
Esempio n. 12
0
        private bool Spawn(PlayerLocation position, EntityType entityType, Random random)
        {
            Level world = Level;
            Mob   mob   = null;

            switch (entityType)
            {
            case EntityType.Chicken:
                mob      = new Chicken(world);
                mob.NoAi = true;
                break;

            case EntityType.Cow:
                mob      = new Cow(world);
                mob.NoAi = true;
                break;

            case EntityType.Pig:
                mob      = new Pig(world);
                mob.NoAi = true;
                break;

            case EntityType.Sheep:
                mob      = new Sheep(world, random);
                mob.NoAi = true;
                break;

            case EntityType.Wolf:
                mob      = new Wolf(world);
                mob.NoAi = true;
                break;

            case EntityType.Horse:
                mob        = new Horse(world, random.NextDouble() < 0.10, random);
                mob.IsBaby = random.NextDouble() < 0.20;
                mob.NoAi   = true;
                break;

            case EntityType.Ocelot:
                mob      = new Ocelot(world);
                mob.NoAi = true;
                break;

            case EntityType.Rabbit:
                mob      = new Rabbit(world);
                mob.NoAi = true;
                break;

            case EntityType.Spider:
                mob      = new Spider(world);
                mob.NoAi = true;
                break;

            case EntityType.Zombie:
                mob        = new Zombie(world);
                mob.IsBaby = random.NextDouble() < 0.05;
                mob.NoAi   = true;
                break;

            case EntityType.Skeleton:
                mob      = new Skeleton(world);
                mob.NoAi = true;
                break;

            case EntityType.Enderman:
                mob      = new Enderman(world);
                mob.NoAi = true;
                break;

            case EntityType.Creeper:
                mob      = new Creeper(world);
                mob.NoAi = true;
                break;
            }

            if (mob == null)
            {
                return(false);
            }

            mob.DespawnIfNotSeenPlayer = true;
            mob.KnownPosition          = position;
            var bbox = mob.GetBoundingBox();

            if (!SpawnAreaClear(bbox))
            {
                return(false);
            }

            ThreadPool.QueueUserWorkItem(state => mob.SpawnEntity());

            if (Log.IsDebugEnabled)
            {
                Log.Debug($"Spawn mob {entityType}");
            }
            return(true);
        }
Esempio n. 13
0
 public void addToList(Cow cow)
 {
     _place.Add(cow);
 }
Esempio n. 14
0
		public override void PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
		{
			Log.WarnFormat("Player {0} trying to spawn Mob #{1}.", player.Username, Metadata);

			var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face);

			Mob mob = null;

			EntityType type = (EntityType) Metadata;
			switch (type)
			{
				case EntityType.Chicken:
					mob = new Chicken(world);
					break;
				case EntityType.Cow:
					mob = new Cow(world);
					break;
				case EntityType.Pig:
					mob = new Pig(world);
					break;
				case EntityType.Sheep:
					mob = new Sheep(world);
					break;
				case EntityType.Wolf:
					mob = new Wolf(world) {Owner = player};
					break;
				case EntityType.Villager:
					mob = new Villager(world);
					break;
				case EntityType.MushroomCow:
					mob = new MushroomCow(world);
					break;
				case EntityType.Squid:
					mob = new Squid(world);
					break;
				case EntityType.Rabbit:
					mob = new Rabbit(world);
					break;
				case EntityType.Bat:
					mob = new Bat(world);
					break;
				case EntityType.IronGolem:
					mob = new IronGolem(world);
					break;
				case EntityType.SnowGolem:
					mob = new SnowGolem(world);
					break;
				case EntityType.Ocelot:
					mob = new Ocelot(world);
					break;
				case EntityType.Zombie:
					mob = new Zombie(world);
					break;
				case EntityType.Creeper:
					mob = new Creeper(world);
					break;
				case EntityType.Skeleton:
					mob = new Skeleton(world);
					break;
				case EntityType.Spider:
					mob = new Spider(world);
					break;
				case EntityType.ZombiePigman:
					mob = new ZombiePigman(world);
					break;
				case EntityType.Slime:
					mob = new Slime(world);
					break;
				case EntityType.Enderman:
					mob = new Enderman(world);
					break;
				case EntityType.Silverfish:
					mob = new Silverfish(world);
					break;
				case EntityType.CaveSpider:
					mob = new CaveSpider(world);
					break;
				case EntityType.Ghast:
					mob = new Ghast(world);
					break;
				case EntityType.MagmaCube:
					mob = new MagmaCube(world);
					break;
				case EntityType.Blaze:
					mob = new Blaze(world);
					break;
				case EntityType.ZombieVillager:
					mob = new ZombieVillager(world);
					break;
				case EntityType.Witch:
					mob = new Witch(world);
					break;
				case EntityType.Stray:
					mob = new Stray(world);
					break;
				case EntityType.Husk:
					mob = new Husk(world);
					break;
				case EntityType.WitherSkeleton:
					mob = new WitherSkeleton(world);
					break;
				case EntityType.Guardian:
					mob = new Guardian(world);
					break;
				case EntityType.ElderGuardian:
					mob = new ElderGuardian(world);
					break;
				case EntityType.Horse:
					mob = new Horse(world);
					break;
				case EntityType.PolarBear:
					mob = new PolarBear(world);
					break;
				case EntityType.Shulker:
					mob = new Shulker(world);
					break;
				case EntityType.Dragon:
					mob = new Dragon(world);
					break;
				case EntityType.SkeletonHorse:
					mob = new SkeletonHorse(world);
					break;
				case EntityType.Wither:
					mob = new Wither(world);
					break;
				case EntityType.Evoker:
					mob = new Evoker(world);
					break;
				case EntityType.Vindicator:
					mob = new Vindicator(world);
					break;
				case EntityType.Vex:
					mob = new Vex(world);
					break;
				case EntityType.Npc:
					mob = new PlayerMob("test", world);
					break;
			}

			if (mob == null) return;

			mob.KnownPosition = new PlayerLocation(coordinates.X, coordinates.Y, coordinates.Z);
			mob.SpawnEntity();

			Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata);
		}
Esempio n. 15
0
 public void Enter(Cow cow)
 {
     _cow = cow;
     _cow.isAwakenState = true;
 }
Esempio n. 16
0
        //public void Pet(Player player, string type)
        public void Pet(Player player, string type, params string[] name)
        {
            //TODO: Fix space in pets name, too difficult damn..

            PetTypes petType;

            try
            {
                petType = (PetTypes)Enum.Parse(typeof(PetTypes), type, true);
            }
            catch (ArgumentException e)
            {
                return;
            }

            if (!Enum.IsDefined(typeof(PetTypes), petType))
            {
                player.SendMessage("No pet found");
                return;
            }


            double height = 0.5;

            switch (petType)
            {
            case PetTypes.Chicken:
                height = new Chicken(null).Height;
                break;

            case PetTypes.Cow:
                height = new Cow(null).Height;
                break;

            case PetTypes.Pig:
                height = new Pig(null).Height;
                break;

            case PetTypes.Sheep:
                height = new Sheep(null).Height;
                break;

            case PetTypes.Wolf:
                height = new Wolf(null).Height;
                break;

            case PetTypes.Npc:
                break;

            case PetTypes.Mooshroom:
                break;

            case PetTypes.Squid:
                break;

            case PetTypes.Rabbit:
                break;

            case PetTypes.Bat:
                break;

            case PetTypes.IronGolem:
                break;

            case PetTypes.SnowGolem:
                break;

            case PetTypes.Ocelot:
                break;

            case PetTypes.Zombie:
                break;

            case PetTypes.Creeper:
                break;

            case PetTypes.ZombiePigman:
                break;

            case PetTypes.Enderman:
                break;

            case PetTypes.Blaze:
                break;

            case PetTypes.ZombieVillager:
                break;

            case PetTypes.Witch:
                break;
            }

            string petName = null;

            if (name.Length > 0)
            {
                petName = string.Join(" ", name);
            }

            var entities = player.Level.GetEntites();

            foreach (var entity in entities)
            {
                Pet pet = entity as Pet;
                if (pet != null && pet.Owner == player)
                {
                    pet.HealthManager.Kill();
                    break;
                }
            }

            Pet newPet = new Pet(player, player.Level, (int)petType)
            {
                NameTag = petName, KnownPosition = (PlayerLocation)player.KnownPosition.Clone(),
                Height  = height,
            };

            newPet.SpawnEntity();
        }
Esempio n. 17
0
        public virtual void Fill_OnTarget(Mobile from, object targ)
        {
            if (!IsEmpty || !Fillable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (bev.IsEmpty || !bev.ValidateUse(from, true))
                {
                    return;
                }

                this.Content  = bev.Content;
                this.Poison   = bev.Poison;
                this.Poisoner = bev.Poisoner;

                if (bev.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    bev.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += bev.Quantity;
                    bev.Quantity   = 0;
                }
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Quantity == 0 || (Content == BeverageType.Water && !IsFull))
                {
                    int iNeed = Math.Min((MaxQuantity - Quantity), bwc.Quantity);

                    if (iNeed > 0 && !bwc.IsEmpty && !IsFull)
                    {
                        bwc.Quantity -= iNeed;
                        Quantity     += iNeed;
                        Content       = BeverageType.Water;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is Item)
            {
                Item         item = (Item)targ;
                IWaterSource src;

                src = (item as IWaterSource);

                if (src == null && item is AddonComponent)
                {
                    src = (((AddonComponent)item).Addon as IWaterSource);
                }

                if (src == null || src.Quantity <= 0)
                {
                    return;
                }

                if (from.Map != item.Map || !from.InRange(item.GetWorldLocation(), 2) || !from.InLOS(item))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045);   // I can't reach that.
                    return;
                }

                this.Content  = BeverageType.Water;
                this.Poison   = null;
                this.Poisoner = null;

                if (src.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    src.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += src.Quantity;
                    src.Quantity   = 0;
                }

                from.SendLocalizedMessage(1010089);   // You fill the container with water.
            }
            else if (targ is Cow)
            {
                Cow cow = (Cow)targ;

                if (cow.TryMilk(from))
                {
                    Content  = BeverageType.Milk;
                    Quantity = MaxQuantity;
                    from.SendLocalizedMessage(1080197);   // You fill the container with milk.
                }
            }
        }
Esempio n. 18
0
 public static void Moo(this Cow _this)
 {
     _this.numMoos++;
     Console.WriteLine("Mooo " + _this.numMoos);
 }
Esempio n. 19
0
    // Update is called once per frame
    void Update()
    {
        // Health Regeneration Calculation
        startRegen += Time.deltaTime;
        if (startRegen > 5)
        {
            regen = true;
        }
        if (regen == true)
        {
            regentimer += Time.deltaTime;
            if (regentimer > 5)
            {
                regentimer      = 0;
                CurrentStamina += 1;
            }
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            selling = true;
        }

        if (CurrentStamina > MaxStamina)
        {
            CurrentStamina = MaxStamina;
        }

        if (selling == false)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;

                if (InventoryManager.equippeditem().Equals("Tomato Seed"))
                {
                    var t_seeds = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Tomato Seed");
                    if (CurrentStamina >= t_seeds.cost)
                    {
                        RaycastHit hitinfo;
                        if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Crops")))
                        {
                            CropTileClass CropTileComponent = (CropTileClass)hitinfo.collider.gameObject.GetComponent("CropTileClass");
                            if (CropTileComponent != null)
                            {
                                if (CropTileComponent.plantseed(t_seeds.howmuchtowater, "Tomato"))
                                {
                                    if (t_seeds.minustool() == false)
                                    {
                                        InventoryManager.removetool();
                                    }
                                    CurrentStamina -= t_seeds.cost;
                                    regen           = false;
                                    regentimer      = 0;
                                    startRegen      = 0;
                                }
                            }
                        }
                    }
                }

                else if (InventoryManager.equippeditem().Equals("Corn Seed"))
                {
                    var c_seeds = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Corn Seed");
                    if (CurrentStamina >= c_seeds.cost)
                    {
                        RaycastHit hitinfo;
                        if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Crops")))
                        {
                            CropTileClass CropTileComponent = (CropTileClass)hitinfo.collider.gameObject.GetComponent("CropTileClass");
                            if (CropTileComponent != null)
                            {
                                if (CropTileComponent.plantseed(c_seeds.howmuchtowater, "Corn"))
                                {
                                    if (c_seeds.minustool() == false)
                                    {
                                        InventoryManager.removetool();
                                    }
                                    CurrentStamina -= c_seeds.cost;
                                    regen           = false;
                                    regentimer      = 0;
                                    startRegen      = 0;
                                }
                            }
                        }
                    }
                }

                else if (InventoryManager.equippeditem().Equals("Waterbucket"))
                {
                    var waterbucket = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Waterbucket");
                    if (CurrentStamina >= waterbucket.cost)
                    {
                        RaycastHit hitinfo;
                        if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Crops")))
                        {
                            CropTileClass CropTileComponent = (CropTileClass)hitinfo.collider.gameObject.GetComponent("CropTileClass");
                            if (CropTileComponent != null)
                            {
                                CropTileComponent.watercrop();
                                CurrentStamina -= waterbucket.cost;
                                regen           = false;
                                regentimer      = 0;
                                startRegen      = 0;
                            }
                        }
                    }
                }

                else if (InventoryManager.equippeditem().Equals("Waterbucket Lvl 2"))
                {
                    var waterbucket2 = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Waterbucket Lvl 2");
                    if (CurrentStamina >= waterbucket2.cost)
                    {
                        RaycastHit hitinfo;
                        if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Crops")))
                        {
                            CropTileClass CropTileComponent = (CropTileClass)hitinfo.collider.gameObject.GetComponent("CropTileClass");
                            if (CropTileComponent != null)
                            {
                                CropTileComponent.watercrop();
                                CurrentStamina -= waterbucket2.cost;
                                regen           = false;
                                regentimer      = 0;
                                startRegen      = 0;
                            }
                        }
                    }
                }


                else if (InventoryManager.equippeditem().Equals("Hoe"))
                {
                    var hoe = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Hoe");
                    if (CurrentStamina >= hoe.cost)
                    {
                        RaycastHit hitinfo;
                        if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Crops")))
                        {
                            CropTileClass CropTileComponent = (CropTileClass)hitinfo.collider.gameObject.GetComponent("CropTileClass");
                            if (CropTileComponent != null)
                            {
                                CropTileComponent.tillcrop();
                                CurrentStamina -= hoe.cost;
                                regen           = false;
                                regentimer      = 0;
                                startRegen      = 0;
                            }
                        }
                    }
                }

                else if (InventoryManager.equippeditem().Equals("Hoe Lvl 2"))
                {
                    var hoe2 = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Hoe Lvl 2");
                    if (CurrentStamina >= hoe2.cost)
                    {
                        RaycastHit hitinfo;
                        if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Crops")))
                        {
                            CropTileClass CropTileComponent = (CropTileClass)hitinfo.collider.gameObject.GetComponent("CropTileClass");
                            if (CropTileComponent != null)
                            {
                                CropTileComponent.tillcrop();
                                CurrentStamina -= hoe2.cost;
                                regen           = false;
                                regentimer      = 0;
                                startRegen      = 0;
                            }
                        }
                    }
                }
                else if (InventoryManager.equippeditem().Equals("Hands"))
                {
                    RaycastHit hitinfo;             //TO HARVEST CROPS
                    if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Crops")))
                    {
                        CropTileClass CropTileComponent = (CropTileClass)hitinfo.collider.gameObject.GetComponent("CropTileClass");
                        if (CropTileComponent != null)
                        {
                            CropTileComponent.harvestcrop();
                            var takecrop = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == CropTileComponent.cropname);
                            //if(InventoryManager.Inventory.Find(Toolmanager => (Toolmanager.Tooltype == CropTileComponent.cropname)) != new Toolmanager("0", 0, 0, 0, 0))
                            Debug.Log("inside if statement");
                            takecrop.addtool();
                            Debug.Log(takecrop.Tooltype);
                        }
                    }             //TO PICK UP FLOWERS
                    else if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Flowers")))
                    {
                        var flower = InventoryManager.Inventory.Find(Toolmanager => (Toolmanager.Tooltype == "Flower"));
                        flower.addtool();
                        FlowerManager myFlower = (FlowerManager)hitinfo.collider.gameObject.GetComponent("FlowerManager");
                        myFlower.DestroyFlower();
                    }

                    else if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Egg")))
                    {
                        Egg pickedEgg = (Egg)hitinfo.collider.gameObject.GetComponent("Egg");
                        pickedEgg.destroyegg();
                        var egg = InventoryManager.Inventory.Find(Toolmanager => (Toolmanager.Tooltype == "Egg"));
                        egg.addtool();
                        //InventoryManager.Inventory.Add(new Toolmanager("Egg", 0, 0, 1, 0));
                    }
                }
                else if (InventoryManager.equippeditem().Equals("Tomato"))
                {
                    var tomato = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Tomato");
                    tomato.minustool();
                    Debug.Log("EATING A TOMATO");
                    CurrentStamina += 50;
                }

                else if (InventoryManager.equippeditem().Equals("Feed"))
                {
                    RaycastHit hitinfo;
                    var        feed = InventoryManager.Inventory.Find(Toolmanager => Toolmanager.Tooltype == "Feed");
                    if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Chicken")))
                    {
                        Debug.Log("Hit chicken");
                        Chicken chickenComponent = (Chicken)hitinfo.collider.gameObject.GetComponent("Chicken");
                        chickenComponent.feed();
                        if (feed.minustool() == false)
                        {
                            InventoryManager.removetool();
                        }
                    }
                    else if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Cow")))
                    {
                        Debug.Log("Hit Cow");
                        Cow cowComponent = (Cow)hitinfo.collider.gameObject.GetComponent("Cow");
                        cowComponent.feed();
                        if (feed.minustool() == false)
                        {
                            InventoryManager.removetool();
                        }
                    }
                }

                if (InventoryManager.equippeditem().Equals("Milker"))
                {
                    RaycastHit hitinfo;
                    if (Physics.Raycast(this.transform.position, this.transform.forward, out hitinfo, this.Interactdistance, 1 << LayerMask.NameToLayer("Cow")))
                    {
                        Cow cowComponent = (Cow)hitinfo.collider.gameObject.GetComponent("Cow");
                        int milkNum      = cowComponent.milk();
                        var milk         = InventoryManager.Inventory.Find(Toolmanager => (Toolmanager.Tooltype == "Milk"));
                        while (milkNum > 0)
                        {
                            milk.addtool();
                            milkNum--;
                        }
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.RightArrow))      //cycle through inventory
            {
                InventoryManager.equipnextitem();
                this.updateVisibleTool();
            }
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                InventoryManager.equippreviousitem();
                this.updateVisibleTool();
            }
        }
    }
 static void Main()
 {
     Cat cat = new Cat(4, "Black", true, "White");
     Tiger tiger = new Tiger(4, "Black", true, "Yellow");
     Cow cow = new Cow(4, "Black", true, "Black");
 }
Esempio n. 21
0
        private bool SpawnPassive(PlayerLocation position, EntityType entityType)
        {
            Level world = Level;
            Mob   mob   = null;

            switch (entityType)
            {
            case EntityType.Chicken:
                mob      = new Chicken(world);
                mob.NoAi = true;
                break;

            case EntityType.Cow:
                mob      = new Cow(world);
                mob.NoAi = true;
                break;

            case EntityType.Pig:
                mob      = new Pig(world);
                mob.NoAi = true;
                break;

            case EntityType.Sheep:
                mob      = new Sheep(world);
                mob.NoAi = true;
                break;

            case EntityType.Wolf:
                mob      = new Wolf(world);
                mob.NoAi = true;
                break;

            case EntityType.Horse:
                mob      = new Horse(world);
                mob.NoAi = true;
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;
            }

            if (mob == null)
            {
                return(false);
            }

            mob.DespawnIfNotSeenPlayer = true;
            mob.KnownPosition          = position;
            var bbox = mob.GetBoundingBox();

            if (!SpawnAreaClear(bbox))
            {
                return(false);
            }


            mob.SpawnEntity();


            if (Log.IsDebugEnabled)
            {
                Log.Warn($"Spawn friendly {entityType}");
            }
            return(true);
        }
Esempio n. 22
0
 private ShimSham Create(Cow toWrap, bool fuzzy)
 {
     return(new ShimSham(new object[] { toWrap }, toWrap.GetType(), fuzzy));
 }
Esempio n. 23
0
 protected StatusBar(CowGameScreen cowGameScreen, Cow cow)
 {
     _cowGameScreen = cowGameScreen;
     _cow           = cow;
 }
Esempio n. 24
0
        static void Main(string[] args)
        {
            //
            // OLD MACDONALD
            //
            Console.WriteLine("Old MacDonald had a farm ee ay ee ay oh");

            // Let's try singing about a Farm Animal
            FarmAnimal animal = new Horse();
            FarmAnimal bird   = new Duck();
            FarmAnimal cow1   = new Cow("Bessie");
            FarmAnimal cow2   = new Cow("Angus");
            // Can we swap out any animal in place here?
            List <FarmAnimal> farmAnimals = new List <FarmAnimal>();

            farmAnimals.Add(animal);
            farmAnimals.Add(bird);
            farmAnimals.Add(cow1);
            farmAnimals.Add(cow2);
            Cat felix = new Cat();

            farmAnimals.Add(felix);
            felix.ToggleSleeping();
            animal.ToggleSleeping();
            bird.ToggleSleeping();

            foreach (FarmAnimal critter in farmAnimals)
            {
                if (critter.GetType() == typeof(Duck))
                {
                    Console.WriteLine(((Duck)critter).WhatSeason());
                }

                Console.WriteLine("And on his farm there was a " + critter.Name + " ee ay ee ay oh");
                Console.WriteLine("With a " + critter.MakeSoundTwice() + " here and a " + critter.MakeSoundTwice() + " there");
                Console.WriteLine("Here a " + critter.MakeSoundOnce() + ", there a " + critter.MakeSoundOnce() + " everywhere a " + critter.MakeSoundTwice());
                Console.WriteLine("Old Macdonald had a farm, ee ay ee ay oh");
                Console.WriteLine();
                Console.WriteLine($"{critter.Name} is eating by {critter.Eat()}");
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine("Old MacDonald had a farm ee ay ee ay oh: Interfaces");

            // What if we wanted to sing about other things on the farm that were
            // singable but not farm animals?
            // Can it be done?
            Tractor          tractor   = new Tractor();
            List <ISingable> singables = new List <ISingable>();

            singables.Add(tractor);
            singables.AddRange(farmAnimals);
            Apple apple = new Apple("Red Delicious");

            singables.Add(apple);
            foreach (ISingable tunefull in singables)
            {
                Console.WriteLine("And on his farm there was a " + tunefull.Name + " ee ay ee ay oh");
                Console.WriteLine("With a " + tunefull.MakeSoundTwice() + " here and a " + tunefull.MakeSoundTwice() + " there");
                Console.WriteLine("Here a " + tunefull.MakeSoundOnce() + ", there a " + tunefull.MakeSoundOnce() + " everywhere a " + tunefull.MakeSoundTwice());
                Console.WriteLine("Old Macdonald had a farm, ee ay ee ay oh");
                Console.WriteLine();
            }

            Console.WriteLine(apple);
            ISellable gd = new Apple("Golden Delicious");

            Console.WriteLine(gd);
            Console.WriteLine(((Duck)bird).GetSalesPrice());
            Console.WriteLine(((Duck)bird).WhatSeason());
            Console.ReadLine();
        }
Esempio n. 25
0
        private Cow WrapCowItem(DataRow cowRow)
        {
            Cow cowItem = new Cow();

            if (cowRow != null)
            {
                cowItem.EarNum        = Convert.ToInt32(cowRow["EarNum"]);
                cowItem.DisplayEarNum = cowRow["DisplayEarNum"].ToString();
                cowItem.GroupID       = Convert.ToInt32(cowRow["GroupID"]);
                cowItem.GroupName     = cowRow["GroupName"].ToString();
                if (cowRow["HouseID"] != DBNull.Value)
                {
                    cowItem.HouseID = Convert.ToInt32(cowRow["HouseID"]);
                }
                else
                {
                    cowItem.HouseID = 0; //表示无牛舍?
                }

                cowItem.Gender    = cowRow["Gender"].ToString();
                cowItem.FarmCode  = Convert.ToInt32(cowRow["FarmID"]);
                cowItem.BirthDate = Convert.ToDateTime(cowRow["BirthDate"]);
                DateTime dtNow = DateTime.Now;
                //cowItem.AgeMonth = (dtNow.Year - cowItem.BirthDate.Year) * 12 + (dtNow.Month - cowItem.BirthDate.Month);

                if (cowRow["BirthWeight"] != null && !string.IsNullOrWhiteSpace(cowRow["BirthWeight"].ToString()))
                {
                    cowItem.BirthWeight = float.Parse(cowRow["BirthWeight"].ToString());
                }
                if (cowRow["Color"] != DBNull.Value)
                {
                    cowItem.Color = cowRow["Color"].ToString();
                }
                else
                {
                    cowItem.Color = String.Empty;
                }

                //经产牛和青年牛才有繁殖状态,从繁殖相关事件表可以得出,初始买的牛必须输入
                if (cowRow["Status"] != DBNull.Value)
                {
                    cowItem.Status = GetCowStatus(Convert.ToInt32(cowRow["Status"]));
                }
                else
                {
                    cowItem.Status = String.Empty;
                }
                int ill = Convert.ToInt32(cowRow["IsIll"]);
                if (ill == 0)
                {
                    cowItem.IsIll = false;
                }
                else
                {
                    cowItem.IsIll = true;
                }

                if (cowRow["FatherID"] != DBNull.Value)
                {
                    cowItem.FatherID = cowRow["FatherID"].ToString();
                }
                else
                {
                    cowItem.FatherID = String.Empty;
                }
                if (cowRow["MotherID"] != DBNull.Value)
                {
                    cowItem.MotherID = cowRow["MotherID"].ToString();
                }
                else
                {
                    cowItem.MotherID = String.Empty;
                }
                cowItem.IsStray = Convert.ToInt32(cowRow["IsStray"]) == 0 ? false : true;
                //----------------------Modify By LJW-------------------//
                if (cowRow["PedometerID"] != DBNull.Value)
                {
                    cowItem.Pedometer = Convert.ToInt32(cowRow["PedometerID"]);
                }
                //----------------------Modify By LJW-------------------//
            }
            return(cowItem);
        }
 public static bool TryParse(string s, out Cow cow)
 {
     cow = null;
     Console.WriteLine("TryParse is called!");
     return(false);
 }
Esempio n. 27
0
        static void Main(string[] args)
        {
            //
            // OLD MACDONALD
            //
            Console.WriteLine("Farm Animals");
            Console.WriteLine("Old MacDonald had a farm ee ay ee ay oh");

            // Let's try singing about a Farm Animal
            Horse   horse = new Horse();
            Duck    duck  = new Duck();
            Chicken tyson = new Chicken();

            List <FarmAnimal> animals = new List <FarmAnimal>();

            animals.Add(horse);
            animals.Add(duck);
            animals.Add(new Chicken());
            animals.Add(new Horse());

            // Can we swap out any animal in place here?
            // Polymorphis through inheritance

            foreach (FarmAnimal animal in animals)
            {
                Console.WriteLine("And on his farm there was a " + animal.Name + " ee ay ee ay oh");
                Console.WriteLine("With a " + animal.MakeSoundTwice() + " here and a " + animal.MakeSoundTwice() + " there");
                Console.WriteLine("Here a " + animal.MakeSoundOnce() + ", there a " + animal.MakeSoundOnce() + " everywhere a " + animal.MakeSoundTwice());
                Console.WriteLine("Old Macdonald had a farm, ee ay ee ay oh");
                Console.WriteLine();
            }


            // What if we wanted to sing about other things on the farm that were
            // singable but not farm animals?
            // Can it be done?
            // Polymorphism through interface

            List <ISingable> singables = new List <ISingable>();

            singables.Add(horse);
            singables.Add(duck);

            Tractor tractor = new Tractor();

            singables.Add(tractor);
            Cow bessie = new Cow();

            singables.Add(bessie);
            singables.Add(tyson);
            Pitchfork pitchfork = new Pitchfork();

            singables.Add(pitchfork);

            Console.WriteLine();
            Console.WriteLine("Singables");
            Console.WriteLine("Old MacDonald had a farm ee ay ee ay oh");

            foreach (ISingable singable in singables)
            {
                Console.WriteLine("And on his farm there was a " + singable.Name + " ee ay ee ay oh");
                Console.WriteLine("With a " + singable.MakeSoundTwice() + " here and a " + singable.MakeSoundTwice() + " there");
                Console.WriteLine("Here a " + singable.MakeSoundOnce() + ", there a " + singable.MakeSoundOnce() + " everywhere a " + singable.MakeSoundTwice());
                Console.WriteLine("Old Macdonald had a farm, ee ay ee ay oh");
                Console.WriteLine();
            }

            List <ISellable> sellables = new List <ISellable>();

            sellables.Add(tyson);
            sellables.Add(pitchfork);
            foreach (ISellable sellable in sellables)
            {
                Console.WriteLine(sellable);
            }


            Console.ReadLine();
        }
Esempio n. 28
0
        public void CowCanEatWhatFood()
        {
            Cow cow = new Cow();

            Assert.Equal("Vegetation", cow.Food);
        }
Esempio n. 29
0
 public void Enter(Cow cow)
 {
     _cow = cow;
     _cow.isDeathState          = true;
     _cow._navMeshAgent.enabled = false;
 }
Esempio n. 30
0
 public void AddCow(Cow c)
 {
     cows.Add(c);
 }
Esempio n. 31
0
        public static Entity Create(this EntityType entityType, World world)
        {
            Entity entity = null;

            switch (entityType)
            {
            case EntityType.None:
                return(null);

            case EntityType.Chicken:
                entity = new Chicken(world);
                break;

            case EntityType.Cow:
                entity = new Cow(world);
                break;

            case EntityType.Pig:
                entity = new Pig(world);
                break;

            case EntityType.Sheep:
                entity = new Sheep(world);
                break;

            case EntityType.Wolf:
                entity = new Wolf(world);
                break;

            case EntityType.Villager:
                entity = new Villager(world);
                break;

            case EntityType.MushroomCow:
                entity = new Mooshroom(world);
                break;

            case EntityType.Squid:
                entity = new Squid(world);
                break;

            case EntityType.Rabbit:
                entity = new Rabbit(world);
                break;

            case EntityType.Bat:
                entity = new Bat(world);
                break;

            case EntityType.IronGolem:
                entity = new VillagerGolem(world);
                break;

            case EntityType.SnowGolem:
                entity = new Snowman(world);
                break;

            case EntityType.Ocelot:
                entity = new Ocelot(world);
                break;

            case EntityType.Zombie:
                entity = new Zombie(world);
                break;

            case EntityType.Creeper:
                entity = new Creeper(world);
                break;

            case EntityType.Skeleton:
                entity = new Skeleton(world);
                break;

            case EntityType.Spider:
                entity = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                entity = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                entity = new Slime(world);
                break;

            case EntityType.Endermite:
                entity = new Endermite(world);
                break;

            case EntityType.Enderman:
                entity = new Enderman(world);
                break;

            case EntityType.Silverfish:
                entity = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                entity = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                entity = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                entity = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                entity = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                entity = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                entity = new Witch(world);
                break;

            case EntityType.Stray:
                entity = new Stray(world);
                break;

            case EntityType.Husk:
                entity = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                entity = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                entity = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                entity = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                entity = new Horse(world);
                break;

            case EntityType.ZombieHorse:
                entity = new ZombieHorse(world);
                break;

            case EntityType.PolarBear:
                entity = new PolarBear(world);
                break;

            case EntityType.Shulker:
                entity = new Shulker(world);
                break;

            case EntityType.EnderDragon:
                entity = new EnderDragon(world);
                break;

            case EntityType.SkeletonHorse:
                entity = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                entity = new Wither(world);
                break;

            case EntityType.Evoker:
                entity = new EvocationIllager(world);
                break;

            case EntityType.Vindicator:
                entity = new VindicationIllager(world);
                break;

            case EntityType.Vex:
                entity = new Vex(world);
                break;

            case EntityType.FallingBlock:
                entity = new EntityFallingBlock(world);
                break;

            case EntityType.ArmorStand:
                entity = new EntityArmorStand(world, null);
                break;

            case EntityType.Arrow:
                entity = new ArrowEntity(world, null);
                break;

            case EntityType.Item:
                entity = new ItemEntity(world);
                break;

            case EntityType.Mooshroom:
                entity = new Mooshroom(world);
                break;

            case EntityType.Snowball:
                entity = new SnowballEntity(world, null);
                break;

            case EntityType.ThrownEgg:
                entity = new EggEntity(world, null);

                break;

            case EntityType.Donkey:
                entity = new Donkey(world);
                break;

            case EntityType.Llama:
                entity = new Llama(world);
                break;

            case EntityType.Mule:
                entity = new Mule(world);
                break;

            case EntityType.Fox:
                entity = new Fox(world);
                break;

            case EntityType.Parrot:
                entity = new Parrot(world);
                break;

            case EntityType.Phantom:
                entity = new Phantom(world);
                break;

            case EntityType.Bee:
                entity = new Bee(world);
                break;

            case EntityType.LlamaSpit:
                entity = new LlamaSpit(world);
                break;

            case EntityType.Cat:
                entity = new Cat(world);
                break;

            case EntityType.SmallFireball:
                entity = new SmallFireball(world);
                break;

            case EntityType.Fireball:
                entity = new Fireball(world);
                break;

            case EntityType.Dolphin:
                entity = new Dolphin(world);
                break;

            case EntityType.Cod:
                entity = new Cod(world);
                break;

            case EntityType.PufferFish:
                entity = new PufferFish(world);
                break;

            case EntityType.Salmon:
                entity = new Salmon(world);
                break;

            case EntityType.TropicalFish:
                entity = new TropicalFish(world);
                break;

            case EntityType.FireworkRocket:
                entity = new FireworkRocket(world, null);
                break;

            //case EntityType.Human:
            //entity = new PlayerMob("test", world, );
            //	break;
            default:
                return(null);
            }

            return(entity);
        }
Esempio n. 32
0
        static void giggle(object sender, EventArgs e)
        {
            Cow c = sender as Cow;

            Console.WriteLine(" Giggle giggle ... we made" + c.Name + "moo!");
        }
Esempio n. 33
0
        public static Entity Create(this EntityType entityType, Level world)
        {
            Entity entity = null;

            switch (entityType)
            {
            case EntityType.None:
                return(null);

            case EntityType.Chicken:
                entity = new Chicken(world);
                break;

            case EntityType.Cow:
                entity = new Cow(world);
                break;

            case EntityType.Pig:
                entity = new Pig(world);
                break;

            case EntityType.Sheep:
                entity = new Sheep(world);
                break;

            case EntityType.Wolf:
                entity = new Wolf(world);
                break;

            case EntityType.Villager:
                entity = new Villager(world);
                break;

            case EntityType.MushroomCow:
                entity = new MushroomCow(world);
                break;

            case EntityType.Squid:
                entity = new Squid(world);
                break;

            case EntityType.Rabbit:
                entity = new Rabbit(world);
                break;

            case EntityType.Bat:
                entity = new Bat(world);
                break;

            case EntityType.IronGolem:
                entity = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                entity = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                entity = new Ocelot(world);
                break;

            case EntityType.Zombie:
                entity = new Zombie(world);
                break;

            case EntityType.Creeper:
                entity = new Creeper(world);
                break;

            case EntityType.Skeleton:
                entity = new Skeleton(world);
                break;

            case EntityType.Spider:
                entity = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                entity = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                entity = new Slime(world);
                break;

            case EntityType.Enderman:
                entity = new Enderman(world);
                break;

            case EntityType.Silverfish:
                entity = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                entity = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                entity = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                entity = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                entity = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                entity = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                entity = new Witch(world);
                break;

            case EntityType.Stray:
                entity = new Stray(world);
                break;

            case EntityType.Husk:
                entity = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                entity = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                entity = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                entity = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                var random = new Random();
                entity = new Horse(world, random.NextDouble() < 0.10, random);
                break;

            case EntityType.PolarBear:
                entity = new PolarBear(world);
                break;

            case EntityType.Shulker:
                entity = new Shulker(world);
                break;

            case EntityType.Dragon:
                entity = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                entity = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                entity = new Wither(world);
                break;

            case EntityType.Evoker:
                entity = new Evoker(world);
                break;

            case EntityType.Vindicator:
                entity = new Vindicator(world);
                break;

            case EntityType.Vex:
                entity = new Vex(world);
                break;

            case EntityType.Npc:
                entity = new PlayerMob("test", world);
                break;

            default:
                return(null);
            }

            return(entity);
        }
Esempio n. 34
0
 public void Enter(Cow cow)
 {
     _cow = cow;
     _cow.isTakeDamageState = true;
 }
Esempio n. 35
0
 public FoodBar(CowGameScreen cowGameScreen, Cow cow) : base(cowGameScreen, cow)
 {
     _drawRect = new Rectangle((int)cow.Inventory.EndPosition.X - 19, (int)cow.Inventory.EndPosition.Y - 19, 18, 18);
 }
        static void Main(string[] args)
        {
            //
            // OLD MACDONALD
            //
            List <FarmAnimal> livestock     = new List <FarmAnimal>();
            List <ISingable>  singingThings = new List <ISingable>();
            List <ISellable>  forSale       = new List <ISellable>();

            var cow     = new Cow();
            var duck    = new Duck();
            var chicken = new Josh(4.00M);
            var tractor = new Tractor();
            var apple   = new Apple();

            livestock.Add(cow);
            forSale.Add(cow);
            singingThings.Add(cow);

            livestock.Add(duck);
            forSale.Add(duck);
            singingThings.Add(duck);

            livestock.Add(chicken);
            forSale.Add(chicken);
            singingThings.Add(chicken);

            singingThings.Add(tractor);

            forSale.Add(apple);

            Console.WriteLine("Old MacDonald had a farm ee ay ee ay oh");

            foreach (FarmAnimal animal in livestock)
            {
                Console.WriteLine("And on his farm there was a " + animal.Name + " ee ay ee ay oh");
                Console.WriteLine("With a " + animal.MakeSoundTwice() + " here and a " + animal.MakeSoundTwice() + " there");
                Console.WriteLine("Here a " + animal.MakeSoundOnce() + ", there a " + animal.MakeSoundOnce() + " everywhere a " + animal.MakeSoundTwice());
                Console.WriteLine("Old Macdonald had a farm, ee ay ee ay oh");
                Console.WriteLine();

                //Cow cow = animal as Cow;
                //if (animal != null)
                //{
                //    Console.WriteLine(cow.Graze());
                //    Console.WriteLine();
                //}
            }

            // ------ NOW
            // What if we wanted to sing about other things on the farm?
            // Can it be done?
            Console.WriteLine();
            foreach (ISingable singer in singingThings)
            {
                Console.WriteLine("And on his farm there was a " + singer.Name + " ee ay ee ay oh");
                Console.WriteLine("With a " + singer.MakeSoundTwice() + " here and a " + singer.MakeSoundTwice() + " there");
                Console.WriteLine("Here a " + singer.MakeSoundOnce() + ", there a " + singer.MakeSoundOnce() + " everywhere a " + singer.MakeSoundTwice());
                Console.WriteLine("Old Macdonald had a farm, ee ay ee ay oh");
                Console.WriteLine();
            }

            Console.WriteLine();
            foreach (ISellable item in forSale)
            {
                Console.WriteLine($"Price: {item.Price.ToString("C")}");
            }
            Console.ReadLine();
        }
Esempio n. 37
0
        public void Summon(Player player, EntityTypeEnum entityType, bool noAi = true, BlockPos spawnPos = null)
        {
            EntityType petType;

            try
            {
                petType = (EntityType)Enum.Parse(typeof(EntityType), entityType.Value, true);
            }
            catch (ArgumentException e)
            {
                return;
            }

            if (!Enum.IsDefined(typeof(EntityType), petType))
            {
                player.SendMessage("No entity found");
                return;
            }

            var coordinates = player.KnownPosition;

            if (spawnPos != null)
            {
                if (spawnPos.XRelative)
                {
                    coordinates.X += spawnPos.X;
                }
                else
                {
                    coordinates.X = spawnPos.X;
                }

                if (spawnPos.YRelative)
                {
                    coordinates.Y += spawnPos.Y;
                }
                else
                {
                    coordinates.Y = spawnPos.Y;
                }

                if (spawnPos.ZRelative)
                {
                    coordinates.Z += spawnPos.Z;
                }
                else
                {
                    coordinates.Z = spawnPos.Z;
                }
            }

            var world = player.Level;

            Mob mob = null;

            EntityType type = (EntityType)(int)petType;

            switch (type)
            {
            case EntityType.Chicken:
                mob = new Chicken(world);
                break;

            case EntityType.Cow:
                mob = new Cow(world);
                break;

            case EntityType.Pig:
                mob = new Pig(world);
                break;

            case EntityType.Sheep:
                mob = new Sheep(world);
                break;

            case EntityType.Wolf:
                mob = new Wolf(world)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(world);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(world);
                break;

            case EntityType.Squid:
                mob = new Squid(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Bat:
                mob = new Bat(world);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                mob = new Slime(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                mob = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                mob = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                mob = new Witch(world);
                break;

            case EntityType.Stray:
                mob = new Stray(world);
                break;

            case EntityType.Husk:
                mob = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                mob = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                mob = new Horse(world);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(world);
                break;

            case EntityType.Shulker:
                mob = new Shulker(world);
                break;

            case EntityType.Dragon:
                mob = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                mob = new Mob(EntityType.Wither, world);
                break;

            case EntityType.Npc:
                mob = new PlayerMob("test", world);
                break;
            }

            if (mob == null)
            {
                return;
            }
            mob.NoAi = noAi;
            var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;

            mob.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw);
            mob.SpawnEntity();
        }
Esempio n. 38
0
        public virtual void Fill_OnTarget(Mobile from, object targ)
        {
            if (!IsEmpty || !Fillable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (bev.IsEmpty || !bev.ValidateUse(from, true))
                {
                    return;
                }

                Content  = bev.Content;
                Poison   = bev.Poison;
                Poisoner = bev.Poisoner;

                if (bev.Quantity > MaxQuantity)
                {
                    Quantity      = MaxQuantity;
                    bev.Quantity -= MaxQuantity;
                }
                else
                {
                    Quantity    += bev.Quantity;
                    bev.Quantity = 0;
                }
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Quantity == 0 || (Content == BeverageType.Water && !IsFull))
                {
                    Content = BeverageType.Water;

                    int iNeed = Math.Min((MaxQuantity - Quantity), bwc.Quantity);

                    if (iNeed > 0 && !bwc.IsEmpty && !IsFull)
                    {
                        bwc.Quantity -= iNeed;
                        Quantity     += iNeed;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is Item)
            {
                Item         item = (Item)targ;
                IWaterSource src;

                src = (item as IWaterSource);

                if (src == null && item is AddonComponent)
                {
                    src = (((AddonComponent)item).Addon as IWaterSource);
                }

                if (src == null || src.Quantity <= 0)
                {
                    if (item.ItemID >= 0xB41 && item.ItemID <= 0xB44)
                    {
                        Caddellite.CheckWaterSource(from, this, item);
                    }

                    return;
                }

                if (from.Map != item.Map || !from.InRange(item.GetWorldLocation(), 2) || !from.InLOS(item))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                    return;
                }

                Content  = BeverageType.Water;
                Poison   = null;
                Poisoner = null;

                if (src.Quantity > MaxQuantity)
                {
                    Quantity      = MaxQuantity;
                    src.Quantity -= MaxQuantity;
                }
                else
                {
                    Quantity    += src.Quantity;
                    src.Quantity = 0;
                }

                if (!(src is WaterContainerComponent))
                {
                    from.SendLocalizedMessage(1010089); // You fill the container with water.
                }
            }
            else if (targ is Cow)
            {
                Cow cow = (Cow)targ;

                if (cow.TryMilk(from))
                {
                    Content  = BeverageType.Milk;
                    Quantity = MaxQuantity;
                    from.SendLocalizedMessage(1080197); // You fill the container with milk.
                }
            }
            else if (targ is LandTarget)
            {
                int tileID = ((LandTarget)targ).TileID;

                PlayerMobile player = from as PlayerMobile;

                if (player != null)
                {
                    QuestSystem qs = player.Quest;

                    if (qs is WitchApprenticeQuest)
                    {
                        FindIngredientObjective obj = qs.FindObjective(typeof(FindIngredientObjective)) as FindIngredientObjective;

                        if (obj != null && !obj.Completed && obj.Ingredient == Ingredient.SwampWater)
                        {
                            bool contains = false;

                            for (int i = 0; !contains && i < m_SwampTiles.Length; i += 2)
                            {
                                contains = (tileID >= m_SwampTiles[i] && tileID <= m_SwampTiles[i + 1]);
                            }

                            if (contains)
                            {
                                Delete();

                                player.SendLocalizedMessage(1055035); // You dip the container into the disgusting swamp water, collecting enough for the Hag's vile stew.
                                obj.Complete();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 39
0
        static void Main(string[] args)
        {
            //
            // OLD MACDONALD
            //
            Cow     Bessie      = new Cow();
            Chicken RhodeIsland = new Chicken();
            // George is only a FarmAnimal unless cast
            FarmAnimal George = new Sheep("George", "Baa");
            Jersey     Jeff   = new Jersey();

            Console.WriteLine(((Sheep)George).Shear());

            RhodeIsland.LayEgg();
            List <FarmAnimal> farmAnimals = new List <FarmAnimal>();

            farmAnimals.Add(Bessie);
            farmAnimals.Add(RhodeIsland);
            farmAnimals.Add(George);
            farmAnimals.Add(Jeff);

            foreach (FarmAnimal critter in farmAnimals)
            {
                // checks to see if the current critter is of type Chicken
                // then cast critter to Chicken and LayEgg
                if (critter.GetType() == typeof(Chicken))
                {
                    ((Chicken)critter).LayEgg();
                }
                Console.WriteLine("Old MacDonald had a farm, ee ay ee ay oh!");
                Console.WriteLine("And on his farm he had a " + critter.Name + ", ee ay ee ay oh!");
                Console.WriteLine("With a " + critter.Sound + " " + critter.Sound + " here");
                Console.WriteLine("And a " + critter.Sound + " " + critter.Sound + " there");
                Console.WriteLine("Here a " + critter.Sound + " there a " + critter.Sound + " everywhere a " + critter.Sound + " " + critter.Sound);
                Console.WriteLine();
            }

            ///// Using Interfaces
            Console.WriteLine("Using Interfaces");
            Tractor JD = new Tractor();

            List <ISingable> singables = new List <ISingable>();

            singables.Add(JD);
            singables.AddRange(farmAnimals);
            foreach (ISingable singable in singables)
            {
                Console.WriteLine("Old MacDonald had a farm, ee ay ee ay oh!");
                Console.WriteLine("And on his farm he had a " + singable.Name + ", ee ay ee ay oh!");
                Console.WriteLine("With a " + singable.MakeSoundTwice() + " here");
                Console.WriteLine("And a " + singable.MakeSoundTwice() + " there");
                Console.WriteLine("Here a " + singable.Sound + " there a " + singable.Sound + " everywhere a " + singable.Sound + " " + singable.Sound);
                Console.WriteLine();
            }

            Apple            apple     = new Apple();
            List <ISellable> sellables = new List <ISellable>();

            sellables.Add(apple);
            sellables.Add(RhodeIsland);
            foreach (ISellable sellable in sellables)
            {
                Console.WriteLine(sellable);
            }

            string cowMinimum = Jeff.MinimumOffer();
        }
    /**
     * Creates a new instance of this class and places the entities in
     * it on random positions.
     */
    public Pasture()
    {
        engine = new Engine(this);

        /* The pasture is surrounded by a fence. Replace Dummy for
         * Fence when you have created that class */
        for (int i = 0; i < width; i++)
        {
            AddEntity(new Fence(), new Point(i, 0));
            AddEntity(new Fence(), new Point(i, this.height - 1));
        }
        for (int i = 1; i < height - 1; i++)
        {
            AddEntity(new Fence(), new Point(0, i));
            AddEntity(new Fence(), new Point(width - 1, i));
        }

        /*
         * Now insert the right number of different entities in the
         * pasture.
         */
        for (int i = 0; i < dummys; i++)
        {
            IEntity dummy = new Dummy(this, true);
            Point   p     = GetFreePosition(dummy);
            if (p.Valid())
            {
                AddEntity(dummy, p);
            }
        }

        for (int i = 0; i < grass; i++)
        {
            IEntity grass = new Grass(this, 1);
            Point   p     = GetFreePosition(grass);
            if (p.Valid())
            {
                AddEntity(grass, p);
            }
        }

        for (int i = 0; i < tigers; i++)
        {
            IEntity tiger = new Tiger(this, 3, 8, 16);
            Point   p     = GetFreePosition(tiger);
            if (p.Valid())
            {
                AddEntity(tiger, p);
            }
        }

        for (int i = 0; i < cows; i++)
        {
            IEntity cow = new Cow(this, 2, 9, 7);
            Point   p   = GetFreePosition(cow);
            if (p.Valid())
            {
                AddEntity(cow, p);
            }
        }


        engine.Run();
    }
Esempio n. 41
0
 public static void KillCow(Cow cow)//just parsing "Transform" would delete image, not other parts.
 {
     gm._KillCow(cow);
     //gm.StartCoroutine(gm.RespawnEnemy());
     //need theis "coroutine" for IEnumerator stuff.
 }
Esempio n. 42
0
    // Use this for initialization
    void Start()
    {
        m_catched = null;
        m_catched_array = new ArrayList ();

        GameObject beam = transform.gameObject;
        MeshFilter mesh_filter = beam.GetComponent<MeshFilter>();
        Rigidbody2D mesh_rigidBody2D = beam.GetComponent<Rigidbody2D> ();
        BoxCollider2D mesh_boxCollider2D = beam.GetComponent<BoxCollider2D> ();
        mesh_rigidBody2D.isKinematic = true;
        mesh_boxCollider2D.isTrigger = true;
        Vector2 boxColl2D_center = mesh_boxCollider2D.offset;
        boxColl2D_center = new Vector2 (0, (m_y_top-m_y_base)/2.0f);
        mesh_boxCollider2D.offset = boxColl2D_center;
        Vector2 boxColl2D_size = mesh_boxCollider2D.size;
        boxColl2D_size = new Vector2 ((m_x_base>m_x_top?m_x_base:m_x_top), (m_y_top>m_y_base?m_y_top:m_y_base));
        mesh_boxCollider2D.size = boxColl2D_size;
        BuildBeamMesh (mesh_filter.mesh);
        ParticleSystem beam_particles = beam.GetComponentInChildren<ParticleSystem> ();
        beam_particles.transform.localPosition = new Vector3 (transform.localPosition.x, m_y_base, 0.0f);

        float angle = Mathf.Atan ((m_x_base-m_x_top) / m_y_top) * 180/Mathf.PI; // 10.0f
        MeshCollider meshcol_tmp;
        Beam_borders_collider border;
        m_border_top = GameObject.CreatePrimitive (PrimitiveType.Quad);
        m_border_top.transform.parent = transform;
        m_border_top.transform.localScale = new Vector3 (2.0f, 2.0f, 0.0f);
        m_border_top.transform.localPosition = new Vector3 (0.0f, m_y_top-0.5f, 0.0f);
        m_border_top.GetComponent<MeshRenderer> ().enabled = false;
        meshcol_tmp = m_border_top.GetComponent<MeshCollider> ();
        Component.DestroyImmediate (meshcol_tmp);
        m_border_top.AddComponent<BoxCollider2D> ().isTrigger = true;
        border = m_border_top.AddComponent<Beam_borders_collider> ();
        border.isBorderTop = true;
        border.parent = this;
    }