Exemple #1
0
 public void PlaySpawnTransition()
 {
     BattleCamera.Shake(0.6f);
     AudioConstants.Instance.PlayerSpawn.PlaySFX();
     SetShieldAlpha(0.0f);
     spawnTransition_.AnimateIn(() => {
         SetShieldAlpha(GameConstants.Instance.PlayerShieldAlphaMin);
     });
 }
Exemple #2
0
    public virtual void Magic(string sid, Entity other = null)
    {
        Skill      s      = GameFuncs.GetSkill(sid);
        Hero       h      = BattleGlobals.currentObj.GetComponent <Hero>();
        GameObject effect = Instantiate((GameObject)GameFuncs.GetResource("Effect/" + sid));

        Destroy(effect, 2);
        BattleCamera.Shake();
        int   cost  = s.isCp ? s.cost : s.cost / 5;
        float ats   = s.isCp ? h.infos[4] : (h.infos[2] + h.infos[4]) / 2;
        float value = cost * ats;

        if (s.isAoe)
        {
            if (BattleGlobals.currentObj.tag == "Hero")
            {
                effect.transform.position = Battle.mone.position;
                List <string> temp = new List <string>();
                foreach (string lm in BattleGlobals.liveMonsters)
                {
                    temp.Add(lm);
                }
                for (int i = 0; i < temp.Count; i++)
                {
                    string es = temp[i];
                    Enemy  en = BattleFuncs.FindObj(es).GetComponent <Enemy>();
                    en.GetHurt(value, GetRestrict(en, ref value));
                }
            }
            else if (BattleGlobals.currentObj.tag == "Enemy")
            {
                List <string> temp = BattleGlobals.liveHeroes;
                for (int i = 0; i < temp.Count; i++)
                {
                    string hs = temp[i];
                    Hero   he = BattleFuncs.FindObj(hs).GetComponent <Hero>();
                    he.GetHurt(value, GetRestrict(he, ref value));
                }
            }
        }
        else
        {
            effect.transform.position = other.gameObject.transform.position;
            other.GetHurt(value, GetRestrict(other, ref value));
        }
        BattleGlobals.currentSid = "";
        Invoke("SetTurnOver", 2);
    }
Exemple #3
0
        public void Init(BattlePlayer battlePlayer)
        {
            ChangeBattlePlayerSource(battlePlayer);
            AddSpeedFromVelocity(battlePlayer.Rigidbody.velocity);

            AudioConstants.Instance.LaserShoot.PlaySFX(volumeScale: 0.33f);
            BattleCamera.Shake(0.14f);

            Color laserColor = battlePlayer.Skin.LaserColor;

            laserRenderer_.material          = battlePlayer.Skin.SmearedLaserMaterial;
            light_.color                     = laserColor;
            laserHitMaterial_                = battlePlayer.Skin.LaserMaterial;
            particleSystemRenderer_.material = battlePlayer.Skin.LaserMaterial;

            GameNotifications.OnBattlePlayerShotLaser.Invoke(this, battlePlayer);
        }
        public void TakeDamage(int damage, Vector3 forward, object damageSource = null)
        {
            if (health_ <= 0)
            {
                return;
            }

            if (invulnerable_)
            {
                return;
            }

            health_ -= damage;
            OnBattlePlayerDamaged.Invoke(Player_, damage);

            if (health_ <= 0)
            {
                GameObject playerParts = ObjectPoolManager.Create(playerPartsPrefab_, this.transform.position, Quaternion.identity, parent: BattleRecyclables.Instance);

                // NOTE (darren): remove any negative y component from damage forward vector
                // since gravity + explosive downwards force looks crazy
                Vector3 explosionForward  = forward.SetY(Mathf.Max(forward.y, 0.0f));
                Vector3 explosionPosition = this.transform.position - (explosionForward.normalized * kExplosionRadius / 4.0f);
                foreach (Rigidbody rigidbody in playerParts.GetComponentsInChildren <Rigidbody>())
                {
                    float distance       = (rigidbody.position - explosionPosition).magnitude;
                    float explosionForce = Mathf.Clamp(1.0f - (distance / kExplosionForce), 0.0f, 1.0f);
                    explosionForce *= UnityEngine.Random.Range(0.1f, 1.3f);
                    rigidbody.AddExplosionForce(explosionForce * kExplosionForce, explosionPosition, kExplosionRadius, upwardsModifier: 1.0f);
                }

                // Animate single material to batch
                SetEmissiveMaterialsFor(playerParts, Player_.Skin.BodyPartMaterial);

                Material[] partMaterialArray = new Material[] { Player_.Skin.BodyPartMaterial };
                AnimateDamageEmissionFor(partMaterialArray);
                AudioConstants.Instance.PlayerDeath.PlaySFX();
                BattleCamera.Shake(1.0f);
                BattleCamera.StopTimeForKill();
                OnBattlePlayerDied.Invoke(Player_);
                if (damageSource != null)
                {
                    GameNotifications.OnBattlePlayerDiedWithSource.Invoke(Player_, damageSource);
                }

                ObjectPoolManager.Recycle(this);
            }
            else
            {
                float multiplier = 1.0f;
                if (damage > 0)
                {
                    AnimateShieldHit(hideShieldAfterwards: health_ <= 1);
                    // AnimateDamageEmissionFor(Player_.BodyRenderers.Select(r => r.sharedMaterial));
                    multiplier = 0.5f;
                }

                Knockback(forward, damageSource: damageSource);
                AudioConstants.Instance.PlayerHurt.PlaySFX(volumeScale: multiplier);
                BattleCamera.Shake(0.55f * multiplier);
            }
        }