public GameTimer(ProgressBar progressbar, float percent, Action callback, Button slotBtn, double interval = 1000d) { this.progressbar = progressbar; this.callback = callback; try { step = Convert.ToInt32(percent * progressbar.TextureWidth); } catch { //just for lulz. try { step = Convert.ToInt32(0.01f * progressbar.TextureWidth); } catch { step = 1; } } this.interval = interval; changeProgress = false; width = 0; //isBeingStarted = false; timer = new Timer(interval); timer.Elapsed += new ElapsedEventHandler(Tick); SlotBtn = slotBtn; }
public StationOnBuilding(Texture2D first, Texture2D second, Texture2D third, Texture2D fourth, Vector2 position, Vector2 scale, ProgressBar progress, int hp) { FirstStageTexture = first; SecondStageTexture = second; ThirdStageTexture = third; FourthStageTexture = fourth; CurrentTexture = FirstStageTexture; Position = position; Scale = scale; FinalWidth = Position.X + CurrentTexture.Width * Scale.X; FinalHeight = Position.Y + CurrentTexture.Height * Scale.Y; IsVisible = true; MaxHP = HP = hp; this.progress = progress; Query = new ProductQuery(); Query.IsVisible = true; Query.Add(new GameTimer(Progress, 0.1f, () => { Progress.PWidth = 0; if (OnBuildingComplete != null) { OnBuildingComplete(this); } }, null)); }
public StationOnBuilding GetStationOnBuilding(StationBuilder builder) { Texture2D first = Content.Load<Texture2D>("Stations/StationOnBuildingStage1"); Texture2D second = Content.Load<Texture2D>("Stations/StationOnBuildingStage2"); Texture2D third = Content.Load<Texture2D>("Stations/StationOnBuildingStage3"); Texture2D fourth = Content.Load<Texture2D>("Stations/StationOnBuildingStage4"); Texture2D progressTexture = Content.Load<Texture2D>("UI/Lines/YellowLine"); Vector2 progressPosition = new Vector2(builder.Position.X, builder.Position.Y - progressTexture.Height - 5); ProgressBar progress = new ProgressBar(progressTexture, progressPosition, new Vector2(Scales.None)); StationOnBuilding temp = new StationOnBuilding(first, second, third, fourth, builder.Position, new Vector2(Scales.None), progress, 100); temp.Owner = "Enemy";//Player.Name; temp.Name = "Station On Build"; temp.PositionFromCenter = builder.PositionFromCenter; return temp; }