示例#1
0
        public void endJob(Environment.Map map)
        {
            switch (jobTyp)
            {
            case Vars_Func.ImpJob.Harvest:
                ((Entity.Nest)(map.getHexagonAt(destination).Obj)).GetsHarvested = false;
                break;

            case Vars_Func.ImpJob.Feed:
                ((Entity.Nest)(map.getHexagonAt(destination).Obj)).GetsFedded = false;
                break;

            case Vars_Func.ImpJob.Mine:
                map.MineJobs.Remove(destination);
                map.getHexagonAt(destination).Obj = null;
                break;

            case Vars_Func.ImpJob.MineDiamonds:
                break;

            case Vars_Func.ImpJob.MineGold:
                map.MineJobs.Remove(destination);
                map.getHexagonAt(destination).Obj = null;
                break;
            }
            map.JobsDone.Remove(this);
        }
示例#2
0
 public static void resetHexagonColors(Environment.Map map)
 {
     foreach (Environment.Hexagon hex in map.getMapHexagons())
     {
         hex.Color = Color.White;
     }
     //colors the room-hexagons in CreateRoom mode, MergeRooms mode, DeleteRoom mode, Build  mode, BuildUpgrade mode
     if (Interaction.GameState == Vars_Func.GameState.CreateRoom ||
         Interaction.GameState == Vars_Func.GameState.MergeRooms ||
         Interaction.GameState == Vars_Func.GameState.DeleteRoom ||
         Interaction.GameState == Vars_Func.GameState.Build ||
         Interaction.GameState == Vars_Func.GameState.BuildUpgrade ||
         Interaction.GameState == Vars_Func.GameState.PlaceAnts ||
         Interaction.GameState == Vars_Func.GameState.PlaceSkeletons ||
         Interaction.GameState == Vars_Func.GameState.PlaceFarm ||
         Interaction.GameState == Vars_Func.GameState.PlaceTemple ||
         Interaction.GameState == Vars_Func.GameState.PlaceEntrance)
     {
         foreach (Environment.Hexagon hex in map.getMapHexagons())
         {
             if (hex.RoomNumber == 0)
             {
             }
             else if (hex.RoomNumber % 6 == 0)
             {
                 hex.Color = Color.Red;
             }
             else if (hex.RoomNumber % 6 == 1)
             {
                 hex.Color = Color.Yellow;
             }
             else if (hex.RoomNumber % 6 == 2)
             {
                 hex.Color = Color.Blue;
             }
             else if (hex.RoomNumber % 6 == 3)
             {
                 hex.Color = Color.Black;
             }
             else if (hex.RoomNumber % 6 == 4)
             {
                 hex.Color = Color.Green;
             }
             else if (hex.RoomNumber % 6 == 5)
             {
                 hex.Color = Color.Purple;
             }
         }
     }
     //colors the hexagons which are in the mineJobs list
     else if (Interaction.GameState == Vars_Func.GameState.Mine)
     {
         foreach (Vector2 pos in map.MineJobs)
         {
             map.getHexagonAt(pos).Color = Color.Purple;
         }
     }
 }
示例#3
0
        static private void randomwalk(Creature creature, Environment.Map map)
        {
            //random determination of next step
            int random = (int)rand.Next(6);

            if (map.getHexagonAt(map.getHexagonAt(creature.Position).Neighbors[random]).Obj == null)
            {
                creature.Path.Push(map.getHexagonAt(creature.Position).Neighbors[random]);
            }
        }
 public static void update(GameTime gameTime, Environment.Map map)
 {
     timeCounter += gameTime.ElapsedGameTime.Milliseconds;
     if (timeCounter >= interWaveTime)
     {
         map.Waves.Add(new Wave(waveCounter * 10, (int)(5 + waveCounter / 3)));
         ++waveCounter;
         timeCounter  -= interWaveTime;
         interWaveTime = Math.Max(interWaveTime - (60000 * 2.0f), 60000);
     }
 }
示例#5
0
 public Wall(Vector2 indexPosition, Vars_Func.WallTyp typ, int hp, Environment.Map map)
 {
     thingTyp           = Vars_Func.ThingTyp.Wall;
     this.indexPosition = indexPosition;
     this.typ           = typ;
     this.hp            = hp;
     this.initHP        = hp;
     map.getHexagonAt(indexPosition).Obj = this;
     if (typ == Vars_Func.WallTyp.Gold)
     {
         gold = 100;
     }
     //boneTransforms = new Matrix[Entity.Vars_Func.getWallModell(typ).Model.Bones.Count];
 }
示例#6
0
        static private void randomwalk(Imp imp, Environment.Map map)
        {
            //random determination of next step
            int random = (int)rand.Next(6);

            if (map.getHexagonAt(map.getHexagonAt(imp.Position).Neighbors[random]).Obj == null ||
                map.getHexagonAt(map.getHexagonAt(imp.Position).Neighbors[random]).Obj.getThingTyp() != Vars_Func.ThingTyp.Wall)
            {
                if (imp.Path == null)
                {
                    imp.Path = new Stack <Vector2>();
                }
                imp.Path.Push(map.getHexagonAt(imp.Position).Neighbors[random]);
            }
        }
示例#7
0
        override public void update(GameTime time, Environment.Map map)
        {
            AI.compute(this, time, map);

            if (tempPosition != currentHex.getDrawPosition())
            {
                positionLerpCounter += (float)time.ElapsedGameTime.Milliseconds;
                if ((positionLerpCounter / 500) > 1)
                {
                    positionLerpCounter = 500;
                }
                tempPosition = Vector3.Lerp(oldHex.getDrawPosition(), currentHex.getDrawPosition(), (positionLerpCounter / 500));
                degree       = this.Rotate(oldHex.getDrawPosition(), currentHex.getDrawPosition());
            }
            this.UpdateState(time);
            this.model.Update(time);
        }
示例#8
0
        public static int computeDistance(Vector2 pos1, Vector2 pos2, Environment.Map map)
        {
            //return statement
            int distanz = 0;

            //breadth-first search
            Vector2         tmp   = new Vector2();
            Queue <Vector2> queue = new Queue <Vector2>();

            queue.Enqueue(pos1);
            map.getHexagonAt(pos1).Visited = true;
            queue.Enqueue(new Vector2(map.getPlanelength(), 0));

            while (queue.Count != 1)
            {
                tmp = queue.Dequeue();
                if (tmp == pos2)
                {
                    break;
                }
                if (tmp.X == map.getPlanelength())
                {
                    ++distanz;
                    queue.Enqueue(tmp);
                    continue;
                }
                foreach (Vector2 hex in map.getHexagonAt(tmp).Neighbors)
                {
                    if (!map.getHexagonAt(hex).Visited)
                    {
                        queue.Enqueue(hex);
                        map.getHexagonAt(hex).Visited = true;
                    }
                }
            }
            //clear Hexmap for next search
            for (int i = 0; i < map.getPlanelength(); ++i)
            {
                for (int j = 0; j < map.getPlanelength(); ++j)
                {
                    map.getHexagonAt(i, j).Visited = false;
                }
            }

            return(distanz);
        }
示例#9
0
        public void Update(GameTime time, Environment.Map map, MouseState mouseState)
        {
            // Set color when element is disabled
            if (!enabled)
            {
                spriteColor = Color.SteelBlue;
                if (frameElement != null)
                {
                    frameElement.SpriteColor = Color.SteelBlue;
                }
            }
            else
            {
                if (frameElement != null)
                {
                    frameElement.SpriteColor = Color.White;
                }
                // Set the right color
                this.SetColor(mouseState);
                // Set selection
                this.SetSelection(mouseState);
            }
            // Move children
            if (move)
            {
                this.MoveForward(time);
            }
            else
            {
                this.MoveBackward(time);
            }

            if (positionLerpCounter > 0)
            {
                foreach (GUI_Element c in childElements)
                {
                    this.UpdatePosition(c);
                }
            }

            // Update children
            foreach (GUI_Element c in childElements)
            {
                c.Update(time, map, mouseState);
            }
        }
示例#10
0
        override public void update(GameTime time, Environment.Map map)
        {
            AI.compute(this, time, map);
            if (thingTyp == Logic.Vars_Func.ThingTyp.DungeonCreature && age > maxAge)
            {
                map.DyingCreatures.Add(this);
            }
            age += (float)time.ElapsedGameTime.Milliseconds / 1000;
            ageing();

            if (typ != Vars_Func.CreatureTyp.HQCreatur)
            {
                if (tempPosition != currentHex.getDrawPosition())
                {
                    positionLerpCounter += (float)time.ElapsedGameTime.Milliseconds;
                    if ((positionLerpCounter / (1000 * 1 / speed)) > 1)
                    {
                        positionLerpCounter = (1000 * 1 / speed);
                    }
                    tempPosition = Vector3.Lerp(oldHex.getDrawPosition(), currentHex.getDrawPosition(), (positionLerpCounter / (1000 * 1 / speed)));
                    degree       = this.Rotate(oldHex.getDrawPosition(), currentHex.getDrawPosition());
                }
                this.UpdateState(time);
                this.model.Update(time);
            }
            else
            {
                if (currentState == Vars_Func.CreatureState.OpenMouth && (positionLerpCounter / (1000 * 1 / speed)) < 1)
                {
                    positionLerpCounter += (float)time.ElapsedGameTime.Milliseconds;
                    tempZ = positionLerpCounter / (500 * 1 / speed) * 0.3f;
                }
                else if (currentState == Vars_Func.CreatureState.CloseMouth && (positionLerpCounter / (500 * 1 / speed)) > 0)
                {
                    positionLerpCounter -= (float)time.ElapsedGameTime.Milliseconds;
                    tempZ = positionLerpCounter / (500 * 1 / speed) * 0.3f;
                }
                else if (currentState == Vars_Func.CreatureState.PingPong)
                {
                    positionLerpCounter += (float)time.ElapsedGameTime.Milliseconds;
                    tempZ = ((float)(0.5f * Math.Cos(positionLerpCounter / 500 * (1 / speed) + MathHelper.PiOver2)) + 0.5f) * 0.3f;
                }
            }
        }
示例#11
0
        public void update(GameTime gameTime, Environment.Map map)
        {
            spawncounter += gameTime.ElapsedGameTime.Milliseconds;

            if (spawncounter >= 1500)
            {
                foreach (Entity.Nest e in map.Entrances)
                {
                    e.spawnCreature(map, startage);
                }
                --numberEnemys;
                spawncounter = 0;

                if (numberEnemys <= 0)
                {
                    map.EndedWaves.Add(this);
                }
            }
        }
示例#12
0
 public Imp(Vector2 position, Environment.Map map)
 {
     actionTimeCounter = 0;
     hp            = 100;
     damage        = 0;
     thingTyp      = Vars_Func.ThingTyp.Imp;
     this.position = position;
     path          = new Stack <Vector2>();
     map.getHexagonAt(position).Imps.Add(this);
     map.ImpList.Add(this);
     currentJob         = new Job(Vars_Func.ImpJob.Idle);
     this.model         = new CharacterModel(Vars_Func.getImpModell().Model, Vars_Func.getImpModell().AnimationClip);
     updatePlayer       = true;
     currentHex         = map.getHexagonAt(position);
     oldHex             = map.getHexagonAt(position);
     targetHex          = null;
     animationSpeeds    = new float[4];
     animationSpeeds[0] = 2;
     animationSpeeds[1] = 1;
     animationSpeeds[2] = 1;
     animationSpeeds[3] = 1;
 }
示例#13
0
 abstract public void update(GameTime gameTime, Environment.Map map);
示例#14
0
        static public void compute(Creature creature, GameTime time, Environment.Map map)
        {
            // time for creatur to act and none HQcreature?
            if (creature.ActionTimeCounter >= 1000 / creature.Speed && creature.getThingTyp() != Vars_Func.ThingTyp.HQCreature)
            {
                Vector2 nearestEnemy = computeNearestEnemy(creature, map);
                if (creature.Path == null)
                {
                    creature.Path = new Stack <Vector2>();
                }
                // neutral creatures only randomwalk
                if (creature.getThingTyp() == Vars_Func.ThingTyp.NeutralCreature)
                {
                    randomwalk(creature, map);
                }
                // walk to nearest Enemy and attack if there is one
                else if (nearestEnemy.X != map.getPlanelength())
                {
                    if (map.getHexagonAt(creature.Position).Neighbors.Contains(nearestEnemy))
                    {
                        if (creature.ActionTimeCounter >= 1000 / creature.Speed)
                        {
                            // attack creature
                            if (map.getHexagonAt(nearestEnemy).Obj != null)
                            {
                                creature.State         = Vars_Func.CreatureState.Fighting;
                                creature.TargetHexagon = map.getHexagonAt(nearestEnemy);

                                Creature target = (Creature)map.getHexagonAt(nearestEnemy).Obj;
                                creature.TargetPosition = target.TempDrawPositon;
                                target.takeDamage(creature.Damage);
                                if (target.DamageTaken >= target.HP)
                                {
                                    map.DyingCreatures.Add(target);
                                }
                                creature.ActionTimeCounter = 0;
                            }
                            //// attack imp
                            //else
                            //{
                            //    Imp target = map.getHexagonAt(nearestEnemy).Imps[0];
                            //    target.takeDamage(creature.Damage);
                            //    if (target.DamageTaken >= target.HP) map.remove(target);
                            //    creature.ActionTimeCounter = 0;
                            //}
                        }
                    }
                    // serach path
                    else
                    {
                        creature.Path = determinePath(creature.Position, map.getHexagonAt(nearestEnemy).Neighbors, map, false);
                    }
                }

                // calculate path if creature has none
                else if (creature.Path.Count == 0)
                {
                    if (Logic.Vars_Func.computeDistance(creature.Home.TargetPosition, creature.Position, map) < 5)
                    {
                        randomwalk(creature, map);
                    }
                    else
                    {
                        creature.Path = determinePath(creature.Position, creature.Home.TargetPosition, map);
                    }
                    //// herocreature found no path and so burrow throug walls
                    //if (creature.Path == null && creature.getThingTyp() == Vars_Func.ThingTyp.HeroCreature)
                    //    creature.Path = determinePath(creature.Position, creature.Home.TargetPosition, map, true, true);
                }

                // time left for action?
                if (creature.ActionTimeCounter >= 1000 / creature.Speed)
                {
                    creature.State = Vars_Func.CreatureState.Walking;
                    map.move(creature);
                    if (creature.Path == null)
                    {
                        foreach (Vector2 v in map.getHexagonAt(creature.Position).Neighbors)
                        {
                            if (map.getHexagonAt(v).Obj == null)
                            {
                                creature.Path = new Stack <Vector2>();
                                creature.Path.Push(v);
                                map.move(creature);
                                break;
                            }
                        }
                    }
                }
                creature.ActionTimeCounter = 0;
            }
            creature.ActionTimeCounter += time.ElapsedGameTime.Milliseconds;
        }
示例#15
0
        public void updateJob(Environment.Map map, Entity.Imp imp)
        {
            imp.CurrentJob.Worktime -= imp.ActionTimeCounter;
            imp.ActionTimeCounter    = 0;

            switch (jobTyp)
            {
            case Vars_Func.ImpJob.Harvest:
                Player.Food += Math.Min(20, ((Entity.Nest)map.getHexagonAt(destination).Obj).Food);
                ((Entity.Nest)map.getHexagonAt(destination).Obj).Food -= Math.Min(20, ((Entity.Nest)map.getHexagonAt(destination).Obj).Food);

                if (((Entity.Nest)map.getHexagonAt(destination).Obj).Food <= 0)
                {
                    map.JobsDone.Add(this);
                    map.JobsInProgress.Remove(this);
                    imp.CurrentJob = new Job(Vars_Func.ImpJob.Idle);
                }
                break;

            case Vars_Func.ImpJob.Feed:
                int feedvalue = (int)Math.Min(10, ((Entity.Nest)map.getHexagonAt(destination).Obj).MaxNutrition - ((Entity.Nest)map.getHexagonAt(destination).Obj).Nutrition);
                if (Player.enoughFood(feedvalue))
                {
                    Player.Food -= feedvalue;
                    ((Entity.Nest)map.getHexagonAt(destination).Obj).increaseNutrition(feedvalue);
                }

                if (((Entity.Nest)map.getHexagonAt(destination).Obj).Nutrition == ((Entity.Nest)map.getHexagonAt(destination).Obj).MaxNutrition)
                {
                    map.JobsDone.Add(this);
                    map.JobsInProgress.Remove(this);
                    imp.CurrentJob = new Job(Vars_Func.ImpJob.Idle);
                }
                break;

            case Vars_Func.ImpJob.Mine:
                Entity.Wall wall = ((Entity.Wall)map.getHexagonAt(destination).Obj);
                wall.HP -= 10;
                if (wall.HP <= 0)
                {
                    map.JobsDone.Add(this);
                    map.JobsInProgress.Remove(this);
                    imp.CurrentJob = new Job(Vars_Func.ImpJob.Idle);
                }
                break;

            case Vars_Func.ImpJob.MineDiamonds:
                Player.Gold += 2;
                break;

            case Vars_Func.ImpJob.MineGold:
                Entity.Wall goldWall = ((Entity.Wall)map.getHexagonAt(destination).Obj);
                goldWall.HP -= 5;
                if (goldWall.Gold > 0)
                {
                    Player.Gold   += Math.Min(5, goldWall.Gold);
                    goldWall.Gold -= Math.Min(5, goldWall.Gold);
                }
                if (goldWall.HP <= 0)
                {
                    Player.Gold += goldWall.Gold;
                    map.JobsDone.Add(this);
                    map.JobsInProgress.Remove(this);
                    imp.CurrentJob = new Job(Vars_Func.ImpJob.Idle);
                }
                break;
            }
        }
示例#16
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;
            //    }
            //}
        }
示例#17
0
        static private Stack <Vector2> determinePath(Vector2 start, List <Vector2> destination, Environment.Map map, bool ignoreCreatures = true, bool ignoreWalls = false)
        {
            //return statement
            Stack <Vector2> path = new Stack <Vector2>();

            //breadth-first search
            Vector2         tmp   = new Vector2();
            Queue <Vector2> queue = new Queue <Vector2>();

            queue.Enqueue(start);
            map.getHexagonAt(start).Visited = true;

            while (queue.Count != 0)
            {
                tmp = queue.Dequeue();
                if (destination.Contains(tmp))
                {
                    break;
                }
                foreach (Vector2 hex in map.getHexagonAt(tmp).Neighbors)
                {
                    // is the hex a not wall objekt?
                    if (!map.getHexagonAt(hex).Visited&& (map.getHexagonAt(hex).Obj == null || (destination.Contains(hex)) ||
                                                          ((map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.Wall || ignoreWalls) &&
                                                           (map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.DungeonCreature || ignoreCreatures) &&
                                                           (map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.HeroCreature || ignoreCreatures) &&
                                                           (map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.NeutralCreature || ignoreCreatures) &&
                                                           map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.Nest && map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.Upgrade &&
                                                           (map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.HQCreature || (map.getHexagonAt(start).Obj != null && map.getHexagonAt(start).Obj.getThingTyp() == Vars_Func.ThingTyp.HeroCreature))
                                                          )))
                    {
                        queue.Enqueue(hex);
                        map.getHexagonAt(hex).Visited = true;
                        map.getHexagonAt(hex).Parent  = tmp;
                    }
                }
            }

            //push path on stack
            if (!destination.Contains(tmp))
            {
                path = null;
            }
            else
            {
                while (tmp != start)
                {
                    path.Push(tmp);
                    tmp = map.getHexagonAt(tmp).Parent;
                }
            }
            //clear Hexmap for next search
            for (int i = 0; i < map.getPlanelength(); ++i)
            {
                for (int j = 0; j < map.getPlanelength(); ++j)
                {
                    map.getHexagonAt(i, j).Visited = false;
                    map.getHexagonAt(i, j).Parent  = new Vector2(i, j);
                }
            }
            return(path);
        }
示例#18
0
        static private Stack <Vector2> determinePath(Vector2 start, Vector2[] destination, Environment.Map map, bool ignoreCreatures = true, bool ignoreWalls = false)
        {
            List <Vector2> des = new List <Vector2>();

            foreach (Vector2 vec in destination)
            {
                des.Add(vec);
            }
            return(determinePath(start, des, map, ignoreCreatures, ignoreWalls));
        }
示例#19
0
        static private Vector2 computeNearestEnemy(Creature creature, Environment.Map map)
        {
            //return statement
            Vector2 nearesEnemy = new Vector2(map.getPlanelength(), 0);

            //breadth-first search
            Vector2         tmp   = new Vector2();
            Queue <Vector2> queue = new Queue <Vector2>();

            queue.Enqueue(creature.Position);
            map.getHexagonAt(creature.Position).Visited = true;
            queue.Enqueue(new Vector2(map.getPlanelength(), creature.Vision));

            while (queue.Count != 1)
            {
                tmp = queue.Dequeue();

                if (tmp.X == map.getPlanelength())
                {
                    //is vision of creature reached?
                    if (tmp.Y <= 1)
                    {
                        break;
                    }
                    queue.Enqueue((new Vector2(tmp.X, tmp.Y - 1)));
                    continue;
                }
                //contains position an enemy creature?
                if (map.getHexagonAt(tmp).Obj != null &&
                    // Enemys can attack player creatures
                    (((/*map.getHexagonAt(tmp).Imps.Count > 0 || */ map.getHexagonAt(tmp).Obj.getThingTyp() == Vars_Func.ThingTyp.DungeonCreature ||
                       map.getHexagonAt(tmp).Obj.getThingTyp() == Vars_Func.ThingTyp.HQCreature) &&
                      (creature.getThingTyp() != Vars_Func.ThingTyp.HQCreature && creature.getThingTyp() != Vars_Func.ThingTyp.DungeonCreature)) ||
                     // everyone can attack neural and heroes expect themselfe
                     ((map.getHexagonAt(tmp).Obj.getThingTyp() == Vars_Func.ThingTyp.HeroCreature || map.getHexagonAt(tmp).Obj.getThingTyp() == Vars_Func.ThingTyp.NeutralCreature) &&
                      map.getHexagonAt(tmp).Obj.getThingTyp() != creature.getThingTyp())))
                {
                    nearesEnemy = tmp;
                    break;
                }

                foreach (Vector2 hex in map.getHexagonAt(tmp).Neighbors)
                {
                    // is the hex a not wall objekt?
                    if (!map.getHexagonAt(hex).Visited&& (map.getHexagonAt(hex).Obj == null || map.getHexagonAt(hex).Obj.getThingTyp() != Logic.Vars_Func.ThingTyp.Wall))
                    {
                        queue.Enqueue(hex);
                        map.getHexagonAt(hex).Visited = true;
                    }
                }
            }
            //clear Hexmap for next search
            for (int i = 0; i < map.getPlanelength(); ++i)
            {
                for (int j = 0; j < map.getPlanelength(); ++j)
                {
                    map.getHexagonAt(i, j).Visited = false;
                }
            }

            return(nearesEnemy);
        }
示例#20
0
        static public void compute(Imp imp, GameTime time, Environment.Map map)
        {
            if (imp.ActionTimeCounter >= 500)
            {
                //20 trys for jobsearch
                for (int i = 0; i < 20; ++i)
                {
                    if (imp.Path == null)
                    {
                        imp.Path = new Stack <Vector2>();
                    }
                    // search Job
                    if (imp.CurrentJob.JobTyp == Vars_Func.ImpJob.Idle)
                    {
                        //jobs there?
                        if (map.JobsWaiting.Count != 0)
                        {
                            imp.CurrentJob = map.JobsWaiting.Dequeue();
                            map.JobsInProgress.Add(imp.CurrentJob);
                        }
                    }
                    // search path to workplace
                    if (imp.Path.Count == 0 && imp.CurrentJob.JobTyp != Vars_Func.ImpJob.Idle)
                    {
                        imp.Path = determinePath(imp.Position, imp.CurrentJob.Destination, map);
                    }
                    //job not reachable enque job
                    if (imp.Path == null)
                    {
                        map.JobsInProgress.Remove(imp.CurrentJob);
                        map.JobsWaiting.Enqueue(imp.CurrentJob);
                        imp.CurrentJob = new Job(Vars_Func.ImpJob.Idle);
                    }
                    else
                    {
                        break;
                    }
                }
                // working
                if (imp.CurrentJob.JobTyp != Vars_Func.ImpJob.Idle && map.getHexagonAt(imp.Position).Neighbors.Contains(imp.CurrentJob.Destination))
                {
                    imp.CurrentJob.updateJob(map, imp);
                    imp.CurrentJob.Worktime -= time.ElapsedGameTime.Milliseconds;

                    switch (imp.CurrentJob.JobTyp)
                    {
                    case Vars_Func.ImpJob.Mine:
                    case Vars_Func.ImpJob.MineDiamonds:
                    case Vars_Func.ImpJob.MineGold:
                        //imp.ExternalTarget =
                        imp.State         = Vars_Func.ImpState.Digging;
                        imp.TargetHexagon = map.getHexagonAt(imp.CurrentJob.Destination);
                        break;

                    case Vars_Func.ImpJob.Harvest:
                        imp.State         = Vars_Func.ImpState.Harvesting;
                        imp.TargetHexagon = map.getHexagonAt(imp.CurrentJob.Destination);
                        break;
                    }

                    if (imp.CurrentJob.Worktime <= 0)
                    {
                        imp.CurrentJob.Worktime = 5000;
                        map.JobsInProgress.Remove(imp.CurrentJob);
                        map.JobsWaiting.Enqueue(imp.CurrentJob);
                        imp.CurrentJob = new Job(Vars_Func.ImpJob.Idle);
                    }
                }
                // nothing to do?
                if (imp.Path == null || imp.Path.Count == 0)
                {
                    randomwalk(imp, map);
                }

                // time left for action?
                if (imp.ActionTimeCounter >= 500)
                {
                    imp.State = Vars_Func.ImpState.Walking;
                    map.move(imp);
                }
                imp.ActionTimeCounter = 0;
            }
            imp.ActionTimeCounter += time.ElapsedGameTime.Milliseconds;
        }
示例#21
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;
        }
示例#22
0
        //override public void DrawModel(Renderer.Camera camera, Vector3 drawPosition, Color drawColor)
        //{
        //    Matrix modelMatrix = Matrix.Identity *
        //    Matrix.CreateScale(1) *
        //    Matrix.CreateRotationX(0) *
        //    Matrix.CreateRotationY(0) *
        //    Matrix.CreateRotationZ(0) *
        //    Matrix.CreateTranslation(drawPosition);

        //    Vars_Func.getNestModell(typ).Color = drawColor;
        //    Vars_Func.getNestModell(typ).Draw(camera, modelMatrix);
        //}

        public void spawnCreature(Environment.Map map, int startage = 0)
        {
            Vector2         tmp   = map.getHexagonAt(this.position).Neighbors[3];
            Queue <Vector2> queue = new Queue <Vector2>();

            switch (typ)
            {
            case Vars_Func.NestTyp.Entrance:
                //find free position for the new creature through a broad-first-search
                queue.Enqueue(tmp);
                map.getHexagonAt(tmp).Visited = true;
                while (queue.Count != 0)
                {
                    tmp = queue.Dequeue();
                    if (map.getHexagonAt(tmp).Obj == null)
                    {
                        break;
                    }
                    //for all neighbors

                    for (int i = 0; i < 6; ++i)
                    {
                        Vector2 neighbor = map.getHexagonAt(tmp).Neighbors[i];
                        //which weren't visited already
                        if (map.getHexagonAt(neighbor).Visited == false)
                        {
                            map.getHexagonAt(neighbor).Visited = true; //set visited at true
                            queue.Enqueue(neighbor);                   //add the neighbor to the queue
                        }
                    }
                }
                //set visited for all hexagon at false (for the next use of searching)
                foreach (Environment.Hexagon hex in map.getMapHexagons())
                {
                    if (hex.Visited == true)
                    {
                        hex.Visited = false;
                    }
                }
                new Creature(Vars_Func.CreatureTyp.Knight, tmp, this, Vars_Func.ThingTyp.HeroCreature, map, upgradeCount, startage);
                break;

            case Vars_Func.NestTyp.Beetle:
                //find free position for the new creature through a broad-first-search
                queue.Enqueue(tmp);
                map.getHexagonAt(tmp).Visited = true;
                while (queue.Count != 0)
                {
                    tmp = queue.Dequeue();
                    if (map.getHexagonAt(tmp).Obj == null)
                    {
                        break;
                    }
                    //for all neighbors

                    for (int i = 0; i < 6; ++i)
                    {
                        Vector2 neighbor = map.getHexagonAt(tmp).Neighbors[i];
                        //which weren't visited already
                        if (map.getHexagonAt(neighbor).Visited == false)
                        {
                            map.getHexagonAt(neighbor).Visited = true; //set visited at true
                            queue.Enqueue(neighbor);                   //add the neighbor to the queue
                        }
                    }
                }
                //set visited for all hexagon at false (for the next use of searching)
                foreach (Environment.Hexagon hex in map.getMapHexagons())
                {
                    if (hex.Visited == true)
                    {
                        hex.Visited = false;
                    }
                }
                new Creature(Vars_Func.CreatureTyp.Beetle, tmp, this, Vars_Func.ThingTyp.DungeonCreature, map, upgradeCount);
                break;

            case Vars_Func.NestTyp.Skeleton:
                //find free position for the new creature through a broad-first-search
                queue.Enqueue(tmp);
                map.getHexagonAt(tmp).Visited = true;
                while (queue.Count != 0)
                {
                    tmp = queue.Dequeue();
                    if (map.getHexagonAt(tmp).Obj == null)
                    {
                        break;
                    }
                    //for all neighbors

                    for (int i = 0; i < 6; ++i)
                    {
                        Vector2 neighbor = map.getHexagonAt(tmp).Neighbors[i];
                        //which weren't visited already
                        if (map.getHexagonAt(neighbor).Visited == false)
                        {
                            map.getHexagonAt(neighbor).Visited = true; //set visited at true
                            queue.Enqueue(neighbor);                   //add the neighbor to the queue
                        }
                    }
                }
                //set visited for all hexagon at false (for the next use of searching)
                foreach (Environment.Hexagon hex in map.getMapHexagons())
                {
                    if (hex.Visited == true)
                    {
                        hex.Visited = false;
                    }
                }
                new Creature(Vars_Func.CreatureTyp.Skeleton, tmp, this, Vars_Func.ThingTyp.DungeonCreature, map, upgradeCount);
                break;
            }
        }
示例#23
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;
            }
        }
示例#24
0
        public Creature(Vars_Func.CreatureTyp typ, Vector2 position, Nest home, Vars_Func.ThingTyp allignment, Environment.Map map, int[] upgrades, int startage = 0)
        {
            switch (typ)
            {
            case Vars_Func.CreatureTyp.Beetle:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1 + upgrades[2] * 0.2f;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 200 + upgrades[1] * 100;
                damage      = 10 + upgrades[0] * 4;
                age         = startage;
                maxAge      = 100;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Creatures.Add(this);
                animationSpeeds    = new float[2];
                animationSpeeds[0] = 2.5f;
                animationSpeeds[1] = 1;
                break;

            case Vars_Func.CreatureTyp.Skeleton:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1 + upgrades[2] * 0.2f;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 100 + upgrades[1] * 50;
                damage      = 15 + upgrades[0] * 6;
                age         = startage;
                maxAge      = 120;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Creatures.Add(this);
                animationSpeeds    = new float[2];
                animationSpeeds[0] = 2;
                animationSpeeds[1] = 0.8f;
                break;

            case Vars_Func.CreatureTyp.Knight:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 150;
                damage      = 10;
                age         = startage;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Heroes.Add(this);
                currentState       = Vars_Func.CreatureState.Starting;
                startHex           = map.getHexagonAt(home.Position);
                startLerpCounter   = 0;
                reachGround        = false;
                animationSpeeds    = new float[3];
                animationSpeeds[0] = 2;
                animationSpeeds[1] = 0.8f;
                animationSpeeds[2] = 1;
                break;

            case Vars_Func.CreatureTyp.HQCreatur:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 5000;
                damage      = 500;
                age         = startage;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Creatures.Add(this);
                map.getHexagonAt(position).IsHQ = true;
                map.getHexagonAt(position).EnlightendHexagon(map);
                currentState       = Vars_Func.CreatureState.PingPong;
                animationSpeeds    = new float[2];
                animationSpeeds[0] = 1;
                animationSpeeds[1] = 1;
                // Some Fireball Test
                //map.getHexagonAt(position).Fireball = Vars_Func.getFireBall();
                break;
            }
            this.model          = new CharacterModel(Vars_Func.getCreatureModell(typ).Model);
            model.AnimationClip = Vars_Func.getCreatureModell(typ).AnimationClip;
            updatePlayer        = true;
            currentHex          = map.getHexagonAt(position);
            oldHex       = map.getHexagonAt(position);
            targetHex    = null;
            oldTargetHex = null;
            tempZ        = 0;
        }
示例#25
0
        public static void generateMap(Environment.Map map, int size, int diamond, int gold, bool random)
        {
            List <Vars_Func.WallTyp> specials = new List <Vars_Func.WallTyp>();

            if (random || size != 50)
            {
                specials.Add(Vars_Func.WallTyp.HQ);
                specials.Add(Vars_Func.WallTyp.EN);
            }
            Random  rand = new Random();
            Vector2 EN   = new Vector2();
            int     randnum;
            int     dia = diamond;
            int     go  = gold;

            //determine special walls
            if (random || size != 50)
            {
                for (int i = 0; i < Math.Pow((size / 5), 2) - 2; ++i)
                {
                    if (dia > 0)
                    {
                        specials.Add(Vars_Func.WallTyp.Diamond);
                        --dia;
                    }
                    else if (go > 0)
                    {
                        specials.Add(Vars_Func.WallTyp.Gold);
                        --go;
                    }
                    else
                    {
                        specials.Add(Vars_Func.WallTyp.Stone);
                    }
                }
            }
            else
            {
                demomap(specials);
            }
            // build map
            for (int i = 0; i < size; ++i)
            {
                for (int j = 0; j < size; ++j)
                {
                    if (random || size != 50)
                    {
                        randnum = rand.Next(specials.Count);
                    }
                    else
                    {
                        randnum = 0;
                    }
                    // special wall
                    if (j % 5 == 0 && i % 5 == 0)
                    {
                        // if entrance place entrance
                        if (specials[randnum] == Vars_Func.WallTyp.EN)
                        {
                            new Nest(Vars_Func.NestTyp.Entrance, new Vector2(i, j), map, map.HQPosition);
                        }
                        // if HQ place HQ
                        else if (specials[randnum] == Vars_Func.WallTyp.HQ)
                        {
                            new Creature(Vars_Func.CreatureTyp.HQCreatur, new Vector2(i, j), null, Vars_Func.ThingTyp.HQCreature, map, new int[3]);
                        }
                        //place specila wall if not entrance or HQ
                        else
                        {
                            new Wall(new Vector2(i, j), specials[randnum], 300, map);
                        }

                        if (specials[randnum] == Vars_Func.WallTyp.Diamond || Vars_Func.WallTyp.Gold == specials[randnum])
                        {
                            foreach (Vector2 hex in map.getHexagonAt(i, j).Neighbors)
                            {
                                new Wall(new Vector2(hex.X, hex.Y), Vars_Func.WallTyp.Gold, 150, map);
                            }
                        }
                        else if (specials[randnum] == Vars_Func.WallTyp.HQ)
                        {
                            map.HQPosition = new Vector2(i, j);
                        }
                        else if (specials[randnum] == Vars_Func.WallTyp.EN)
                        {
                            EN = new Vector2(i, j);
                        }
                        specials.RemoveAt(randnum);
                    }
                    // fill rest with normal walls
                    else if (map.getHexagonAt(i, j).Obj == null)
                    {
                        new Wall(new Vector2(i, j), Vars_Func.WallTyp.Stone, 40, map);
                    }
                }
            }
            // set entrance target correct
            ((Nest)map.getHexagonAt(EN).Obj).TargetPosition = map.HQPosition;
            // room for HQ
            foreach (Vector2 hex in map.getHexagonAt(map.HQPosition.X, map.HQPosition.Y).Neighbors)
            {
                map.getHexagonAt(hex.X, hex.Y).Obj = null;
            }
            //creat start imps
            Spells.castSpell(Vars_Func.SpellType.SummonImp, map.getHexagonAt(map.HQPosition).Neighbors[3], map);
            Spells.castSpell(Vars_Func.SpellType.SummonImp, map.getHexagonAt(map.HQPosition).Neighbors[3], map);
            Spells.castSpell(Vars_Func.SpellType.SummonImp, map.getHexagonAt(map.HQPosition).Neighbors[3], map);
            // room for entrance
            foreach (Vector2 hex in map.getHexagonAt(EN.X, EN.Y).Neighbors)
            {
                map.getHexagonAt(hex.X, hex.Y).Obj = null;
            }
            // build path from first entrance to HQ
            while (!map.getHexagonAt(map.HQPosition.X, map.HQPosition.Y).Neighbors.Contains(EN))
            {
                Vector2 tempPos = Vector2.Zero;
                if (map.HQPosition.X < EN.X)
                {
                    map.getHexagonAt(EN.X - 1, EN.Y).Obj = null;
                    tempPos = new Vector2(EN.X - 1, EN.Y);
                    counter++;
                    --EN.X;
                }
                else if (map.HQPosition.X > EN.X)
                {
                    map.getHexagonAt(EN.X + 1, EN.Y).Obj = null;
                    tempPos = new Vector2(EN.X + 1, EN.Y);
                    counter++;
                    ++EN.X;
                }
                if (map.HQPosition.Y < EN.Y && !map.getHexagonAt(map.HQPosition.X, map.HQPosition.Y).Neighbors.Contains(EN))
                {
                    map.getHexagonAt(EN.X, EN.Y - 1).Obj = null;
                    tempPos = new Vector2(EN.X, EN.Y - 1);
                    counter++;
                    --EN.Y;
                }
                else if (map.HQPosition.Y > EN.Y && !map.getHexagonAt(map.HQPosition.X, map.HQPosition.Y).Neighbors.Contains(EN))
                {
                    map.getHexagonAt(EN.X, EN.Y + 1).Obj = null;
                    tempPos = new Vector2(EN.X, EN.Y + 1);
                    counter++;
                    ++EN.Y;
                }
                if (tempPos != Vector2.Zero)
                {
                    if (counter == 8)
                    {
                        map.getHexagonAt(tempPos).EnlightendHexagon(map);
                        counter = 0;
                    }
                }
            }
        }
示例#26
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;
     }
 }
示例#27
0
 override public void update(GameTime gameTime, Environment.Map map)
 {
 }
示例#28
0
        public static void castSpell(Logic.Vars_Func.SpellType typ, Vector2 position, Environment.Map map)
        {
            switch (typ)
            {
            case Vars_Func.SpellType.SummonImp:
                if (Player.enoughMana(summonImpCost))
                {
                    Player.Mana -= summonImpCost;
                    new Imp(map.getHexagonAt(map.HQPosition).Neighbors[3], map);
                }
                if (map.ImpList.Count >= 3)
                {
                    summonImpCost = map.ImpList.Count * 100;
                }
                break;

            case Vars_Func.SpellType.Fireball:
                if (Player.enoughMana(fireballCost))
                {
                    Player.Mana -= fireballCost;
                    map.getHexagonAt(position).Fireballs.Add(new Basic.FireBallModel(Vars_Func.getFireBall().Model, Vars_Func.getFireBall().Fires, map, position));

                    //// is the target a creature?
                    //if (map.getHexagonAt(position).Obj != null && (map.getHexagonAt(position).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.DungeonCreature ||
                    //        map.getHexagonAt(position).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.NeutralCreature || map.getHexagonAt(position).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.HeroCreature))
                    //{
                    //    //damage creature
                    //    Creature target = (Creature)map.getHexagonAt(position).Obj;
                    //    target.takeDamage(100);
                    //    //is creature dead?
                    //    if (target.DamageTaken >= target.HP) map.DyingCreatures.Add(target);
                    //}
                    ////// is the target an imp?
                    ////else if (map.getHexagonAt(position).Obj != null && map.getHexagonAt(position).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.Imp)
                    ////{
                    ////    //damage imp
                    ////    Imp target = (Imp)map.getHexagonAt(position).Obj;
                    ////    target.takeDamage(100);
                    ////    // is imp dead?
                    ////    if (target.DamageTaken >= target.HP) map.remove(target);
                    ////}

                    //// effects neighbors
                    //foreach (Vector2 hex in map.getHexagonAt(position).Neighbors)
                    //{
                    //    // is the target a creature?
                    //    if (map.getHexagonAt(hex).Obj != null && (map.getHexagonAt(hex).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.DungeonCreature ||
                    //        map.getHexagonAt(hex).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.NeutralCreature || map.getHexagonAt(hex).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.HeroCreature))
                    //    {
                    //        //damage creature
                    //        Creature target = (Creature)map.getHexagonAt(hex).Obj;
                    //        target.takeDamage(60);
                    //        //is creature dead?
                    //        if (target.DamageTaken >= target.HP) map.DyingCreatures.Add(target);
                    //    }
                    //    //// is the target an imp?
                    //    //else if (map.getHexagonAt(hex).Obj != null && map.getHexagonAt(hex).Obj.getThingTyp() == Logic.Vars_Func.ThingTyp.Imp)
                    //    //{
                    //    //    //damage imp
                    //    //    Imp target = (Imp)map.getHexagonAt(hex).Obj;
                    //    //    target.takeDamage(100);
                    //    //    // is imp dead?
                    //    //    if (target.DamageTaken >= target.HP) map.remove(target);
                    //    //}
                    //}
                }
                break;
            }
        }