예제 #1
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.tag == "Enemy")
     {
         //PathThroughObjects path = collision.gameObject.GetComponent<PathThroughObjects>();
         //path.speed *= slowPercentage;
         //restoreSpeedObject = new RestoreSpeed(); // Instantiate< RestoreSpeed>() as RestoreSpeed;
         restoreSpeedObject = collision.gameObject.GetComponent <RestoreSpeed>();
         GameObject slowDownEffect = null;
         if (restoreSpeedObject == null)
         {
             restoreSpeedObject = collision.gameObject.AddComponent <RestoreSpeed>();
             slowDownEffect     = Instantiate(Resources.Load("SlowDownEffect"), collision.gameObject.transform.position, Quaternion.identity) as GameObject;
             slowDownEffect.transform.parent = collision.gameObject.transform;
         }
         restoreSpeedObject.Begin(slowPercentage, slowTime, slowDownEffect);
         Destroy(gameObject);
     }
 }
예제 #2
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == "Enemy")
        {
            if (!collision.collider.GetComponentInChildren <RestoreSpeed>())
            {
                PathThroughObjcets scriptInstance = collision.collider.GetComponent <PathThroughObjcets>();

                GameObject restoreSpeedInstance = Instantiate(restoreSpeedObject, collision.collider.transform.position, Quaternion.identity) as GameObject;

                restoreSpeedInstance.transform.parent = collision.collider.transform;
                RestoreSpeed scriptInstance2 = restoreSpeedInstance.GetComponent <RestoreSpeed>();
                scriptInstance2.time          = slowTime;
                scriptInstance2.originalSpeed = scriptInstance.speed;

                scriptInstance.speed *= slowPercentage;
            }
        }
    }
예제 #3
0
    void OnCollisionEnter(Collision col)
    {
        if (col.collider.tag == "Enemy")
        {
            col.collider.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);

            if (col.collider.GetComponentInChildren <RestoreSpeed>() == null)
            {
                PathTroughObject scriptInstance = col.collider.GetComponent <PathTroughObject>();


                GameObject restoreSpeedIntsnce = Instantiate(restoreSoeedObhect, col.collider.transform.position, Quaternion.identity) as GameObject;
                restoreSpeedIntsnce.transform.parent = col.collider.transform;
                RestoreSpeed scriptInstance2 = restoreSpeedIntsnce.GetComponent <RestoreSpeed>();
                scriptInstance2.time          = slowSpeed;
                scriptInstance2.originalSpeed = scriptInstance.speed;

                scriptInstance.speed *= slowPercentage;
            }
            Destroy(gameObject);
        }
    }