Example #1
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            //Hide Cows and Bulls
            #region
            Bull1.Hide();
            Bull2.Hide();
            Bull3.Hide();
            Bull4.Hide();
            Cow1.Hide();
            Cow2.Hide();
            Cow3.Hide();
            Cow4.Hide();
            #endregion

            //Accept data
            #region
            data = System.IO.File.ReadAllLines("data.txt");
            num1 = Convert.ToInt32(data[0]);
            num2 = Convert.ToInt32(data[1]);
            num3 = Convert.ToInt32(data[2]);
            num4 = Convert.ToInt32(data[3]);



            #endregion

            //Zero
            #region
            bull = 0;
            cow  = 0;
            #endregion

            //Divide a number (rozdělit na celé císlo)
            #region
            int i = Convert.ToInt32(textBox1.Text);

            int a = i / 1000;
            int b = (i - (a * 1000)) / 100;
            int c = ((i - ((a * 1000) + (b * 100))) / 10);
            int d = (i - ((a * 1000) + (b * 100) + (c * 10)));
            #endregion

            //chief code (Hlavni kod)
            #region
            if (a == b || a == c || a == d)
            {
                MessageBox.Show("Type different numbers");
            }
            else
            {
                if (b == a || b == c || b == d)
                {
                    MessageBox.Show("Type different numbers");
                }
                else
                {
                    if (c == d || c == b || c == a)
                    {
                        MessageBox.Show("Type different numbers");
                    }
                    else
                    {
                        //Beyond (Dal)
                        #region
                        //Bulls
                        #region
                        if (a == num2 || a == num3 || a == num4)
                        {
                            bull++;
                        }
                        if (b == num1 || b == num3 || b == num4)
                        {
                            bull++;
                        }
                        if (c == num1 || c == num2 || c == num4)
                        {
                            bull++;
                        }
                        if (d == num1 || d == num2 || d == num3)
                        {
                            bull++;
                        }
                        #endregion

                        //Cow
                        #region
                        if (a == num1)
                        {
                            cow++;
                        }
                        if (b == num2)
                        {
                            cow++;
                        }
                        if (c == num3)
                        {
                            cow++;
                        }
                        if (d == num4)
                        {
                            cow++;
                        }
                        #endregion
                        #endregion
                    }
                }
            }
            #endregion

            //Show
            #region

            //bull
            #region
            if (bull == 1)
            {
                Bull1.Show();
            }
            if (bull == 2)
            {
                Bull1.Show();
                Bull2.Show();
            }
            if (bull == 3)
            {
                Bull1.Show();
                Bull2.Show();
                Bull3.Show();
            }
            if (bull == 4)
            {
                Bull1.Show();
                Bull2.Show();
                Bull3.Show();
                Bull4.Show();
            }
            #endregion

            //cow
            #region
            if (cow == 1)
            {
                Cow1.Show();
            }
            if (cow == 2)
            {
                Cow1.Show();
                Cow2.Show();
            }
            if (cow == 3)
            {
                Cow1.Show();
                Cow2.Show();
                Cow3.Show();
            }
            if (cow == 4)
            {
                Cow1.Show();
                Cow2.Show();
                Cow3.Show();
                Cow4.Show();

                if (point == 1)
                {
                    blabla = "You are lucky! XD";
                }
                else if (point <= 10)
                {
                    blabla = "Very very good! Nice game! xD";
                }
                else if (point > 10 && point <= 20)
                {
                    blabla = "Not bad!";
                }
                else if (point > 20)
                {
                    blabla = "May be better.";
                }

                MessageBox.Show("You won! You had " + point.ToString() + " attempts! " + blabla);
            }
            #endregion
            #endregion

            //Points
            #region
            point++;
            lblPoint.Text = point.ToString();
            #endregion
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Schovat Kravy a Byky
            #region
            Bull1.Hide();
            Bull2.Hide();
            Bull3.Hide();
            Bull4.Hide();
            Cow1.Hide();
            Cow2.Hide();
            Cow3.Hide();
            Cow4.Hide();

            point         = 0;
            lblPoint.Text = point.ToString();
            #endregion

            //Generovani
            #region
            //Prvni kroky
            #region
            Random rnd = new Random();
            num1 = 0;
            num2 = 0;
            num3 = 0;
            num4 = 0;
            #endregion

            //Generovani
            #region
            num1 = rnd.Next(0, 9);
            num2 = rnd.Next(0, 9);
            while (num2 == num1)
            {
                num2 = rnd.Next(0, 9);
            }

            num3 = rnd.Next(0, 9);
            while (num3 == num2 || num3 == num1)
            {
                num3 = rnd.Next(0, 9);
            }

            num4 = rnd.Next(0, 9);
            while (num4 == num3 || num4 == num2 || num4 == num1)
            {
                num4 = rnd.Next(0, 9);
            }

            #endregion

            //Uchovani
            #region
            data = new string[]
            {
                num1.ToString(),
                    num2.ToString(),
                    num3.ToString(),
                    num4.ToString(),
            };
            System.IO.File.WriteAllLines("data.txt", data);

            #endregion
            #endregion
        }
Example #3
0
        public virtual void Fill_OnTarget(Mobile from, object targ)
        {
            if (!IsEmpty || !Fillable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (bev.IsEmpty || !bev.ValidateUse(from, true))
                {
                    return;
                }

                Content  = bev.Content;
                Poison   = bev.Poison;
                Poisoner = bev.Poisoner;

                if (bev.Quantity > MaxQuantity)
                {
                    Quantity      = MaxQuantity;
                    bev.Quantity -= MaxQuantity;
                }
                else
                {
                    Quantity    += bev.Quantity;
                    bev.Quantity = 0;
                }
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Quantity == 0 || (Content == BeverageType.Water && !IsFull))
                {
                    Content = BeverageType.Water;

                    int iNeed = Math.Min((MaxQuantity - Quantity), bwc.Quantity);

                    if (iNeed > 0 && !bwc.IsEmpty && !IsFull)
                    {
                        bwc.Quantity -= iNeed;
                        Quantity     += iNeed;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is Item)
            {
                Item         item = (Item)targ;
                IWaterSource src;

                src = (item as IWaterSource);

                if (src == null && item is AddonComponent)
                {
                    src = (((AddonComponent)item).Addon as IWaterSource);
                }

                if (src == null || src.Quantity <= 0)
                {
                    return;
                }

                if (from.Map != item.Map || !from.InRange(item.GetWorldLocation(), 2) || !from.InLOS(item))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045);
                    return;
                }

                Content  = BeverageType.Water;
                Poison   = null;
                Poisoner = null;

                if (src.Quantity > MaxQuantity)
                {
                    this.Quantity = MaxQuantity;
                    src.Quantity -= MaxQuantity;
                }
                else
                {
                    Quantity    += src.Quantity;
                    src.Quantity = 0;
                }

                from.SendLocalizedMessage(1010089);
            }
            else if (targ is Cow1)
            {
                Cow1 cow = (Cow1)targ;

                if (cow.TryMilk(from))
                {
                    Content  = BeverageType.Milk;
                    Quantity = MaxQuantity;
                    from.SendLocalizedMessage(1080197); // You fill the container with milk.
                }
            }
            else if (targ is LandTarget)
            {
                int tileID = ((LandTarget)targ).TileID;

                PlayerMobile player = from as PlayerMobile;

                if (player != null)
                {
                    QuestSystem qs = player.Quest;

                    if (qs is WitchApprenticeQuest)
                    {
                        FindIngredientObjective obj = qs.FindObjective(typeof(FindIngredientObjective)) as FindIngredientObjective;

                        if (obj != null && !obj.Completed && obj.Ingredient == Ingredient.SwampWater)
                        {
                            bool contains = false;

                            for (int i = 0; !contains && i < m_SwampTiles.Length; i += 2)
                            {
                                contains = (tileID >= m_SwampTiles[i] && tileID <= m_SwampTiles[i + 1]);
                            }

                            if (contains)
                            {
                                this.Delete();

                                player.SendLocalizedMessage(1055035);
                                obj.Complete();
                            }
                        }
                    }
                }
            }
        }