示例#1
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;
            }
        }
示例#2
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);
            }
        }