Example #1
0
        private void HandleExplorerProximity()
        {
            if (!photonView.isMine)
            {
                return;
            }
            Collider2D[] explorers = Physics2D.OverlapCircleAll(transform.position, circleCollider.radius * (transform.localScale.x + transform.localScale.y) / 2, whatIsExplorer);
            if (explorers.Length == 0)
            {
                explorerCharges -= Time.deltaTime;
                explorerCharges  = Mathf.Max(explorerCharges, 0f);
            }
            else
            {
                float modifier = 0f;
                HashSet <BaseExplorer> playerSet = new HashSet <BaseExplorer>();
                foreach (Collider2D collider in explorers)
                {
                    BaseExplorer behavior = collider.GetComponentInParent <BaseExplorer>();
                    if (behavior == null || playerSet.Contains(behavior))
                    {
                        continue;
                    }
                    playerSet.Add(behavior);
                    float explorerModifier     = 1f;
                    int   mirrorActivationRank = behavior.GetTalentRank(TalentEnum.MIRROR_ACTIVATION);
                    if (behavior.HasPowerup(Powerup.DOUBLE_OBJECTIVE_SPEED))
                    {
                        explorerModifier *= 2f;
                    }

                    switch (mirrorActivationRank)
                    {
                    case 1:
                        explorerModifier *= 1.25f;
                        break;

                    case 2:
                        explorerModifier *= 2.5f;
                        break;

                    case 3:
                        explorerCharges = requiredCharges;
                        break;
                    }
                    modifier += explorerModifier;
                }
                explorerCharges += Time.deltaTime * modifier;
                explorerCharges  = Mathf.Min(explorerCharges, requiredCharges);
            }
        }
        private void HandlePlayerEvents()
        {
            if (photonView.isMine && currentCharges < GetRequiredCharges())
            {
                Collider2D[] otherPlayers = Physics2D.OverlapCircleAll(transform.position, circleCollider.radius * (transform.localScale.x + transform.localScale.y) / 2, whatIsPlayer);
                if (otherPlayers.Length == 0)
                {
                    currentCharges -= Time.deltaTime * regressionFactor;
                    currentCharges  = Mathf.Max(currentCharges, 0f);
                }
                else
                {
                    float multiplier = 0;
                    HashSet <BaseExplorer> playerSet = new HashSet <BaseExplorer>();
                    foreach (Collider2D collider in otherPlayers)
                    {
                        BaseExplorer behavior = collider.GetComponentInParent <BaseExplorer>();
                        if (behavior == null || playerSet.Contains(behavior))
                        {
                            continue;
                        }
                        playerSet.Add(behavior);
                        float explorerModifier = 1.0f + (behavior.GetTalentRank(TalentEnum.BONFIRE_SPEED) * 0.05f);
                        if (behavior.HasPowerup(Powerup.DOUBLE_OBJECTIVE_SPEED))
                        {
                            explorerModifier *= 2f;
                        }
                        float embers = Time.deltaTime * explorerModifier;
                        multiplier += explorerModifier;
                        behavior.photonView.RPC("ReceiveObjectiveEmbers", PhotonTargets.All, embers);

                        if (!behavior.HasTouchedFirstBonfire())
                        {
                            behavior.OnTouchFirstBonfire();
                            behavior.photonView.RPC("OnTouchFirstBonfire", PhotonTargets.All);
                            float freeProgress = 0.2f * behavior.GetTalentRank(TalentEnum.FIRST_BONFIRE_SPEED);
                            currentCharges += freeProgress * GetRequiredCharges();
                        }
                    }
                    currentCharges += Time.deltaTime * multiplier;
                    if (currentCharges >= GetRequiredCharges())
                    {
                        wasLitBefore   = true;
                        currentCharges = GetRequiredCharges();
                        photonView.RPC("NotifyLit", PhotonTargets.All);
                        photonView.RPC("PlayLitSound", PhotonTargets.All);
                    }
                }
            }
        }
        private void HandleNotifications()
        {
            if (gameManagerBehavior == null)
            {
                return;
            }
            List <GameObject>     objectsToDisplay   = new List <GameObject>();
            List <PortalBehavior> particlesToDisplay = new List <PortalBehavior>();

            switch (PlayerStateContainer.Instance.TeamSelection)
            {
            case PlayerStateContainer.EXPLORER:
                BaseExplorer explorer = gameManagerBehavior.Explorer;
                if (explorer != null)
                {
                    if (!explorer.IsDead())
                    {
                        objectsToDisplay.AddRange(GetDeadExplorerNotifications());
                    }
                    else
                    {
                        objectsToDisplay.AddRange(GetLiveExplorerNotifications());
                        objectsToDisplay.AddRange(GetAllLitBonfires());
                    }

                    if (gameManagerBehavior.ShowMirrorNotifications)
                    {
                        objectsToDisplay.AddRange(GetAllUnlitBonfires());
                        objectsToDisplay.AddRange(GetNightmareNotifications());
                        if (!explorer.IsDead())
                        {
                            objectsToDisplay.AddRange(GetLiveExplorerNotifications());
                        }

                        int chestLocatorRank = explorer.GetTalentRank(TalentEnum.CHEST_LOCATOR);
                        if (chestLocatorRank >= 1)
                        {
                            objectsToDisplay.AddRange(GetClosedChests());
                        }
                        if (chestLocatorRank >= 2)
                        {
                            objectsToDisplay.AddRange(GetOpenedChests());
                        }
                    }
                    else if (explorer.HasPowerup(Powerup.NIGHTMARE_VISION))
                    {
                        objectsToDisplay.AddRange(GetNightmareNotifications());
                    }

                    int portalNotificationRank = explorer.GetTalentRank(TalentEnum.PORTAL_NOTIFICATIONS);
                    if (portalNotificationRank >= 1)
                    {
                        particlesToDisplay.AddRange(GetRecentlyChargedPortals());
                    }
                    if (portalNotificationRank >= 2)
                    {
                        particlesToDisplay.AddRange(GetInProgressPortals());
                    }

                    int bonfireNotificationRank = explorer.GetTalentRank(TalentEnum.BONFIRE_PROGRESS_NOTIFICATIONS);
                    if (bonfireNotificationRank == 1)
                    {
                        objectsToDisplay.AddRange(GetAllInProgressBonfires());
                    }
                }
                break;

            case PlayerStateContainer.NIGHTMARE:
                BaseNightmare nightmare = gameManagerBehavior.Nightmare;
                if (nightmare != null)
                {
                    if (gameManagerBehavior.ShowMirrorNotifications)
                    {
                        objectsToDisplay.AddRange(GetNightmareNotifications());
                        objectsToDisplay.AddRange(GetLiveExplorerNotifications());

                        int chestLocatorRank = nightmare.GetTalentRank(TalentEnum.CHEST_LOCATOR);
                        if (chestLocatorRank >= 1)
                        {
                            objectsToDisplay.AddRange(GetClosedChests());
                        }
                        if (chestLocatorRank >= 2)
                        {
                            objectsToDisplay.AddRange(GetOpenedChests());
                        }
                    }
                    else if (nightmare.HasPowerup(Powerup.DREAMER_VISION))
                    {
                        objectsToDisplay.AddRange(GetLiveExplorerNotifications());
                    }
                }
                break;

            default:
                break;
            }
            objectsToDisplay.AddRange(GetRecentlyLitBonfires());
            objectsToDisplay.AddRange(GetRecentlyOpenedChests());
            DrawNotifications(objectsToDisplay);
            DrawParticles(particlesToDisplay);
        }