Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        m_currentState = (int)State.Default;

        // instantiate each state of matter
        m_defaultMatty = Instantiate (defaultMatty, gameObject.transform.position, Quaternion.identity) as GameObject;
        m_solidMatty = Instantiate (solidMatty, gameObject.transform.position, Quaternion.identity) as GameObject;
        m_liquidMatty = Instantiate (liquidMatty, gameObject.transform.position, Quaternion.identity) as GameObject;
        m_gasMatty = Instantiate (gasMatty, gameObject.transform.position, Quaternion.identity) as GameObject;
        m_plasmaMatty = Instantiate (plasmaMatty, gameObject.transform.position, Quaternion.identity) as GameObject;

        // find the class associated with each state of matter
        m_defaultMattyScript = m_defaultMatty.GetComponent<MattyScript>();
        m_solidMattyScript = m_solidMatty.GetComponent<MattySolidScript>();
        m_liquidMattyScript = m_liquidMatty.GetComponent<MattyLiquidScript>();
        m_gasMattyScript = m_gasMatty.GetComponent<MattyGasScript>();
        m_plasmaMattyScript = m_plasmaMatty.GetComponent<MattyPlasmaScript>();
        m_platCtrlScript = gameObject.GetComponent<PlatformerController>();

        // Temp: Make sure this collider does not collide with each state of matter's colliders
        Physics.IgnoreCollision(collider, m_defaultMatty.collider);
        Physics.IgnoreCollision(collider, m_solidMatty.collider);
        Physics.IgnoreCollision(collider, m_plasmaMatty.collider);

        playerDead = false;
        m_camera = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<CameraFollow>();
        dir = GameObject.FindGameObjectWithTag ("Director").GetComponent<Director>();

        collidedWithGrates = false;

        origWalkSpeed = m_platCtrlScript.movement.walkSpeed;
        origExtraHeight = m_platCtrlScript.jump.extraHeight;
        spawnPoint = new Vector3 ();
        spawnPoint = dir.GetSpawnPoint ();
        m_platCtrlScript.SetSpawnPoint (spawnPoint, true);

        m_platCtrlScript.movement.maxSpeedUp = dir.GetMaxSpeedUp ();

        enableState ((int)State.Default);
    }