Example #1
0
 public Upgrade(Vars_Func.UpgradeTyp typ, Vector2 position, Environment.Hexagon hex, Environment.Map map)
 {
     thingTyp      = Vars_Func.ThingTyp.Upgrade;
     this.typ      = typ;
     this.position = position;
     hex.Obj       = this;
     hex.Building  = true;
     for (int i = 0; i < 6; ++i)
     {
         Vector2 neighbor = hex.Neighbors[i];
         map.getHexagonAt(neighbor).Building = true;
     }
 }
Example #2
0
        public void addUpgrade(Vars_Func.UpgradeTyp typ, Vector2 position, Environment.Hexagon hex, Environment.Map map)
        {
            upgrades.Add(new Upgrade(typ, position, hex, map));
            switch (typ)
            {
            case Vars_Func.UpgradeTyp.Damage:
                ++upgradeCount[0];
                break;

            case Vars_Func.UpgradeTyp.Life:
                ++upgradeCount[1];
                break;

            case Vars_Func.UpgradeTyp.Speed:
                ++upgradeCount[2];
                break;
            }
        }
Example #3
0
        public Nest(Vars_Func.NestTyp typ, Vector2 position, Environment.Map map, Vector2 targetPosition)
        {
            nextUpgradeCost = 100;
            Environment.Hexagon hex = map.getHexagonAt(position);
            if (typ != Vars_Func.NestTyp.Entrance)
            {
                map.Rooms.ElementAt(map.getHexagonAt(position).RoomNumber - 1).NestType   = typ;
                map.Rooms.ElementAt(map.getHexagonAt(position).RoomNumber - 1).RoomObject = this;
            }
            possibleNextNestHexagons = new List <Vector2>();
            nestHexagons             = new List <Vector2>();
            nestHexagons.Add(position);
            switch (typ)
            {
            case Vars_Func.NestTyp.Entrance:
                hex.Building = true;
                hex.Nest     = true;
                map.Entrances.Add(this);
                hex.IsEntrance = true;
                hex.EnlightendHexagon(map);
                map.Light = Vars_Func.getEntranceRayModel();
                thingTyp  = Vars_Func.ThingTyp.Nest;
                break;

            case Vars_Func.NestTyp.Beetle:
                hex.Typ      = Vars_Func.HexTyp.BeetleNest;
                hex.Building = true;
                hex.Nest     = true;
                getsFeeded   = false;
                maxNutrition = 500f;
                nutrition    = 0f;
                upgrades     = new List <Upgrade>();
                thingTyp     = Vars_Func.ThingTyp.Nest;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ      = Vars_Func.HexTyp.BeetleNest;
                    map.getHexagonAt(neighbor).Building = true;
                    map.getHexagonAt(neighbor).Nest     = true;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Nests.Add(this);
                break;

            case Vars_Func.NestTyp.Skeleton:
                hex.Typ      = Vars_Func.HexTyp.Graveyard;
                hex.Building = true;
                hex.Nest     = true;
                getsFeeded   = false;
                maxNutrition = 500f;
                nutrition    = 0f;
                upgrades     = new List <Upgrade>();
                thingTyp     = Vars_Func.ThingTyp.Nest;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ        = Vars_Func.HexTyp.Graveyard;
                    map.getHexagonAt(neighbor).Building   = true;
                    map.getHexagonAt(neighbor).Nest       = true;
                    map.getHexagonAt(neighbor).GrowObject = Vars_Func.GrowObject.Graveyard;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Nests.Add(this);
                break;

            case Vars_Func.NestTyp.Farm:
                hex.Typ       = Vars_Func.HexTyp.Farm;
                hex.Building  = true;
                hex.Nest      = true;
                nutrition     = 1;
                maxNutrition  = 1;
                thingTyp      = Vars_Func.ThingTyp.Nest;
                food          = 0;
                getsHarvested = false;
                foodCounter   = 0;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ        = Vars_Func.HexTyp.Farm;
                    map.getHexagonAt(neighbor).Building   = true;
                    map.getHexagonAt(neighbor).Nest       = true;
                    map.getHexagonAt(neighbor).GrowObject = Vars_Func.GrowObject.Farm;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Farms.Add(this);
                break;

            case Vars_Func.NestTyp.Temple:
                hex.Typ      = Vars_Func.HexTyp.Temple;
                hex.Building = true;
                hex.Nest     = true;
                nutrition    = 1;
                maxNutrition = 1;
                thingTyp     = Vars_Func.ThingTyp.Nest;
                foodCounter  = 0;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ        = Vars_Func.HexTyp.Temple;
                    map.getHexagonAt(neighbor).Building   = true;
                    map.getHexagonAt(neighbor).Nest       = true;
                    map.getHexagonAt(neighbor).GrowObject = Vars_Func.GrowObject.Temple;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Temples.Add(this);
                break;
            }
            this.typ            = typ;
            this.position       = position;
            this.targetPosition = targetPosition;
            hex.Obj             = this;
        }
Example #4
0
        override public void update(GameTime gameTime, Environment.Map map)
        {
            map.getHexagonAt(this.position).Obj = this;
            growCounter  += gameTime.ElapsedGameTime.Milliseconds;
            spawnCounter += gameTime.ElapsedGameTime.Milliseconds;
            foodCounter  += gameTime.ElapsedGameTime.Milliseconds;
            //update a nest
            if (this.typ != Vars_Func.NestTyp.Entrance)
            {
                //timer for growth of the nest
                if (growCounter > 10000 && nutrition > 0)
                {
                    if (possibleNextNestHexagons.Count != 0)
                    {
                        Random  rand = new Random();
                        int     tmp  = rand.Next(possibleNextNestHexagons.Count);
                        Vector2 pos  = possibleNextNestHexagons[tmp];
                        nestHexagons.Add(pos);
                        Environment.Hexagon hex = map.getHexagonAt(pos);
                        switch (typ)
                        {
                        case Vars_Func.NestTyp.Beetle:
                            hex.Typ = Vars_Func.HexTyp.BeetleNest;
                            break;

                        case Vars_Func.NestTyp.Skeleton:
                            hex.Typ        = Vars_Func.HexTyp.Graveyard;
                            hex.GrowObject = Vars_Func.GrowObject.Graveyard;
                            break;

                        case Vars_Func.NestTyp.Farm:
                            hex.Typ        = Vars_Func.HexTyp.Farm;
                            hex.GrowObject = Vars_Func.GrowObject.Farm;
                            break;

                        case Vars_Func.NestTyp.Temple:
                            hex.Typ        = Vars_Func.HexTyp.Temple;
                            hex.GrowObject = Vars_Func.GrowObject.Temple;
                            break;
                        }
                        hex.Nest = true;
                        for (int i = 0; i < 6; ++i)
                        {
                            Vector2 nextNeighbor = map.getHexagonAt(pos).Neighbors[i];
                            if (!map.getHexagonAt(nextNeighbor).Nest&& map.getHexagonAt(nextNeighbor).RoomNumber == hex.RoomNumber && !possibleNextNestHexagons.Contains(nextNeighbor))
                            {
                                possibleNextNestHexagons.Add(nextNeighbor);
                            }
                        }
                        possibleNextNestHexagons.RemoveAt(tmp);
                    }
                    growCounter = 0;
                }
                if (this.typ == Vars_Func.NestTyp.Temple)
                {
                    foodCounter += gameTime.ElapsedGameTime.Milliseconds;

                    if (foodCounter > 10000 / this.nestHexagons.Count)
                    {
                        Player.Mana++;
                        foodCounter = 0;
                    }
                }
                else if (this.typ == Vars_Func.NestTyp.Farm)
                {
                    foodCounter += gameTime.ElapsedGameTime.Milliseconds;

                    if (foodCounter > 10000 / this.nestHexagons.Count)
                    {
                        food++;
                        foodCounter = 0;
                        if (food >= 100 && getsHarvested == false)
                        {
                            getsHarvested = true;
                            map.JobsWaiting.Enqueue(new Logic.Job(Logic.Vars_Func.ImpJob.Harvest, position));
                        }
                    }
                }
                else
                {
                    //timer to decrease the nutrition of the nest
                    if (foodCounter > 1000)
                    {
                        decreaseNutrition(1.0f);
                        foodCounter = 0;
                        if (nutrition < 0.4 * maxNutrition && getsFeeded == false)
                        {
                            getsFeeded = true;
                            map.JobsWaiting.Enqueue(new Job(Vars_Func.ImpJob.Feed, position));
                        }
                    }
                    //timer to spawn creatures
                    if (spawnCounter > Math.Max(10000, (250000 / nestHexagons.Count)) && nutrition > 0)
                    {
                        spawnCreature(map);
                        spawnCounter = 0;
                    }
                }
            }
            ////update an entrance
            //else
            //{
            //    //timer to spawn heroes
            //    if (spawnCounter > 5000)
            //    {
            //        spawnCreature(map);
            //        spawnCounter = 0;
            //    }
            //}
        }