public override void CompletePurchase() { float totalPrice = GetTotalPrice(); bool success = totalPrice <= Stats.Money; if (!success) { GameLibOfMethods.CreateFloatingText("Not enough money.", 2); AlertNotification(); return; } Stats.RemoveMoney(totalPrice); foreach (var item in basketItems) { var upgradeData = (FurnitureItemData)item.currentItem; UpgradesManager.GetValidator(upgradeData.Type).ApplyUpgrade(upgradeData.LinkedPrefab); Destroy(item.gameObject); } basketItems.Clear(); ResetToDefault(); currentlyOpenStore.ForceRefresh(); }
protected override void Effect() { base.Effect(); Stats.XpMultiplier += 0.02f; GameLibOfMethods. CreateFloatingText("Now you receive " + (Stats.XpMultiplier + Stats.BonusXpMultiplier) + "% XP!", 2); }
public void PickupItem(Item item) { if (!IsFull(item.Code)) { var slotWithItem = SlotOf(item.Code, false); if (slotWithItem != null && slotWithItem.FreeQty >= item.Count) { slotWithItem.Add(item.Count); Destroy(item.gameObject); return; } if (FreeSlot != 0) { AddItem(new ItemList.ItemInfo { itemCode = item.Code, count = item.Count }); Destroy(item.gameObject); return; } } GameLibOfMethods.CreateFloatingText("Not enough space in inventory", 2); }
protected override void Effect() { base.Effect(); Stats.PriceMultiplier -= 0.02f; GameLibOfMethods. CreateFloatingText(string.Format("Items now costs only {0:P1} of their price!", Stats.PriceMultiplier), 2); }
public void CheckOut() { if (basket.Empty) { return; } if (Stats.Money < basket.TotalCost) { GameLibOfMethods.CreateFloatingText("Not enough money", 2); return; } if (!Inventory.PlaceOnBag(basket.Itemlist)) { GameLibOfMethods.CreateFloatingText("Not enough space in inventory", 2); return; } Stats.GetMoney(basket.TotalCost); Stats.AddXP(Type.Charisma, basket.TotalCost * 0.2f); ClearBasketItems(); Inventory.SetBagItemActions(ItemActionOnShopping); }
public IEnumerator TakingShower() { if (!GameLibOfMethods.canInteract) { GameLibOfMethods.cantMove = true; GameLibOfMethods.Walking = false; GameLibOfMethods.animator.SetBool("Jumping", false); GameLibOfMethods.animator.SetBool("TakingShower", true); Emission.enabled = true; yield return(new WaitForEndOfFrame()); SpriteControler.Instance.FaceDOWN(); GameLibOfMethods.canInteract = true; yield return(new WaitForEndOfFrame()); float timeWithFullBar = 0; while (!Input.GetKey(InteractionChecker.Instance.KeyToInteract) && !GameLibOfMethods.passedOut && !isBroken) { Stats.Status(Type.Hygiene).Add(HygieneGainAmount * Time.fixedDeltaTime); float chance = Random.Range(0f, 100f); if (chance <= breakChancePerSecond / 60) { isBroken = true; Break(); } if (Stats.Status(Type.Hygiene).CurrentAmount >= Stats.Status(Type.Hygiene).MaxAmount) { timeWithFullBar += Time.deltaTime; if (timeWithFullBar >= 2) { GameLibOfMethods.CreateFloatingText("You are too clean for this.", 2); break; } } yield return(new WaitForFixedUpdate()); } Emission.enabled = false; yield return(new WaitForEndOfFrame()); PlayExitSound(); GameLibOfMethods.animator.SetBool("TakingShower", false); yield return(new WaitForEndOfFrame()); void act() => SpriteControler.Instance.ChangeSortingOrder(0); PlayerCommands.JumpOff(0, act); } }
public override void Activate() { if (type == PopUpUIEffectType.OnEnd) { return; } GameLibOfMethods.CreateFloatingText(Text, 2); }
protected virtual void LevelUp() { data.xp = 0; data.level += 1; Stats.InvokeLevelUp(type); Effect(); GameLibOfMethods.CreateFloatingText($"{name} Leveled UP!", 3); GameLibOfMethods.AddChatMessege(name + " level UP!"); }
protected virtual void LevelUp() { data.xp = 0; data.level += 1; Stats.InvokeLevelUp(type); Effect(); GameLibOfMethods.CreateFloatingText($"{name} Leveled UP!", 3); PlayerChatLog.Instance.AddChatMessege(name + " level UP!"); Notify.Show($"Congratulations, you have reached level {data.level} in {name}!", GetSkillSprite()); }
private void MoveToBasket(ShopList.ItemInfo itemData) { if (!basket.Contains(itemData)) { basket.AddItem(itemData); } else { GameLibOfMethods.CreateFloatingText("You already ordered this.", 1.5f); } }
public void Deposit() { int inputInt = int.Parse(InputField.text); if (inputInt > Stats.Money) { GameLibOfMethods.CreateFloatingText("Not enough money!", 3); return; } Stats.GetMoney(inputInt); MoneyInBank += inputInt; UpdateBalance(); }
public bool Deposit(float amount) { if (amount > Stats.Money) { GameLibOfMethods.CreateFloatingText("Not enough money!", 3); return(false); } Stats.RemoveMoney(amount); MoneyInBank += amount; UpdateBalance(); return(true); }
public void PutInBag(ItemSlot itemSlot) { if (!playerInventory.CanFit(itemSlot)) { GameLibOfMethods.CreateFloatingText("Not enough space in inventory", 2); return; } playerInventory.AddItem(itemSlot); if (containerOpen) { playerInventory.UpdateSlotActions(PutInCurrentContainer); } }
private void PutInCurrentContainer(ItemSlot itemSlot) { if (!currentContainer.IsOpen) { return; } if (currentContainer.CanFit(itemSlot)) { currentContainer.AddItem(itemSlot); } else { GameLibOfMethods.CreateFloatingText($"Not enough space in {currentContainer.name}", 2); } }
public void PickupItem(Item item) { if (IsFull(item.Code) && !Contains(item.Code)) { GameLibOfMethods.CreateFloatingText("Not enough space in inventory", 2); } else { AddItem(new ItemList.ItemInfo { itemCode = item.Code, count = item.Count }); Destroy(item.gameObject); } }
private void TryAction(List <ItemList.ItemInfo> itemsToCook) { if (!CanAct()) { return; } if (!Inventory.CanFitOnBag(itemsToCook)) { GameLibOfMethods.CreateFloatingText("Not enough space in inventory.", 2f); return; } CookingHandler.EnableCanvas = false; GameLibOfMethods.doingSomething = true; PlayerCommands.MoveTo(StandArea.position, () => StartAction(itemsToCook).Start(MEC.Segment.LateUpdate)); }
public override void Deactivate(bool canceled) { if (type == PopUpUIEffectType.OnBegin) { return; } if (canceled) { if (string.IsNullOrWhiteSpace(CanceledText)) { return; } GameLibOfMethods.CreateFloatingText(CanceledText, 2); } else { GameLibOfMethods.CreateFloatingText(Text, 2); } }
private void Cook() { var itemsToCook = GetRecipeToCook(); if (!Inventory.CanFitOnBag(itemsToCook)) { GameLibOfMethods.CreateFloatingText("Not enough space in inventory.", 2f); return; } if (PlayerStatsManager.statWarning.ContainsValue(true)) { PlayerChatLog.Instance.AddChatMessege("I'm not feeling well to cook."); return; } Stats.RemoveMoney(_price); CookingEntity.StartAction(itemsToCook, true); }
public void CheckOut() { if (basket.Empty) { return; } if (Stats.Money < basket.TotalCost) { GameLibOfMethods.CreateFloatingText("Not enough money", 2); return; } Stats.GetMoney(basket.TotalCost); Stats.AddXP(Type.Charisma, basket.TotalCost * 0.2f); ExecuteUpgrades(); Shop.CloseUpgradeShop(); }
IEnumerator UseToilet() { GameLibOfMethods.cantMove = true; SpriteControler.Instance.FaceLEFT(); GameLibOfMethods.animator.SetBool("Jumping", false); GameLibOfMethods.animator.SetBool("TakingADump", true); yield return(new WaitForFixedUpdate()); SpriteControler.Instance.FaceLEFT(); float timeWithFullBar = 0; while (!Input.GetKey(InteractionChecker.Instance.KeyToInteract) && !GameLibOfMethods.passedOut) { Stats.Status(Type.Bladder).Add(BladderGainAmount * Time.fixedDeltaTime); if (Stats.Status(Type.Bladder).CurrentAmount >= Stats.Status(Type.Bladder).MaxAmount) { timeWithFullBar += Time.deltaTime; if (timeWithFullBar >= 2) { GameLibOfMethods.CreateFloatingText("You have no juice left in your body.", 2); break; } } yield return(new WaitForFixedUpdate()); } PlayExitSound(); GameLibOfMethods.animator.SetBool("TakingADump", false); yield return(new WaitForEndOfFrame()); void act() => SpriteControler.Instance.ChangeSortingOrder(0); PlayerCommands.JumpOff(0, act); }
public override void CompletePurchase() { float totalPrice = GetTotalPrice(); if (totalPrice > Stats.Money) { GameLibOfMethods.CreateFloatingText("Not enough money", 2); AlertNotification(); return; } var itemInfos = new List <ItemList.ItemInfo>(basketItems.Count); foreach (var item in basketItems) { var itemCode = ((ItemData)item.currentItem).code; var info = new ItemList.ItemInfo() { itemCode = itemCode, count = item.currentQuantity }; itemInfos.Add(info); } bool success = Inventory.PlaceOnBag(itemInfos); if (!success) { GameLibOfMethods.CreateFloatingText("Not enough space in inventory", 2); AlertNotification(); return; } Stats.RemoveMoney(totalPrice); foreach (var item in basketItems) { Destroy(item.gameObject); } basketItems.Clear(); Refresh(); }
public void OnBeginDrag(PointerEventData eventData) { if (CookingHandler.Ongoing) { return; } if (!GameLibOfMethods.doingSomething && GameLibOfMethods.canInteract && !GameLibOfMethods.cantMove) { sourceCell = GetCell(); draggedItem = this; icon = new GameObject(); icon.name = "Icon"; Image myImage = GetComponentsInChildren <Image>()[1]; icon.transform.SetParent(canvas.transform); myImage.raycastTarget = false; // Disable icon's raycast for correct drop handling Image iconImage = icon.AddComponent <Image>(); iconImage.raycastTarget = false; iconImage.sprite = myImage.sprite; RectTransform iconRect = icon.GetComponent <RectTransform>(); // Set icon's dimensions RectTransform myRect = GetComponent <RectTransform>(); iconRect.pivot = new Vector2(0.5f, 0.5f); iconRect.anchorMin = new Vector2(0.5f, 0.5f); iconRect.anchorMax = new Vector2(0.5f, 0.5f); iconRect.sizeDelta = new Vector2(myRect.rect.width, myRect.rect.height); iconImage.preserveAspect = true; icon.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); GetSlot()?.SetButtonEnable(false); Inventory.SFX(Inventory.Sound.StartDrag); } else { GameLibOfMethods.CreateFloatingText("You are busy, can't rearrange inventory now!", 2); } }
public void ManualCook() { if (_cookingSlots.Count == 0) { return; } var itemsToCook = GetRecipesToCook(); if (!Inventory.CanFitOnBag(itemsToCook)) { GameLibOfMethods.CreateFloatingText("Not enough space in inventory.", 2f); return; } if (PlayerStatsManager.statWarning.ContainsValue(true)) { PlayerChatLog.Instance.AddChatMessege("I'm not feeling well to cook."); return; } CookingEntity.StartAction(itemsToCook, false); ClearList(); }
protected override void Effect() { base.Effect(); Stats.IncreaseMaxAmount(Status.Type.Energy, 5f); GameLibOfMethods.CreateFloatingText("Now you have " + Stats.MaxAmount(Status.Type.Energy) + " max energy!", 4); }
IEnumerator <float> Sleeping() { HandlePlayerSprites(enable: false); //PlayerAnimationHelper.ResetPlayer(); yield return(0f); Debug.Log("Went to sleep"); Physics2D.IgnoreLayerCollision(GameLibOfMethods.player.layer, 10, true); GameLibOfMethods.isSleeping = true; GameLibOfMethods.cantMove = true; GameLibOfMethods.animator.SetBool("Sleeping", true); GameLibOfMethods.player.GetComponent <Rigidbody2D>().velocity = Vector2.zero; yield return(MEC.Timing.WaitForSeconds(0.5f)); GameLibOfMethods.AddChatMessege("Went to sleep."); float T = 0; GameClock.ChangeSpeedToSleepingSpeed(); while (true) { GameLibOfMethods.concecutiveSleepTime += (Time.deltaTime * GameClock.TimeMultiplier) * GameClock.Speed; float Multi = (Time.deltaTime / GameClock.Speed) * GameClock.TimeMultiplier; Stats.Status(Type.Energy).Add(EnergyGainPerHour * Multi); Stats.Status(Type.Mood).Add(MoodGainPerHour * Multi); Stats.Status(Type.Health).Add(HealthGainPerHour * Multi); if (Input.GetKeyUp(KeyCode.E)) { break; } if (Stats.Status(Type.Energy).CurrentAmount >= Stats.Status(Type.Energy).MaxAmount) { T += Time.deltaTime; if (T >= 2) { GameLibOfMethods.CreateFloatingText("Can't sleep more", 2); break; } } yield return(0f); } PlayExitSound(); GameLibOfMethods.animator.SetBool("Sleeping", false); yield return(0f); while (true) { var state = GameLibOfMethods.animator.GetCurrentAnimatorStateInfo(0); if (!state.IsName("JumpOffToBed")) { Debug.Log("Something is wrong.. this finished before firing the method. Make sure you don't call this from FixedUpdate."); break; } if (state.normalizedTime >= 40 / 50f) { break; } yield return(0f); } HandlePlayerSprites(enable: true); PlayerCommands.JumpOff(JumpOffSpeed); GameClock.ResetSpeed(); }
/// <summary>Prints the error message to the screen.</summary> public void PrintErrorMessage() => GameLibOfMethods.CreateFloatingText(ErrorMessage, 1);