public void Spin()
        {
            Spins = 0;
            var t = 1000;

            Slot0.Spin(t);
            Slot1.Spin(t * 2);
            Slot2.Spin(t * 3);
            SoundPlayer.Instance.Play(SoundTrack.Get("sfx_slot" + RNG.Next(0, 3)));
        }
Exemplo n.º 2
0
 public InventoryManager()
 {
     Slot1          = new Slot1(CommonEnums.Interactables.None);
     Slot2          = new Slot2(CommonEnums.Interactables.None);
     Slot3          = new Slot3(CommonEnums.Interactables.None);
     InventorySlots = new Dictionary <CommonEnums.InventorySlot, CommonEnums.Interactables>();
     InventorySlots.Add(CommonEnums.InventorySlot.Slot1, Slot1.Contains);
     InventorySlots.Add(CommonEnums.InventorySlot.Slot2, Slot2.Contains);
     InventorySlots.Add(CommonEnums.InventorySlot.Slot3, Slot3.Contains);
 }
Exemplo n.º 3
0
        public override void Write(ref NetworkStream netstream)
        {
            using (Stream stream = new MemoryStream())
            {
                // write id
                stream.Write(BitConverter.GetBytes((ushort)this.ID), 0, 2);

                // write temporary size
                stream.Write(BitConverter.GetBytes(0), 0, 4);

                // write pctypes
                stream.WriteByte((byte)_pctypes[0]);
                stream.WriteByte((byte)_pctypes[1]);
                stream.WriteByte((byte)_pctypes[2]);

                // store header size
                int headersize = (int)stream.Position;

                // write slots
                if (Slot1 != null)
                {
                    Slot1.Write(stream);
                }

                if (Slot2 != null)
                {
                    Slot2.Write(stream);
                }

                if (Slot3 != null)
                {
                    Slot3.Write(stream);
                }

                byte[] result = new byte[stream.Length];

                // go back and write body size
                this.BodySize = (uint)(stream.Length - headersize);

                stream.Position = 2;
                stream.Write(BitConverter.GetBytes(this.BodySize), 0, 4);

                // write memorystream to networkstream
                stream.Position = 0;
                stream.CopyTo(netstream);
            }
        }
Exemplo n.º 4
0
        public override void SetActualSize(Point available)
        {
            if (!Visible)
            {
                SetDimension(Point.Zero, available);
                return;
            }

            Point minSize = GetExpectedSize(available);

            SetDimension(minSize, available);

            Rectangle client = ActualClientArea;

            if (Orientation == Orientation.Horizontal)
            {
                // Trennung zwischen links und rechts
                if (Slot1 != null)
                {
                    Slot1.SetActualSize(new Point(ActualSplitterPosition, client.Height));
                }
                if (Slot2 != null)
                {
                    Slot2.SetActualSize(new Point(client.Width - SplitterSize - ActualSplitterPosition, client.Height));
                    Slot2.ActualPosition += new Point(ActualSplitterPosition + SplitterSize, 0);
                }
            }
            else if (Orientation == Orientation.Vertical)
            {
                // Trennung zwischen oben und unten
                if (Slot1 != null)
                {
                    Slot1.SetActualSize(new Point(client.Width, ActualSplitterPosition));
                }
                if (Slot2 != null)
                {
                    Slot2.SetActualSize(new Point(client.Width, client.Height - SplitterSize - ActualSplitterPosition));
                    Slot2.ActualPosition += new Point(0, ActualSplitterPosition + SplitterSize);
                }
            }
        }
 private void Slot_FinishedSpin(object sender, EventArgs e)
 {
     Spins++;
     if (Spins == 3)
     {
         Int32  dice;
         Entity prize = null;
         var    res0  = Slot0.GetResult();
         var    res1  = Slot1.GetResult();
         var    res2  = Slot2.GetResult();
         dice = RNG.Next(100);
         if (res0 == res1 && res0 == res2)
         {
             if (dice < 65)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.VeryRare).Random();
             }
             else if (dice < 80)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Epic).Random();
             }
             else if (dice <= 95)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Legendary).Random();
             }
         }
         else if (res0 == res1 || res1 == res2 || res0 == res2)
         {
             if (dice < 30)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Uncommon).Random();
             }
             else if (dice < 60)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Rare).Random();
             }
             else if (dice < 90)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.VeryRare).Random();
             }
             else if (dice <= 100)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Epic).Random();
             }
         }
         else
         {
             if (dice < 50)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Common).Random();
             }
             else if (dice < 70)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Uncommon).Random();
             }
             else if (dice < 95)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Rare).Random();
             }
             else if (dice < 99)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.VeryRare).Random();
             }
             else if (dice <= 100)
             {
                 prize = Entity.GetAll().Where(x => x.Rarity == Rarity.Epic).Random();
             }
         }
         var prizeSticker = new Sticker(prize, overrideValidation: true);
         prizeSticker.Width  = 150;
         prizeSticker.Height = 225;
         LastPrizePanel.Children.Clear();
         LastPrizePanel.Children.Add(prizeSticker);
         GameMaster.Player.Inventory.Add(new SimpleSticker()
         {
             ItemID = prize.ID
         });
         DebugUtils.Log($"Minigame prize => <{prize.ID}> => {prize.Rarity}!");
         SoundPlayer.Instance.Play(SoundTrack.Get("sfx_coins"));
         IsSpinning = false;
     }
 }