Пример #1
0
    void RestoreSpeedFunction()
    {
        PathThroughObjects scriptInstance = gameObject.transform.parent.GetComponent <PathThroughObjects>();

        scriptInstance.speed = originalSpeed;
        Destroy(gameObject);
    }
Пример #2
0
 public void Begin(float percentage, float time, GameObject slowDownEffect)
 {
     Invoke("Restore", time);
     if (calledCount == 0)
     {
         path          = gameObject.GetComponent <PathThroughObjects>();
         originalSpeed = path.speed;
         path.speed   *= percentage;
     }
     if (slowDownEffect != null)
     {
         this.slowDownEffect = slowDownEffect;
     }
     calledCount++;
 }
Пример #3
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == "Enemy")
        {
            if (!collision.collider.GetComponentInChildren <RestoreSpeed> ())
            {
                PathThroughObjects scriptInstance = collision.collider.GetComponent <PathThroughObjects> ();


                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;
            }
        }
    }