public static void HandleFreshMovingPlatforms()    //Called at the end of NovaPlayer update()
    {
        if (xa.player == null)
        {
            return;
        }
        GameObject pl = xa.player;

        //Update platforms
        for (int i = 0; i < movingPlats.Count; i++)
        {
            MovingPlat m = movingPlats[i];
            m.vel = new Vector2(0, 0);
            //Debug.Log(m.state);
            switch (m.state)
            {
            case State.Launching:
                m.vel.y = m.launchSpeed * fa.deltaTime;
                m.go.transform.Translate(new Vector3(0, m.launchSpeed * fa.deltaTime, 0));
                if (m.go.transform.position.y > m.nodePos.y)
                {
                    m.timeset = fa.time; m.state = State.WaitingAtTop; m.go.transform.SetY(m.nodePos.y);
                }
                break;

            case State.WaitingAtTop:
                if (fa.time > (m.timeset + m.delayAtTop))
                {
                    m.state = State.Resetting;
                }
                break;

            case State.Resetting:
                m.vel.y = -m.resetSpeed * fa.deltaTime;
                m.go.transform.Translate(new Vector3(0, -m.resetSpeed * fa.deltaTime, 0));
                if (m.go.transform.position.y < m.startPos.y)
                {
                    m.timeset = fa.time; m.state = State.WaitingAtBottom; m.go.transform.SetY(m.startPos.y);
                }
                break;

            case State.WaitingAtBottom:
                if (fa.time > (m.timeset + m.delayAtBottom))
                {
                    m.state = State.Launching;
                }
                break;
            }
        }
    }
Ejemplo n.º 2
0
    void Awake()
    {
        animator = GetComponent <Animator>();

        animator.SetInteger("Animation", Animation);
        animator.SetBool("canStart", startFromBeginning);

        MovingPlat plat = GetComponentInChildren <MovingPlat>();

        if (plat != null)
        {
            plat.setStart(startFromBeginning);
        }
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     mov    = GameObject.FindGameObjectWithTag("Movingplat").GetComponent <MovingPlat>();
     player = gameObject.GetComponentInParent <Player>();
 }