상속: MonoBehaviour
예제 #1
0
 public void Ensure_that_every_new_fridge_comes_fully_stocked()
 {
     Fridge fridge = new Fridge();
     Assert.AreEqual(5, fridge.BaconSlabs.Count());
     Assert.AreEqual(3, fridge.IceCreamTubs.Count());
     Assert.AreEqual(500, fridge.BeerRemaining);
 }
예제 #2
0
파일: DataManager.cs 프로젝트: rkj/ieat
        public DataManager()
        {
            /*
            if (File.Exists(RecipesFile))
            {
                StreamReader myReader = new StreamReader(RecipesFile);
                recipesList = (RecipesList)recipesListSerializer.Deserialize(myReader);
                myReader.Close();
            }
            else
                recipesList = new RecipesList();

            if (File.Exists(FridgeFile))
            {
                StreamReader myReader = new StreamReader(FridgeFile);
                fridge = (Fridge)fridgeSerializer.Deserialize(myReader);
                myReader.Close();
            }
            else
                fridge = new Fridge();

            if (File.Exists(ProductsFile))
            {
                StreamReader myReader = new StreamReader(ProductsFile);
                productsList = (ProductsList)productsListSerializer.Deserialize(myReader);
                myReader.Close();
            }
            else
                productsList = new ProductsList();
            */

            recipesList = new RecipesList();
            fridge = new Fridge();
            productsList = new ProductsList();
        }
예제 #3
0
        public void Ensure_that_the_beer_tap_does_not_dispense_beer_if_there_is_none_left()
        {
            Avatar avatar = new Avatar();
            Glass glass = new Glass();
            avatar.PickUp(glass);

            Fridge fridge = new Fridge();
            fridge.BeerRemaining = 0;
            avatar.DispenseBeerFrom(fridge).Into(glass);
        }
    private void setFridge()
    {
        Transform nextTransform = this.transform.parent;

        while (fridge == null && nextTransform != null)
        {
            fridge = nextTransform.GetComponent<Fridge>();
            nextTransform = this.transform.parent;
        }
    }
예제 #5
0
        public void Ensure_that_if_there_is_only_a_little_bit_of_beer_left_the_container_will_not_be_totally_full()
        {
            Avatar avatar = new Avatar();
            Glass glass = new Glass();
            avatar.PickUp(glass);

            Fridge fridge = new Fridge();
            fridge.BeerRemaining = 2;
            avatar.DispenseBeerFrom(fridge).Into(glass);

            Assert.IsFalse(glass.IsEmpty);
            Assert.IsFalse(glass.IsFull);
            Assert.AreEqual(48, glass.RemainingCapacity);
            Assert.AreEqual(0, fridge.BeerRemaining);
        }
예제 #6
0
        public void Ensure_that_the_beer_tap_dispenses_beer_fills_containers_and_makes_containers_dirtier()
        {
            Avatar avatar = new Avatar();
            Glass glass = new Glass();
            avatar.PickUp(glass);
            FineChinaTeacup teacup = new FineChinaTeacup();
            avatar.PickUp(teacup);

            Fridge fridge = new Fridge();
            avatar.DispenseBeerFrom(fridge).Into(glass);
            avatar.DispenseBeerFrom(fridge).Into(teacup);

            Assert.IsTrue(glass.IsFull);
            Assert.AreEqual(80m, glass.PercentClean);
            Assert.AreEqual(DirtRating.Smudged, glass.DirtRating);
            Assert.IsTrue(teacup.IsFull);
            Assert.AreEqual(80m, teacup.PercentClean);
            Assert.AreEqual(DirtRating.Smudged, teacup.DirtRating);
            Assert.AreEqual(425, fridge.BeerRemaining);
        }
 public static Fridge GetIndesit(string name)
 {
     Fridge fridge = new Fridge(name, new Coldstore(233, new Lamp(15)), new Refrigeratory(85));
     return fridge;
 }
예제 #8
0
파일: Grid.cs 프로젝트: adahera222/properme
	void CreateDefaultGridItems()
	{
		if ((doorPrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize <= UserBase.I.gridBlocksContainer.gridBlockItems.Count && (doorPrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize >= 0)  // -1 so we start at block 0
		{
			BlockHelper doorStartBlock = UserBase.I.gridBlocksContainer.gridBlockItems[(doorPrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize].myBlock;
			
			Door newDoor = Instantiate(doorPrefab, doorStartBlock.myTransform.position, doorStartBlock.myTransform.rotation) as Door;
			newDoor.currentBlockID = doorStartBlock.blockID;
			doorStartBlock.myItem = newDoor;
			
			theDoor = newDoor;
		}
		else
			ScreenLog.AddMessage("ERROR Couldnt spawn " + doorPrefab.GetType().ToString() + ". Check " + StringExtensions.GetVariableName(()=> doorPrefab.gridStartingPos) + " variable in " + doorPrefab.GetType().ToString() + " Prefab and gridsize", ScreenLogType.Error);
		
		if ((lapTopPrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize <= UserBase.I.gridBlocksContainer.gridBlockItems.Count && (lapTopPrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize >= 0)  // -1 so we start at block 0
		{
			BlockHelper lapTopStartBlock = UserBase.I.gridBlocksContainer.gridBlockItems[(lapTopPrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize].myBlock;
			
			Laptop newLapTop = Instantiate(lapTopPrefab, lapTopStartBlock.myTransform.position, lapTopStartBlock.myTransform.rotation) as Laptop;
			newLapTop.currentBlockID = lapTopStartBlock.blockID;
			lapTopStartBlock.myItem = newLapTop;
			
			theLapTop = newLapTop;
		}
		else
			ScreenLog.AddMessage("ERROR Couldnt spawn " + lapTopPrefab.GetType().ToString() + ". Check " + StringExtensions.GetVariableName(()=> lapTopPrefab.gridStartingPos) + " variable in " + lapTopPrefab.GetType().ToString() + " Prefab and gridsize", ScreenLogType.Error);
		
		if ((fridgePrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize <= UserBase.I.gridBlocksContainer.gridBlockItems.Count && (fridgePrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize >= 0)  // -1 so we start at block 0
		{
			BlockHelper fridgeStartBlock = UserBase.I.gridBlocksContainer.gridBlockItems[(fridgePrefab.gridStartingPos - 1) * UserBase.I.gridBlocksContainer.gridSize].myBlock;
			
			Fridge newFridge = Instantiate(fridgePrefab, fridgeStartBlock.myTransform.position, fridgeStartBlock.myTransform.rotation) as Fridge;
			newFridge.currentBlockID = fridgeStartBlock.blockID;
			fridgeStartBlock.myItem = newFridge;
			
			theFridge = newFridge;
		}
		else
			ScreenLog.AddMessage("ERROR Couldnt spawn " + fridgePrefab.GetType().ToString() + ". Check " + StringExtensions.GetVariableName(()=> fridgePrefab.gridStartingPos) + " variable in " + fridgePrefab.GetType().ToString() + " Prefab and gridsize", ScreenLogType.Error);
	}
예제 #9
0
 public override void AddInteractions(InteractionObjectPair iop, Sim sim, Fridge fridge, List<InteractionObjectPair> results)
 {
     if (sim != null && Party.IsHostAtAParty(sim))
     {
         Lot lotCurrent = fridge.LotCurrent;
         if (lotCurrent == sim.LotHome || (lotCurrent.IsResidentialLot && sim.Household.IsGreetedOnLot(lotCurrent, ObjectGuid.InvalidObjectGuid)))
         {
             base.AddFoodPrepInteractions(iop, sim, results, null);
         }
     }
 }
예제 #10
0
        public void Ensure_that_you_cannot_fill_a_plate_with_beer()
        {
            Avatar avatar = new Avatar();
            Plate plate = new Plate();
            avatar.PickUp(plate);

            Fridge fridge = new Fridge();
            avatar.DispenseBeerFrom(fridge).Into(plate);
        }
 /// <summary>
 /// Initializes a new instance of the DispenseBeerOperator class.
 /// </summary>
 /// <param name="avatar">The avatar performing the action</param>
 /// <param name="fridge">The fridge that will dispense the beer</param>
 public DispenseBeerOperator(Avatar avatar, Fridge fridge)
 {
     _fridge = fridge;
     _avatar = avatar;
 }
예제 #12
0
파일: DataManager.cs 프로젝트: rkj/ieat
        public void getFridge()
        {
            try
            {
                //  if (cookie == null)
                //    if (!login())B
                //      return;
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(config.Current.serverAddress + "/containers/"+fridgeList.containers[0].id+".xml");
                req.Headers["Cookie"] = cookie;
                req.AllowWriteStreamBuffering = true;
                req.KeepAlive = true;
                req.Method = "Get";
                HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
                XmlTextReader xmltr = new XmlTextReader(HttpWResp.GetResponseStream());
                    XmlSerializer xs  = new XmlSerializer(typeof(IEatMobile.Fridge));
                    fridge = (IEatMobile.Fridge)xs.Deserialize(xmltr);
                    List<FridgeProduct> fps = new List<FridgeProduct>();
                    for (int i = 0; i < fridge.Products.Count; i++)
                    {
                        FridgeProduct fp = fridge.Products[i];
                        fp.Product = productsList.getById(fp.ProductId);
                        fps.Add(fp);

                    }
                    fridge.Products = fps;

            }
            catch (WebException ee)
            {
                /*
                WebResponse resp = ee.Response;

                StreamReader sr=new StreamReader(resp.GetResponseStream());
                string allresp=sr.ReadToEnd();
                string respmes = ee.Message;

                 */
                MessageBox.Show(ee.Message);
            }
        }
예제 #13
0
        public void Ensure_that_you_cannot_dispense_a_beverage_into_a_container_that_is_full()
        {
            Avatar avatar = new Avatar();
            Glass glass = new Glass();
            avatar.PickUp(glass);

            Fridge fridge = new Fridge();
            avatar.DispenseBeerFrom(fridge).Into(glass);
            avatar.DispenseBeerFrom(fridge).Into(glass);
        }
예제 #14
0
 public void Ensure_that_you_cannot_dispense_a_beverage_into_a_container_not_being_held()
 {
     Avatar avatar = new Avatar();
     Fridge fridge = new Fridge();
     avatar.DispenseBeerFrom(fridge).Into(new Glass());
 }
예제 #15
0
        public void Ensure_that_you_can_always_fill_a_partially_full_container()
        {
            Avatar avatar = new Avatar();
            Glass glass = new Glass();
            avatar.PickUp(glass);

            Fridge fridge1 = new Fridge();
            fridge1.BeerRemaining = 2;
            avatar.DispenseBeerFrom(fridge1).Into(glass);
            Assert.AreEqual(0, fridge1.BeerRemaining);

            Fridge fridge2 = new Fridge();
            avatar.DispenseBeerFrom(fridge2).Into(glass);
            Assert.AreEqual(452, fridge2.BeerRemaining);
            Assert.IsFalse(glass.IsEmpty);
            Assert.IsTrue(glass.IsFull);
        }
예제 #16
0
 public static Fridge GetSamsung(string name)
 {
     Fridge fridge = new Fridge(name, new Coldstore(254, new Lamp(15)), new Refrigeratory(92));
     return fridge;
 }
예제 #17
0
 public static Fridge GetAtlant(string name)
 {
     Fridge fridge = new Fridge(name, new Coldstore(202, new Lamp(15)), new Refrigeratory(70));
     return fridge;
 }
예제 #18
0
        public void Ensure_that_you_cannot_fill_a_bag_of_holding_with_beer()
        {
            Avatar avatar = new Avatar();
            BagOfHolding bag = new BagOfHolding();
            avatar.PickUp(bag);

            Fridge fridge = new Fridge();
            avatar.DispenseBeerFrom(fridge).Into(bag);
        }
예제 #19
0
파일: DataManager.cs 프로젝트: rkj/ieat
 public void loadFridge()
 {
     XmlTextReader xmlr = new XmlTextReader(FridgeFile);
     XmlSerializer xs = new XmlSerializer(typeof(Fridge));
     fridge = (Fridge)xs.Deserialize(xmlr);
 }
예제 #20
0
 public override bool SpecificTest(Sim a, Fridge target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
 {
     /*if (target.FridgeInventory == null && target.LotCurrent != null && !target.LotCurrent.IsCommunityLot)
     {
         return false;
     }
     if (isAutonomous && a.SimDescription.IsFrankenstein)
     {
         return false;
     }
     if (ChosenRecipe != null && !ChosenRecipe.IsSnack)
     {
         Recipe.CanMakeFoodTestResult result = Food.CanMake(ChosenRecipe, true, true, Recipe.MealTime.DO_NOT_CHECK, Repetition, target.LotCurrent, a, Quantity, Cost, ObjectClickedOn);
         return Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(a, ChosenRecipe, result, ref greyedOutTooltipCallback);
     }
     if (ChosenRecipe != null && ChosenRecipe.IsSnack)
     {
         return CommonMethods.PrepareTestResultCheckAndGrayedOutPieMenuSet(ChosenRecipe, a, ref greyedOutTooltipCallback);
     }
     return !target.InUse;*/
     return base.SpecificTest(a, target, isAutonomous, ref greyedOutTooltipCallback) && (ChosenRecipe != null || a.IsNPC || ChooseRecipeRandomly(target.LotCurrent, a, Quantity, true) != null);
 }
예제 #21
0
 /// <summary>
 /// Attempt to dispense a beverage from the fridge
 /// </summary>
 /// <param name="fridge">The fridge containing the beverage</param>
 /// <returns>An object used to complete the operation</returns>
 public DispenseBeerOperator DispenseBeerFrom(Fridge fridge)
 {
     return new DispenseBeerOperator(this, fridge);
 }
예제 #22
0
            public override void AddInteractions(InteractionObjectPair iop, Sim sim, Fridge fridge, List<InteractionObjectPair> results)
            {
                /*if (sim == null)
                {
                    return;
                }

                bool lotHasCounter = Food.LotHasUsableCounter(fridge.LotCurrent);
                bool lotHasStove = Food.LotHasUsableStove(fridge.LotCurrent);
                bool lotHasMicrowave = Food.LotHasUsableMicrowave(fridge.LotCurrent);
                bool lotHasGrill = Food.LotHasUsableGrill(fridge.LotCurrent);
                Lot lotCurrent = fridge.LotCurrent;
                if (lotCurrent == sim.LotHome || (lotCurrent.IsResidentialLot && sim.Household.IsGreetedOnLot(lotCurrent, ObjectGuid.InvalidObjectGuid)))
                {
                    base.AddFoodPrepInteractions(iop, sim, results, null);
                }
                Food.StringIndices stringIndex;
                if (sim.HasTrait(TraitNames.PartyAnimal) && Party.IsInvolvedInAnyTypeOfParty(sim))
                {
                    stringIndex = Food.StringIndices.PartySnack;
                }
                else
                {
                    if (sim.HasTrait(TraitNames.Evil))
                    {
                        stringIndex = Food.StringIndices.EvilSnack;
                    }
                    else
                    {
                        if (sim.HasTrait(TraitNames.EnvironmentallyConscious))
                        {
                            stringIndex = Food.StringIndices.OrganicSnack;
                        }
                        else
                        {
                            if (sim.HasTrait(TraitNames.Good))
                            {
                                stringIndex = Food.StringIndices.GoodSnack;
                            }
                            else
                            {
                                if (sim.TraitManager.HasElement(TraitNames.Mooch) && lotCurrent != sim.LotHome)
                                {
                                    stringIndex = Food.StringIndices.MoochSnack;
                                }
                                else
                                {
                                    stringIndex = Food.StringIndices.HaveSnack;
                                }
                            }
                        }
                    }
                }
                string[] menuPath = new string[]
				{
					Food.GetString(stringIndex) + Localization.Ellipsis
				};

                foreach (Recipe current in Recipe.Snacks)
                {
                    if ((!current.CookingProcessData.UsesAMicrowave || !sim.SimDescription.ChildOrBelow) && (!(current.Key == "VampireJuice") || sim.SimDescription.IsVampire) && current.DoesLotHaveRightTech(lotHasCounter, lotHasStove, lotHasMicrowave, lotHasGrill, Recipe.MealQuantity.Single) == Recipe.CanMakeFoodTestResult.Pass)
                    {
                        InteractionObjectPair item = new InteractionObjectPair(Create(current.GenericName, current, menuPath, null, Recipe.MealDestination.SurfaceOrEat, Recipe.MealQuantity.Single, Recipe.MealRepetition.MakeOne, false, 0), iop.Target);
                        results.Add(item);
                    }
                }*/
                base.AddInteractions(iop, sim, fridge, results);
                List<Ingredient> simIngredients = Recipe.GetCookableIngredients(sim.Inventory);
                List<Ingredient> lotIngredients = sim.Household != null && sim.Household.SharedFridgeInventory != null ? Recipe.GetCookableIngredients(sim.Household.SharedFridgeInventory.Inventory) : new List<Ingredient>();
                List<Ingredient> list = null;
                for (int i = results.Count - 1; i >= 0; i--)
                {
                    Fridge_Have.Definition definition = results[i].InteractionDefinition as Fridge_Have.Definition;
                    if (definition == null || definition.ChosenRecipe == null || !definition.ChosenRecipe.IsSnack)
                    {
                        return;
                    }
                    if (definition.ChosenRecipe.BuildIngredientList(simIngredients, lotIngredients, ref list, ref list).Count > 0)
                    {
                        definition.Cost = -2147483648;
                    }
                }
            }
예제 #23
0
 public override bool Test(Sim a, Fridge target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
 {
     return Party.IsHostAtAParty(a) && (!isAutonomous || target.LotCurrent.CountObjects<IPreparedFood>() <= 0u) && base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback);
 }
예제 #24
0
        public void Ensure_that_you_cannot_fill_a_frying_pan_with_beer()
        {
            Avatar avatar = new Avatar();
            FryingPan pan = new FryingPan();
            avatar.PickUp(pan);

            Fridge fridge = new Fridge();
            avatar.DispenseBeerFrom(fridge).Into(pan);
        }