Пример #1
0
    public static void Main()
    {
        Chicken mara = new Chicken("Mara", 3);
        Chicken chicki = new Chicken("Chicki", 9);

        Console.WriteLine(mara.ProductPerDay);
        Console.WriteLine(chicki.ProductPerDay);
    }
Пример #2
0
	// Use this for initialization
	void Start () {
       SceneManager.UnloadScene(1);
       chicken = GameObject.FindGameObjectWithTag("Chicken").GetComponent<Chicken>();
	   startGame();
       GameObject backgroundController = GameObject.FindGameObjectWithTag("BackgroundMusic");
       if (backgroundController == null){
           backgroundController = GameController.Instantiate(BackgroundMusicGo, Vector3.zero, Quaternion.identity) as GameObject;
       }
       backgroundController.GetComponent<BackgroundMusicController>().playInGame();
       
	}
Пример #3
0
        static void Main(string[] args)
        {
            //numbers , adultKillos

            Pheasant pheasant = new Pheasant(0,0);
            pheasant.ProduceFood(0,0);
            

            Chicken chicken = new Chicken("Kokoshka",6);
            Console.WriteLine(chicken.GetHumanAge());
            Console.WriteLine(chicken.ProduceProduct());
            Console.WriteLine("end");
            
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Создание коллекции типа Array из объектов Animal и её использование.");
            Animal[] animalArray = new Animal[2];
            Cow myCow1 = new Cow("Бурёнка");

            animalArray[0] = myCow1;
            animalArray[1] = new Chicken("Дося");

            foreach (var animal in animalArray)
            {
                Console.WriteLine("Объект {0} был добавлен в коллекцию Array, " + "Имя = {1}.", animal.ToString(), animal.Name);
            }

            Console.WriteLine("Коллекция Array содержит {0} объектов.", animalArray.Length);
            animalArray[0].Feed();
            ((Chicken)animalArray[1]).LayEgg();
            Console.WriteLine();
            Console.WriteLine("Сщздание коллекции объектов Animal типа Array и её использование.");
            ArrayList animalArrayList = new ArrayList();
            Cow myCow2 = new Cow("Таня");
            animalArrayList.Add(myCow2);
            animalArrayList.Add(new Chicken("Феня"));

            foreach(Animal myAnimal in animalArrayList)
            {
                Console.WriteLine("Объект {0}  был добавлен в коллекцию ArrayList, " + " Имя = {1}.", myAnimal.ToString(), myAnimal.Name);
            }
            Console.WriteLine("Коллекция ArrayList содержит {0} объктов.", animalArrayList.Count);
            ((Animal)animalArrayList[0]).Feed();
            ((Chicken)animalArrayList[1]).LayEgg();
            Console.WriteLine();

            Console.WriteLine("Дополнительное манипулирование коллекцией ArrayList:");
            animalArrayList.RemoveAt(0);
            ((Animal)animalArrayList[0]).Feed();
            animalArrayList.AddRange(animalArray);
            ((Chicken)animalArrayList[2]).LayEgg();
            Console.WriteLine("Животное по имени {0} находится под индексом {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1));
            myCow1.Name = "Джанис";
            Console.WriteLine("Животное теперь зовут {0}!", ((Animal)animalArrayList[1]).Name);
            Console.ReadKey();
        }
Пример #5
0
        static void Main(string[] args)
        {
            //Create our animal objects but only talk to them by the interface (contract) they signed
            IAnimal eagle = new Eagle();
            IAnimal chicken = new Chicken();
            IAnimal bear = new Bear();

            //Add our animals to an array the only cares about the interface they implement (the contract or the what) not the
            //classes that are really implementing the code inside (the how)
            IAnimal[] animals = new IAnimal[] { eagle, chicken, bear };

            //Call the static DoSomething method on  AnimalUtility passing in each animal
            foreach(var animal in animals)
            {
                AnimalUtility.DoSomething(animal);
            }

            Console.ReadLine();
        }
Пример #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("=== Animal ===");
            IAnimal animal = new Animal();
            animal.input();
            animal.display();
            animal.watingToExit();

            Console.WriteLine("=== Cat ===");
            IAnimal cat = new Cat();
            cat.input();
            cat.display();
            cat.watingToExit();
            cat.caculateMyAge();

            Console.WriteLine("=== Chicken ===");
            IAnimal chicken = new Chicken();
            chicken.input();
            chicken.display();
            chicken.caculateMyAge();
            chicken.watingToExit();
        }
Пример #7
0
    public override void OnActionStart(Vector2 direction)
    {
        if (SequenceMode)
        {
            return;
        }

        if (_caughtChicken != null)
        {
            Debug.Log(_lastInputDirection);
            _caughtChickenRigidbody.velocity = _lastInputDirection * _currentThrowForce;
            _currentThrowForce = 0.0f;
            _caughtChicken = null;
            _caughtChickenRigidbody = null;
            _animator.SetBool("kick", true);
        }
        else if (_actionCoroutine == null)
        {
            _actionCoroutine = StartCoroutine(HitCoroutine());
            _animator.SetBool("attack", true);

            Attack = true;
        }
    }
Пример #8
0
        public void CanChickenStopSwimming()
        {
            Chicken chicken = new Chicken();

            Assert.True(chicken.Stop());
        }
Пример #9
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);
        }
Пример #10
0
        public override void ProcessEvent(Jabber.Util.Event ev)
        {
            if (!IsTopScreen)
            {
                return;
            }
            if (ev is ExplosionEvent)
            {
                ExplosionPlayed = true;
            }
            if (!ExplosionPlayed)
            {
                /*
                if (ev is BreakableDestroyed && !(ev is BreakableHit))
                {
                    if (!SFXPlayed((ev as BreakableDestroyed).Broken))
                    {
                       // if (SFXTime((ev as BreakableDestroyed).Broken) <= 0)
                        {
                            BreakableBody.PlaySFXBreakForMaterial((ev as BreakableDestroyed).Broken);
                            SFXPlayed((ev as BreakableDestroyed).Broken, true);
                        }
                    }
                    else
                    {
                        int k = 0;
                    }
                }
                else if (ev is BreakableHit)
                {
                    if (!SFXPlayed((ev as BreakableHit).Broken))
                    {
                        if (SFXTime((ev as BreakableHit).Broken) <= 0.0f)
                        {
                            BreakableBody.PlayHitSFXForMaterial((ev as BreakableHit).Broken);
                            SFXPlayed((ev as BreakableHit).Broken, true);
                        }
                    }
                }*/
            }
            if (ev is CannonFireEvent && scene.ToFire.Count > 0)
            {
                CannonFireEvent e = ev as CannonFireEvent;

                Vector2 dir = e.Dir;
                Chicken chick = null;// new Chicken_Dash(world);

                switch (scene.ToFire[scene.ToFire.Count - 1])
                {
                    case 0:
                        chick = new Chicken(scene);
                        break;
                    case 1:
                        chick = new Chicken_Dash(scene);
                        break;
                    case 2:
                        chick = new Chicken_Egg(scene);
                        break;
                    case 3:
                        chick = new Chicken_Explode(scene);
                        break;
                    case 4:
                        chick = new Chicken_Mini_Launcher(scene);
                        break;
                }

                chick.Initialize(Content);
                chick.Position = e.Position;
                chick.Body.LinearVelocity = dir;
                withChicks.AddNode(chick);

                bForceInactiveChicken = false;
                bFollowingChicken = true;

                scene.ToFire.RemoveAt(scene.ToFire.Count - 1);
            }
            else if (ev is MenuEvent && IsTopScreen)
            {
                if ((ev as MenuEvent).sender is MenuObj)
                {
                    if (((ev as MenuEvent).sender as MenuObj).Name == "pause")
                    {
                        PauseScreen s = new PauseScreen();
                        s.Initialize(Content);
                        ScreenManager.Get.AddScreen(s);
                    }
                    else if (((ev as MenuEvent).sender as MenuObj).Name == "restart")
                    {
                        Restart();
                        AudioManager.PlayOnce("Sounds/Restart");
                    }
                    else if (((ev as MenuEvent).sender as MenuObj).Name == "forceendgame")
                    {
                        //if (!AnyFox)
                        {
                            for (int i = 0; i < scene.Nodes.Count; i++)
                            {
                                if (scene.Nodes[i] is DonutCase)
                                {
                                    scene.Nodes[i].RaiseFlag(Flags.DELETE);
                                    scene.Nodes[i].UnloadContent();
                                    scene.Nodes.RemoveAt(i); --i;
                                }
                                else if(scene.Nodes[i] is Donut)
                                {
                                    scene.Nodes[i].RaiseFlag(Flags.DELETE);
                                    scene.Nodes[i].UnloadContent();
                                    scene.Nodes.RemoveAt(i); --i;
                                }
                            }
                            //HasWon = true;
                            LevelEndScreen n = new LevelEndScreen(this);
                            n.Initialize(Content);
                            ScreenManager.Get.AddScreen(n);

                            LowerFlag(Jabber.Flags.FADE_OUT);
                            LowerFlag(Jabber.Flags.FADE_IN);

                            if (GetRemainingFox() == 0)
                                AudioManager.PlayOnce("Sounds/Win_Stinger");
                            else
                                AudioManager.PlayOnce("Sounds/Lose_Stinger");
                        }
                    }
                }
            }
            base.ProcessEvent(ev);
        }
Пример #11
0
            public Task ListAsync(CommandContext ctx)
            {
                CachedGuildConfig gcfg = ctx.Services.GetRequiredService <GuildConfigService>().GetCachedConfig(ctx.Guild.Id);

                return(ctx.RespondWithLocalizedEmbedAsync(emb => {
                    emb.WithLocalizedTitle("str-chicken-types");
                    emb.WithColor(this.ModuleColor);
                    foreach (((ChickenType type, ChickenStats stats), int i) in Chicken.StartingStats.Select((kvp, i) => (kvp, i)))
                    {
                        emb.AddLocalizedTitleField($"str-chicken-type-{i}", stats, titleArgs: new object[] { Chicken.Price(type), gcfg.Currency });
                    }
                }));
            }
Пример #12
0
 public FleeState(Chicken chicken, float speedModifier) : base(chicken.gameObject)
 {
     this._chicken       = chicken;
     this._speedModifier = speedModifier;
 }
Пример #13
0
            private async Task TryBuyInternalAsync(CommandContext ctx, ChickenType type, string name)
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new InvalidCommandUsageException("Name for your chicken is missing.");
                }

                if (name.Length < 2 || name.Length > 30)
                {
                    throw new InvalidCommandUsageException("Name cannot be shorter than 2 and longer than 30 characters.");
                }

                if (!name.All(c => Char.IsLetterOrDigit(c) || Char.IsWhiteSpace(c)))
                {
                    throw new InvalidCommandUsageException("Name cannot contain characters that are not letters or digits.");
                }

                if (await this.Database.GetChickenAsync(ctx.User.Id, ctx.Guild.Id) != null)
                {
                    throw new CommandFailedException("You already own a chicken!");
                }

                if (!await ctx.WaitForBoolReplyAsync($"{ctx.User.Mention}, are you sure you want to buy a chicken for {Formatter.Bold(Chicken.Price(type).ToString())} {this.Shared.GetGuildConfig(ctx.Guild.Id).Currency ?? "credits"}?"))
                {
                    return;
                }

                if (!await this.Database.DecreaseBankAccountBalanceAsync(ctx.User.Id, ctx.Guild.Id, Chicken.Price(type)))
                {
                    throw new CommandFailedException($"You do not have enough {this.Shared.GetGuildConfig(ctx.Guild.Id).Currency ?? "credits"} to buy a chicken ({Chicken.Price(type)} needed)!");
                }

                await this.Database.AddChickenAsync(ctx.User.Id, ctx.Guild.Id, name, Chicken.StartingStats[type]);

                await this.InformAsync(ctx, StaticDiscordEmoji.Chicken, $"{ctx.User.Mention} bought a chicken named {Formatter.Bold(name)}");
            }
Пример #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:
                var random = new Random();
                mob = new Horse(world, random.NextDouble() < 0.10, random);
                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.NoAi          = true;
            mob.SpawnEntity();

            Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata);

            if (player.GameMode == GameMode.Survival)
            {
                var itemInHand = player.Inventory.GetItemInHand();
                itemInHand.Count--;
                player.Inventory.SetInventorySlot(player.Inventory.InHandSlot, itemInHand);
            }
        }
Пример #15
0
        public async Task FightAsync(CommandContext ctx,
                                     [Description("Member whose chicken to fight.")] DiscordMember member)
        {
            if (this.Shared.GetEventInChannel(ctx.Channel.Id) is ChickenWar ambush)
            {
                throw new CommandFailedException("There is a chicken war running in this channel. No fights are allowed before the war finishes.");
            }

            if (member.Id == ctx.User.Id)
            {
                throw new CommandFailedException("You can't fight against your own chicken!");
            }

            Chicken chicken1 = await this.Database.GetChickenAsync(ctx.User.Id, ctx.Guild.Id);

            if (chicken1 != null)
            {
                if (chicken1.Stats.TotalVitality < 25)
                {
                    throw new CommandFailedException($"{ctx.User.Mention}, your chicken is too weak to start a fight with another chicken! Heal it using {Formatter.InlineCode("chicken heal")} command.");
                }
            }
            else
            {
                throw new CommandFailedException("You do not own a chicken!");
            }

            Chicken chicken2 = await this.Database.GetChickenAsync(member.Id, ctx.Guild.Id);

            if (chicken2 == null)
            {
                throw new CommandFailedException("The specified user does not own a chicken!");
            }

            if (Math.Abs(chicken1.Stats.TotalStrength - chicken2.Stats.TotalStrength) > 50)
            {
                throw new CommandFailedException("The bare strength difference is too big (50 max)! Please find a more suitable opponent.");
            }

            string header = $"{Formatter.Bold(chicken1.Name)} ({chicken1.Stats.ToShortString()}) {StaticDiscordEmoji.DuelSwords} {Formatter.Bold(chicken2.Name)} ({chicken2.Stats.ToShortString()}) {StaticDiscordEmoji.Chicken}\n\n";

            Chicken winner = chicken1.Fight(chicken2);

            winner.Owner = winner.OwnerId == ctx.User.Id ? ctx.User : member;
            Chicken loser = winner == chicken1 ? chicken2 : chicken1;
            int     gain  = winner.DetermineStrengthGain(loser);

            winner.Stats.BareStrength    += gain;
            winner.Stats.BareMaxVitality -= gain;
            if (winner.Stats.TotalVitality == 0)
            {
                winner.Stats.BareVitality = 1;
            }
            loser.Stats.BareVitality -= 50;

            await this.Database.ModifyChickenAsync(winner, ctx.Guild.Id);

            if (loser.Stats.TotalVitality > 0)
            {
                await this.Database.ModifyChickenAsync(loser, ctx.Guild.Id);
            }
            else
            {
                await this.Database.RemoveChickenAsync(loser.OwnerId, ctx.Guild.Id);
            }

            await this.Database.IncreaseBankAccountBalanceAsync(winner.OwnerId, ctx.Guild.Id, gain * 2000);

            await this.InformAsync(ctx, StaticDiscordEmoji.Chicken,
                                   header +
                                   $"{StaticDiscordEmoji.Trophy} Winner: {Formatter.Bold(winner.Name)}\n\n" +
                                   $"{Formatter.Bold(winner.Name)} gained {Formatter.Bold(gain.ToString())} strength!\n" +
                                   (loser.Stats.TotalVitality > 0 ? $"{Formatter.Bold(loser.Name)} lost {Formatter.Bold("50")} HP!" : $"{Formatter.Bold(loser.Name)} died in the battle!") +
                                   $"\n\n{winner.Owner.Mention} won {gain * 200} {this.Shared.GetGuildConfig(ctx.Guild.Id).Currency ?? "credits"}."
                                   , important : true
                                   );
        }
Пример #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)
            {
                NameTag       = petName,
                KnownPosition = (PlayerLocation)player.KnownPosition.Clone(),
                Height        = height,
            };

            newPet.SpawnEntity();
        }
Пример #17
0
        public void CanChickenUseIswim()
        {
            Chicken chicken = new Chicken();

            Assert.True(chicken.Swim());
        }
Пример #18
0
        public void CanChickenSpeak()
        {
            Chicken chicken = new Chicken();

            Assert.True(chicken.Speak());
        }
Пример #19
0
        public void CanChickenStopFlying()
        {
            Chicken chicken = new Chicken();

            Assert.True(chicken.Land());
        }
Пример #20
0
        public void CanChickenUseIfly()
        {
            Chicken chicken = new Chicken();

            Assert.True(chicken.Fly());
        }
Пример #21
0
 // Start is called before the first frame update
 void Start()
 {
     chicken = FindObjectOfType <Chicken>();
 }
Пример #22
0
    List <GameObject> EvaluateTargets(Chicken chicken, Action action, Resource resource)
    {
        List <GameObject> potentialTargets = new List <GameObject>();

        for (int x = 0; x < targets.Count; x++)
        {
            Target target = targets[x].GetComponent <Target>();


            if (action == Action.Sleep)                                         // if we're sleeping
            {
                if (target.actions.Contains(Action.Sleep))                      // if this place lets us sleep
                {
                    if (target.open && target.chickens.Count < target.maxSpots) // if it's open and has space
                    {
                        potentialTargets.Add(targets[x]);                       // add it to the list to consider
                    }
                }
            }

            if (action == Action.Get)                                               // if we're getting something
            {
                if (target.actions.Contains(Action.Get))                            // if this place let's us get
                {
                    if (target.inventory[(int)resource].x > 0)                      // and it has some of this resource
                    {
                        if (target.open && target.chickens.Count < target.maxSpots) // if it's open and has space
                        {
                            potentialTargets.Add(targets[x]);                       // add it to the list to consider
                        }
                    }
                }
            }

            if (action == Action.Put)             // if we're putting something
            {
                // if this place has room to put what we're putting
                if (target.inventory[(int)resource].x < target.inventory[(int)resource].y)
                {
                    if (target.open && target.chickens.Count < target.maxSpots)    // if it's open and has space
                    {
                        potentialTargets.Add(targets[x]);                          // add it to the list to consider
                    }
                }
            }

            if (action == Action.Make)
            {
                if (target.actions.Contains(Action.Make) && target.resourceProduced == resource)                 // if this place lets us make what we're making
                {
                    bool     hasIngredients = true;
                    Resource resourceNeeded = Resource.None;

                    for (int y = 0; y < target.actionIngredients.Count; y++)
                    {
                        if (target.inventory[y].x < target.actionIngredients[y] && hasIngredients)
                        {
                            hasIngredients = false;
                            resourceNeeded = (Resource)y;
                        }
                    }

                    if (hasIngredients)
                    {
                        if (target.open && target.chickens.Count < target.maxSpots)        // if it's open and has space
                        {
                            potentialTargets.Add(targets[x]);                              // add it to the list to consider
                        }
                    }
                    else
                    {
                        if (GetResource(chicken, resourceNeeded, null))                         // get the first material we come across that we dont have, in the amount that we need
                        {
                            DropOffResources(chicken, target.gameObject);                       // put the materials here
                        }
                    }
                }
            }

            if (action == Action.Forester)
            {
                if (target.actions.Contains(Action.Forester) && target.resourceProduced == resource) // if this place lets us make what we're making
                {
                    if (target.open && target.chickens.Count < target.maxSpots)                      // if it's open and has space
                    {
                        potentialTargets.Add(targets[x]);                                            // add it to the list to consider
                    }
                }
            }

            if (action == Action.PlantTree)
            {
                if (target.actions.Contains(Action.PlantTree))
                {
                    if (target.open && target.chickens.Count < target.maxSpots)    // if it's open and has space
                    {
                        potentialTargets.Add(targets[x]);                          // add it to the list to
                    }
                }
            }

            if (action == Action.ChopTree)
            {
                if (target.actions.Contains(Action.ChopTree))
                {
                    if (target.open && target.chickens.Count < target.maxSpots)    // if it's open and has space
                    {
                        potentialTargets.Add(targets[x]);                          // add it to the list to
                    }
                }
            }

            if (action == Action.Build)                    // if we're building or laboring
            {
                if (target.actions.Contains(Action.Build)) // if this place lets us build
                {
                    Construction construction = target.GetComponent <Construction>();

                    bool     hasMaterials   = true;
                    int      amountNeeded   = 0;
                    Resource resourceNeeded = Resource.None;

                    for (int y = 0; y < construction.constructionMaterials.Count; y++)
                    {
                        if (target.inventory[y].x < construction.constructionMaterials[y] && hasMaterials)
                        {
                            hasMaterials   = false;
                            amountNeeded   = construction.constructionMaterials[y] - (int)target.inventory[y].x;
                            resourceNeeded = (Resource)y;
                        }
                    }

                    if (hasMaterials)
                    {
                        if (target.open && target.chickens.Count < target.maxSpots)        // if it's open and has space
                        {
                            potentialTargets.Add(targets[x]);                              // add it to the list to consider
                        }
                    }
                    else
                    {
                        if (GetResource(chicken, resourceNeeded, null, amountNeeded))                 // get the first material we come across that we dont have, in the amount that we need
                        {
                            DropOffResources(chicken, target.gameObject);                             // put the materials here
                        }
                    }
                }
            }

            if (action == Action.Labor)                   // if we're making something or laboring
            {
                if (target.actions.Contains(Action.Make)) // if this place lets us make what we're making
                {
                    bool hasIngredients = true;
                    for (int y = 0; y < target.actionIngredients.Count; y++)
                    {
                        if (target.inventory[y].x < target.actionIngredients[y])
                        {
                            hasIngredients = false;
                        }
                    }
                    if (!hasIngredients)                                            // if it doesn't have the ingredients // TODO we need to make this a priority over other tasks, and laborers need to keep putting resources at any open place that doesnt have max cap.
                    {
                        if (target.open && target.chickens.Count < target.maxSpots) // if it's open and has space
                        {
                            potentialTargets.Add(targets[x]);                       // add it to the list to consider
                        }
                    }
                }
                if (target.actions.Contains(Action.Build))
                {
                    Construction construction = target.GetComponent <Construction>();

                    bool hasMaterials = true;
                    for (int y = 0; y < construction.constructionMaterials.Count; y++)
                    {
                        if (target.inventory[y].x < construction.constructionMaterials[y])
                        {
                            hasMaterials = false;
                        }
                    }
                    if (!hasMaterials)                                              // if it doesn't have the ingredients // TODO we need to make this a priority over other tasks, and laborers need to keep putting resources at any open place that doesnt have max cap.
                    {
                        if (target.open && target.chickens.Count < target.maxSpots) // if it's open and has space
                        {
                            potentialTargets.Add(targets[x]);                       // add it to the list to consider
                        }
                    }
                }
            }
        }

        return(potentialTargets);
    }
Пример #23
0
    // determine chicken job and create potential jobs, test and see if they are available, and do them (or their backup jobs)
    public void GetJobQueue(Chicken chicken)
    {
        chickenManager.UpdateChicken(chicken);         //update this chicken

        //clear out old queues
        chicken.targetQueue         = new List <GameObject> {
        };
        chicken.actionQueue         = new List <Action> {
        };
        chicken.resourceNeededQueue = new List <Resource> {
        };

        chicken.currentTarget  = null;
        chicken.action         = Action.None;
        chicken.resourceNeeded = Resource.None;

        if (gameManager.night == true)
        {
            Sleep(chicken);
        }
        else
        {
            if (chicken.job == Job.Farmer)
            {
                if (!MakeResource(chicken, Resource.Wheat, null))
                {
                    AddTask(chicken, chicken.gameObject, Action.Wander);
                }
            }

            if (chicken.job == Job.Millworker)
            {
                if (!MakeResource(chicken, Resource.Grain, null))
                {
                    AddTask(chicken, chicken.gameObject, Action.Wander);
                }
            }

            if (chicken.job == Job.Miner)
            {
                if (!MakeResource(chicken, Resource.Stone, null))
                {
                    AddTask(chicken, chicken.gameObject, Action.Wander);
                }
            }

            if (chicken.job == Job.Mason)
            {
                if (!MakeResource(chicken, Resource.Bricks, null))
                {
                    AddTask(chicken, chicken.gameObject, Action.Wander);
                }
            }

            if (chicken.job == Job.Lumberjack)
            {
                if (!Forester(chicken))
                {
                    AddTask(chicken, chicken.gameObject, Action.Wander);
                }
            }

            if (chicken.job == Job.SawMill)
            {
                if (!MakeResource(chicken, Resource.Planks, null))
                {
                    AddTask(chicken, chicken.gameObject, Action.Wander);
                }
            }

            if (chicken.job == Job.Builder)
            {
                if (!Build(chicken))
                {
                    AddTask(chicken, chicken.gameObject, Action.Wander);
                }
            }
        }
    }
Пример #24
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);
        }
Пример #25
0
        public void ChickenIsAnimal()
        {
            Chicken chicken = new Chicken();

            Assert.IsType <Chicken>(chicken);
        }
Пример #26
0
        public static void CollectInput(Farm farm, Chicken animal)
        {
            Boolean choiceBoolean = true;
            Boolean placeBoolean  = true;

            Utils.Clear();

            List <ChickenHouse> availableHouses = farm.ChickenHouses.Where(singleHouse => singleHouse.AnimalCount < singleHouse.Capacity).ToList();

            if (availableHouses.Count == 0)
            {
                Console.WriteLine("0. Return to main menu");
            }

            for (int i = 0; i < availableHouses.Count; i++)
            {
                if (i == 0)
                {
                    Console.WriteLine("0. Return to main menu");
                }
                string chickenString = "chicken";
                if (availableHouses[i].AnimalCount != 1)
                {
                    chickenString += "s";
                }
                Console.WriteLine($"{i + 1}. Chicken House ({availableHouses[i].AnimalCount} {chickenString})");
            }

            Console.WriteLine();

            // How can I output the type of animal chosen here?
            Console.WriteLine($"Place the animal where?");

            int choice = 1;

            while (choiceBoolean)
            {
                Console.Write("> ");

                try
                {
                    choice = Int32.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("No number detected");
                }
                if (choice == 0)
                {
                    choiceBoolean = false;
                    placeBoolean  = false;
                }
                else if (choice < 1 || choice > availableHouses.Count)
                {
                    Console.WriteLine("Please input a number corresponding to a choice");
                }
                else if (availableHouses[choice - 1].AnimalCount >= availableHouses[choice - 1].Capacity)
                {
                    Console.WriteLine("This house is full, please choose another!");
                }
                else
                {
                    choiceBoolean = false;
                }
            }

            if (placeBoolean)
            {
                availableHouses[choice - 1].AddResource(animal);
                Console.WriteLine("Chicken successfully added to the house! Press enter to return to the main menu.");
                Console.ReadLine();
            }

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Пример #27
0
        public void CanChickenNotEat()
        {
            Chicken chicken = new Chicken();

            Assert.False(chicken.Eat());
        }
Пример #28
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.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.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.Human:
            //entity = new PlayerMob("test", world, );
            //	break;
            default:
                return(null);
            }

            return(entity);
        }
            public Task HelpAsync(CommandContext ctx)
            {
                Chicken chicken = this.TryJoinInternal(ctx, team2: false);

                return(this.InformAsync(ctx, StaticDiscordEmoji.Chicken, $"{Formatter.Bold(chicken.Name)} has joined the ambushed party."));
            }
Пример #30
0
        static void Main(string[] args)
        {
            // Configure Observer pattern
            ConcreteKitchen sKitchen    = new ConcreteKitchen();
            ConcreteKitchen sIngredient = new ConcreteKitchen();

            // Sets the predefined observers available
            sKitchen.Attach(new ConcreteObserver(sKitchen, "Kitchen"));
            sIngredient.Attach(new ConcreteObserver(sIngredient, "Ingredient"));

            string ing, kitchen;

            Console.Write("Enter Country (SA/US): ");
            kitchen = Console.ReadLine();

            switch (kitchen)
            {
            // Changes the Kitchen observer to be kitchen location
            case "US": sKitchen.SubjectState = "US Kitchen"; break;

            case "us": sKitchen.SubjectState = "US Kitchen"; break;

            case "SA": sKitchen.SubjectState = "SA Kitchen"; break;

            case "sa": sKitchen.SubjectState = "SA Kitchen"; break;
            }
            //Goes through Subject class to ConcreteObserver class to output in the console window
            sKitchen.Notify();

            //Setting the Ingredient
            Console.Write("Choose Ingredient Taco/Burrito: ");
            ing = Console.ReadLine();
            switch (ing)
            {
            // Changes the Ingredient observer to be an ingredient type
            case "Taco": sIngredient.SubjectState = "Taco"; break;

            case "taco": sIngredient.SubjectState = "Taco"; break;

            case "Burrito": sIngredient.SubjectState = "Burrito"; break;

            case "burrito": sIngredient.SubjectState = "Burrito"; break;
            }
            //Goes through Subject class to ConcreteObserver class to output in the console window
            sIngredient.Notify();


            Console.WriteLine();
            Console.WriteLine();

            if (kitchen == "SA" || kitchen == "sa" || kitchen == "Sa")
            {
                if (ing == "Taco" || ing == "taco" || ing == "TACO")
                {
                    Taco saTaco = new Taco(new SAIngredientFactory());
                    Console.WriteLine($"SA Taco: {saTaco.DescribeTaco()}");
                    // ---------------------------- observer testing
                    Ingredient newIngredientSA = new Taco(new SAIngredientFactory());
                    string     userInputSA     = "Yes";
                    string     chosenFillingSA;
                    while (userInputSA == "Yes" || userInputSA == "yes" || userInputSA == "YES")
                    {
                        Console.Write("What filling do you want to add to your ingredient? ");
                        chosenFillingSA = Console.ReadLine();
                        switch (chosenFillingSA)
                        {
                        case "Chicken":
                        case "chicken":
                            newIngredientSA = new Chicken(newIngredientSA);
                            break;

                        case "Mutton":
                        case "mutton":
                            newIngredientSA = new Mutton(newIngredientSA);
                            break;

                        case "Samp":
                        case "samp":
                            newIngredientSA = new Samp(newIngredientSA);
                            break;

                        case "Cheddar Cheese":
                        case "cheddar cheese":
                        case "Cheddar cheese":
                            newIngredientSA = new CheddarCheese(newIngredientSA);
                            break;

                        case "Sliced Avocados":
                        case "sliced avocados":
                        case "Sliced avocados":
                            newIngredientSA = new SlicedAvocados(newIngredientSA);
                            break;

                        case "Jasmin Rice":
                        case "jasmin rice":
                        case "Jasmin rice":
                            newIngredientSA = new JasminRice(newIngredientSA);
                            break;

                        case "Refried Beans":
                        case "Refried beans":
                        case "refried beans":
                            newIngredientSA = new RefriedBeans(newIngredientSA);
                            break;

                        case "Smooth Cream Cheese":
                        case "smooth cream cheese":
                        case "Smooth Cream cheese":
                            newIngredientSA = new SmoothCreamCheese(newIngredientSA);
                            break;

                        case "Relish":
                        case "relish":
                            newIngredientSA = new Relish(newIngredientSA);
                            break;

                        case "Jalapeno Chilies":
                        case "jalapeno chilies":
                        case "Jalapeno chilies":
                            newIngredientSA = new JalapenoChilies(newIngredientSA);
                            break;
                        }// end switch
                        Console.Write("Do you want to add another filling to your ingredient? ");
                        userInputSA = Console.ReadLine();
                    } // end while loop
                    Console.WriteLine();
                    Console.WriteLine(newIngredientSA.GetDiscription() + " \tFinal Price: " + newIngredientSA.Cost().ToString("C"));
                    Console.WriteLine();
                    // ---------------------------- end observer testing
                }
                else if (ing == "Burrito" || ing == "burrito" || ing == "BURRITO")
                {
                    Burrito saBurrito = new Burrito(new SAIngredientFactory());
                    Console.WriteLine($"SA Burrito: {saBurrito.DescribeBurrito()}");
                    // ---------------------------- observer testing
                    Ingredient newIngredientSA = new Burrito(new SAIngredientFactory());
                    string     userInputSA     = "Yes";
                    string     chosenFillingSA;
                    while (userInputSA == "Yes" || userInputSA == "yes" || userInputSA == "YES")
                    {
                        Console.Write("What filling do you want to add to your ingredient? ");
                        chosenFillingSA = Console.ReadLine();
                        switch (chosenFillingSA)
                        {
                        case "Chicken":
                        case "chicken":
                            newIngredientSA = new Chicken(newIngredientSA);
                            break;

                        case "Mutton":
                        case "mutton":
                            newIngredientSA = new Mutton(newIngredientSA);
                            break;

                        case "Samp":
                        case "samp":
                            newIngredientSA = new Samp(newIngredientSA);
                            break;

                        case "Cheddar Cheese":
                        case "cheddar cheese":
                        case "Cheddar cheese":
                            newIngredientSA = new CheddarCheese(newIngredientSA);
                            break;

                        case "Sliced Avocados":
                        case "sliced avocados":
                        case "Sliced avocados":
                            newIngredientSA = new SlicedAvocados(newIngredientSA);
                            break;

                        case "Jasmin Rice":
                        case "jasmin rice":
                        case "Jasmin rice":
                            newIngredientSA = new JasminRice(newIngredientSA);
                            break;

                        case "Refried Beans":
                        case "Refried beans":
                        case "refried beans":
                            newIngredientSA = new RefriedBeans(newIngredientSA);
                            break;

                        case "Smooth Cream Cheese":
                        case "smooth cream cheese":
                        case "Smooth Cream cheese":
                            newIngredientSA = new SmoothCreamCheese(newIngredientSA);
                            break;

                        case "Relish":
                        case "relish":
                            newIngredientSA = new Relish(newIngredientSA);
                            break;

                        case "Jalapeno Chilies":
                        case "jalapeno chilies":
                        case "Jalapeno chilies":
                            newIngredientSA = new JalapenoChilies(newIngredientSA);
                            break;
                        }// end switch
                        Console.Write("Do you want to add another filling to your ingredient? ");
                        userInputSA = Console.ReadLine();
                    } // end while loop
                    Console.WriteLine();
                    Console.WriteLine(newIngredientSA.GetDiscription() + " \tFinal Price: " + newIngredientSA.Cost().ToString("C"));
                    Console.WriteLine();
                    // ---------------------------- end observer testing
                }
            }
            else if (kitchen == "US" || kitchen == "us" || kitchen == "Us")
            {
                if (ing == "Taco" || ing == "taco" || ing == "TACO")
                {
                    Taco usTaco = new Taco(new USIngredientFactory());
                    Console.WriteLine($"US Taco: {usTaco.DescribeTaco()}");
                    // ---------------------- observer testing start
                    Ingredient newIngredientUS = new Taco(new USIngredientFactory());
                    string     userInputUS     = "Yes";
                    string     chosenFillingUS;
                    while (userInputUS == "Yes" || userInputUS == "yes" || userInputUS == "YES")
                    {
                        Console.Write("What filling do you want to add to your ingredient? ");
                        chosenFillingUS = Console.ReadLine();
                        switch (chosenFillingUS)
                        {
                        case "Turkey":
                        case "turkey":
                            newIngredientUS = new Turkey(newIngredientUS);
                            break;

                        case "Beef":
                        case "beef":
                            newIngredientUS = new Beef(newIngredientUS);
                            break;

                        case "Chickpeas":
                        case "chickpeas":
                            newIngredientUS = new Chickpeas(newIngredientUS);
                            break;

                        case "Pepper Jack Cheese":
                        case "pepper jack cheese":
                        case "Pepper jack cheese":
                            newIngredientUS = new PepperJackCheese(newIngredientUS);
                            break;

                        case "Guacamole":
                        case "guacomole":
                            newIngredientUS = new Guacamole(newIngredientUS);
                            break;

                        case "Basmati Rice":
                        case "basmati rice":
                        case "Basmati rice":
                            newIngredientUS = new BasmatiRice(newIngredientUS);
                            break;

                        case "Black Beans":
                        case "black beans":
                        case "Black beans":
                            newIngredientUS = new BlackBeans(newIngredientUS);
                            break;

                        case "Chunky Cream Cheese":
                        case "chunky cream cheese":
                        case "Chunky Cream cheese":
                            newIngredientUS = new ChunkyCreamCheese(newIngredientUS);
                            break;

                        case "Salsa":
                        case "salsa":
                            newIngredientUS = new Salsa(newIngredientUS);
                            break;

                        case "Habanero Chilies":
                        case "habanero chilies":
                        case "Habanero chilies":
                            newIngredientUS = new HabaneroChilies(newIngredientUS);
                            break;
                        }// end switch
                        Console.Write("Do you want to add another filling to your ingredient? ");
                        userInputUS = Console.ReadLine();
                    } // end while loop
                    Console.WriteLine();
                    Console.WriteLine(newIngredientUS.GetDiscription() + " \tFinal Price: " + newIngredientUS.Cost().ToString("C"));
                    Console.WriteLine();
                    // ---------------------- observer testing end
                }
                else if (ing == "Burrito" || ing == "burrito" || ing == "BURRITO")
                {
                    Burrito usBurrito = new Burrito(new USIngredientFactory());
                    Console.WriteLine($"US Burrito: {usBurrito.DescribeBurrito()}");
                    // ---------------------- observer testing start
                    Ingredient newIngredientUS = new Burrito(new USIngredientFactory());
                    string     userInputUS     = "Yes";
                    string     chosenFillingUS;
                    while (userInputUS == "Yes" || userInputUS == "yes" || userInputUS == "YES")
                    {
                        Console.Write("What filling do you want to add to your ingredient? ");
                        chosenFillingUS = Console.ReadLine();
                        switch (chosenFillingUS)
                        {
                        case "Turkey":
                        case "turkey":
                            newIngredientUS = new Turkey(newIngredientUS);
                            break;

                        case "Beef":
                        case "beef":
                            newIngredientUS = new Beef(newIngredientUS);
                            break;

                        case "Chickpeas":
                        case "chickpeas":
                            newIngredientUS = new Chickpeas(newIngredientUS);
                            break;

                        case "Pepper Jack Cheese":
                        case "pepper jack cheese":
                        case "Pepper jack cheese":
                            newIngredientUS = new PepperJackCheese(newIngredientUS);
                            break;

                        case "Guacamole":
                        case "guacomole":
                            newIngredientUS = new Guacamole(newIngredientUS);
                            break;

                        case "Basmati Rice":
                        case "basmati rice":
                        case "Basmati rice":
                            newIngredientUS = new BasmatiRice(newIngredientUS);
                            break;

                        case "Black Beans":
                        case "black beans":
                        case "Black beans":
                            newIngredientUS = new BlackBeans(newIngredientUS);
                            break;

                        case "Chunky Cream Cheese":
                        case "chunky cream cheese":
                        case "Chunky Cream cheese":
                            newIngredientUS = new ChunkyCreamCheese(newIngredientUS);
                            break;

                        case "Salsa":
                        case "salsa":
                            newIngredientUS = new Salsa(newIngredientUS);
                            break;

                        case "Habanero Chilies":
                        case "habanero chilies":
                        case "Habanero chilies":
                            newIngredientUS = new HabaneroChilies(newIngredientUS);
                            break;
                        }// end switch
                        Console.Write("Do you want to add another filling to your ingredient? ");
                        userInputUS = Console.ReadLine();
                    } // end while loop
                    Console.WriteLine();
                    Console.WriteLine(newIngredientUS.GetDiscription() + " \tFinal Price: " + newIngredientUS.Cost().ToString("C"));
                    Console.WriteLine();
                    // ---------------------- observer testing end
                }
            }

            Console.ReadLine();
        }
            public async Task ExecuteGroupAsync(CommandContext ctx,
                                                [Description("Whose chicken to ambush?")] DiscordMember member)
            {
                if (this.Shared.IsEventRunningInChannel(ctx.Channel.Id))
                {
                    if (this.Shared.GetEventInChannel(ctx.Channel.Id) is ChickenWar)
                    {
                        await this.JoinAsync(ctx);
                    }
                    else
                    {
                        throw new CommandFailedException("Another event is already running in the current channel.");
                    }
                    return;
                }

                var ambushed = Chicken.FromDatabase(this.Database, ctx.Guild.Id, member.Id);

                if (ambushed is null)
                {
                    throw new CommandFailedException("Given user does not have a chicken in this guild!");
                }

                var ambusher = Chicken.FromDatabase(this.Database, ctx.Guild.Id, ctx.User.Id);

                if (ambusher is null)
                {
                    throw new CommandFailedException("You do not own a chicken!");
                }

                if (ambusher.Stats.TotalStrength > ambushed.Stats.TotalStrength)
                {
                    throw new CommandFailedException("You cannot start an ambush against a weaker chicken!");
                }

                var ambush = new ChickenWar(ctx.Client.GetInteractivity(), ctx.Channel, "Ambushed chickens", "Evil ambushers");

                this.Shared.RegisterEventInChannel(ambush, ctx.Channel.Id);
                try {
                    ambush.AddParticipant(ambushed, member, team1: true);
                    await this.JoinAsync(ctx);

                    await this.InformAsync(ctx, StaticDiscordEmoji.Clock1, $"The ambush will start in 1 minute. Use command {Formatter.InlineCode("chicken ambush")} to make your chicken join the ambush, or {Formatter.InlineCode("chicken ambush help")} to help the ambushed chicken.");

                    await Task.Delay(TimeSpan.FromMinutes(1));

                    if (ambush.Team2.Any())
                    {
                        await ambush.RunAsync();

                        var sb = new StringBuilder();

                        using (DatabaseContext db = this.Database.CreateContext()) {
                            foreach (Chicken chicken in ambush.Team1Won ? ambush.Team1 : ambush.Team2)
                            {
                                chicken.Stats.BareStrength += 5;
                                chicken.Stats.BareVitality -= 10;
                                db.Chickens.Update(chicken.ToDatabaseChicken());
                                sb.AppendLine($"{Formatter.Bold(chicken.Name)} gained 5 STR and lost 10 HP!");
                            }

                            foreach (Chicken chicken in ambush.Team1Won ? ambush.Team2 : ambush.Team1)
                            {
                                chicken.Stats.BareVitality -= 50;
                                if (chicken.Stats.TotalVitality > 0)
                                {
                                    db.Chickens.Update(chicken.ToDatabaseChicken());
                                    sb.AppendLine($"{Formatter.Bold(chicken.Name)} lost 50 HP!");
                                }
                                else
                                {
                                    db.Chickens.Remove(new DatabaseChicken {
                                        GuildId = ctx.Guild.Id,
                                        UserId  = chicken.OwnerId
                                    });
                                    sb.AppendLine($"{Formatter.Bold(chicken.Name)} died!");
                                }
                            }

                            await db.SaveChangesAsync();
                        }

                        await this.InformAsync(ctx, StaticDiscordEmoji.Chicken, $"{Formatter.Bold(ambush.Team1Won ? ambush.Team1Name : ambush.Team2Name)} won!\n\n{sb.ToString()}");
                    }
                } finally {
                    this.Shared.UnregisterEventInChannel(ctx.Channel.Id);
                }
            }
Пример #32
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.Human:
            //entity = new PlayerMob("test", world, );
            //	break;
            default:
                return(null);
            }

            return(entity);
        }
Пример #33
0
 public static void Main()
 {
     Chicken chicken = new Chicken("Mara", 3);
     Console.WriteLine(chicken.Name);
 }
Пример #34
0
 public HenAdapter(Chicken chicken)
 {
     this.chicken = chicken;
 }
Пример #35
0
 public ChickenWrapper(object chick)
 {
     this.chick = chick as Chicken;
 }
Пример #36
0
 public ChickenWindow(Chicken chicken, FarmContext context) : this()
 {
     DataContext = new ChickenViewModel(chicken, context);
 } // ctorf.
Пример #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 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.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();
        }
Пример #38
0
 public override void OnAwake()
 {
     _chicken = GetComponent <Chicken>();
 }
Пример #39
0
 protected void OnTriggerEnter2D(Collider2D other)
 {
     Chicken c = other.GetComponent<Chicken>();
     if (c != null)
     {
         c.BlockMovement();
         _caughtChickenRigidbody = c.GetComponent<Rigidbody2D>();
         c.transform.position = ChickenPosition.position;
         _caughtChicken = c;
     }
 }
 public static void Main(string[] args)
 {
     var chicken1     = new Chicken();
     var egg          = chicken1.Lay();
     var childChicken = egg.Hatch();
 }
        public static void Main(string[] args)
        {
            Type chickenType = typeof(Chicken);
            FieldInfo[] fields = chickenType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo[] methods = chickenType.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
            Debug.Assert(fields.Where(f => f.IsPrivate).Count() == 2);
            Debug.Assert(methods.Where(m => m.IsPrivate).Count() == 1);

            string name = Console.ReadLine();
            int age = int.Parse(Console.ReadLine());

            try
            {
                Chicken chicken = new Chicken(name, age);
                Console.WriteLine(
                    "Chicken {0} (age {1}) can produce {2} eggs per day.",
                    chicken.Name,
                    chicken.Age,
                    chicken.GetProductPerDay());
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }