Example #1
0
 public void Chop(Mobile from)
 {
     if (from.InRange(this.GetWorldLocation(), 1))
     {
         if (from == m_sower)
         {
             from.Direction = from.GetDirectionTo(this);
             double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100;
             if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue))
             {
                 Avocado fruit = new Avocado(Utility.Random(m_yield + 2));
                 from.AddToBackpack(fruit);
                 int cnt  = Utility.Random(20) + 1;
                 Log logs = new Log(cnt);
                 from.AddToBackpack(logs);
             }
             this.Delete();
             from.SendMessage("You chop the plant up");
         }
         else
         {
             from.SendMessage("You do not own this plant !!!");
         }
     }
     else
     {
         from.SendLocalizedMessage(500446);
     }
 }
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        ///
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="GridCS.Common.NavigationHelper.LoadState"/>
        /// and <see cref="GridCS.Common.NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.

        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            navigationHelper.OnNavigatedTo(e);
            var    args = (Dictionary <string, string>)e.Parameter;
            string email;
            string password;

            args.TryGetValue(Avocado.EMAIL, out email);
            args.TryGetValue(Avocado.PASSWORD, out password);
            authToken = await Avocado.Login(email, password);
            await LoadCoupleData();
            await LoadActivities();

            ThreadPoolTimer PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) =>
            {
                //
                // Update the UI thread by using the UI core dispatcher.
                //
                await Dispatcher.RunAsync(CoreDispatcherPriority.High,
                                          async() =>
                {
                    await LoadActivities();
                });
            }, TimeSpan.FromSeconds(5));
        }
Example #3
0
    // Use this for initialization
    void Start()
    {
        rand = new System.Random();

        indexIcon = rand.Next(0, 12);
        noEffect  = new Effect("No Disease", 0, false);

        purifyEffect = new Effect("Cure", 1, false);

        malaria = new Effect("Malaria", -1, false);

        bilharzia = new Effect("Bilharzia", -2, false);

        effectExp1 = "lose 1 HP every turn";
        effectExp2 = "Cure all disease and +1 HP";
        effectExp3 = "lose 2 HP every turn";

        effectsActive = new ArrayList();
        foods         = new ArrayList();

        birdseed = new BirdSeed("Bird Seed", 1, noEffect, 0);
        oat      = new Oat("Oat", 1, malaria, 1);
        Lettuce             lettuce             = new Lettuce("Lettuce", 3, bilharzia, 2); // lose speed -> speed/2
        Rice                rice                = new Rice("Rice", 1, purifyEffect, 3);
        RottenGrape         rottenGrape         = new RottenGrape("Rotten Grape", -2, malaria, 4);
        PollutedCrackedCorn pollutedCrackedCorn = new PollutedCrackedCorn("Polluted Cracked Corn", -2, malaria, 5);
        Avocado             avocado             = new Avocado("Avocado", -2, malaria, 6);
        Onion               onion               = new Onion("Onion", -2, purifyEffect, 7);
        Nuts                nuts                = new Nuts("Nuts", -2, purifyEffect, 8);
        Chocolate           chocolate           = new Chocolate("Chocolate", -2, purifyEffect, 9);
        Popcorn             popcorn             = new Popcorn("Popcorn", -2, bilharzia, 10);
        Bread               bread               = new Bread("Bread", -2, malaria, 11);



        for (int i = 0; i < 3; i++)
        {
            foods.Add(birdseed);
            foods.Add(oat);
            foods.Add(lettuce);
            foods.Add(rice);
            foods.Add(rottenGrape);
            foods.Add(pollutedCrackedCorn);
            foods.Add(avocado);
            foods.Add(onion);
            foods.Add(nuts);
            foods.Add(chocolate);
            foods.Add(popcorn);
            foods.Add(bread);
        }
    }
        public void Chop(Mobile from)
        {
            if (from.InRange(this.GetWorldLocation(), 1))
            {
                if ((chopTimer == null) || (!chopTimer.Running))
                {
                    if ((TreeHelper.TreeOrdinance) && (from.AccessLevel == AccessLevel.Player))
                    {
                        if (from.Region is Regions.GuardedRegion)
                        {
                            from.CriminalAction(true);
                        }
                    }

                    chopTimer = new TreeHelper.ChopAction(from);

                    Point3D pnt = this.Location;
                    Map     map = this.Map;

                    from.Direction = from.GetDirectionTo(this);
                    chopTimer.Start();

                    double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100;
                    if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue))
                    {
                        Avocado fruit = new Avocado((int)Utility.Random(13) + m_yield);
                        from.AddToBackpack(fruit);

                        int cnt  = Utility.Random((int)(lumberValue * 10) + 1);
                        Log logs = new Log(cnt);                           // Fruitwood Logs ??
                        from.AddToBackpack(logs);

                        FruitTreeStump i_stump = new FruitTreeStump(typeof(AvocadoTree));
                        Timer          poof    = new StumpTimer(this, i_stump, from);
                        poof.Start();
                    }
                    else
                    {
                        from.SendLocalizedMessage(500495);                        // You hack at the tree for a while, but fail to produce any useable wood.
                    }
                    //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", lumberValue ));
                }
            }
            else
            {
                from.SendLocalizedMessage(500446);                 // That is too far away.
            }
        }
Example #5
0
    public void Stamp(PathTraverser traverser, PathNode node, PathNode nextNode)
    {
        // If this object doesn't have an avocado, then it's a fruit that should've been binned.
        // Still stamp it, but don't add any labels
        Avocado avo = traverser.GetComponent <Avocado>();

        if (avo)
        {
            // Assign the appropriate stamp to this avocado when the stamper has finished
            avocadosToStamp.Add(avo);
        }

        if (!isStamping)
        {
            StampInternal();
        }
    }
        /// <summary>
        /// Fills the user's and partner's id fields, as well as image fields so it doesn't need to be perpetually reloaded
        /// Private because this should only be called on login
        /// </summary>
        /// <returns></returns>
        private async Task <Boolean> LoadCoupleData()
        {
            var userArray = await Avocado.GetUsers(authToken);

            // Parse Json
            var user1 = userArray.GetObjectAt(0);
            var user2 = userArray.GetObjectAt(1);
            var img1  = FetchUserImage(user1);
            var img2  = FetchUserImage(user2);

            var id1 = user1.GetNamedString("id");
            var id2 = user2.GetNamedString("id");

            icons.Add(id1, img1);
            icons.Add(id2, img2);
            return(true);
        }
Example #7
0
    public override IFruit GetFruit(FruitType fruitType)
    {
        switch (fruitType)
        {
        case FruitType.Apple:
            IFruit apple = new Apple();
            return(apple);

        case FruitType.Banana:
            IFruit banana = new Banana();
            return(banana);

        case FruitType.Avocado:
            IFruit avocado = new Avocado();
            return(avocado);
        }
        return(null);
    }
Example #8
0
        public IEnumerator ContinueAfterLoadScene()
        {
            player = transform.GetComponentInChildren <Player>();
            player.Initialize();

            if (Game.Ctx.isTutorial)
            {
                Avocado avo = transform.GetComponentInChildren <Avocado>();
                avo.Initialize();

                Game.Ctx.EnemyOperator.AddEnemy(avo);
            }

            BattleSeq         = NextStep();
            turnCount         = 0;
            inSelectEnemyMode = false;

            if (Game.Ctx.UserOperator && !Game.Ctx.isTutorial)
            {
                transform.Find("RoundText").GetComponent <TextMeshPro>().text =
                    $"Round {Game.Ctx.GameOperator.roundCount + 1} / {Game.Ctx.UserOperator.totalRound}";
            }
            else
            {
                if (!Game.Ctx.isTutorial)
                {
                    transform.Find("RoundText").GetComponent <TextMeshPro>().enabled     = false;
                    transform.Find("RoundText").GetComponentInChildren <Image>().enabled = false;
                }
            }


            // Wait a frame so every Awake and Start method is called
            yield return(new WaitForEndOfFrame());

            Game.Ctx.CardOperator.pileDeck.AdjustAllPositions();

            Continue();
        }
Example #9
0
        static void Main(string[] args)
        {
            //The Dependency Inversion Principle (DIP) states that high-level modules/classes should not depend on low-level modules/classes.
            //Both should depend upon abstractions. Secondly, abstractions should not depend upon details. Details should depend upon abstractions.
            //dependency inversion principle
            var employee = new EmployeeBusinessLogic();

            Console.WriteLine(JsonSerializer.Serialize(employee.GetEmployeeDetails(1)));

            //dependency inversion principle

            //liskov substitution principle : This principle states that, if S is a subtype of T, then objects of type T should be replaced with the objects of type S.
            // yerine koyma

            Apple apple = new Orange();

            Console.WriteLine(apple.GetColor());

            //after

            Fruit fruit = new Avocado();

            Console.WriteLine(fruit.GetColor());
            fruit = new Banana();
            Console.WriteLine(fruit.GetColor());

            //liskov substitution principle

            //open close principle

            var invoice = new Invoice();

            Console.WriteLine(invoice.GetInvoiceDiscount(1000, InvoiceType.FinalInvoice));
            Console.WriteLine(invoice.GetInvoiceDiscount(1000, InvoiceType.ProposedInvoice));

            //after

            InvoiceOCP fInvoice = new FinalInvoice();
            InvoiceOCP pInvoice = new ProposedInvoice();
            InvoiceOCP rInvoice = new RecurringInvoice();

            Console.WriteLine(fInvoice.GetInvoiceDiscount(100));
            Console.WriteLine(pInvoice.GetInvoiceDiscount(100));
            Console.WriteLine(rInvoice.GetInvoiceDiscount(100));

            //open close principle


            Console.Read();


            /*
             *
             * Single Responsibility : Sınıflarımızın iyi tanımlanmış tek bir sorumluluğu olmalı.
             * Open/Closed : Sınıflarımız değişikliğe kapalı ancak yeni davranışların eklenmesine açık olmalı.
             * Liskov Substitution(yerine koyma) : Kodumuzda herhangi bir değişiklik yapmaya gerek kalmadan türetilmiş sınıfları (sub class) türedikleri ata sınıfın (base class) yerine kullanabilmeliyiz.
             * Interface Segregation : Genel kullanım amaçlı tek bir kontrat yerine daha özelleşmiş birden çok kontrat oluşturmayı tercih etmeliyiz.
             * Dependency Inversion : Katmanlı mimarilerde üst seviye modüller alt seviyedeki modüllere doğruda bağımlı olmamalıdır.
             *
             */

            // https://dotnettutorials.net/lesson/dependency-inversion-principle/
        }
        /// <summary>
        /// Loads a list of the latest 100 avocado activities. Currently only supports messages
        /// </summary>
        private async Task <Boolean> LoadActivities()
        {
            var activitiesArray = await Avocado.GetActivities(authToken, lastActivityTime);

            foreach (var activity in activitiesArray)
            {
                var sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                var tb = new TextBlock();
                tb.TextWrapping      = TextWrapping.WrapWholeWords;
                tb.VerticalAlignment = VerticalAlignment.Center;

                if (activity.ValueType != JsonValueType.Object)
                {
                    throw new Exception();
                }
                try
                {
                    var activityObj = activity.GetObject();

                    // For debugging only
                    System.Diagnostics.Debug.WriteLine(activityObj.Stringify());

                    // Record timestamp
                    var timestamp = (long)activityObj.GetNamedNumber("timeCreated", 0.0);
                    if (timestamp > lastActivityTime)
                    {
                        lastActivityTime = timestamp;
                    }

                    // Get user and image
                    var         userId = activityObj.GetNamedString("userId");
                    BitmapImage original;
                    icons.TryGetValue(userId, out original);
                    var img = new Image();
                    img.Width  = 50;
                    img.Height = 50;
                    img.Source = original;
                    img.Margin = new Thickness(0, 5, 20, 0);
                    sp.Children.Add(img);

                    if (!activityObj.GetNamedString("type").Equals("message"))
                    {
                        // TODO: Gray, italicized
                        tb.Text = "Only messages are currently supported by this client";
                    }
                    else
                    {
                        tb.Text = activity.GetObject().GetNamedObject("data").GetNamedString("text");
                    }
                }
                catch
                {
                    // TODO: Gray, italicized
                    tb.Text = "Error retrieving activity";
                }
                sp.Children.Add(tb);
                activityList.Children.Add(sp);
                activityScrollViewer.Measure(activityScrollViewer.RenderSize);
                activityScrollViewer.ChangeView(0, activityScrollViewer.ScrollableHeight, 1);
            }
            return(true);
        }
 private void SendButton_Click(object sender, RoutedEventArgs e)
 {
     Avocado.SendMessage(authToken, messageInput.Text);
     messageInput.Text = "";
 }
 private void LogoutButton_Click(object sender, RoutedEventArgs e)
 {
     Avocado.Logout(authToken);
     this.Frame.Navigate(typeof(LoginPage));
 }
Example #13
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from.Mounted && !TreeHelper.CanPickMounted)
            {
                from.SendMessage("You cannot pick fruit while mounted.");
                return;
            }

            if (DateTime.Now > lastpicked.AddSeconds(3))               // 3 seconds between picking
            {
                lastpicked = DateTime.Now;

                int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 20;
                if (from.Mounted)
                {
                    ++lumberValue;
                }

                if (lumberValue < 0)                                                                            //Changed lumberValue == 0 to lv < 0
                {
                    from.SendMessage("You have no idea how to pick this fruit.");
                    return;
                }

                if (from.InRange(this.GetWorldLocation(), 2))
                {
                    if (m_yield < 1)
                    {
                        from.SendMessage("There is nothing here to harvest.");
                    }
                    else                     //check skill
                    {
                        from.Direction = from.GetDirectionTo(this);

                        from.Animate(from.Mounted ? 26:17, 7, 1, true, false, 0);

                        if (lumberValue < m_yield)                                                                                              //Changed lumberValue > to lv < 0
                        {
                            lumberValue = m_yield + 1;
                        }

                        int pick = Utility.Random(lumberValue);
                        if (pick == 0)
                        {
                            from.SendMessage("You do not manage to gather any fruit.");
                            return;
                        }

                        m_yield -= pick;
                        from.SendMessage("You pick {0} Avocado{1}!", pick, (pick == 1 ? "" : "s"));

                        //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield ));

                        Avocado crop = new Avocado(pick);
                        from.AddToBackpack(crop);

                        if (!regrowTimer.Running)
                        {
                            regrowTimer.Start();
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(500446);                       // That is too far away.
                }
            }
        }
 public DataTable Convert(Avocado obj)
 {
 }
Example #15
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_sower == null || m_sower.Deleted)
            {
                m_sower = from;
            }
            if (from != m_sower)
            {
                from.SendMessage("You do not own this plant !!!"); return;
            }

            if (from.Mounted && !CropHelper.CanWorkMounted)
            {
                from.SendMessage("You cannot harvest a crop while mounted."); return;
            }
            if (DateTime.UtcNow > lastpicked.AddSeconds(3))
            {
                lastpicked = DateTime.UtcNow;
                int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20;
                if (cookValue == 0)
                {
                    from.SendMessage("You have no idea how to harvest this crop."); return;
                }
                if (from.InRange(this.GetWorldLocation(), 1))
                {
                    if (m_yield < 1)
                    {
                        from.SendMessage("There is nothing here to harvest.");
                    }
                    else
                    {
                        from.Direction = from.GetDirectionTo(this);
                        from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0);
                        m_lastvisit = DateTime.UtcNow;
                        if (cookValue > m_yield)
                        {
                            cookValue = m_yield + 1;
                        }
                        int pick = Utility.RandomMinMax(cookValue - 4, cookValue);
                        if (pick < 0)
                        {
                            pick = 0;
                        }
                        if (pick == 0)
                        {
                            from.SendMessage("You do not manage to harvest any crops."); return;
                        }
                        m_yield -= pick;
                        from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s"));
                        if (m_yield < 1)
                        {
                            ((Item)this).ItemID = pickedGraphic;
                        }
                        Avocado crop = new Avocado(pick);
                        from.AddToBackpack(crop);
                        if (!regrowTimer.Running)
                        {
                            regrowTimer.Start();
                        }
                    }
                }
                else
                {
                    from.SendMessage("You are too far away to harvest anything.");
                }
            }
        }