void InstantiateSalesItems() { GrottoSpawnPoint gsp = GrottoSpawnPoint; for (int i = 0; i < gsp.SaleItemPrefabs.Count; i++) { Collectible cPrefab = gsp.SaleItemPrefabs[i]; SaleItemView v = _saleItemViews[i]; // TODO: Instantiate these dynamically if (cPrefab == null || v == null) { continue; } cPrefab.riseUpWhenCollected = false; int price = gsp.SaleItemPrices[i]; string cName = cPrefab.itemPrefab.name; Item item = Inventory.Instance.GetItem(cName); if (!item.IsMaxedOut) { Collectible c = Grotto.InstantiateItem(cPrefab.gameObject, v.transform, price); c.name = cName; _salesItems.Add(c); } string priceText = price.ToString(); v.UpdatePriceText(priceText); v.gameObject.SetActive(!item.IsMaxedOut); } }
public void OnPlayerEnteredPortal(GrottoPortal portal) { int warpDestination = GrottoSpawnPoint.GetWarpDestinationIndexForPortal(portal); Locations.Instance.WarpToGrottoWarpDestination(warpDestination); //WarpToPortalInsideGrotto(portal); }
void SpawnNewActiveGrotto(GrottoSpawnPoint gSP) { if (!_spawningEnabled) { return; } gSP.SpawnGrotto(); _activeGrottoSP = gSP; }
void DestroyCurrentlyActiveGrotto() { if (_activeGrottoSP == null) { return; } _activeGrottoSP.DestroyGrotto(); _activeGrottoSP = null; }
public void SetGrottoHasBeenTapped(GrottoSpawnPoint gsp, bool value) { if (value == HasGrottoBeenTapped(gsp)) { return; } if (value) { _tappedGrottos.Add(gsp.name); } else { _tappedGrottos.Remove(gsp.name); } }
void WarpToPortalInsideGrotto(GrottoPortal fromPortal) { Player player = CommonObjects.Player_C; ZeldaPlayerController pc = player.PlayerController; GrottoSpawnPoint warpToGrottoSP = null; Transform warpToLocation = null; Grotto destinationGrotto = null; if (fromPortal == Grotto.warpA) { warpToGrottoSP = GrottoSpawnPoint.warpToA; destinationGrotto = warpToGrottoSP.SpawnGrotto(); warpToLocation = destinationGrotto.warpA.transform; } else if (fromPortal == Grotto.warpB) { warpToGrottoSP = GrottoSpawnPoint.warpToB; destinationGrotto = warpToGrottoSP.SpawnGrotto(); warpToLocation = destinationGrotto.warpB.transform; } else if (fromPortal == Grotto.warpC) { warpToGrottoSP = GrottoSpawnPoint.warpToC; destinationGrotto = warpToGrottoSP.SpawnGrotto(); warpToLocation = destinationGrotto.warpC.transform; } Vector3 eulerDiff = warpToLocation.eulerAngles - fromPortal.transform.eulerAngles; Transform t = pc.transform; Vector3 offset = t.position - fromPortal.transform.position; offset = Quaternion.Euler(eulerDiff) * offset; t.position = warpToLocation.position + offset; Vector3 newEuler = pc.transform.eulerAngles + eulerDiff; player.ForceNewRotation(newEuler); pc.Stop(); OnPlayerExit(); destinationGrotto.OnPlayerEnter(); }
float GetGrottoClosestToPlayer(out GrottoSpawnPoint gSP) { Vector3 playerPos = CommonObjects.Player_C.Position; float closestDistSq = float.PositiveInfinity; Transform closestGSP = null; foreach (Transform child in transform) { Vector3 toPlayer = playerPos - child.GetComponent <GrottoSpawnPoint>().marker.transform.position; float distanceToPlayerSqr = Vector3.SqrMagnitude(toPlayer); if (distanceToPlayerSqr < closestDistSq) { closestDistSq = distanceToPlayerSqr; closestGSP = child; } } gSP = closestGSP.GetComponent <GrottoSpawnPoint>(); return(closestDistSq); }
void ISpawnManager.DoUpdate(bool ignoreProxThreshMin = false) { if (PlayerIsInsideAGrotto()) { return; } GrottoSpawnPoint closestGSP = null; float closestDistSq = GetGrottoClosestToPlayer(out closestGSP); if (_activeGrottoSP != null) { if (closestDistSq > _spawnDistThresholdSq || closestGSP != _activeGrottoSP) { DestroyCurrentlyActiveGrotto(); } } if (closestDistSq <= _spawnDistThresholdSq && closestGSP != _activeGrottoSP) { SpawnNewActiveGrotto(closestGSP); } }
public bool HasGrottoBeenTapped(GrottoSpawnPoint gsp) { return(_tappedGrottos.Contains(gsp.name)); }