Ejemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        Transform frontTransform = transform.Find("frontLocation");
        Transform backTransform  = transform.Find("backLocation");

        //quickly just puts these transforms relative to plane
        frontTransform.localPosition = new Vector3(0, -10, 0);
        backTransform.localPosition  = new Vector3(0, 10, 0);

        Vector3 frontPosition  = frontTransform.transform.position;
        Vector3 backPosition   = backTransform.transform.position;
        Vector3 othersPosition = other.transform.position;

        if (Vector3.Distance(othersPosition, frontPosition) < Vector3.Distance(othersPosition, backPosition))
        {
            int             checkpointNumber = int.Parse(this.name.Substring(1));
            RideCheckpoints rc = other.transform.root.GetComponent("RideCheckpoints") as RideCheckpoints;
            for (int i = 0; i < checkpointNumber; i++)
            {
                if (rc.m_Checkpoints[i] == false)
                {
                    return;
                }
            }
            rc.m_Checkpoints[checkpointNumber] = true;
        }
    }
Ejemplo n.º 2
0
    public void Setup()
    {
        m_Movement        = m_Instance.GetComponent <RideMovement>();
        m_RideCheckpoints = m_Instance.GetComponent <RideCheckpoints>();
        //m_CanvasGameObject = m_Instance.GetComponentInChildren<Canvas>().gameObject;

        m_Movement.m_PlayerNumber       = m_PlayerNumber;
        m_RideCheckpoints.m_Checkpoints = new bool[m_NumberOfCheckpoints];

        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";

        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = m_PlayerColor;
        }
    }