예제 #1
0
 public void DrawMaterialSlot(int Index, int Position)
 {
     Rectangle Rect = Renderer.GetPartialRect(0.1f , 0.1f + 0.05f * Position, 0.05f, 0.05f);
     Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, Rect, Color.White);
     if (GeneralManager.Singleton.CurrentPlayer.MaterialsInventory.Count > Index && GeneralManager.Singleton.CurrentPlayer.MaterialsInventory[Index] != null)
     {
         Renderer.Singleton.batch.Draw(GeneralManager.Singleton.CurrentPlayer.MaterialsInventory[Index].Tex, Rect, Color.White);
         Rectangle SmallRect = Renderer.GetPartialRect(0.13f, 0.13f + 0.05f * Position, 0.02f, 0.02f);
         Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, SmallRect, Color.White);
         Text Label = new Text(Game);
         Label.Font = Renderer.Singleton.Content.Load<SpriteFont>("Font");
         Label.Rect = SmallRect;
         Label.Name = GeneralManager.Singleton.CurrentPlayer.MaterialsInventory[Index].Count.ToString();
         Label.Draw(null);
     }
 }
예제 #2
0
        public void DrawComponentsTrade(TradeOptions Options)
        {
            int i = 0;
            foreach (BuyOption B in Options.Buy)
            {
                i++;
                Rectangle Slot = new Rectangle((int)(Renderer.Width * 1.5 / 10), (int)(10 + Renderer.Height * i / 10), (int)(Renderer.Width/ 10), (int)(Renderer.Height /10));
                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, Slot, Color.White);
                Renderer.Singleton.batch.Draw(B.Item.Tex, Slot, Color.White);

                Rectangle PriceRect = new Rectangle(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4, Slot.Width * 1 / 4, Slot.Height * 1 / 4);

                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, PriceRect, Color.White);
                Text PriceText = new Text(Game);
                PriceText.Name = B.Price.ToString();
                PriceText.Rect = PriceRect;
                PriceText.Font = Font;
                PriceText.Draw(null);
                //Renderer.Singleton.batch.DrawString(Font, B.Price.ToString(), new Vector2(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4), Color.White, 0.0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0.0f);

            }

            i = 0;

            foreach (SellOption B in Options.Sell)
            {
                i++;
                Rectangle Slot = new Rectangle((int)(Renderer.Width * 2.5 / 10), (int)(10 + Renderer.Height * i  / 10), (int)(Renderer.Width / 10), (int)(Renderer.Height / 10));
                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, Slot, Color.White);
                Renderer.Singleton.batch.Draw(B.Item.Tex, Slot, Color.White);

                Rectangle PriceRect = new Rectangle(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4, Slot.Width * 1 / 4, Slot.Height * 1 / 4);

                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, PriceRect, Color.White);
                Text PriceText = new Text(Game);
                PriceText.Name = B.Price.ToString();
                PriceText.Rect = PriceRect;
                PriceText.Font = Font;
                PriceText.Draw(null);
               // Renderer.Singleton.batch.DrawString(Font, B.Price.ToString(), new Vector2(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4), Color.White, 0.0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0.0f);
            }
        }
예제 #3
0
        public override void Draw(GameTime gameTime)
        {
            if (Visible)
            {

                foreach (Background B in Backgrounds)
                {
                    Renderer.Singleton.batch.Draw(B.Tex, new Rectangle(0, 0, Camera.Width, Camera.Height), new Rectangle((int)(Camera.X / 10), (int)(Camera.Y / 10), (int)(B.Tex.Width / B.Scale.X), (int)(B.Tex.Height / B.Scale.Y)), B.Color);
                }

                bool IsCurrentPlayerOnVertex = false;

                foreach (VertexComponent C in Components)
                {
                    C.Draw(gameTime);
                }

                foreach (Ship S in Ships)
                {
                    if (S.Equals(GeneralManager.Singleton.CurrentPlayer.Ship) && S.State == Ship.ShipState.InVertex)
                    {
                        IsCurrentPlayerOnVertex = true;
                    }
                    if (S.State == Ship.ShipState.InVertex)
                    {
                        if (S.Equals(SelectedShip))
                        {
                            Renderer.Animations["ShipSelector"].Position = S.DrawPosition - Renderer.Animations["ShipSelector"].FrameSize / 2;
                            Renderer.Animations["ShipSelector"].Draw(gameTime);
                        }
                        if (S.ShipView)
                        {
                            S.DrawOutside(gameTime);
                        }
                        else
                        {
                            S.DrawInside(gameTime);
                        }

                        if (S.Equals(SelectedShip))
                        {
                            Renderer.Singleton.batch.Draw(Renderer.Textures["ShipInfo"], new Rectangle((int)(S.DrawPosition.X), (int)(S.DrawPosition.Y - Renderer.Height * 0.1f), (int)(Renderer.Width * 0.1f), (int)(Renderer.Height * 0.1f)), Color.White);
                            Text Text = new Text(Game);
                            Text.Font = Renderer.Fonts["Visitor"];
                            Text.Name = S.HitPoints.ToString() + " / " + S.Hull.BasicHull.ToString();
                            Text.Rect = new Rectangle((int)(S.DrawPosition.X) + 10, (int)(S.DrawPosition.Y - Renderer.Height * 0.1f + 10), 100, 12);
                            Text.Draw(gameTime);
                        }
                    }

                    if (S.Hull.Mask.CheckCollision(GeneralManager.Singleton.MousePos - S.DrawPosition + S.OutsideView.FrameSize/2) && GeneralManager.Singleton.CheckLMB())
                    {
                        SelectedShip = S;
                    }
                }

                if (IsCurrentPlayerOnVertex)
                {
                    if (!Camera.Intersects(new Rectangle((int)GeneralManager.Singleton.CurrentPlayer.Ship.Position.X, (int)GeneralManager.Singleton.CurrentPlayer.Ship.Position.Y, (int)GeneralManager.Singleton.CurrentPlayer.Ship.OutsideView.FrameSize.X, (int)GeneralManager.Singleton.CurrentPlayer.Ship.OutsideView.FrameSize.Y)))
                    {
                        ShipIndicatorPosition = GeneralManager.Singleton.CurrentPlayer.Ship.Position - new Vector2(Camera.X, Camera.Y);

                        short Direction = 0; // 0 - top, 1 - right, 2 - bottom, 3- left

                        if (ShipIndicatorPosition.X < 100)
                        {
                            Direction = 3;
                            ShipIndicatorPosition.X = 100;
                        }
                        else if (ShipIndicatorPosition.X > Camera.Width - 100)
                        {
                            Direction = 1;
                            ShipIndicatorPosition.X = Camera.Width - 100;
                        }
                        if (ShipIndicatorPosition.Y < 100)
                        {
                            Direction = 0;
                            ShipIndicatorPosition.Y = 100;
                        }
                        else if (ShipIndicatorPosition.Y > Camera.Height - 100)
                        {
                            Direction = 2;
                            ShipIndicatorPosition.Y = Camera.Height - 100;
                        }
                        switch (Direction)
                        {
                            case 0:
                                Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, ShipIndicatorPosition - new Vector2(Renderer.Singleton.ShipIndicator.Width / 2, Renderer.Singleton.ShipIndicator.Height / 2), Color.White);
                                break;
                            case 1:
                                Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, new Vector2((ShipIndicatorPosition.X - (Renderer.Singleton.ShipIndicator.Width / 2)), (ShipIndicatorPosition.Y - Renderer.Singleton.ShipIndicator.Height / 2)), null, Color.White, (float)(0.5f * Math.PI), new Vector2(50, 50), Vector2.One, SpriteEffects.None, 0.0f);
                                break;
                            case 2:
                                Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, new Vector2((ShipIndicatorPosition.X - (Renderer.Singleton.ShipIndicator.Width / 2)), (ShipIndicatorPosition.Y - Renderer.Singleton.ShipIndicator.Height / 2)), null, Color.White, (float)(1.0f * Math.PI), new Vector2(50, 50), Vector2.One, SpriteEffects.None, 0.0f);
                                break;
                            case 3:
                                Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, new Vector2((ShipIndicatorPosition.X - (Renderer.Singleton.ShipIndicator.Width / 2)), (ShipIndicatorPosition.Y - Renderer.Singleton.ShipIndicator.Height / 2)), null, Color.White, (float)(1.5f * Math.PI), new Vector2(50, 50), Vector2.One, SpriteEffects.None, 0.0f);
                                break;
                        }

                    }

                }

                Renderer.Singleton.batch.Draw(Renderer.Singleton.FromVertexToLevelGUI, Vector2.Zero, Color.White);
                DrawMinimap();
                DrawWeaponsMenu();
                Renderer.Singleton.DrawMoney();
            }
        }
예제 #4
0
        public void UpdateWeaponsMenu()
        {
            int Count = 0;
            foreach (Slot S in GeneralManager.Singleton.CurrentPlayer.Ship.Hull.Slots)
            {
                if (S.Component is Weapon)
                {
                    Count++;
                }
            }

            int i = 0;

            if (WeaponMode.Count == Count)
            {
                foreach (Slot S in GeneralManager.Singleton.CurrentPlayer.Ship.Hull.Slots)
                {
                    if (S.Component is Weapon)
                    {
                        Weapon W = S.Component as Weapon;
                        switch (W.WeaponMode)
                        {
                            case Weapon.Mode.Cursor:
                                WeaponMode[i].Choosen = 0;
                                break;
                            case Weapon.Mode.Auto:
                                WeaponMode[i].Choosen = 1;
                                break;
                            case Weapon.Mode.Off:
                                WeaponMode[i].Choosen = 2;
                                break;
                            case Weapon.Mode.Select:
                                WeaponMode[i].Choosen = 3;
                                break;
                        }
                        WeaponHeat[i].Progress = (float)W.Heat / (float)W.MaxHeat;
                        i++;
                    }
                }
            }

            else
            {
                WeaponMode = new List<RadioButton>();

                int x = 0;
                Weapon CurrentWeapon;

                for (int j = 0; j < Count; j++)
                {

                    while (!(GeneralManager.Singleton.CurrentPlayer.Ship.Hull.Slots[x].Component is Weapon))
                    {

                        x++;
                    }

                    CurrentWeapon = GeneralManager.Singleton.CurrentPlayer.Ship.Hull.Slots[x].Component as Weapon;

                    RadioButton Tmp = new RadioButton(Game);

                    Tmp.Boxes.Add(new CheckBox(Game, Renderer.GetPartialRect(0.91f, 0.25f + 0.02f * j, 0.015f, 0.015f), Renderer.Singleton.CheckBoxOn, Renderer.Singleton.CheckBoxOff));
                    Tmp.Boxes.Add(new CheckBox(Game, Renderer.GetPartialRect(0.93f, 0.25f + 0.02f * j, 0.015f, 0.015f), Renderer.Singleton.CheckBoxOn, Renderer.Singleton.CheckBoxOff));
                    Tmp.Boxes.Add(new CheckBox(Game, Renderer.GetPartialRect(0.95f, 0.25f + 0.02f * j, 0.015f, 0.015f), Renderer.Singleton.CheckBoxOn, Renderer.Singleton.CheckBoxOff));
                    Tmp.Boxes.Add(new CheckBox(Game, Renderer.GetPartialRect(0.97f, 0.25f + 0.02f * j, 0.015f, 0.015f), Renderer.Singleton.CheckBoxOn, Renderer.Singleton.CheckBoxOff));

                    WeaponMode.Add(Tmp);

                    Text Label = new Text(Game);
                    Label.Name = CurrentWeapon.Name;
                    Label.Rect = Renderer.GetPartialRect(0.81f, 0.25f + 0.02f * j, 0.09f, 0.02f);
                    Label.Font = Renderer.Singleton.Content.Load<SpriteFont>("Font");
                    WeaponLabel.Add(Label);

                    ProgressBar Progr = new ProgressBar(Game, Renderer.GetPartialRect(0.81f, 0.25f + 0.02f * j, 0.09f, 0.02f), Renderer.Singleton.ProgressBackground, Renderer.Singleton.HeatGradient, Renderer.Singleton.ProgressOverlay);

                    WeaponHeat.Add(Progr);
                }

            }

            foreach (RadioButton R in WeaponMode)
            {
                R.Update(null);
            }
        }
예제 #5
0
 public void DrawMoney()
 {
     Rectangle Rect = new Rectangle((int)(Width * 0.4), 0, (int)(Width * 0.2), (int)(Height * 0.1));
     batch.Draw(MoneyBackground, Rect, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.2f);
     Text Money = new Text(Game);
     Money.Rect = Rect;
     Money.Font = Content.Load<SpriteFont>("Font");
     Money.Name = GeneralManager.Singleton.CurrentPlayer.Money.ToString();
     Money.Draw(null);
 }
예제 #6
0
        public void DrawMaterialsTrade()
        {
            //TODO : Drawing avalible buy and sell materials
            for (int i = 0; i < SellMaterials.Count; i++ )
            {
                Rectangle Slot = Renderer.GetPartialRect(0.2f, 0.2f + 0.05f * i, 0.05f, 0.05f);
                Rectangle PriceRect = Renderer.GetPartialRect(0.23f, 0.23f + 0.05f * i, 0.02f, 0.02f);

                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, Slot, Color.White);
                Renderer.Singleton.batch.Draw(SellMaterials[i].Tex, Slot, Color.White);

                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, PriceRect, Color.White);
                Text PriceText = new Text(Game);
                PriceText.Name = SellMaterials[i].AvgPrice.ToString();
                PriceText.Rect = PriceRect;
                PriceText.Font = Font;
                PriceText.Draw(null);
            }

            for (int i = 0; i < BuyMaterials.Count; i++)
            {
                Rectangle Slot = Renderer.GetPartialRect(0.3f, 0.2f + 0.05f * i, 0.05f, 0.05f);
                Rectangle PriceRect = Renderer.GetPartialRect(0.33f, 0.23f + 0.05f * i, 0.02f, 0.02f);

                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, Slot, Color.White);
                Renderer.Singleton.batch.Draw(BuyMaterials[i].Tex, Slot, Color.White);

                Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, PriceRect, Color.White);
                Text PriceText = new Text(Game);
                PriceText.Name = BuyMaterials[i].AvgPrice.ToString();
                PriceText.Rect = PriceRect;
                PriceText.Font = Font;
                PriceText.Draw(null);
            }

            Renderer.Singleton.batch.Draw(Renderer.Textures["BuyButton"], Renderer.GetPartialRect(0.18f, 0.75f, 0.15f, 0.1f), Color.White);
            Renderer.Singleton.batch.Draw(Renderer.Textures["SellButton"], Renderer.GetPartialRect(0.37f, 0.75f, 0.15f, 0.1f), Color.White);
        }