コード例 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (soundEffects == null)
        {
            soundEffects = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <SoundEffectsManager>();
        }
        // Items is for player ultimately. It will be trouble if monster can even pick up the stuff!
        if (other.tag.Equals("Player"))
        {
            // Need to find the inventory again if can't find it!
            if (playerInventory == null)
            {
                Start();
            }
            if (theItemStuff == null)
            {
                Start();
            }
            Debug.Log("Interacting with: " + other.name);
            playerInventory.passInInventory(theItemStuff.m_itemInform);

            // We also need to give the player back some health!
            HealthScript zePlayerHealth = other.GetComponent <HealthScript>();
            zePlayerHealth.modifyHealth(m_heal);

            itemInteractParticles.transform.position = transform.position;
            itemInteractParticles.playEffect();
            if (soundEffects != null)
            {
                soundEffects.playSound("pickupItems");
            }
            Destroy(gameObject);
        }
    }
コード例 #2
0
 void Update()
 {
     m_timeCounter += Time.deltaTime;
     if (m_timeCounter > m_timeInterval)
     {
         for (int zeNum = 0; zeNum < m_times; ++zeNum)
         {
             m_TheParticleSystem.stopEffect();
             m_TheParticleSystem.playEffect();
             transform.position = new Vector3(transform.position.x + m_SpacingX, transform.position.y, transform.position.z);
         }
         transform.position = particleSystemPos;
         m_timeCounter      = 0;
     }
 }
コード例 #3
0
ファイル: GolemProjectile.cs プロジェクト: 360Tomahawk/SP4
 // Update is called once per frame
 void Update()
 {
     if (soundEffects == null)
     {
         soundEffects = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <SoundEffectsManager>();
     }
     if (hasSpawned)
     {
         if (circleCollider.enabled)
         {
             if (checkForCollision())
             {
                 Destroy(gameObject);
                 return;
             }
         }
         foreach (GameObject zeGO in rockParticleSystems)
         {
             ParticleScript zeParticleEffects = zeGO.GetComponent <ParticleScript>();
             // Need to make sure that the particle system is not playing
             if (!zeParticleEffects.isPlaying())
             {
                 zeParticleEffects.transform.position = transform.position;
                 zeParticleEffects.playEffect();
                 break;
             }
         }
         //if (projectileParticles != null)
         //{
         //    projectileParticles.transform.position = transform.position;
         //    projectileParticles.GetComponent<ParticleScript>().playEffect();
         //}
         Destroy(gameObject);
     }
     //if (projectileParticles != null)
     //{
     //    projectileParticles = GameObject.Find(particlesystemname);
     //}
     if (speed != 0 && direction != Vector3.zero)
     {
         if (!circleCollider.enabled)
         {
             circleCollider.enabled = true;
         }
         rb.velocity = direction * speed * Time.deltaTime;
         if (circleCollider.enabled)
         {
             if (checkForCollision())
             {
                 Destroy(gameObject);
             }
         }
     }
     else if (speed != 0 && direction == Vector3.zero && rb.velocity == Vector2.zero && spriteR.color.a == 1)
     {
         if (!circleCollider.enabled)
         {
             circleCollider.enabled = true;
         }
         hasSpawned = true;
         //aliveTime +=
         if (circleCollider.enabled)
         {
             if (checkForCollision())
             {
                 Destroy(gameObject);
             }
         }
     }
 }
コード例 #4
0
ファイル: GolemProjectile.cs プロジェクト: 360Tomahawk/SP4
    public bool checkForCollision()
    {
        collision = Physics2D.CircleCastAll(transform.position, circleCollider.bounds.size.x - 0.5f, Vector2.zero, 0);

        foreach (RaycastHit2D temp in collision)
        {
            if (temp.collider != null)
            {
                if (temp.collider.gameObject.tag == "Player" && temp.collider.gameObject.GetComponent <HealthScript>() != null)
                {
                    //if (projectileParticles != null)
                    //{
                    //    projectileParticles.transform.position = transform.position;
                    //    projectileParticles.GetComponent<ParticleScript>().playEffect();
                    //}
                    foreach (GameObject zeGO in rockParticleSystems)
                    {
                        ParticleScript zeParticleEffects = zeGO.GetComponent <ParticleScript>();
                        // Need to make sure that the particle system is not playing
                        if (!zeParticleEffects.isPlaying())
                        {
                            zeParticleEffects.transform.position = transform.position;
                            zeParticleEffects.playEffect();
                            break;
                        }
                    }
                    temp.collider.gameObject.GetComponent <HealthScript>().modifyHealth(-damage);
                    if (soundEffects != null)
                    {
                        soundEffects.playSound("smashing");
                    }
                    return(true);
                }
                else if (temp.collider.gameObject.tag != "GolemBoss" && temp.collider.gameObject.tag != "GolemBoss_Projectile" && temp.collider.gameObject.tag != "Arrows")
                {
                    //if (projectileParticles != null)
                    //{
                    //    projectileParticles.transform.position = transform.position;
                    //    projectileParticles.GetComponent<ParticleScript>().playEffect();
                    //}
                    foreach (GameObject zeGO in rockParticleSystems)
                    {
                        ParticleScript zeParticleEffects = zeGO.GetComponent <ParticleScript>();
                        // Need to make sure that the particle system is not playing
                        if (!zeParticleEffects.isPlaying())
                        {
                            zeParticleEffects.transform.position = transform.position;
                            zeParticleEffects.playEffect();
                            break;
                        }
                    }
                    if (soundEffects != null)
                    {
                        soundEffects.playSound("smashing");
                    }
                    //Debug.Log(temp.collider.gameObject.name);
                    return(true);
                }
            }
        }
        return(false);
    }