Exemplo n.º 1
0
        void Forward(Grid grid, Architech arch)
        {
            WayPoints.Clear();
            //check if can move forward
            Vector2 a_nextLocation = Position;

            Point gridLocation = Grid.ToGridPosition(Position, Grid.GetTileSize);
            Tile  nextTile     = grid.GetTile(new Point(gridLocation.X + 1, gridLocation.Y));

            if (nextTile != null)
            {
                if (nextTile.State != TileStates.Blocked && nextTile.State != TileStates.Immpassable)
                {
                    a_nextLocation = nextTile.Position;
                    WayPoints.Add(new Vector2(Position.X + 64, Position.Y));
                    Ai_States = Ai_States.Moving;
                }

                else
                {
                    Ai_States         = Ai_States.Target;
                    waypointsReached += 15;
                    this.Speed        = norm_speed;
                }
            }

            else
            {
                Ai_States         = Ai_States.Target;
                waypointsReached += 15;
                this.Speed        = norm_speed;
            }
        }
Exemplo n.º 2
0
        //idle around a grave checks surroundings for enemies constantly
        void GraveHover(Architech arch, Overseer os, Grid grid, Random rnd)
        {
            var grave = arch.GetBuilding(home);

            if (grave == null)
            {
                SetHome(arch, os);
            }

            var b  = arch.GetBuilding(home);
            var ts = b.AdjacentTiles;

            if (b.AdjacentTiles.Count == 0)
            {
                List <Vector2> dests = new List <Vector2>()
                {
                    new Vector2(64, 0), new Vector2(-64, 0), new Vector2(64, 64),
                    new Vector2(-64, -64), new Vector2(-64, 64), new Vector2(64, -64), new Vector2(0, 64), new Vector2(0, -64)
                };

                destination = Grid.ToGridPosition(dests[rnd.Next(0, dests.Count - 1)], Grid.GetTileSize);
            }

            else
            {
                destination = Grid.ToGridPosition(ts[rnd.Next(0, ts.Count)], Grid.GetTileSize);
            }

            Ai_States = Ai_States.Idle;
            Think_Pathing(grid, rnd);
        }
Exemplo n.º 3
0
        public void Update(GameTime gt, Architech arch, Overseer os, Grid grid, Player p)
        {
            elaspedAlive += gt.ElapsedGameTime.Milliseconds;
            elaspedTick  += gt.ElapsedGameTime.Milliseconds;

            if (elaspedTick >= stats.Tick && state == Spell_States.Alive && p.Energy > stats.Cost && Options.GetTick)
            {
                arch.SpellEffect(this);
                os.SpellEffect(this, grid, arch);
                elaspedTick       = 0;
                p.IncreaseEnergy -= stats.Cost;
            }

            else if (p.Energy <= stats.Cost)
            {
                state = Spell_States.Dead;
            }

            if (elaspedAlive >= stats.Duration)
            {
                state = Spell_States.Dead;
            }

            base.Update(gt);
        }
Exemplo n.º 4
0
        public void Update(Player player, Architech arch, Overseer os)
        {
            base.Update(player.Cursor);

            Dictionary <Point, object> unitpoints = os.GetUnitPoints();

            foreach (Tile tile in tiles)
            {
                tile.Update(player.Cursor);
                if (tile.IsClicked || (player.Cursor.isRightPressed && tile.IsHighlighted))
                {
                    SelectTile(tile.Order);
                }

                /*if (unitpoints.ContainsKey(new Point(tile.Order.X, tile.Order.Y)))
                 * {
                 *      if(tile.State != TileStates.Immpassable)
                 *              tile.PreviousState = tile.State;
                 *      tile.State = TileStates.Immpassable;
                 *
                 * }
                 * else if(tile.State != TileStates.Blocked ) tile.State = tile.PreviousState;
                 */
            }

            //CheckTiles(arch.CompileBuildingTiles());
        }
Exemplo n.º 5
0
 protected void Moving(Architech arch, Grid grid, GameTime gt)
 {
     if (WayPoints.Count > 0)
     {
         Moving(gt);
     }
 }
Exemplo n.º 6
0
        void ZombieSwap(Guid ai, Grid grid, Architech arch)  //swaps a unit to an equalivalent zombie unit
        {
            var old   = ais[ai];
            var zombi = new Zombie(old.Position, new Point(32, 32), unit_types[ConvertToZombie(old.GetStats().Type)], ai_stats[ConvertToZombie(old.GetStats().Type)], grid, arch);

            zombies.Add(zombi.ID, zombi);
            ais.Remove(ai);
        }
Exemplo n.º 7
0
        void AiSwap(Guid ai, Grid grid, Architech arch)  //swaps a unit to an equalivalent zombie unit
        {
            var old  = zombies[ai];
            var unit = new Grounded(old.Position, new Point(32, 32), unit_types[ConvertToGrounded(old.GetStats().Type)], ai_stats[ConvertToGrounded(old.GetStats().Type)], grid);

            unit.GetStats().Health = 0;
            ais.Add(unit.ID, unit);
            zombies.Remove(ai);
        }
Exemplo n.º 8
0
 public void Update(GameTime gt, Researcher rs, Player p, Architech arch)
 {
     if (state == ResearchState.Done)
     {
         return;
     }
     if (state == ResearchState.Researching)
     {
         Produce(gt, p, rs, arch);
     }
 }
Exemplo n.º 9
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            Statistics.Load(@"Content/settings/save.dat");
            Message.DisplayTime       = 5000;
            AiUnit.statusBarTexture   = new Texture2D[] { Content.Load <Texture2D>(@"texture/ui/status_bar_bottom"), Content.Load <Texture2D>(@"texture/ui/status_bar_top") };
            Building.statusBarTexture = new Texture2D[] { Content.Load <Texture2D>(@"texture/ui/status_bar_bottom"), Content.Load <Texture2D>(@"texture/ui/status_bar_top") };
            BaseObject.DebugFont      = Content.Load <SpriteFont>(@"fonts/debug");
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Texture2D t_r = new Texture2D(GraphicsDevice, 1, 1);
            Texture2D t_g = new Texture2D(GraphicsDevice, 1, 1);
            Texture2D t_b = new Texture2D(GraphicsDevice, 1, 1);

            Color[] red   = new Color[1];
            Color[] green = new Color[1];
            Color[] blue  = new Color[1];

            for (int i = 0; i < t_r.Height * t_g.Width; i++)
            {
                red[i]   = new Color(255, 0, 0);
                green[i] = new Color(0, 255, 0);
                blue[i]  = new Color(0, 0, 255);
            }

            t_r.SetData <Color>(red);
            t_g.SetData <Color>(green);
            t_b.SetData <Color>(blue);

            for (int i = 0; i < points.Count(); i++)
            {
                points[i] = new Vector2(rng.Next(0, 600), rng.Next(0, 600));
            }

            grid       = new Grid(gridSize, new Vector2(0, 0), Content.Load <Texture2D>(@"texture/tile_n"), Content.Load <Texture2D>(@"texture/tile_h"), Content.Load <Texture2D>(@"texture/tile_c"), tileSize, @"Content/buildings/buildings.txt", @"Content/UI/ui_grid_menu.txt", Content);
            player     = new Player(t_b, new Point(1900, 50), new Texture2D[] { Content.Load <Texture2D>(@"texture/ui/healthbar_bottom"), Content.Load <Texture2D>(@"texture/ui/healthbar_top") }, Content);
            os         = new Overseer(Content, new Texture2D[] { t_r, t_g });
            architech  = new Architech(Content, grid);
            uiMaster   = new UiMaster(Content);
            wizard     = new Wizard(Content);
            researcher = new Researcher(Content, rng);
            backdrop   = new StaticSprite(new Vector2(0, 0), Content.Load <Texture2D>(@"texture/ui/backdrop2"), new Point(1920, 1080));
            terrain    = new StaticSprite(new Vector2(0, -5), Content.Load <Texture2D>(@"texture/terrain"), new Point(1920, 1080 - (3 * 64)));
            light      = new StaticSprite(Vector2.Zero, Content.Load <Texture2D>(@"texture/terrainLight"), new Point(1920, 1080 - (3 * 64)));
            screens    = new Texture2D[3];

            screens[0]     = Content.Load <Texture2D>(@"texture/menu_screen");
            screens[1]     = Content.Load <Texture2D>(@"texture/ui/guide");
            screens[2]     = Content.Load <Texture2D>(@"texture/end_screen");
            overlay_Screen = new StaticSprite(Vector2.Zero, screens[0], new Point(1920, 1080));

            update = new TimeSpan();
        }
Exemplo n.º 10
0
        void Produce(GameTime gt, Player p, Researcher rs, Architech arch)
        {
            if (Options.GetTick && currentProgress < data.ResearchTime && p.Energy > arch.GetOrrery())
            {
                p.IncreaseEnergy -= arch.GetOrrery() * 2;
                currentProgress  += arch.GetOrrery() * 2;
            }

            else if (currentProgress >= data.ResearchTime)
            {
                state = ResearchState.Done;
            }
        }
Exemplo n.º 11
0
        protected void AcquireTarget(Architech arch, Grid grid, bool newTarget, Random rng)
        {
            if (newTarget)
            {
                PFResult = null;
                if (Stats.Focus == Focus.Focused && rng.Next(0, 10) > 5)
                {
                    defenderID = arch.Home;
                    var home  = arch.GetBuilding(defenderID);
                    var edges = home.AdjacentTiles;
                    if (edges == null)
                    {
                        Ai_States = Ai_States.Idle;
                        return;
                    }
                    var dest = edges.GetRandom(rng);
                    destination = Grid.ToGridPosition(dest, Grid.GetTileSize);
                }


                else
                {
                    var building = arch.NearBuilding(Position, 1000);
                    var edges    = building.Value.AdjacentTiles;

                    if (edges == null)
                    {
                        Ai_States = Ai_States.Idle;
                        return;
                    }
                    var dest = edges.GetRandom(rng);
                    destination = Grid.ToGridPosition(dest, Grid.GetTileSize);
                    defenderID  = building.Key;
                }
            }

            if (Think_Pathing(grid, rng))
            {
                Ai_States = Ai_States.Thinking;
            }

            if (pathAttempts >= maxPattempts)
            {
                wait         = false;
                pathAttempts = 0;
                Ai_States    = Ai_States.Target;
                p_wait       = true;
            }
        }
Exemplo n.º 12
0
        protected void Attacking(Overseer os, Architech arch, GameTime gt, Random rng)
        {
            hitElasped += gt.ElapsedGameTime.Milliseconds;

            if (CheckTarget(arch))
            {
                if (hitElasped >= Stats.HitDelay)
                {
                    os.Combat(this, arch.GetBuilding(defenderID), rng);
                    hitElasped = 0;
                    Projectile p = new Projectile(this.Center, new Point(16, 16), data.Projectile, 5, arch.GetBuilding(defenderID).Center);
                    projectile.Add(p.ID, p);
                }
            }
        }
Exemplo n.º 13
0
        //attack target once in range, go back to pursue if not in range
        void Attacking(Overseer os, Architech arch, GameTime gt, Random rng, Grid grid)
        {
            hitElasped += gt.ElapsedGameTime.Milliseconds;

            if (hitElasped >= Stats.HitDelay)
            {
                hitElasped = 0;
                os.Combat(this, (Grounded)os.Ais[target], rng);

                if (base.data.Type == Ai_Type.Z_Archer || base.data.Type == Ai_Type.Z_Priest)
                {
                    var p = new Projectile(Position, new Point(16, 16), data.Projectile, 5, ((Grounded)os.Ais[target]).Center);
                    projectile.Add(p.ID, p);
                }
            }
        }
Exemplo n.º 14
0
 void ResearchUpdate(GameTime gt, Overseer os, Architech arch, Wizard wiz, UiMaster master, Player player, int ind, ButtonFunction b)
 {
     if (research[b].ToList()[stager[b].Item3].Value.State == ResearchState.Researching)
     {
         research[b].ToList()[stager[b].Item3].Value.Update(gt, this, player, arch);
     }
     else if (research[b].ToList()[stager[b].Item3].Value.State == ResearchState.Done && !stager[b].Item2)
     {
         ApplyResearch(research[b].ToList()[stager[b].Item3].Value.Data, os, arch, wiz, master);
         master.Messenger.AddMessage(new Text(Vector2.Zero, research[b].ToList()[stager[b].Item3].Value.Data.Name + "Complete", Color.DarkGreen));
         stager[b].Item3++;
         if (stager[b].Item3 >= research[b].ToList().Count)
         {
             stager[b].Item2 = true;
             stager[b].Item3 = research[b].ToList().Count - 1;
         }
         //NextResearch(ind, master, b, );
     }
 }
Exemplo n.º 15
0
        protected void Idle(Architech arch, Grid grid, Random rng)
        {
            //decide whether to move or find a target
            //move or acquire a target
            Focus focus = Think(rng);

            switch (focus)
            {
            case Focus.Aggressive: Ai_States = Ai_States.Moving;
                break;

            case Focus.Focused: Ai_States = Ai_States.Target;
                break;

            case Focus.Hyper: Ai_States = Ai_States.Moving;
                break;

            case Focus.Violent: Ai_States = Ai_States.Target;
                break;
            }
        }
Exemplo n.º 16
0
        bool CheckTarget(Architech arch)
        {
            if (arch.GetBuilding(defenderID) != null)
            {
                if (arch.IsInRange(Corners, defenderID, (float)Stats.Range))
                {
                    noRetaliate = false;
                    Ai_States   = Ai_States.Attacking;
                    return(true);
                }
                else if (WayPoints.Count == 0)
                {
                    Ai_States = Ai_States.Target;  keepTarget = !keepTarget;
                }
            }

            else
            {
                Ai_States = Ai_States.Target; defenderID = new Point(); WayPoints.Clear(); keepTarget = false;
            }

            return(false);
        }
Exemplo n.º 17
0
        public void Update(UiMaster master, MouseState ms, Architech arch, GameTime gt)
        {
            cursor.Update(ms, gt);
            status_bar.Update(energy);
            UpdatePopulation();
            pop_changed = false;
            pop_cap     = arch.GetCountByType(BuildingTypes.Grave) * 5;

            if (!arch.IsHomeAlive)
            {
                mode = Player_Modes.End_Screen;
            }

            if ((mode == Player_Modes.End_Screen || Statistics.Ending != Endings.Passive) && !finished)
            {
                finished = true;
                switch (Statistics.Ending)
                {
                case Endings.Death:
                    master.ManipulateElements(new Text(Vector2.Zero, "You have destroyed all those who opposed you, death stalks the land at your bidding.", Color.Khaki), Player_Modes.End_Screen, "", 0);
                    master.ManipulateElements(new Text(Vector2.Zero, Statistics.Output, Color.AntiqueWhite), Player_Modes.End_Screen, "", 0);
                    mode = Player_Modes.End_Screen;
                    break;

                case Endings.God:
                    master.ManipulateElements(new Text(Vector2.Zero, "Humanity kneel at your feet, you are their new prophet. Peace finally.", Color.PaleVioletRed), Player_Modes.End_Screen, "", 0);
                    master.ManipulateElements(new Text(Vector2.Zero, Statistics.Output, Color.AntiqueWhite), Player_Modes.End_Screen, "", 0);
                    mode = Player_Modes.End_Screen;
                    break;

                case Endings.Passive:
                    master.ManipulateElements(new Text(Vector2.Zero, "Either through your own fruition or your enemies, you have been defeated.", Color.PaleVioletRed), Player_Modes.End_Screen, "", 0);
                    master.ManipulateElements(new Text(Vector2.Zero, Statistics.Output, Color.AntiqueWhite), Player_Modes.End_Screen, "", 0);
                    mode = Player_Modes.End_Screen;
                    break;
                }
            }

            if (controls.IsPressed(Ctrls.HotKey_Build))
            {
                mode = Player_Modes.Building;
            }
            if (controls.IsPressed(Ctrls.HotKey_Research))
            {
                mode = Player_Modes.Research;
            }
            if (controls.IsPressed(Ctrls.HotKey_Spells))
            {
                mode = Player_Modes.Spells;
            }
            if (controls.IsPressed(Ctrls.HotKey_Pause))
            {
                mode = Player_Modes.Pause;
            }
            switch (master.NextAction)
            {
            case ButtonFunction.M_Build:
                master.Pop_Action();
                mode = Player_Modes.Building;
                break;

            case ButtonFunction.M_Research:
                master.Pop_Action();
                mode = Player_Modes.Research;
                break;

            case ButtonFunction.M_Spells:
                master.Pop_Action();
                mode = Player_Modes.Spells;
                break;

            case ButtonFunction.M_Tools:
                master.Pop_Action();
                mode = Player_Modes.Tools;
                break;

            case ButtonFunction.M_Pause:
                master.Pop_Action();
                mode = Player_Modes.Pause;
                break;

            case ButtonFunction.MM_Start:
                master.Pop_Action();
                mode = Player_Modes.Tutorial;
                break;

            case ButtonFunction.MM_Hiscores:
                master.Pop_Action();
                break;

            case ButtonFunction.Guide:
                master.Pop_Action();
                mode = Player_Modes.Tutorial;
                break;

            case ButtonFunction.ES_End:
                master.Pop_Action();
                mode = Player_Modes.Surrender;
                break;

            case ButtonFunction.ReallySurrender:
                master.Pop_Action();
                mode = Player_Modes.End_Screen;
                break;

            case ButtonFunction.Settings:
                master.Pop_Action();
                mode = Player_Modes.Settings;
                break;

            case ButtonFunction.Tog_EHB:
                master.Pop_Action();
                if (sub_m.HasFlag(Sub_Player_Modes.Display_EHB))
                {
                    sub_m &= ~Sub_Player_Modes.Display_EHB;
                }
                else
                {
                    sub_m |= Sub_Player_Modes.Display_EHB;
                }
                break;

            case ButtonFunction.Tog_FHB:
                master.Pop_Action();
                if (sub_m.HasFlag(Sub_Player_Modes.Display_FHB))
                {
                    sub_m &= ~Sub_Player_Modes.Display_FHB;
                }
                else
                {
                    sub_m |= Sub_Player_Modes.Display_FHB;
                }
                break;
            }

            switch (this.mode)
            {
            case Player_Modes.Building:
                this.cursor.CurrentState = ButtonFunction.M_Build.ToString();
                break;

            case Player_Modes.Pause:
                this.cursor.CurrentState = ButtonFunction.M_Pause.ToString();
                break;

            case Player_Modes.Research:
                this.cursor.CurrentState = ButtonFunction.M_Research.ToString();
                break;

            case Player_Modes.Tools:
                this.cursor.CurrentState = ButtonFunction.M_Tools.ToString();
                break;

            case Player_Modes.Spells:
            case Player_Modes.MainMenu:
                this.cursor.CurrentState = ButtonFunction.M_Spells.ToString();
                break;
            }
        }
Exemplo n.º 18
0
        public void Update(GameTime gt, Cursor ms, Architech arch, UiMaster ui, Grid grid, Player p, Random rng)
        {
            p.Population = zombies.Count;

            foreach (Ai ai in ais.Values)
            {
                if (ai is Grounded)
                {
                    ((Grounded)ai).Update(ms, gt, arch, grid, rng, this, ui);
                }
                else if (ai is AiUnit)
                {
                    ai.Update(ms, gt);
                }

                if (ai is AiUnit)
                {
                    if (ai.GetStats().Health <= 0 && ai.Ai_States != Ai_States.Dead)
                    {
                        ai.Ai_States = Ai_States.Dead;
                        Statistics.Kills++;
                    }

                    if (arch.BuildingPlaced)
                    {
                        if (ai.Ai_States != Ai_States.Attacking && ai.Ai_States != Ai_States.Dead)
                        {
                            ((Grounded)ai).CheckWaypoints = true;
                        }
                    }
                }
            }

            foreach (Zombie Z in zombies.Values)
            {
                Z.Update(ms, gt, arch, grid, rng, this, ui);

                if (arch.BuildingPlaced)
                {
                    if (Z.Ai_States != Ai_States.Attacking && Z.Ai_States != Ai_States.Dead)
                    {
                        Z.WayPoints.Clear();
                        Z.Wait      = false;
                        Z.PFResult  = null;
                        Z.Ai_States = Ai_States.Target;
                    }
                }

                if (arch.BuilingDestroyed)
                {
                    if (Z.Ai_States == Ai_States.Thinking)
                    {
                        Z.Ai_States = Ai_States.Target;
                    }
                }
                if (Z.Ai_States == Ai_States.Thinking && rng.Next(0, 10) == 5)
                {
                    Z.Ai_States = Ai_States.Target;
                }

                if (Z.GetStats().Health <= 0)
                {
                    remove_queue.Add(Z.ID);
                }
            }

            if (ais.Count > 100)
            {
                CleanUp();
            }

            foreach (Guid id in remove_queue)
            {
                if (ais.ContainsKey(id))
                {
                    ais.Remove(id);
                    p.IncreaseEnergy += 100;
                }
                if (zombies.ContainsKey(id))
                {
                    zombies.Remove(id);
                }
            }

            s_elasped += gt.ElapsedGameTime.Milliseconds;
            if (s_elasped > s_target && !spawning)
            {
                CreateNewFormation(rng, grid);
                s_target = formations[0].LongLength * 500;
                spawning = true;
                //CalcTarget();
                s_elasped = 0;
            }

            if (spawning)
            {
                spawn_elasped += gt.ElapsedGameTime.Milliseconds;
                if (spawn_elasped >= spawn_target)
                {
                    Spawn(grid, rng);
                    spawn_elasped = 0;
                }
            }
        }
Exemplo n.º 19
0
        public void Update(GameTime gt, Overseer os, Architech arch, UiMaster master, Player player, Wizard wiz, Random rnd)
        {
            int i = 0;

            foreach (ButtonFunction bf in functions)
            {
                ResearchUpdate(gt, os, arch, wiz, master, player, i, bf);
                NextResearch(0, master, bf);
                i++;
            }

            if (master.NextAction != ButtonFunction.Nan)
            {
                switch (master.NextAction)
                {
                case ButtonFunction.R1:
                    master.Pop_Action();
                    if (CheckResearchActivity(ButtonFunction.R1, stager[ButtonFunction.R1].Item3))
                    {
                        ChangeState(ButtonFunction.R1);
                    }
                    break;

                case ButtonFunction.R2:
                    master.Pop_Action();
                    if (CheckResearchActivity(ButtonFunction.R2, stager[ButtonFunction.R2].Item3))
                    {
                        ChangeState(ButtonFunction.R2);
                    }
                    break;

                case ButtonFunction.R3:
                    master.Pop_Action();
                    if (CheckResearchActivity(ButtonFunction.R3, stager[ButtonFunction.R3].Item3))
                    {
                        ChangeState(ButtonFunction.R3);
                    }
                    break;
                }
            }

            if (master.Highlight != ButtonFunction.Nan)
            {
                switch (master.Highlight)
                {
                case ButtonFunction.R1:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(research[master.Highlight].ToList()[stager[ButtonFunction.R1].Item3].Value.ID,
                                                                          research[master.Highlight].ToList()[stager[ButtonFunction.R1].Item3].Value.Info));
                    RemoveInfo(master, new ButtonFunction[] { ButtonFunction.R2, ButtonFunction.R3 });
                    break;

                case ButtonFunction.R2:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(research[master.Highlight].ToList()[stager[ButtonFunction.R2].Item3].Value.ID,
                                                                          research[master.Highlight].ToList()[stager[ButtonFunction.R2].Item3].Value.Info));
                    RemoveInfo(master, new ButtonFunction[] { ButtonFunction.R1, ButtonFunction.R3 });
                    break;

                case ButtonFunction.R3:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(research[master.Highlight].ToList()[stager[ButtonFunction.R3].Item3].Value.ID,
                                                                          research[master.Highlight].ToList()[stager[ButtonFunction.R3].Item3].Value.Info));
                    RemoveInfo(master, new ButtonFunction[] { ButtonFunction.R2, ButtonFunction.R1 });
                    break;
                }
            }

            if (player.Mode != Player_Modes.Research)
            {
                RemoveInfo(master, new ButtonFunction[] { ButtonFunction.R1, ButtonFunction.R2, ButtonFunction.R3 });
            }

            elasped += gt.ElapsedGameTime.Milliseconds;

            if (elasped >= aiResearchTimer && airesearch.Count > 0)
            {
                var r = new ResearchData();
                r.Modifiers = new List <KeyValuePair <Researchables, float> >();
                float percent = (float)rnd.NextDouble();
                if (percent == 0)
                {
                    percent = 0.1f / 10f;
                }
                else
                {
                    percent = percent / 10f;
                }
                r.Modifiers.Add(new KeyValuePair <Researchables, float>(airesearch.First(), percent));
                ApplyResearch(r, os, arch, wiz, master);
                elasped = 0;
            }
        }
Exemplo n.º 20
0
        public void ApplyResearch(ResearchData rd, Overseer os, Architech arch, Wizard wiz, UiMaster master)
        {
            List <Ai_Type> zombies = new List <Ai_Type>()
            {
                Ai_Type.Z_Archer,
                Ai_Type.Z_Horseman,
                Ai_Type.Z_Knight,
                Ai_Type.Z_Priest
            };
            List <Ai_Type> ais = new List <Ai_Type>()
            {
                Ai_Type.Archer,
                Ai_Type.Horseman,
                Ai_Type.Knight,
                Ai_Type.Priest
            };
            List <BuildingTypes> buildings = new List <BuildingTypes>()
            {
                BuildingTypes.EnergyConduit,
                BuildingTypes.Grave,
                BuildingTypes.Wall
            };
            List <SpellType> spells = new List <SpellType>()
            {
                SpellType.DrainEssence,
                SpellType.Ressurect,
                SpellType.RestoreEssence
            };

            switch (rd.Modifiers[0].Key)
            {
            case Researchables.ZDamage:
            case Researchables.ZHealth:
            case Researchables.ZSpeed:
            case Researchables.WCost:
            case Researchables.WHealth:
            case Researchables.WProduct:
            case Researchables.SCost:
            case Researchables.SLength:
            case Researchables.SPower:
                master.Messenger.AddMessage(new Text(Vector2.Zero, rd.Name + " Complete", Color.DodgerBlue));
                break;

            case Researchables.AiDamage:
            case Researchables.AiHealth:
            case Researchables.AiSpeed:
                master.Messenger.AddMessage(new Text(Vector2.Zero, "A holy disturbance can be felt.", Color.PaleVioletRed));
                break;
            }



            foreach (KeyValuePair <Researchables, float> rf in rd.Modifiers)
            {
                switch (rf.Key)
                {
                case Researchables.ZDamage:
                case Researchables.ZHealth:
                case Researchables.ZSpeed:
                    os.ChangeStats(rf.Value, zombies, rf.Key);
                    break;

                case Researchables.WCost:
                case Researchables.WHealth:
                case Researchables.WProduct:
                    arch.ChangeStats(rf.Value, buildings, rf.Key);
                    break;

                case Researchables.AiDamage:
                case Researchables.AiHealth:
                case Researchables.AiSpeed:
                    os.ChangeStats(rf.Value, ais, rf.Key);
                    airesearch.RemoveAt(0);
                    break;

                case Researchables.SCost:
                case Researchables.SLength:
                case Researchables.SPower:
                    wiz.ChangeStats(rf.Value, spells, rf.Key);
                    break;
                }
            }
        }
Exemplo n.º 21
0
        public void Update(GameTime gt, Architech arch, Overseer os, UiMaster master, Grid grid, Player player)
        {
            foreach (KeyValuePair <int, Spell> kv in castedSpells)
            {
                kv.Value.Update(gt, arch, os, grid, player);

                if (kv.Value.State == Spell_States.Dead)
                {
                    deadSpells.Add(kv.Key);
                }
            }

            foreach (int i in deadSpells)
            {
                castedSpells.Remove(i);
            }

            deadSpells.Clear();

            if (master.NextAction != ButtonFunction.Nan)
            {
                switch (master.NextAction)
                {
                case ButtonFunction.Ressurect:
                    master.Pop_Action();
                    selectedSpell = ButtonFunction.Ressurect.ToString();
                    break;

                case ButtonFunction.RestoreEssence:
                    master.Pop_Action();
                    selectedSpell = ButtonFunction.RestoreEssence.ToString();
                    break;

                case ButtonFunction.DrainEssence:
                    master.Pop_Action();
                    selectedSpell = ButtonFunction.DrainEssence.ToString();
                    break;

                case ButtonFunction.DeadAgain:
                    master.Pop_Action();
                    selectedSpell = ButtonFunction.DeadAgain.ToString();
                    break;

                case ButtonFunction.ClearDead:
                    master.Pop_Action();
                    selectedSpell = ButtonFunction.ClearDead.ToString();
                    break;
                }
            }

            if (master.Highlight != ButtonFunction.Nan)
            {
                switch (master.Highlight)
                {
                case ButtonFunction.DrainEssence:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(spell_data[SpellType.DrainEssence].ID,
                                                                          spell_data[SpellType.DrainEssence].Info));
                    RemoveInfo(master, new SpellType[] { SpellType.Ressurect, SpellType.DeadAgain, SpellType.RestoreEssence });
                    break;

                case ButtonFunction.Ressurect:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(spell_data[SpellType.Ressurect].ID,
                                                                          spell_data[SpellType.Ressurect].Info));
                    RemoveInfo(master, new SpellType[] { SpellType.DrainEssence, SpellType.RestoreEssence, SpellType.DeadAgain });
                    break;

                case ButtonFunction.RestoreEssence:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(spell_data[SpellType.RestoreEssence].ID,
                                                                          spell_data[SpellType.RestoreEssence].Info));
                    RemoveInfo(master, new SpellType[] { SpellType.DrainEssence, SpellType.Ressurect, SpellType.DeadAgain });
                    break;

                case ButtonFunction.DeadAgain:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(spell_data[SpellType.DeadAgain].ID,
                                                                          spell_data[SpellType.DeadAgain].Info));
                    RemoveInfo(master, new SpellType[] { SpellType.DrainEssence, SpellType.Ressurect, SpellType.RestoreEssence });
                    break;

                case ButtonFunction.ClearDead:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(spell_data[SpellType.ClearDead].ID,
                                                                          spell_data[SpellType.ClearDead].Info));
                    break;
                }
            }

            if (player.Mode != Player_Modes.Spells)
            {
                RemoveInfo(master, new SpellType[] { SpellType.Ressurect, SpellType.DrainEssence, SpellType.DeadAgain, SpellType.RestoreEssence });
            }

            if (player.Cursor.isLeftPressed && grid.IsHighlighted && selectedSpell != "" && (player.Mode == Player_Modes.Spells || (player.Mode == Player_Modes.Tools && selectedSpell == ButtonFunction.ClearDead.ToString())) && player.Cursor.GetState != player.Cursor.prevState)
            {
                CastSpell(grid, (SpellType)Enum.Parse(typeof(SpellType), selectedSpell), player, master);
            }

            if (player.HasPopChanged)
            {
                RefreshData(true, os);
            }
        }
Exemplo n.º 22
0
        void EasyGetTarget(Architech arch, Overseer os, Grid grid, Random rng)
        {
            if (!keepTarget)
            {
                var units = os.GetUnitsInRange(arch.GetBuilding(home).Center, 264, true);
                var focus = Think(rng);
                int index = 0;

                if (units.Count <= 0 || stuck)
                {
                    stuck = false;
                    GraveHover(arch, os, grid, rng);

                    return;
                }

                switch (focus)
                {
                case Focus.Focused:
                    index = rng.Next((int)(units.Count * 0.8), units.Count);
                    break;

                case Focus.Hyper:
                    index = rng.Next(0, (int)(units.Count * 0.3));
                    break;

                case Focus.Aggressive:
                    index = rng.Next((int)(units.Count * 0.3), units.Count);
                    break;

                case Focus.Violent:
                    index = rng.Next(0, (int)(units.Count * 0.1));
                    break;
                }

                var unit  = units.ToList()[index];
                var Nunit = os.Ais[unit];

                foreach (var u in units)
                {
                    destinations.Add(u);
                }

                if (Nunit.WayPoints.Count > 0)
                {
                    destination = Grid.ToGridPosition(Nunit.WayPoints.Last(), Grid.GetTileSize);
                }
                else
                {
                    destination = Grid.ToGridPosition(Nunit.Position, Grid.GetTileSize);
                }
                destination = Grid.ToGridPosition(Nunit.Position, Grid.GetTileSize);
                target      = unit;
            }

            else
            {
                if (!os.Ais.ContainsKey(target))
                {
                    keepTarget = !keepTarget;
                    return;
                }

                var Nunit = os.Ais[target];

                destination = Grid.ToGridPosition(Nunit.Position, Grid.GetTileSize);
            }

            Ai_States = Ai_States.Idle;
            Think_Pathing(grid, rng);
        }
Exemplo n.º 23
0
        public void Update(Cursor ms, GameTime gt, Architech arch, Grid grid, Random rng, Overseer os, UiMaster ui)
        {
            base.Update(ms, gt);
            base.Update(gt);
            base.Update(grid);
            CalculateCorners();
            GetFreeCorners(grid);

            RefreshInfo();

            if (Ai_States != Ai_States.Marching)
            {
                this.Speed = norm_speed;
            }

            if (IsHighlighted)
            {
                ui.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(this.ID, Info));
            }
            else
            {
                ui.RemoveInfo(this.ID);
            }

            if (base.data.Type == Ai_Type.Archer || base.data.Type == Ai_Type.Priest)
            {
                foreach (var proj in projectile.Values)
                {
                    if (arch.GetBuilding(defenderID) != null)
                    {
                        proj.Update(gt);
                    }
                }
            }

            if (Ai_States == Ai_States.Dead)
            {
                CurrentState = "Dead";
                return;
            }
            if (Ai_States != Ai_States.Retaliating && Ai_States != Ai_States.Marching && !marcher)
            {
                CheckTarget(arch);
            }

            switch (Ai_States)
            {
            case Ai_States.Idle:
                CurrentState = "Think";
                if (wait)
                {
                    Think_Pathing(grid, rng);
                }
                else if (PFResult != null)
                {
                    Think_Pathing(grid, rng);
                }
                return;

            case Ai_States.Target:
                CurrentState = "Think";
                EasyGetTarget(arch, grid, rng);     //can go to idle or move
                break;

            case Ai_States.Moving: Moving(arch, grid, gt);                     // can go to idle or attacking
                CurrentState = "Move";
                break;

            case Ai_States.Attacking:
                CurrentState = "Attack";
                Attacking(os, arch, gt, rng);     // can go to idle or target
                break;

            case Ai_States.Retaliating:
                Fighting(os, gt, rng);
                break;

            case Ai_States.Dead:
                CurrentState = "Dead";
                return;

            case Ai_States.Marching:
                Forward(grid, arch);
                break;
            }

            prevPos = Position;
        }
Exemplo n.º 24
0
 public Zombie(Vector2 position, Point rectExtends, Type_Data <Ai_Type> types, Stats stats, Grid grid, Architech arch)
     : base(position, rectExtends, types, stats, grid)
 {
     Ai_States  = Ai_States.Target;
     IsZombie   = true;
     home       = arch.Home;
     temp_speed = stats.Speed;
     RefreshInfo();
     this.Speed = temp_speed;
 }
Exemplo n.º 25
0
 //sets a home grave for the zombie a grave it will return to in less violent times
 void SetHome(Architech arch, Overseer os)
 {
     home = arch.GetGrave(os);
 }
Exemplo n.º 26
0
        void EasyGetTarget(Architech arch, Grid grid, Random rng)
        {
            if (!keepTarget)
            {
                var buildings = arch.GetBuildings;
                var focus     = Think(rng);
                int index     = 0;
                switch (focus)
                {
                case Focus.Focused:
                    index = rng.Next((int)(buildings.Count * 0.8), buildings.Count);
                    break;

                case Focus.Hyper:
                    index = rng.Next(0, (int)(buildings.Count * 0.3));
                    break;

                case Focus.Aggressive:
                    index = rng.Next((int)(buildings.Count * 0.3), buildings.Count);
                    break;

                case Focus.Violent:
                    index = rng.Next(0, (int)(buildings.Count * 0.1));
                    break;
                }

                if (buildings.Count == 0)
                {
                    return;
                }

                KeyValuePair <Point, Building> building = buildings.ToList()[index];
                var edges = building.Value.GetAdjacent(grid);

                if (edges == null || edges.Count == 0)
                {
                    defenderID = Point.Zero;
                    return;
                }

                destination = Grid.ToGridPosition(edges.GetRandom(rng), Grid.GetTileSize);
                defenderID  = building.Key;
            }

            else
            {
                Building building = arch.GetBuilding(defenderID);
                var      edges    = building.AdjacentTiles;

                if (edges == null || edges.Count == 0)
                {
                    defenderID = Point.Zero;
                    return;
                }

                destination = Grid.ToGridPosition(edges.GetRandom(rng), Grid.GetTileSize);
            }

            Ai_States = Ai_States.Idle;
            Think_Pathing(grid, rng);
        }
Exemplo n.º 27
0
        public void Update(Cursor ms, GameTime gt, Architech arch, Grid grid, Random rng, Overseer os, UiMaster ui)
        {
            if (stuck)
            {
                stuck = false;
                var b   = arch.GetBuilding(home);
                var adj = b.GetAdjacent(grid);
                if (adj.Count > 0)
                {
                    Position = adj[0];
                }
            }

            if (Ai_States == Ai_States.Marching)
            {
                Ai_States  = Ai_States.Target;
                this.Speed = temp_speed;
            }
            if (home == arch.Home || !arch.GetBuildings.ContainsKey(home))
            {
                SetHome(arch, os);
            }
            else
            {
                if (Vector2.Distance(Position, arch.GetBuilding(home).Center) > 264)
                {
                    Position  = arch.GetBuilding(home).Center;
                    Ai_States = Ai_States.Target;
                }
            }

            base.Update(ms, gt);
            base.Update(gt);
            base.Update(grid);
            CalculateCorners();
            GetFreeCorners(grid);
            RefreshInfo();

            if (IsHighlighted)
            {
                ui.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(this.ID, Info));
            }
            else
            {
                ui.RemoveInfo(this.ID);
            }

            if (Ai_States == Ai_States.Thinking)
            {
                return;
            }

            if (base.data.Type == Ai_Type.Z_Archer || base.data.Type == Ai_Type.Z_Priest)
            {
                foreach (var proj in projectile.Values)
                {
                    if (os.Ais.ContainsKey(target))
                    {
                        proj.Update(gt);
                    }
                }
            }

            if (Ai_States == Ai_States.Dead)
            {
                return;
            }

            if (Ai_States != Ai_States.Pathing)
            {
                CheckTarget(os);
            }

            switch (Ai_States)
            {
            case Ai_States.Idle:
                CurrentState = "Think";
                if (wait)
                {
                    Think_Pathing(grid, rng);
                }
                else if (PFResult != null)
                {
                    Think_Pathing(grid, rng);
                }
                return;

            case Ai_States.Target:
                CurrentState = "Think";
                EasyGetTarget(arch, os, grid, rng);     //can go to idle or move
                break;

            case Ai_States.Moving:
                CurrentState = "Move";
                Moving(os, grid, gt);     // can go to idle or attacking
                break;

            case Ai_States.Attacking:
                CurrentState = "Attack";
                Attacking(os, arch, gt, rng, grid);     // can go to idle or target
                break;

            case Ai_States.Pathing:
                CycleDestinations(grid, rng, os);
                break;

            case Ai_States.Dead:
                return;
            }
            prevPos = Position;
        }
Exemplo n.º 28
0
        public void SpellEffect(Spell attacker, Grid grid, Architech arch)
        {
            float range = attacker.Stats.Range * 64;
            //get all units in spell radius
            //apply spell effect
            var inrange = GetUnitsInRange(attacker.Center, range, false);
            var zombs   = GetZombsInRange(attacker.Center, range);

            switch (attacker.Stats.Type)
            {
            case SpellType.Ressurect:
                foreach (Guid id in inrange)
                {
                    if (ais[id].GetStats().Health <= 0)
                    {
                        ais[id].IsZombie = true;
                        ZombieSwap(id, grid, arch);
                        Statistics.Ressurections++;
                    }
                }
                break;

            case SpellType.DeadAgain:
                foreach (Guid id in zombs)
                {
                    AiSwap(id, grid, arch);
                }
                break;

            case SpellType.RestoreEssence:
                foreach (Guid id in zombs)
                {
                    if (zombies[id].GetStats().Health < zombies[id].RHealth)
                    {
                        zombies[id].GetStats().Health += attacker.Stats.Damage;
                        zombies[id].GetStats().Health  = MathHelper.Clamp(zombies[id].GetStats().Health, 0, zombies[id].RHealth);
                    }
                }
                break;

            case SpellType.DrainEssence:
                foreach (Guid id in inrange)
                {
                    if (ais.ContainsKey(id))
                    {
                        ais[id].GetStats().Health -= attacker.Stats.Damage;
                    }
                }
                break;

            case SpellType.ClearDead:
                var dead = GetUnitsInRange(attacker.Center, range, false);
                foreach (Guid id in dead)
                {
                    if (ais[id].Ai_States == Ai_States.Dead)
                    {
                        remove_queue.Add(id);
                    }
                }
                break;
            }
        }