public void CreateRandomPickups() { foreach (Map map in TheLastSliceGame.MapManager.Maps) { int numPickups = TheLastSliceGame.Random.Next(1, 1); int numIngredients = TheLastSliceGame.Random.Next(1, 1); for (int i = 0; i < numIngredients; i++) { IngredientType type = (IngredientType)TheLastSliceGame.Random.Next(0, Enum.GetNames(typeof(IngredientType)).Length); Vector2 cell = GetRandomValidCell(map); if (!cell.Equals(Vector2.Zero)) { map.AddEntity(EntityType.Ingredient, (int)cell.Y, (int)cell.X, type.ToString()); } } for (int i = 0; i < numPickups; i++) { PickupType type = (PickupType)TheLastSliceGame.Random.Next(1, Enum.GetNames(typeof(PickupType)).Length); Vector2 cell = GetRandomValidCell(map); if (!cell.Equals(Vector2.Zero)) { map.AddEntity(EntityType.Pickup, (int)cell.Y, (int)cell.X, type.ToString()); } } } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.layer == LayerMask.NameToLayer("Player")) { { if (pickupType != PickupType.finish) { GameManager.instance.UpdatePickups(pickupType.ToString()); StartCoroutine(ShrinkPickup(1.5f)); } else if (pickupType == PickupType.finish && GameManager.instance.CanFinish()) { pickups[0].gameObject.SetActive(true); } } } }
private void GeneratePickup() { int randIndex = Random.Range(0, 4); switch (randIndex) { case 0: currentPickupType = PickupType.Spread; break; case 1: currentPickupType = PickupType.Boomerang; break; case 2: currentPickupType = PickupType.Enlarge; break; case 3: currentPickupType = PickupType.Homing; break; } string pickupName = "Pickup_" + currentPickupType.ToString(); gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Sprites/Pickups/" + pickupName); }
public static bool isPickupType(PickupType pickupType, string assetCode) { return(assetCode == pickupType.ToString()); }