Example #1
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 #2
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 #3
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);
            }
        }