void CreateInventory() { CropItem wheatItem = new CropItem(wheatSprite, new Vector2(-100, -100), 600, 0, "wheat", 600); SeedItem wheatSeed = new SeedItem(wheatSeedSprite, new Vector2(-100, -100), 100, 0, "wheat"); CropItem lettuceItem = new CropItem(lettuceSprite, new Vector2(-100, -100), 250, 0, "lettuce", 250); SeedItem lettuceSeed = new SeedItem(lettuceSeedSprite, new Vector2(-100, -100), 50, 0, "lettuce"); CropItem cornItem = new CropItem(cornSprite, new Vector2(-100, -100), 75, 0, "corn", 50); SeedItem cornSeed = new SeedItem(cornSeedSprite, new Vector2(-100, -100), 5, 0, "corn"); MeatItem cowItem = new MeatItem(cowSprite, new Vector2(-100, -100), 750, 0, "cow", 1150); MeatItem chickenItem = new MeatItem(chickenSprite, new Vector2(-100, -100), 300, 0, "chicken", 650); Inventory.Add(wheatItem); Inventory.Add(lettuceItem); Inventory.Add(cornItem); Inventory.Add(cowItem); Inventory.Add(chickenItem); seeds.Add(wheatSeed); seeds.Add(lettuceSeed); seeds.Add(cornSeed); }
private void OnCollisionEnter(Collision collision) { // Check for player collision if (collision.gameObject.tag == "Player") { player.GetComponent <PlayerController>().RemoveObserver(this); Collider[] colliders = gameObject.GetComponents <Collider>(); foreach (Collider collider in colliders) { colliderItems.Remove(collider.gameObject); collider.enabled = false; } foreach (Transform child in transform) { child.GetComponent <MeshRenderer>().enabled = false; } if (gameObject.GetComponent <MeshRenderer>() != null) { gameObject.GetComponent <MeshRenderer>().enabled = false; } ParticleBehavior pb = null; switch (itemType) { case ItemType.BREAD: pb = new BreadItem(); break; case ItemType.CAN: pb = new CanItem(); break; case ItemType.CHEESE: pb = new CheeseItem(); break; case ItemType.FRUIT: pb = new FruitItem(); break; case ItemType.LIQUID: pb = new LiquidItem(); break; case ItemType.MEAT: pb = new MeatItem(); break; case ItemType.SHELF: pb = new ShelfItem(); break; } if (gameObject.transform.parent == true) { pb.InstantiateParticles(collision.contacts[0].point, gameObject.transform.parent.gameObject); } else { pb.InstantiateParticles(collision.contacts[0].point, gameObject); } } }