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)) { Cucumber fruit = new Cucumber(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); if (Utility.RandomDouble() <= .1) { Vines logs = new Vines(); 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); } }
// Update is called once per frame void Update() { HandList hands = controller.Frame().Hands; for (int i = 0; i < hands.Count; i++) { Hand hand = controller.Frame().Hands[i]; //Leap.Vector rawTp = controller.Frame().Hand(hand.Id).Fingers[1].TipPosition; Leap.Vector rawTp = controller.Frame().Hand(hand.Id).PalmPosition; Vector3 tp = TipPosToVector(rawTp); if ((tp.x < 0 && color == "blue") || (tp.x > 0 && color == "red")) { this.transform.position = tp; lastDrawingState = drawing; Debug.Log(hand.PalmNormal.Pitch); if (hand.PalmNormal.Pitch < activationPitch && !bar.GetComponent <BarController>().gameEnded) { drawing = false; mat.color = movingColor; if (lastDrawingState == true) { Cucumber line = CreateShapeFromPoints(pathX, pathZ); pathX.Clear(); pathZ.Clear(); if (line.length > 0.25f && line.length < 1.4f) { bar.GetComponent <BarController>().changeChalk(0.1f * line.length, color); if (line.vigor) { Transform newLine = Instantiate(vigor, line.position, Quaternion.Euler(0, -(float)(line.angle * 180 / Math.PI), 90)); newLine.GetComponent <VigorController>().init(line.length, color, line.angle); newLine.GetComponent <VigorController>().bar = bar; BarController.toDestroy.Add(newLine.gameObject); } else { Transform newLine = Instantiate(forbiddance, line.position, Quaternion.Euler(0, -(float)(line.angle * 180 / Math.PI), 90)); newLine.GetComponent <ForbiddanceController>().init(line.length, color, line.angle); BarController.toDestroy.Add(newLine.gameObject); } } } } else { drawing = true; mat.color = drawingColor; pathX.Add(tp.x); pathZ.Add(tp.z); } } } //string hand = controller.Frame().Hand(0).ToString(); //Debug.Log(hand); }
public void Harvest() { if (cucumber == Cucumber.growed) { Console.WriteLine("育っていたので収穫します。"); cucumber = Cucumber.none; } else { Console.WriteLine("苗が存在しないか、まだ育ちきっていません。"); } }
public void Water() { if (cucumber == Cucumber.plant) { Console.WriteLine("水をあげるとすくすく育ちます。"); cucumber = Cucumber.growed; } else { Console.WriteLine("苗が存在しないか、育ちきっています。"); } }
public void Plant() { if (cucumber == Cucumber.none) { Console.WriteLine("まずきゅうりの苗を植えます。"); cucumber = Cucumber.plant; } else { Console.WriteLine("既にポットに苗が埋まっています。"); } }
public void GreenCucumberPropertiesNames() { Cucumber greenCucumber = new Cucumber("green", 10, 0.5f, true); Logger.Logger <Cucumber> logger = new Logger <Cucumber>(); PropertyInfo[] actualProperties = logger.GetProperties(greenCucumber); string[] expectedPropertiesNames = { "color", "length", "weight", "isTasty" }; var actualPropertiesNames = Enumerable.Range(0, actualProperties.Length).Select(x => actualProperties[x].Name).ToArray(); Assert.AreEqual(expectedPropertiesNames, actualPropertiesNames); }
private IEnumerable <Point> ComputeMoves(Grid2D <char> grid, Cucumber cucumber) { foreach (var p in grid.CoordEnumerable()) { if (grid.ValueAt(p) == cucumber.Type) { if (grid.ValueAt(cucumber.Neighbour(p, grid)) == '.') { yield return(p); } } } }
public void GreenCucumberPropertiesValues() { Cucumber greenCucumber = new Cucumber("green", 10, 0.5f, true); Logger.Logger <Cucumber> logger = new Logger <Cucumber>(); PropertyInfo[] actualProperties = logger.GetProperties(greenCucumber); string[] expectedPropertiesValues = { "green", "10", "0,5", "True" }; var actualPropertiesNames = Enumerable.Range(0, actualProperties.Length) .Select(x => actualProperties[x].GetValue(greenCucumber).ToString()) .ToArray(); Assert.AreEqual(expectedPropertiesValues, actualPropertiesNames); }
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)) { Cucumber fruit = new Cucumber((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(CucumberCrop)); 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. } } } else { from.SendLocalizedMessage(500446); // That is too far away. } }
static void Main(string[] args) { // Create vegatables and attach restorants Cucumber cucumber = new Cucumber("Краставици", 02.10); cucumber.Attach(new Restorant("Одеон")); cucumber.Attach(new Restorant("Никол")); cucumber.Attach(new Restorant("Виктория")); Cabbage cabbage = new Cabbage("Зеле", 01.05); cabbage.Attach(new Restorant("Одеон")); cabbage.Attach(new Restorant("Никол")); cabbage.Attach(new Restorant("Виктория")); Tomato tomato = new Tomato("Домат", 01.95); tomato.Attach(new Restorant("Одеон")); tomato.Attach(new Restorant("Никол")); tomato.Attach(new Restorant("Виктория")); // Fluctuating prices will notify restorants cucumber.Price = 02.25; cucumber.Price = 02.15; cucumber.Price = 02.20; cabbage.Price = 01.10; cabbage.Price = 01.15; cabbage.Price = 01.10; tomato.Price = 02.10; tomato.Price = 02.25; tomato.Price = 02.20; // Wait for user Console.ReadKey(); }
public IFood CreateFood(int money) { IFood aCucumber = new Cucumber(); IFood aCarrot = new Carrot(); IFood aCabbage = new Cabbage(); if (money >= aCucumber.CostPerKg) { return(aCucumber); } else if (money >= aCarrot.CostPerKg) { return(aCarrot); } else if (money >= aCabbage.CostPerKg) { return(aCabbage); } else { return(null); } }
public void SaladTypeTest() { Cucumber cucumber = new Cucumber(50, 15, "1 year"); Assert.IsInstanceOf(typeof(Cucumber), cucumber); }
static void Main(string[] args) { Calories cl = new Calories(2, 3, 4); Calories c2 = 2 * cl; var potato = new Potato(100); var cucmber = new Cucumber(100); var carrot = new Carrot(200); var cust = new CustomVegetable("1", 2, new Calories()); Console.WriteLine(cust); cust.Weight = 3; cust.Calories = new Calories(); cust.Name = "13"; Console.WriteLine(cust); Console.WriteLine(potato.Name + " " + potato.Calories + " " + potato.Weight); Console.WriteLine(cucmber.Name + " " + cucmber.Calories + " " + cucmber.Weight); Console.WriteLine(carrot.Name + " " + carrot.Calories + " " + carrot.Weight); List <IVegetable> lst = new List <IVegetable>(); lst.Add(cucmber); Salad salad = new Salad(new CloneList <IVegetable>()); salad.Add(potato); salad.Add(carrot); salad.Add(cucmber); Console.WriteLine("total calories = " + salad.TotalCalories); Console.WriteLine(); Console.WriteLine(); salad.PrintVegetables(); var tt = salad.GetVegetables(0, 1000); Console.WriteLine(); Console.WriteLine(); salad.PrintVegetables(); salad.Sort(VegetableComparasions.CompareByName); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("BEFORE SRT"); salad.PrintVegetables(); salad.Sort(vegetable => vegetable.Calories, new CompareByCalories()); Func <int, int> d = delegate(int i) { return(i * 3); }; Console.WriteLine("AFTER SRT"); salad.PrintVegetables(); salad.Sort(VegetableComparasions.CompareByWeight); Console.WriteLine("BEFORE REMOVE"); salad.PrintVegetables(); salad.Remove(potato); Console.WriteLine("AFTER REMOVE"); salad.PrintVegetables(); Console.WriteLine("TESTTTT"); CloneList <IVegetable> list = new CloneList <IVegetable>(); List <int> li = new List <int>(); list.Add(potato); list.Add(cucmber); list.Add(carrot); foreach (var v in list) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } Console.WriteLine("CLONE"); ICloneCollection <IVegetable> list2 = list.CloneObjects(); foreach (var v in list2) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } list[0].Weight = 0; list[1].Weight = 0; list[2].Weight = 0; Console.WriteLine("TESTTTT"); foreach (var v in list) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } Console.WriteLine("CLONE"); foreach (var v in list2) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } }
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; } Cucumber crop = new Cucumber(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
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) { 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) { 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} Cucumber{1}!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); Cucumber crop = new Cucumber(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendLocalizedMessage(500446); // That is too far away. } } }
static void Main(string[] args) { Console.WriteLine("Regular Visitor pattern"); VisitorDomain.IFruitVisitor visitor = new VisitorDomain.FruitVisitor(); VisitorDomain.Fruit apple = new VisitorDomain.Apple("Golden delicious"); VisitorDomain.Fruit grape = new VisitorDomain.Grape("Merlot"); apple.Accept(visitor); grape.Accept(visitor); Console.WriteLine("======================="); Console.WriteLine("Acyclic Visitor pattern"); DegenerateVegetableVisitor acyclicVisitor = new CarretVisitor(); Vegetable carret = new Carret("Red"); carret.Accept(acyclicVisitor); acyclicVisitor = new CucumberVisitor(); Vegetable cucumber = new Cucumber("Green"); cucumber.Accept(acyclicVisitor); Console.WriteLine("======================="); Console.WriteLine("Generic Acyclic Visitor pattern"); CarVisitor carVisitor = new CarVisitor <Toyota>(); Toyota toyota = new Toyota("Corrolla"); toyota.Accept(carVisitor); carVisitor = new CarVisitor <Bmw>() as CarVisitor; Bmw bmw = new Bmw("4"); bmw.Accept(carVisitor); carVisitor = new CarVisitor <Mercedes>() as CarVisitor; Mercedes mercedes = new Mercedes("default"); mercedes.Accept(carVisitor); Console.WriteLine("======================="); Console.WriteLine("Full Visitor pattern"); List <FullDomain.Fruit> fruits = new List <FullDomain.Fruit>() { new FullDomain.Grape() { NumberOfGrapes = 3 }, new FullDomain.Banana() { NumberOfFingers = 4 }, new FullDomain.Apple(), new FullDomain.Grape() { NumberOfGrapes = 6 }, new FullDomain.Banana() { NumberOfFingers = 3 }, new FullDomain.Apple(), new FullDomain.Apple(), new FullDomain.Grape() { NumberOfGrapes = 7 }, new FullDomain.Grape() { NumberOfGrapes = 4 }, new FullDomain.Banana() { NumberOfFingers = 3 } }; List <FullDomain.Apple> allApples = FullDomain.FruitExtensions.Pick <FullDomain.Apple>(fruits).ToList(); // Because of namespace clashes I call extension method like this Console.WriteLine($"Number of apples visited {allApples.Count}"); List <FullDomain.Grape> allGrapes = FullDomain.FruitExtensions.Pick <FullDomain.Grape>(fruits).ToList(); // Because of namespace clashes I call extension method like this Console.WriteLine($"Number of grape objects visited {allGrapes.Count}, number of grapes {allGrapes.Sum(s => s.NumberOfGrapes)}"); List <FullDomain.Banana> allBananas = FullDomain.FruitExtensions.Pick <FullDomain.Banana>(fruits).ToList(); // Because of namespace clashes I call extension method like this Console.WriteLine($"Number of bananas visited {allBananas.Count}, number of fingers {allBananas.Sum(s => s.NumberOfFingers)}"); FullDomain.FruitWeightCalculatorVisitor weightCalculator = new FullDomain.FruitWeightCalculatorVisitor(); fruits.ForEach(fruit => fruit.Accept(weightCalculator)); Console.WriteLine($"Weight of fruits {weightCalculator.WeightInGrams}"); Console.Write("Press any key to continue. . ."); Console.ReadKey(); }