示例#1
0
        private void DisplayNewButtons()
        {
            if (CurrentlySelected == null)
            {
                return;
            }
            ButtonsToDisplay.Clear();

            Tower s = CurrentlySelected;
            //s.DrawRange = false;


            Vector2 DisplayLocation = WritingLocation;

            foreach (Edge e in s.TowersThisCanBeUpgradedInto)
            {
                if (s.TowerName != e.Destination.TowerName)
                {
                    Tower           T    = e.Destination;
                    SpriteAnimation anim = new SpriteAnimation(T.ButtonImage);
                    anim.AddAnimations("Default", new FrameAnimation(1, T.ButtonImage.Width, T.ButtonImage.Height, 1, 0, 0, new Point(1, 1)));

                    ButtonTower b = new ButtonTower(anim, DisplayLocation, T, e.GoldCost);
                    ButtonsToDisplay.Add(b);
                    DisplayLocation.X += b.spriteAnimation.CurrentAnimation.CurrentRect.Width + 2;
                }
            }
        }
示例#2
0
        private void DisplayDefault()
        {
            ButtonsToDisplay.Clear();
            Tower           t    = TowerGraph.Search(DefaultTowerName);
            SpriteAnimation anim = new SpriteAnimation(t.ButtonImage);

            anim.AddAnimations("Default", new FrameAnimation(1, t.ButtonImage.Width, t.ButtonImage.Height, 1, 0, 0, new Point(1, 1)));

            ButtonTower b = new ButtonTower(anim, new Vector2(WritingLocation.X, WritingLocation.Y), t, DefaultTowerCost);

            ButtonsToDisplay.Add(b);
        }
示例#3
0
 private void DisplayOnHoverToolBar()
 {
     if (spinButton.isAnimation1)
     {
         if (MouseScreenRect.Intersects(PanelRec))
         {
             foreach (Button b in ButtonsToDisplay)
             {
                 if (b.CheckIfClicked(MouseWorldRect))
                 {
                     DisplayHoverToolBar = true;
                     onHoverButton       = b as ButtonTower;
                     return;
                 }
             }
         }
     }
     DisplayHoverToolBar = false;
 }
示例#4
0
        //How A Left MouseClick is Handled.
        private void MouseClicked()
        {
            //Code To CheckIf We ClickedOnAnEnemy.
            foreach (Enemies enem in EnemiesInGame)
            {
                if (enem.CheckIfClicked(MouseWorldRect))
                {
                    NullifyEverything();
                    EnemySelected = enem;
                    if (!(EnemySelected.Type.ToString().Equals("Composite")))
                    {
                        GetEnemyElement();
                    }
                    EnemySelected.spriteAnimation.Shader = shader;
                    return;
                }
            }

            //Check if the SpinButtonIsClicked,
            if (spinButton.CheckIfClicked(MouseWorldRect))
            {
                SpinButtonClicked();
            }
            //If We are on the the Tower SelectionScreen.
            if (spinButton.isAnimation1)
            {
                //Check If any of the towers have been Clicked.
                foreach (Tower T in TowersInGame)
                {
                    if (T.CheckIfClicked(MouseWorldRect))
                    {
                        NullifyEverything();
                        CircleEffect = new DrawAble(new SpriteAnimation(CreateCircle((int)T.TowerRange)), T.Location, 0, 0);
                        Vector2 CricleEffectLocation = CircleEffect.Location;
                        CricleEffectLocation.X -= CircleEffect.spriteAnimation.CurrentAnimation.CurrentRect.Width / 2;
                        CricleEffectLocation.Y -= CircleEffect.spriteAnimation.CurrentAnimation.CurrentRect.Height / 2;
                        CricleEffectLocation.X += T.spriteAnimation.CurrentAnimation.CurrentRect.Width / 2;
                        CricleEffectLocation.Y += T.spriteAnimation.CurrentAnimation.CurrentRect.Height / 2;
                        CircleEffect.Location   = CricleEffectLocation;
                        CircleEffect.spriteAnimation.TintColor = Color.Red;
                        CurrentlySelected = T;
                        CurrentlySelected.spriteAnimation.Shader = shader;
                        CurrentlySelected.TurretAnim.Shader      = shader;
                        CreateSellButton();
                        DisplayNewButtons();
                        return;
                    }
                }
                //How To Handle A ButtonClick in TowerSection.
                foreach (Button b in ButtonsToDisplay)
                {
                    ButtonTower BT = b as ButtonTower; //We Know it is of the ButtonTower Kind.

                    if (b.CheckIfClicked(MouseWorldRect))
                    {
                        if (CurrentlySelected != null && CurrentlyClicked == null) //This Statement is True If We Want To update a tower.
                        {
                            Tower t = BT.Value;
                            if (CheckIfElementsRequirementMet(CurrentlySelected, t))
                            {
                                if (Gold >= BT.GoldToCreate)
                                {
                                    Game1.sound.playSound("OnTowerCreation");
                                    //if (r.Next(1, 9) < 4)
                                    //{
                                    //    Game1.sound.playSound("FoolishDecision");
                                    //}
                                    //else if (r.Next(1, 9) > 6)
                                    //{
                                    //    Game1.sound.playSound("SoYouThink");
                                    //}
                                    Gold -= BT.GoldToCreate;
                                    TowersInGame.Add(t.Copy(CurrentlySelected.Location, BT.GoldToCreate / 2));
                                    TowersInGame.Remove(CurrentlySelected);
                                    NullifyEverything();
                                    FlipFlopButtons();
                                }
                                else
                                {
                                    EffectsManager.NoGoldEffect();
                                }
                            }
                            else
                            {
                                EffectsManager.NotEnoughElements();
                            }
                        }
                        else // This Runs When We are making a base Tower
                        {
                            CurrentlyClicked = BT.Value;
                            TowerToDisplay   = CurrentlyClicked.Copy(BT.Location, BT.GoldToCreate / 2);
                        }
                        return;
                    }
                } // End Of Button Looping Code for Tower Panel.

                // This Runs When We have Clicked On a Button to Create a tower and we are not intersecting with the panel. It shows the red and green tower.
                if (CurrentlyClicked != null && !(PanelRec.Intersects(MouseScreenRect)))
                {
                    Vector2 TileAtClick = tilemap.GetCollTileAtPixel(new Vector2(MouseWorldRect.X, MouseWorldRect.Y));
                    if (tilemap.GetCollCellIndex(TileAtClick) == 1)
                    {
                        if (Gold >= DefaultTowerCost)
                        {
                            //This Code will Create A Default Tower if you have selected it.C:\Users\Arsinx\documents\visual studio 2010\Projects\EleTD\EleTD\EleTD\EffectsManager.cs
                            Gold -= DefaultTowerCost;
                            Game1.sound.playSound("OnTowerCreation");
                            //if (r.Next(1, 9) < 4)
                            //{
                            //    Game1.sound.playSound("FoolishDecision");
                            //}
                            //else if (r.Next(1, 9) > 6)
                            //{
                            //    Game1.sound.playSound("SoYouThink");
                            //}
                            TileAtClick *= 64;
                            TowersInGame.Add(CurrentlyClicked.Copy(TileAtClick, DefaultTowerCost));  // We are not Dividing the Tower Cost By 2 Because the basic tower has full Sell price.
                            tilemap.SetCollisionTile((int)TileAtClick.X, (int)TileAtClick.Y, 0);
                            CurrentlyClicked = null;
                            TowerToDisplay   = null;
                            return;
                        }
                        else
                        {
                            EffectsManager.NoGoldEffect();
                        }
                    }
                    else
                    {
                        EffectsManager.CantBuildEffect();
                        Game1.sound.playSound("CannotBuildTower");
                        return;
                    }
                } // End OF Selected Tower Display Code.

                //If We Click the Sell Button.
                if (CurrentlySelected != null)
                {
                    if (sellButton.CheckIfClicked(MouseWorldRect))
                    {
                        TowersInGame.Remove(sellButton.Value);
                        Game1.sound.playSound("OnTowerSell");
                        if (r.Next(1, 9) > 6)
                        {
                            Game1.sound.playSound("FoolishDecision");
                        }

                        EffectsManager.WritingEffect(sellButton.Value.CenterofSprite, sellButton.Value.SellPrice);
                        Gold += sellButton.Value.SellPrice;
                        NullifyEverything();
                        FlipFlopButtons();
                        return;
                    }
                } // End of Sell Code
            }
            else  //If Elements Screen is the main screen.
            {
                //How to handle elements if we are in the screen for Elements.
                foreach (Button b in ButtonsToDisplay)
                {
                    if (b.CheckIfClicked(MouseWorldRect))
                    {
                        ButtonElement BE = b as ButtonElement;
                        if (Materia > 0)
                        {
                            BoughtElementsList.Add(BE.Type);
                            Materia--;
                            return;
                        }
                        else
                        {
                            EffectsManager.NotEnoughMateria();
                        }
                    }
                }

                //TowerClick In Elements Section.
                foreach (Tower T in TowersInGame)
                {
                    if (T.CheckIfClicked(MouseWorldRect))
                    {
                        SpinButtonClicked();
                        CurrentlySelected = T;
                        CurrentlySelected.spriteAnimation.Shader = shader;
                        CurrentlySelected.TurretAnim.Shader      = shader;
                        CreateSellButton();
                        DisplayNewButtons();

                        return;
                    }
                }
            }
            NullifyEverything();
            FlipFlopButtons();
        }