Exemplo n.º 1
0
    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);
        }
    }
Exemplo n.º 2
0
    public void OnPlayerEnteredPortal(GrottoPortal portal)
    {
        int warpDestination = GrottoSpawnPoint.GetWarpDestinationIndexForPortal(portal);

        Locations.Instance.WarpToGrottoWarpDestination(warpDestination);


        //WarpToPortalInsideGrotto(portal);
    }
Exemplo n.º 3
0
    void SpawnNewActiveGrotto(GrottoSpawnPoint gSP)
    {
        if (!_spawningEnabled)
        {
            return;
        }

        gSP.SpawnGrotto();
        _activeGrottoSP = gSP;
    }
Exemplo n.º 4
0
    void DestroyCurrentlyActiveGrotto()
    {
        if (_activeGrottoSP == null)
        {
            return;
        }

        _activeGrottoSP.DestroyGrotto();
        _activeGrottoSP = null;
    }
Exemplo n.º 5
0
    public void SetGrottoHasBeenTapped(GrottoSpawnPoint gsp, bool value)
    {
        if (value == HasGrottoBeenTapped(gsp))
        {
            return;
        }

        if (value)
        {
            _tappedGrottos.Add(gsp.name);
        }
        else
        {
            _tappedGrottos.Remove(gsp.name);
        }
    }
Exemplo n.º 6
0
    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();
    }
Exemplo n.º 7
0
    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);
    }
Exemplo n.º 8
0
    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);
        }
    }
Exemplo n.º 9
0
 public bool HasGrottoBeenTapped(GrottoSpawnPoint gsp)
 {
     return(_tappedGrottos.Contains(gsp.name));
 }