Exemplo n.º 1
0
 void OnCollision2DEnter()
 {
     if (stateOfGate == StateOfGate.targetFall)
     {
         stateOfGate = StateOfGate.destroyBeam;
     }
 }
Exemplo n.º 2
0
    void OnHitByPulse(float pulseWavelength)
    {
//		Debug.Log("Door Trigget Got shot");
//		Debug.Log("The pulse wavelength is ="+ pulseWavelength);
//		Debug.Log("The wavelength is ="+ pulseWavelengthKey);


        //NEEDS TO CHECK IF THE PULS IS ACCEPTABLE

        //IF ACCEPTABLE SEND MESSAGE TO DOOR TO OPEN &
        //TURN OFF THE COLLIDER AND RENDERER OF THE TARGET

        //MESSAGE CAN'T TRAVEL FASTER THAN LIGHT



        if (pulseWavelength < (float)pulseWavelengthKey)
        {
            stateOfGate = StateOfGate.targetTriggered;
            //Destroy(gameObject);
        }
    }
Exemplo n.º 3
0
    void GateSwitchStatement()
    {
        switch (stateOfGate)
        {
        //case (StateOfGate.gateSpawning) :
        //need to extend the cylinder until the laser collides with something
        //need


        case (StateOfGate.gateOn):
            break;

        case (StateOfGate.targetTriggered):

            targetTransform.GetComponent <Rigidbody2D>().isKinematic = false;
            //apply a small force downward. for some reason it doesn't fall
            targetTransform.GetComponent <Rigidbody2D>().AddForce(new Vector2(0.0f, -1.0f));
            timeOfHit = Time.time;

            stateOfGate = StateOfGate.targetFall;
            goto case StateOfGate.targetFall;

        case (StateOfGate.targetFall):
            //let the target fall to the ground(taken care of above
            //shrink the beam as it goes (taken care of by ray cast)
            if (laserTransform.localScale.y > 1.5f)
            {
                break;
            }
            else
            {
                stateOfGate = StateOfGate.destroyBeam;
                goto case StateOfGate.destroyBeam;
            }

        case (StateOfGate.destroyBeam):
            //when the target hits the ground the beam is done for
            laserTransform.GetComponent <Renderer>().enabled = false;
            //turn off the coliders of the object
            laserTransform.GetComponent <Collider2D>().enabled = false;

            laserOn     = false;
            timeOfDeath = Time.time;


            stateOfGate = StateOfGate.targetBounce;
            goto case StateOfGate.targetBounce;

        case (StateOfGate.targetBounce):
            //animate the target shrinking to nothing

            if (Time.time < timeOfDeath + deathTime && Time.time < timeOfHit + maxDeathTime)
            {
                scaleFactorOfTarget        = Mathf.Lerp(initialTransformScale, 0.0f, (Time.time - timeOfDeath) * oneOverDeathTime);
                targetTransform.localScale = new Vector3(scaleFactorOfTarget,
                                                         scaleFactorOfTarget,
                                                         1.0f);

                break;
            }
            else
            {
                stateOfGate = StateOfGate.destroyObject;
                goto case StateOfGate.destroyObject;
            }

        case (StateOfGate.destroyObject):
            //when the target's clear of the screen destroy it
            Destroy(gameObject);
            break;
        }
    }