Example #1
0
 void RemoveInfo(UiMaster master, ButtonFunction[] buttonFunctions)
 {
     foreach (ButtonFunction bf in buttonFunctions)
     {
         master.RemoveInfo(research[bf].ToList()[stager[bf].Item3].Value.ID);
     }
 }
Example #2
0
 void RemoveInfo(UiMaster master, SpellType[] buttonFunctions)
 {
     foreach (SpellType st in buttonFunctions)
     {
         master.RemoveInfo(spell_data[st].ID);
     }
 }
Example #3
0
 void RemoveInfo(UiMaster master, BuildingTypes[] buttonFunctions)
 {
     foreach (BuildingTypes bf in buttonFunctions)
     {
         master.RemoveInfo(building_data[bf].Id);
     }
 }
Example #4
0
        void NextResearch(int ind, UiMaster master, ButtonFunction b)
        {
            if (stager[b].Item2 == true)
            {
                master.ManipulateElements("Tree Complete", Player_Modes.Research, b.ToString(), ind);

                switch (b)
                {
                case ButtonFunction.R1:
                    Statistics.Ending = Endings.Death;
                    break;

                case ButtonFunction.R2:
                    Statistics.Ending = Endings.Passive;
                    break;

                case ButtonFunction.R3:
                    Statistics.Ending = Endings.God;
                    break;
                }

                return;
            }

            master.ManipulateElements(research[b].ToList()[stager[b].Item3].Value.Data.Name + "\r\n" +
                                      research[b].ToList()[stager[b].Item3].Value.CurrentProgress.PercentAofB(research[b].ToList()[stager[b].Item3].Value.Data.ResearchTime) + "%", Player_Modes.Research, b.ToString(), ind);
        }
Example #5
0
 public void CastSpell(Grid grid, SpellType spell, Player p, UiMaster ui)
 {
     if ((spell == SpellType.Ressurect && !p.IsPopFull) || spell != SpellType.Ressurect)
     {
         castedSpells.Add(Guid.NewGuid().GetHashCode(), new Spell(grid.GetTile(grid.SelectedTiles[0]).Position, spell_data[spell], spell_types[spell]));
     }
     else
     {
         ui.Messenger.AddMessage(new Text(Vector2.One, "Population Cap Reached", Color.DarkRed));
     }
 }
Example #6
0
 public void BuildComplete(Building b, Grid grid, UiMaster ui)
 {
     grid.SelectedTiles = new List <Point>(b.GetChildren);
     //set tiles found to blocked
     if (b.GetBuildingData().Type != BuildingTypes.Grave)
     {
         grid.ChangeSelectedTilesState(TileStates.Blocked);
     }
     ui.Messenger.AddMessage(new Text(Vector2.Zero, b.GetBuildingData().Name + " Constructed", Color.DodgerBlue));
     buildingPlaced = true;
 }
Example #7
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();
        }
Example #8
0
    private void StartUpUi()
    {
        UiMaster ui = FindObjectOfType <UiMaster>();

        if (ui)
        {
            ui.InGameUI.SetActive(false);
            ui.FrontEndUI.SetActive(true);
        }
        else
        {
            UiMaster.OnUiLoaded -= OnUiLoaded;
            UiMaster.OnUiLoaded += OnUiLoaded;
        }
    }
Example #9
0
        public void Update(GameTime gt, UiMaster master, Player p)
        {
            List <Guid> temp = timers.Keys.ToList();

            foreach (var id in temp)
            {
                timers[id] += gt.ElapsedGameTime.Milliseconds;

                if (timers[id] >= maxTime)
                {
                    remove_queue.Add(id);
                }
            }

            foreach (var id in remove_queue)
            {
                RemovePanel(id);
            }

            remove_queue.Clear();

            if (p.Input.IsPressed(Ctrls.HotKey_Cycle_Forward, true))
            {
                selectedPanel += 1;
            }
            if (p.Input.IsPressed(Ctrls.HotKey_Cycle_Backward, true))
            {
                selectedPanel -= 1;
            }

            switch (master.NextAction)
            {
            case ButtonFunction.C_Forward:
                selectedPanel += 1;
                master.Pop_Action();
                break;

            case ButtonFunction.C_Backward:
                master.Pop_Action();
                selectedPanel -= 1;
                break;
            }
        }
Example #10
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, );
     }
 }
Example #11
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;
        }
Example #12
0
        public void Update(Player player, GameTime gt, Architech arch, Grid grid, List <Rectangle> units, UiMaster ui)
        {
            base.Update(player.Cursor, gt);

            statusBar.Update(data.Health);
            statusBar.UpdatePosition(Position);

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

            switch (state)
            {
            case BuildingStates.Building:
                Build(gt, arch, grid, units, player, ui);
                break;

            case BuildingStates.Disabled:
                break;
            }
        }
Example #13
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;
                }
            }
        }
Example #14
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;
                }
            }
        }
Example #15
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);
            }
        }
Example #16
0
        public void Update(Grid grid, UiMaster master, Overseer os, Player player, GameTime gt, List <Rectangle> units)
        {
            buildingPlaced    = false;
            buildingDestroyed = false;



            foreach (KeyValuePair <Point, Building> kv in buildings)
            {
                kv.Value.Update(player, gt, this, grid, units, master);

                if (kv.Value.State == BuildingStates.Production)
                {
                    kv.Value.Produce(player, gt, os);
                }

                if (kv.Value.GetBuildingData().Health <= 0)
                {
                    remove_queue.Add(kv.Key);
                }
            }

            foreach (Point id in remove_queue)
            {
                Dismantle(grid, GetBuilding(id), player);
                buildings.Remove(id);
            }
            remove_queue.Clear();

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

                case ButtonFunction.Grave:
                    master.Pop_Action();
                    selectedBuilding = ButtonFunction.Grave.ToString();
                    break;

                case ButtonFunction.EnergyConduit:
                    master.Pop_Action();
                    selectedBuilding = ButtonFunction.EnergyConduit.ToString();
                    break;

                case ButtonFunction.NecroticOrrery:
                    master.Pop_Action();
                    selectedBuilding = ButtonFunction.NecroticOrrery.ToString();
                    break;

                case ButtonFunction.Demolish:
                    master.Pop_Action();
                    selectedBuilding = ButtonFunction.Demolish.ToString();
                    break;
                }
            }

            if (master.Highlight != ButtonFunction.Nan)
            {
                switch (master.Highlight)
                {
                case ButtonFunction.EnergyConduit:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(building_data[BuildingTypes.EnergyConduit].Id,
                                                                          building_data[BuildingTypes.EnergyConduit].Info));
                    RemoveInfo(master, new BuildingTypes[] { BuildingTypes.Grave, BuildingTypes.Wall, BuildingTypes.NecroticOrrery });
                    break;

                case ButtonFunction.NecroticOrrery:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(building_data[BuildingTypes.NecroticOrrery].Id,
                                                                          building_data[BuildingTypes.NecroticOrrery].Info));
                    RemoveInfo(master, new BuildingTypes[] { BuildingTypes.Grave, BuildingTypes.Wall, BuildingTypes.EnergyConduit });
                    break;

                case ButtonFunction.Wall:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(building_data[BuildingTypes.Wall].Id,
                                                                          building_data[BuildingTypes.Wall].Info));
                    RemoveInfo(master, new BuildingTypes[] { BuildingTypes.Grave, BuildingTypes.NecroticOrrery, BuildingTypes.EnergyConduit });
                    break;

                case ButtonFunction.Grave:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(building_data[BuildingTypes.Grave].Id,
                                                                          building_data[BuildingTypes.Grave].Info));
                    RemoveInfo(master, new BuildingTypes[] { BuildingTypes.Wall, BuildingTypes.NecroticOrrery, BuildingTypes.EnergyConduit });
                    break;

                case ButtonFunction.Demolish:
                    master.RecieveInfo(new KeyValuePair <Guid, InfoPanel>(building_data[BuildingTypes.Demolish].Id,
                                                                          building_data[BuildingTypes.Demolish].Info));
                    break;
                }
            }

            if (player.Mode != Player_Modes.Building)
            {
                RemoveInfo(master, new BuildingTypes[] { BuildingTypes.Wall, BuildingTypes.NTower, BuildingTypes.Grave, BuildingTypes.EnergyConduit });
            }


            if (player.Cursor.isLeftPressed && player.Cursor.GetState != player.Cursor.prevState &&
                grid.IsHighlighted && selectedBuilding != "" && player.Mode == Player_Modes.Building)
            {
                PlaceBuilding(grid, (BuildingTypes)Enum.Parse(typeof(BuildingTypes), selectedBuilding));
            }

            else if (player.Cursor.isLeftPressed && player.Cursor.GetState != player.Cursor.prevState &&
                     grid.IsHighlighted && (player.Mode == Player_Modes.Tools && selectedBuilding == ButtonFunction.Demolish.ToString()))
            {
                Dismantle(grid, player);
            }
        }
Example #17
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;
        }
Example #18
0
        void Build(GameTime gt, Architech arch, Grid grid, List <Rectangle> units, Player player, UiMaster ui)
        {
            bool impassable = false;

            foreach (Rectangle rect in units)
            {
                if (this.Box.Intersects(rect))
                {
                    impassable = true;
                    break;
                }
            }

            float tc_inc = GetBuildingData().Cost / 10;

            if ((Options.GetTick && !impassable && player.Energy >= tc_inc) || temp_cost >= GetBuildingData().Cost)
            {
                if (temp_cost < GetBuildingData().Cost)
                {
                    temp_cost += tc_inc;
                    var pct = Extensions.Extensions.PercentAofB(temp_cost, GetBuildingData().Cost) / 100;
                    GetBuildingData().Health = pct * temp_health;
                    player.IncreaseEnergy   -= tc_inc;
                }

                else
                {
                    this.GetBuildingData().Health = temp_health;
                    //finish building
                    state = BuildingStates.Production;                     //start producing
                    arch.BuildComplete(this, grid, ui);
                    base.CurrentState = "Production";
                }
            }

            else if (Options.GetTick && player.Energy <= tc_inc && !impassable)
            {
                float count    = Math.Abs(player.IncreaseEnergy);
                float increase = 1 / (count == 0 ? 1 : count);
                temp_cost += player.Energy + 1 / (Math.Abs(player.IncreaseEnergy) + 1);

                var pct = Extensions.Extensions.PercentAofB(temp_cost, GetBuildingData().Cost) / 100;
                GetBuildingData().Health = pct * temp_health;

                player.IncreaseEnergy -= player.Energy + 1 / (Math.Abs(player.IncreaseEnergy) + 1);
            }
        }
Example #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;
            }
        }
Example #20
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;
            }
        }