Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (b_isActive)
        {
            a_CloseEnemies = Physics.OverlapSphere(transform.position, f_DeathRadius);

            if (a_CloseEnemies.Length > 0)
            {
                foreach (Collider EnnemyInZone in a_CloseEnemies)
                {
                    if (EnnemyInZone.transform.tag == "Ennemi" || EnnemyInZone.transform.tag == "particule")
                    {
                        b_inEnnemyZone    = true;
                        SC_DamageRef      = EnnemyInZone.gameObject.GetComponent <SC_Damage>();
                        f_damageReceived += SC_DamageRef.Damage();
                    }
                    else
                    {
                        b_inEnnemyZone = false;
                    }
                }
                f_LifeAmount    -= f_damageReceived * Time.deltaTime;
                f_damageReceived = 0;
            }

            if (b_inEnnemyZone == false && f_LifeAmount < f_LifeAmountMax)
            {
                f_damageReceived = 0;
                f_LifeAmount    += f_LifeRegenSpeed * Time.deltaTime;
                if (f_LifeAmount > f_LifeAmountMax)
                {
                    f_LifeAmount = f_LifeAmountMax;
                }
            }

            if (f_LifeAmount <= 0 && b_Alive == true)
            {
                foreach (Collider EnnemyInZone in a_CloseEnemies)
                {
                    if (EnnemyInZone.transform.tag == "Ennemi")
                    {
                        SC_EnnemiRef = EnnemyInZone.gameObject.GetComponent <SC_Ennemi>();
                        SC_EnnemiRef.death(SC_TriggerRef.getHitDir(EnnemyInZone.transform), 10, 1, 0, SC_PlayerRef);
                    }
                }

                Death();
            }
            l_LifeLamp.spotAngle = (f_LifeAmount * f_LifeLampMax) / f_LifeAmountMax;
        }
    }
Example #2
0
    void Start()
    {
        g_walls = GameObject.FindGameObjectsWithTag("Wall");

        _AudioSource_Ennemi = gameObject.AddComponent <AudioSource>();
        _Sounds             = GameObject.FindGameObjectWithTag("SOUND_MANAGER").GetComponent <SC_SoundManager>();



        _deathMarkRoot = GameObject.Find("[deathMarkRoot]").gameObject;
        _EnemyAnim     = GetComponent <Animator>();

        SC_DamageRef        = this.GetComponent <SC_Damage>();
        SC_EnemyBehaviorRef = this.GetComponent <SC_EnemyBehavior>();
        SC_ScoreCounterRef  = GameObject.Find("guiSCOREcounter").GetComponent <SC_ScoreCounter>();
        this.tag            = null;

        s_EnemyState = "Walk";
//		AnimationHandeler("Walk");

        f_PushDuration = 0;

        transform.FindChild("corps").GetComponent <SpriteRenderer>().color = this.GetComponent <SpriteRenderer>().color;
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (b_Alive)
        {
            a_CloseEnemies = Physics.OverlapSphere(transform.position, f_DeathRadius);

            if (a_CloseEnemies.Length > 0)
            {
                foreach (Collider EnnemyInZone in a_CloseEnemies)
                {
                    if (EnnemyInZone.transform.tag == "Ennemi" || EnnemyInZone.transform.tag == "particule")
                    {
                        b_inEnnemyZone    = true;
                        SC_DamageRef      = EnnemyInZone.gameObject.GetComponent <SC_Damage>();
                        f_damageReceived += SC_DamageRef.Damage();
                    }
                    else
                    {
                        b_inEnnemyZone = false;
                    }
                }
                f_LifeAmount    -= f_damageReceived * Time.deltaTime;
                f_damageReceived = 0;
            }
            else
            {
                b_inEnnemyZone = false;
            }

            if (b_inEnnemyZone == false && f_LifeAmount < f_LifeAmountMax)
            {
                f_damageReceived = 0;
                f_LifeAmount    += f_LifeRegenSpeed * Time.deltaTime;
                if (f_LifeAmount > f_LifeAmountMax)
                {
                    f_LifeAmount = f_LifeAmountMax;
                }
            }

            if (f_LifeAmount <= 0 && b_Alive == true)
            {
                StartCoroutine(Death());
            }

            if (b_inEnnemyZone)
            {
                if (b_beingAttacked != true)
                {
                    p_damageParticle.enableEmission = true;
                    StartCoroutine(beingDamagedVisual());
                    b_beingAttacked = true;
                }
            }
            else
            {
                p_damageParticle.enableEmission = false;
                b_beingAttacked = false;
                gameObject.renderer.material.color = c_crestColor;
            }

            f_currentAlpha = (f_LifeAmount * 1) / f_LifeAmountMax;
            c_crestColor.a = f_currentAlpha;
            gameObject.renderer.material.color = c_crestColor;
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (b_Alive)
        {
            a_CloseEnemies = Physics.OverlapSphere(transform.position, f_DeathRadius);

            if (a_CloseEnemies.Length > 0)
            {
                foreach (Collider EnnemyInZone in a_CloseEnemies)
                {
                    if (EnnemyInZone.transform.tag == "Ennemi" || EnnemyInZone.transform.tag == "particule")
                    {
                        b_inEnnemyZone    = true;
                        SC_DamageRef      = EnnemyInZone.gameObject.GetComponent <SC_Damage>();
                        f_damageReceived += SC_DamageRef.Damage();

                        p_tanukiParticleAttacked.enableEmission = true;
                        p_tanukiParticle.gameObject.SetActive(false);
                    }
                    else
                    {
                        b_inEnnemyZone = false;
                        p_tanukiParticleAttacked.enableEmission = false;
                        p_tanukiParticle.gameObject.SetActive(true);
                    }
                }
                f_LifeAmount    -= f_damageReceived * Time.deltaTime;
                f_damageReceived = 0;
            }
            else
            {
                b_inEnnemyZone = false;
            }


            if (b_inEnnemyZone && b_animationAlert != true)
            {
                _tanukiAnimator.Play("batimentCentral_alert");

                foreach (GameObject tanukiAlert in g_tanukiPlayerAlert)
                {
                    tanukiAlert.SetActive(true);
                }

                b_animationAlert = true;
            }

            if (b_inEnnemyZone != true && b_animationAlert)
            {
                _tanukiAnimator.Play("batimentCentral_idle");
                foreach (GameObject tanukiAlert in g_tanukiPlayerAlert)
                {
                    tanukiAlert.SetActive(false);
                }
                b_animationAlert = false;
            }


            if (b_inEnnemyZone == false && f_LifeAmount < f_LifeAmountMax)
            {
                f_damageReceived = 0;
                f_LifeAmount    += f_LifeRegenSpeed * Time.deltaTime;
                if (f_LifeAmount > f_LifeAmountMax)
                {
                    f_LifeAmount = f_LifeAmountMax;
                }
            }



            if (f_LifeAmount <= 0 && b_Alive == true)
            {
                StartCoroutine(Death());
            }



//			if(b_inEnnemyZone == true && mainLight.color != Color.red)
//			{
//				mainLight.color = Color.red;
//				mainLight.intensity = 1.4f;
//			}
//			if(b_inEnnemyZone == false && mainLight.color != Color.white)
//			{
//				mainLight.color = Color.white;
//				mainLight.intensity = 0.01f;
//			}


            f_CurSize            = (f_LifeAmount * f_StartSize) / f_LifeAmountMax;
            transform.localScale = new Vector3(f_CurSize, f_CurSize, f_CurSize);


//			if(f_LifeAmount != f_LifeAmountMax)
//			{
//				p_tanukiParticle.startLifetime = 11;
//				p_tanukiParticle.startSize = 6;
//				p_tanukiParticle.startSpeed = 0.38f;
//			}
        }
    }