Example #1
0
 void Start()
 {
     hmd              = GameObject.FindGameObjectWithTag("Player").transform;
     currentProlong   = null;
     prolongOffset    = Vector3.zero;
     inTunnelEntrance = false;
     trespassed       = false;
     trespass_text.SetActive(false);
 }
Example #2
0
    void OnTriggerStay(Collider col)
    {
        if (col.GetComponent <Prolongation> () != null && currentProlong == null)
        {
            if ((col.GetComponent <Prolongation> ().type == ProlongationType.TUNNEL && inTunnelEntrance == true) ||
                col.GetComponent <Prolongation> ().type == ProlongationType.BRIDGE)
            {
                currentProlong = col.GetComponent <Prolongation> ();
                tileStart      = currentProlong.tileStart;
                tileEnd        = currentProlong.tileEnd;
                prolongStart   = currentProlong.prolongationStart;
                prolongEnd     = currentProlong.prolongationEnd;
//				print ("in");
            }
        }
    }
Example #3
0
    void OnTriggerExit(Collider col)
    {
        if (col.tag == "TunnelEntrance")
        {
            inTunnelEntrance = false;
        }
        if (col.GetComponent <Prolongation> () != null && col.GetComponent <Prolongation>() == currentProlong)
        {
            if (currentProlong.prolongedX > 0)
            {
                float p = (hmd.position.x - tileStart) / (tileEnd - tileStart);
                p = Mathf.Clamp01(p);
//				print ("exit " + p);
                float x_offset = 1f * (prolongEnd - prolongStart) * currentProlong.prolongedX / (currentProlong.prolongedX + 1f);
                if (p == 0f && currentProlong.addedToOffset == true)
                {
                    prolongOffset = new Vector3(prolongOffset.x - x_offset, prolongOffset.y, prolongOffset.z);
                    currentProlong.addedToOffset = false;
                }
                else if (p == 1f && currentProlong.addedToOffset == false)
                {
                    prolongOffset = new Vector3(prolongOffset.x + x_offset, prolongOffset.y, prolongOffset.z);
                    currentProlong.addedToOffset = true;
                }
            }
            else if (currentProlong.prolongedZ > 0)
            {
                float p = (hmd.position.z - tileStart) / (tileEnd - tileStart);
                p = Mathf.Clamp01(p);
//				print ("exit " + p);
                float z_offset = 1f * (prolongEnd - prolongStart) * currentProlong.prolongedZ / (currentProlong.prolongedZ + 1f);
                if (p == 0f && currentProlong.addedToOffset == true)
                {
                    prolongOffset = new Vector3(prolongOffset.x, prolongOffset.y, prolongOffset.z - z_offset);
                    currentProlong.addedToOffset = false;
                }
                else if (p == 1f && currentProlong.addedToOffset == false)
                {
                    prolongOffset = new Vector3(prolongOffset.x, prolongOffset.y, prolongOffset.z + z_offset);
                    currentProlong.addedToOffset = true;
                }
            }
            currentProlong = null;
        }
    }