예제 #1
0
        public override void Update(GameTime gameTime)
        {
            doneButton.Update(gameTime);
            undoButton.Update(gameTime);

            if (doneButton.IsClicked(Main.MouseState) && !doneButton.IsClicked(Main.oldMouseState))
            {
                Main.CurrentState  = States.LevelSelect;
                Main.PreviousState = States.StatsScreen;
            }

            //if u want to do multiple undo's u need stack thingy
            if (undoButton.IsClicked(Main.MouseState) && !undoButton.IsClicked(Main.oldMouseState) && lastButtonClicked != null)
            {
                var list = Economics.GetListByName(lastButtonClicked.Name);
                lastButtonClicked.Cost = list[lastButtonClicked.StarTextures.Count - 2];
                Economics.Money       += lastButtonClicked.Cost;
                var starToRemove = lastButtonClicked.StarTextures[lastButtonClicked.StarTextures.Count - 1];
                lastButtonClicked.StarTextures.Remove(starToRemove);
                string[] array = lastButtonClicked.Label.Text.Split(':');
                lastButtonClicked.Label.Text = $"{array[0]}:{lastButtonClicked.StarTextures.Count}";
                lastButtonClicked            = null;
            }

            for (int i = 0; i < TankStats.Count; i++)
            {
                switch (TankStats[i].Name)
                {
                case "sheild":
                    TankStats[i].Cost = Economics.HealthCosts[TankStats[i].StarTextures.Count - 1];
                    break;

                case "damage":
                    TankStats[i].Cost = Economics.DamageCosts[TankStats[i].StarTextures.Count - 1];
                    break;

                case "speed":
                    TankStats[i].Cost = Economics.SpeedCosts[TankStats[i].StarTextures.Count - 1];
                    break;

                case "fog":
                    TankStats[i].Cost = Economics.DeFoggerCosts[TankStats[i].StarTextures.Count - 1];
                    break;
                }
                TankStats[i].Update(gameTime, ref lastButtonClicked);
            }
            base.Update(gameTime);
        }
예제 #2
0
 public void Update(GameTime gameTime, ref StatsButton lastButtonClicked, GraphicsDevice graphicsDevice = null)
 {
     if (Enabled && IsClicked(Main.MouseState) && !IsClicked(Main.oldMouseState) && StarTextures.Count < 4 && Economics.Money - Cost >= 0)
     {
         lastButtonClicked = this;
         var lastStar = StarTextures[StarTextures.Count - 1];
         StarTextures.Add(new Sprite(lastStar.Texture, new Vector2(lastStar.Position.X + lastStar.ScaledWidth, lastStar.Position.Y), Color.White, lastStar.Scale));
         string[] array = Label.Text.Split(':');
         Label.Text       = $"{array[0]}:{StarTextures.Count}";
         Economics.Money -= Cost;
     }
     else if (StarTextures.Count >= 4)
     {
         Enabled = false;
         Color   = Color.Gray;
     }
     base.Update(gameTime, graphicsDevice);
 }