Example #1
0
        public static void playWithAnimals()
        {
            var imbirchik = new Hedgehog();

            imbirchik.MakeFunnySound();

            var toree = new Parrot();

            toree.MakeFunnySound();
        }
Example #2
0
        public Ground(int row, int col)
        {
            Row = row;
            Col = col;
            AmountHerbivorous = 1500;
            AmountPredator    = 1500;
            AmountOmnivorous  = 1500;
            AmountHuman       = 750;
            Field             = new Square[Row, Col];
            AmountGrass       = 1251;
            AmountHouses      = 250;

            Predators = new List <Mob <IPredatorFood> >();

            Herbivorouses = new List <Mob <IHerbivorousFood> >();

            Omnivorouses = new List <Mob <IOmnivorousFood> >();

            Humans = new List <Human>();

            AllGrass = new List <Grass>();

            Houses = new List <House>();

            for (var x = 0; x < Col; x++)
            {
                for (var y = 0; y < Row; y++)
                {
                    Field[x, y] = new Square();
                }
            }

            for (var i = 0; i < AmountHerbivorous; i++)
            {
                int randX = Rnd.Next(1000), randY = Rnd.Next(1000);
                Mob <IHerbivorousFood> cr;
                if (i < AmountHerbivorous / 3)
                {
                    cr = new Deer(this, randX, randY);
                }
                else if (i < (AmountHerbivorous / 3) * 2)
                {
                    cr = new Sheep(this, randX, randY);
                }
                else
                {
                    cr = new Rabbit(this, randX, randY);
                }
                Herbivorouses.Add(cr);
                Field[randX, randY].Objects.Add(cr);
            }

            for (var i = 0; i < AmountPredator; i++)
            {
                int randX = Rnd.Next(1000), randY = Rnd.Next(1000);
                Mob <IPredatorFood> cr;
                if (i < AmountHerbivorous / 3)
                {
                    cr = new Cat(this, randX, randY);
                }
                else if (i < (AmountHerbivorous / 3) * 2)
                {
                    cr = new Wolverine(this, randX, randY);
                }
                else
                {
                    cr = new Wolf(this, randX, randY);
                }
                Predators.Add(cr);
                Field[randX, randY].Objects.Add(cr);
            }

            for (var i = 0; i < AmountOmnivorous; i++)
            {
                int randX = Rnd.Next(1000), randY = Rnd.Next(1000);
                Mob <IOmnivorousFood> cr;
                if (i < AmountOmnivorous / 3)
                {
                    cr = new Bear(this, randX, randY);
                }
                else if (i < (AmountOmnivorous / 3) * 2)
                {
                    cr = new Dog(this, randX, randY);
                }
                else
                {
                    cr = new Hedgehog(this, randX, randY);
                }
                Omnivorouses.Add(cr);
                Field[randX, randY].Objects.Add(cr);
            }
            for (var i = 0; i < AmountHuman; i++)
            {
                int randX = Rnd.Next(1000), randY = Rnd.Next(1000);
                var cr = new Human(this, randX, randY);
                Humans.Add(cr);
                Field[randX, randY].Objects.Add(cr);
            }

            for (var i = 0; i < AmountHouses; i++)
            {
                int randX = Rnd.Next(1000), randY = Rnd.Next(1000);
                var cr = new House(this, randX, randY);
                Houses.Add(cr);
                Field[randX, randY].Objects.Add(cr);
            }

            for (var i = 0; i < AmountGrass; i++)
            {
                int   randX = Rnd.Next(1000), randY = Rnd.Next(1000);
                Grass cr;
                if (i < AmountGrass / 3)
                {
                    cr = new Oats(this, randX, randY);
                }
                else if (i < (AmountGrass / 3) * 2)
                {
                    cr = new Carrot(this, randX, randY);
                }
                else
                {
                    cr = new GreenGrass(this, randX, randY);
                }
                AllGrass.Add(cr);
                Field[randX, randY].Objects.Add(cr);
            }
        }
Example #3
0
        private void InitializeUnits()
        {
            AbstractUnit.GlobalMap = this;

            for (int i = 0; i < _numOfUnits;)
            {
                int newX = Rand.Next(Height);
                int newY = Rand.Next(Width);


                AbstractUnit newOne = new BearUnit(newX, newY);

                var type = Rand.Next(4);

                switch (type)
                {
                case 0: newOne = new BearUnit(newX, newY);
                    break;

                case 1: newOne = new Hedgehog(newX, newY);
                    break;

                case 2: newOne = new Pig(newX, newY);
                    break;

                case 3: newOne = new Human(newX, newY);
                    break;
                }

                Field[newX, newY].Entity.Add(newOne);

                Entity.Add(newOne);
                ChangedCell.Add(Field[newX, newY]);

                i++;
            }

            for (int i = 0; i < _numOfUnits;)
            {
                int newX = Rand.Next(Height);
                int newY = Rand.Next(Width);

                if (Field[newX, newY].Entity.FirstOrDefault() == null)
                {
                    AbstractUnit newOne = new Deer(newX, newY);

                    var type = Rand.Next(3);

                    switch (type)
                    {
                    case 0: newOne = new Deer(newX, newY);
                        break;

                    case 1: newOne = new Rabbit(newX, newY);
                        break;

                    case 2: newOne = new Rat(newX, newY);
                        break;
                    }

                    Field[newX, newY].Entity.Add(newOne);

                    Entity.Add(newOne);
                    ChangedCell.Add(Field[newX, newY]);

                    i++;
                }
            }

            for (int i = 0; i < _numOfUnits;)
            {
                int newX = Rand.Next(Height);
                int newY = Rand.Next(Width);

                if (Field[newX, newY].Entity.FirstOrDefault() == null)
                {
                    AbstractUnit newOne = new Fox(newX, newY);

                    var type = Rand.Next(3);

                    switch (type)
                    {
                    case 0: newOne = new Fox(newX, newY);
                        break;

                    case 1: newOne = new Wolf(newX, newY);
                        break;

                    case 2: newOne = new Wolverine(newX, newY);
                        break;
                    }

                    Field[newX, newY].Entity.Add(newOne);

                    Entity.Add(newOne);
                    ChangedCell.Add(Field[newX, newY]);

                    i++;
                }
            }
        }
    public Enemy AddEnemyEntity(EnemyData data)
    {
        EnemyPrototype proto = EnemyDatabase.GetEnemyPrototype(data.type);

        if (proto == null)
        {
            return(null);
        }
        Enemy temp = null;

        switch (proto.enemyType)
        {
        case EnemyType.Slime:
            temp = new Slime(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Eye:
            temp = new Eye(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.WurmAlien:
            temp = new WurmAlien(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Snek:
            temp = new Snek(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Stag:
            temp = new Stag(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Snowball:
            temp = new Snowball(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Sporby:
            temp = new Sporby(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Voidling:
            temp = new Voidling(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Ghost:
            temp = new Ghost(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Snowdrift:
            temp = new Snowdrift(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Treedude:
            temp = new Treedude(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.FrogLegs:
            temp = new FrogLegs(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Hedgehog:
            temp = new Hedgehog(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Nest:
            temp = new Nest(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Crawler:
            temp = new Crawler(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Nipper:
            temp = new Nipper(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.PhoenixEgg:
            temp = new PhoenixEgg(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;
        }

        return(temp);
    }