Exemplo n.º 1
0
    IEnumerator scaler()
    {
        float tm = Time.deltaTime;

        while (!myTurn)
        {
            yield return(null);
        }

        MusicProc.doEvent(ActionEvent.ShowBlock);

        myTurn = false;
        yield return(new WaitForSeconds(0.1f));

        myTurn = true;
        while (Vector3.SqrMagnitude(transform.localPosition - InitPos) > 0.01f)
        {
            yield return(null);

            tm = Time.deltaTime * 10;
            transform.localScale    = Vector3.MoveTowards(transform.localScale, Vector3.one, tm / 4);
            transform.localPosition = Vector3.MoveTowards(transform.localPosition, InitPos, tm);
        }
        transform.localScale    = Vector3.one;
        transform.localPosition = InitPos;
    }
Exemplo n.º 2
0
    public static void loot(GameObject go)
    {
        ItemOnField itm = go.GetComponent <ItemOnField> ();

        if (itm)
        {
            PlayerItems.AddItem(itm.itemName, itm.count);
            MusicProc.doEvent(ActionEvent.Loot, itm.itemName);
            Destroy(go);
            return;
        }
        CheckPoint cp = go.GetComponent <CheckPoint> ();

        if (cp)
        {
            if (cp.finalDoor)
            {
                instance.LevelDone();
            }
            else
            {
                cp.check();
            }
        }
    }
Exemplo n.º 3
0
 public override void doAction()
 {
     if (!this.gameObject.activeSelf)
     {
         this.gameObject.SetActive(true);
         MusicProc.doEvent(ActionEvent.Open);
     }
 }
Exemplo n.º 4
0
 public override void doAction()
 {
     if (Time.timeSinceLevelLoad - lastTimeCollision > 0.5f)
     {
         lastTimeCollision = Time.timeSinceLevelLoad;
         if (BlobBehaviour.instance.transform.position.y < transform.position.y)
         {
             if (itemCount-- > 0)
             {
                 if (animator != null)
                 {
                     animator.Play();
                 }
                 MusicProc.doEvent(eventName);
                 PlayerItems.AddItem(itemName);
             }
         }
     }
 }
Exemplo n.º 5
0
 void Awake()
 {
     src      = GetComponent <AudioSource> ();
     instance = this;
 }
Exemplo n.º 6
0
    /// <summary>
    /// Update this instance.
    /// </summary>
    void Update()
    {
        grounded = m_JellySprite.IsGrounded(m_GroundLayer, 1);
        //speed = Vector2.SqrMagnitude ((( Vector2)transform.localPosition ) - exexPos);
        //exexPos = exPos;
        //exPos = transform.localPosition;

        if (lastJump > 0)
        {
            lastJump -= Time.deltaTime;
        }
        if (grounded)
        {
            if (inJump)
            {
                MusicProc.doEvent(ActionEvent.Landed);
            }
            inJump = false;
        }
        else
        {
            inJump = true;
        }

        bool left  = false;
        bool right = false;

        foreach (Touch t in Input.touches)
        {
            if (t.position.x > center)
            {
                right = true;
            }
            else
            {
                left = true;
            }
        }

        if (Input.GetKey(KeyCode.RightArrow))
        {
            right = true;
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            left = true;
        }

        if (left && right)
        {
            if (lastJump <= 0 && grounded)
            {
                //m_JellySprite.AddForce(Vector2.up * 10000);
                m_JellySprite.AddForce(Vector3.up * 10000);                // - m_JellySprite.WhereIsGround2D(m_GroundLayer)*500);
                lastJump = 0.5f;
                MusicProc.doEvent(ActionEvent.Jump);
            }
        }
        else if (right)
        {
            //jumpVector += Vector2.right * 150;
            cx += rotSpeed * Time.deltaTime;
            if (cx > 1)
            {
                cx = 1;
            }
        }
        else if (left)
        {
            cx -= rotSpeed * Time.deltaTime;
            if (cx < -1)
            {
                cx = -1;
            }
        }
        else if (cx < 0)
        {
            cx += Time.deltaTime * rotSpeed;
            if (cx >= 0)
            {
                cx = 0;
            }
        }
        else if (cx > 0)
        {
            cx -= Time.deltaTime * rotSpeed;
            if (cx <= 0)
            {
                cx = 0;
            }
        }

        //Camera.main.transform.rotation = Quaternion.Euler(0, 0, cx * maxAngle);
        Physics2D.gravity = new Vector2(Mathf.Sin(cx) * gravity, -Mathf.Cos(cx) * gravity);

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.LoadLevel("menu");
        }
    }