Exemple #1
0
 protected virtual void walkParticle()
 {
     for (int i = 0; i < 2; i++)
     {
         GameObject part = ParticleSpawner.SPAWN(new Color(0.6f, 0.6f, 0.6f), transform.position + new Vector3(0, 0.9f, -0.8f), Quaternion.identity, Random.Range(0.05f, 0.3f));
         part.GetComponent <Particle>().upForce   = 0.2f;
         part.GetComponent <Particle>().sideForce = 0;
     }
 }
Exemple #2
0
        public void Damage(float damage, float knockback, Transform source, string hitSound = "")
        {
            if (immortal)
            {
                return;
            }

            //Cap tegen constante spam van damage
            if (damagedTick > 0)
            {
                return;
            }
            damagedTick = 10;

            //Knockback
            Vector3 dir = (transform.position - source.position) * knockback;

            dir.y = 0;
            GetComponent <Rigidbody>().velocity += dir;

            //Sounds
            if (hitSound.Length > 0)
            {
                SoundManager.PLAY_SOUND(hitSound, transform.position);
            }
            if (hurtSoundName.Length > 0)
            {
                SoundManager.PLAY_SOUND(hurtSoundName, transform.position);
            }

            //Health Reduction + Death
            Health -= (int)damage;
            if (Health - damage <= 0)
            {
                Die();
            }

            //Particles
            if (meshParticle != null)
            {
                ParticleSpawner.SPAWN(meshParticle.material.color, transform.position + new Vector3(0, 1.2f, 0), Quaternion.identity, Random.Range(0.2f, 0.9f));
            }
        }
 IEnumerator chargeWorm()
 {
     for (int i = 0; i < 4; i++)
     {
         SoundManager.PLAY_SOUND("WormAppear", transform.position);
         if (i % 2 != 0)
         {
             continue;
         }
         for (int ang = 0; ang < 360; ang += 6)
         {
             float      posX = 0.2f * Mathf.Sin(ang * Mathf.Deg2Rad);
             float      posY = 0.2f * Mathf.Cos(ang * Mathf.Deg2Rad);
             GameObject part = ParticleSpawner.SPAWN(new Color(0.2f, 0.0f, 0.0f), new Vector3(transform.position.x + posX, 2, transform.position.z + posY), Quaternion.identity, Random.Range(0.1f, 0.4f));
             part.GetComponent <Particle>().upForce   = 0f;
             part.GetComponent <Particle>().sideForce = 0;
         }
         yield return(new WaitForSeconds(0.1f));
     }
 }
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Terrain")
     {
         for (int i = 0; i < Random.Range(35, 52); i++)
         {
             for (int ang = 0; ang < 360; ang++)
             {
                 float      posX = Mathf.Sin(ang * Mathf.Deg2Rad);
                 float      posY = Mathf.Cos(ang * Mathf.Deg2Rad);
                 GameObject part = ParticleSpawner.SPAWN("Sand Particle", new Vector3(transform.position.x + posX, 2, transform.position.z + posY), Quaternion.identity, Random.Range(0.2f, 0.7f));
                 part.GetComponent <Particle>().upForce   = 0.5f;
                 part.GetComponent <Particle>().sideForce = 0;
             }
             SoundManager.PLAY_SOUND("WormAppear", transform.position, 0.2f);
         }
     }
     //Test
     if (col.tag == "Player")
     {
         col.GetComponent <Player>().Damage(10, 5, transform);
     }
 }