private void InitVariables() { switch (_producedItem) { case DropItemType.Bread: _orderTypeToAsk = OrderType.BakeBreadFindWheat; _dropItemTypeToAskFor = DropItemType.Wheat; break; case DropItemType.Tofu: _orderTypeToAsk = OrderType.FermentTofuFindSoybean; _dropItemTypeToAskFor = DropItemType.Soybean; break; case DropItemType.Piggy: _orderTypeToAsk = OrderType.FeedPigFindWheat; _dropItemTypeToAskFor = DropItemType.Wheat; break; case DropItemType.Meat: _orderTypeToAsk = OrderType.MakeMeatFindPig; _dropItemTypeToAskFor = DropItemType.Piggy; break; default: throw new ArgumentOutOfRangeException(); } }
public void DropAt(DropItemType type, Vector3 pos) { GameObjectPool pool; if(m_DropItemTables.TryGetValue(type, out pool)) { pool.PopTo(pos); } }
public void Drop(DropItemType type) { float probability; if (m_DropItemDescTable.TryGetValue(type, out probability)) { if(Random.Range(0, 1) <= probability) PlayerManager.instance.DropAt(type, transform.position); } }
public void Initialize(Transform targetTr, DropItemType itemType, RGBType rgbType) { this.rgbType = rgbType; this.transform.parent = targetTr; this.transform.localPosition = Vector3.up * 0.7f; this.itemType = itemType; ChangeColor(rgbType); ChangeSprite(itemType); }
public void AddToStorage(DropItemType type, uint ammount) { _townModel.Storage[type] += (int)ammount; if (ammount == 0) { return; } TriggerCallback(NotificationType.OnWarehouseStorageChanged); }
// Diese Methode wird ausgelöst, wenn einer der Invader eine Item abwirft. Dazu wird ein Delegate auf diese Methode an alle // Invader mitgegeben, so dass diese die Methode auslösen können. private void DropItemHandler(Point location, DropItemType itemType) { if (dropItems.Count < 2) { dropItems.Add(new cDropItem() { Location = location, ItemType = itemType, Size = dropItemSize, Speed = 3 }); } }
private bool GrabItemFromTownStorage(DropItemType type, uint ammount) { if (!TownStorageContains(type, ammount)) { return(false); } _townController.RemoveFromStorage(type, ammount); _villagerModel.Inventory[type] += (int)ammount; return(true); }
private void ChangeSprite(DropItemType itemType) { if (spriteRenderer == null) { return; } Sprite sprite = Resources.Load <Sprite>(string.Format("Item/{0}", itemType.ToString())); if (sprite != null) { spriteRenderer.sprite = sprite; } }
public void SpawnDropItem(DropItemType dropItemType, Transform targetPlatform, RGBType rgbType = RGBType.End) { if (dropItemPool == null) { return; } DropItem item = dropItemPool.GetItem(); if (item != null) { item.Initialize(targetPlatform, dropItemType, rgbType); } #if UNITY_EDITOR Debug.Log("DropItem생성"); #endif }
public Coin(LevelState parentWorld, Vector2 position) { this.position = position; this.parentWorld = parentWorld; dimensions = new Vector2(24, 24); dropItem = DropItemType.CoinDrop; state = DropState.Inactive; coinAnim = AnimationLib.getFrameAnimationSet("testCoin"); medAnim = AnimationLib.getFrameAnimationSet("itemHealth"); ammoAnim = AnimationLib.getFrameAnimationSet("itemBattery"); animationTime = 0.0f; isKnockedBack = false; }
internal void TakeItem(DropItemType itemType) { if (itemType == DropItemType.Shield) { this.Shield = ShieldMax; } else if (itemType == DropItemType.Life) { this.Health = HealthMax; } else if (itemType == DropItemType.Weapon && WeaponFrequency < 10) { this.Damage += 150; this.WeaponFrequency++; } else if (itemType == DropItemType.Weapon2 && WeaponStrength < 18) { this.WeaponStrength++; } }
public void SpawnDroppedItem(DropItemType type, Vector2Int position, int producedItemAmmount = 1) { GameObject prefab; switch (type) { case DropItemType.Wheat: prefab = _spawnModel.WheatItemPrefab; break; case DropItemType.Bread: prefab = _spawnModel.BreadItemPrefab; break; case DropItemType.Tofu: prefab = _spawnModel.TofuItemPrefab; break; case DropItemType.Soybean: prefab = _spawnModel.SoybeanItemPrefab; break; case DropItemType.Piggy: prefab = _spawnModel.PiggyItemPrefab; break; case DropItemType.Meat: prefab = _spawnModel.MeatItemPrefab; break; case DropItemType.None: throw new ArgumentOutOfRangeException(nameof(type), type, null); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } var item = SpawnCellObject(prefab, position).GetComponent <DroppedItemController>(); item.Ammount = producedItemAmmount; _townModel.DroppedItems.Add(item); }
public void RemoveFromStorage(DropItemType type, uint ammount) { _townModel.Storage[type] -= (int)ammount; TriggerCallback(NotificationType.OnWarehouseStorageChanged); }
public void activate(Vector2 position, DropItemType drop_type, int drop_value) { if (state == DropState.Active) { return; } state = DropState.Active; this.position = position; if (drop_type == DropItemType.CoinDrop) { dropItem = DropItemType.CoinDrop; if (Enum.IsDefined(typeof(CoinValue), drop_value)) { this.value = (CoinValue)drop_value; } else { throw new System.InvalidOperationException("value is not specified in Coin Value"); } isKnockedBack = false; float randDir = (float)(Game1.rand.NextDouble() * 3.14 * 2); knockBack(new Vector2((float)Math.Cos(randDir), (float)Math.Sin(randDir)), 0.0f, 0); switch (value) { case CoinValue.Loonie: image_size = 0.75f; break; case CoinValue.Twoonie: image_size = 0.75f; break; case CoinValue.Laurier: image_size = 0.75f; break; case CoinValue.MacDonald: image_size = 0.90f; break; case CoinValue.Elizabeth: image_size = 0.90f; break; case CoinValue.Mackenzie: image_size = 0.90f; break; case CoinValue.Borden: image_size = 1.0f; break; default: image_size = 0.75f; value = CoinValue.Loonie; break; } } else if (drop_type == DropItemType.MedDrop) { dropItem = DropItemType.MedDrop; if (Enum.IsDefined(typeof(MedValue), drop_value)) { this.med_value = (MedValue)drop_value; } else { throw new System.InvalidOperationException("value is not specified in Coin Value"); } isKnockedBack = false; float randDir = (float)(Game1.rand.NextDouble() * 3.14 * 2); knockBack(new Vector2((float)Math.Cos(randDir), (float)Math.Sin(randDir)), 0.0f, 0); switch (med_value) { case MedValue.smallPack: image_size = 0.65f; break; case MedValue.mediumPack: image_size = 0.80f; break; case MedValue.largePack: image_size = 0.90f; break; case MedValue.fullPack: image_size = 1.0f; break; default: image_size = 0.65f; med_value = MedValue.smallPack; break; } } else if (drop_type == DropItemType.AmmoDrop) { dropItem = DropItemType.AmmoDrop; if (Enum.IsDefined(typeof(AmmoValue), drop_value)) { this.ammo_value = (AmmoValue)drop_value; } else { throw new System.InvalidOperationException("value is not specified in Coin Value"); } isKnockedBack = false; float randDir = (float)(Game1.rand.NextDouble() * 3.14 * 2); knockBack(new Vector2((float)Math.Cos(randDir), (float)Math.Sin(randDir)), 0.0f, 0); switch (ammo_value) { case AmmoValue.smallAmmo: image_size = 0.65f; break; case AmmoValue.mediumAmmo: image_size = 0.80f; break; case AmmoValue.largeAmmo: image_size = 1.0f; break; case AmmoValue.fullAmmo: image_size = 1.0f; break; default: image_size = 0.65f; med_value = MedValue.smallPack; break; } } else { throw new System.InvalidOperationException("not a valid dropItem"); } }
public DropItemBase(DropItemType type) { this.DropType = type; }
public SceneActionBuilder SetDropItem(DropItemType type, int dropRate = 0) { _action.ItemType = type; _action.DropRate = dropRate; return(this); }
private bool TownStorageContains(DropItemType type, uint ammount) { return(_townController.GetStored(type) >= ammount); }
public int GetStored(DropItemType type) { return(_townModel.Storage[type]); }