private void CreateCharacter()
        {
            PlayerStateContainer container = PlayerStateContainer.Instance;

            container.TeamSelection     = PlayerStateContainer.EXPLORER;
            container.ExplorerSelection = PlayerStateContainer.DOUBLE_JUMP_EXPLORER;
            explorer = PhotonNetwork.Instantiate(doubleJumpPrefab.name, new Vector3(2, 2), Quaternion.identity, 0).GetComponent <BaseExplorer>();
            explorer.SendTalentsToNetwork();
            Camera.main.transform.position = explorer.transform.position;
        }
Example #2
0
 private void DamageIfExploding()
 {
     if (!photonView.isMine || !IsExploding()) return;
     Collider2D[] triggers = Physics2D.OverlapCircleAll(transform.position, explosionRadius, whatTakesDamage);
     foreach (Collider2D trigger in triggers) {
         BaseExplorer explorer = trigger.gameObject.GetComponent<BaseExplorer>();
         if (explorer != null && !explorer.IsOutOfHealth() && !playersHit.Contains(explorer)) {
             playersHit.Add(explorer);
             explorer.photonView.RPC("TakeDamage", PhotonTargets.All, currentSpeed);
             CryoLauncherBehavior.photonView.RPC("ReceiveObjectiveEmbers", PhotonTargets.All, 10f);
         }
     }
 }
Example #3
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);
                    }
                }
            }
        }
Example #5
0
        public void OnTriggerEnter2D(Collider2D other)
        {
            if (!photonView.isMine)
            {
                return;
            }
            BaseExplorer associatedBehavior = other.gameObject.GetComponent <BaseExplorer>();

            if (associatedBehavior == null || associatedBehavior.IsOutOfHealth())
            {
                return;
            }
            if (currentState == MovementState.DASHING && Time.time - lastCollisionTime > collisionDebounceTime)
            {
                associatedBehavior.photonView.RPC("TakeDamage", PhotonTargets.All, currentSpeed);
                this.currentSpeed *= -1;
                lastCollisionTime  = Time.time;
                photonView.RPC("ReceiveObjectiveEmbers", PhotonTargets.All, 10f);
            }
        }
Example #6
0
        // Brings the player back to life if they are within range of a bonfire that has living players near it.
        private void ResurrectIfAble()
        {
            if (!photonView.isMine || !IsDead() || IsOutOfLives())
            {
                return;
            }
            bool         ableToRes = false;
            BaseExplorer savior    = null;

            Collider2D[] bonfires = Physics2D.OverlapCircleAll(transform.position, saveCollider.radius, whatIsBonfire);
            foreach (Collider2D fireCollider in bonfires)
            {
                BonfireBehavior behavior = fireCollider.gameObject.GetComponent <BonfireBehavior>();
                if (behavior != null && behavior.IsLit())
                {
                    ableToRes = true;
                }
            }
            Collider2D[] players = Physics2D.OverlapCircleAll(transform.position, saveCollider.radius, whatIsExplorer);
            foreach (Collider2D collider in players)
            {
                BaseExplorer behavior = collider.gameObject.GetComponent <BaseExplorer>();
                if (behavior != null && !behavior.IsOutOfHealth())
                {
                    ableToRes = true;
                    behavior.photonView.RPC("ReceiveRescueEmbers", PhotonTargets.All, 10);
                    savior = behavior;
                }
            }
            if (ableToRes)
            {
                currentHealth = maxHealth;
                GeneratedGameManager behavior = FindObjectOfType <GeneratedGameManager>();
                behavior.photonView.RPC("DisplayAlert", PhotonTargets.Others, "An explorer has been saved!  His light shines once more.", false, PlayerStateContainer.EXPLORER);
                behavior.DisplayAlert("You have been saved!  Your light shines once more.", false, PlayerStateContainer.EXPLORER);
                PlayRelightSound();
                photonView.RPC("PlayRelightSound", PhotonTargets.Others);
            }
        }
        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);
        }