Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (x3 == null)
        {
            x3 = new Xbox360Controller(ID);
        }

        if (SignedIn)
        {
            float hor = x3.HorizontalAxis();
            float ver = x3.VerticalAxis();
            this.transform.position += new Vector3(hor, -ver) * speed;
        }
        else
        {
            if (x3.StartPressed())
            {
                SignedIn = true;
                this.GetComponent <SpriteRenderer> ().enabled            = true;
                select.transform.GetChild(1).GetComponent <Text> ().text = "";
                select.color = desired;
                SignedInCount++;
                AudioSource.PlayClipAtPoint(GameObject.FindObjectOfType <NetworkingObjectMenu>().click, GameObject.FindGameObjectWithTag("MainCamera").transform.position);
            }
        }

        if (collidingLevel != null)
        {
            if (x3.PressedJump())
            {
                LevelType level = collidingLevel.lt;
                GlobalProperties.LEVEL = level.ToString();
                collidingLevel.GetComponent <SpriteRenderer>().color = Color.red;
                AudioSource.PlayClipAtPoint(collidingLevel.noise, GameObject.FindGameObjectWithTag("MainCamera").transform.position);

                if (prevCollidingLevel == null || prevCollidingLevel == collidingLevel)
                {
                    prevCollidingLevel = collidingLevel;
                }
                else
                {
                    prevCollidingLevel.GetComponent <SpriteRenderer>().color = Color.white;
                    prevCollidingLevel = collidingLevel;
                }
            }
        }
        else if (colliding != null)
        {
            if (x3.PressedJump())
            {
                CharacterType character = colliding.ct;
                GlobalProperties.PLAYERCHOICE[ID - 1] = character.ToString();
                select.transform.GetChild(2).GetComponent <Image>().sprite    = GameObject.FindObjectOfType <CharacterDictionary>().GetByText(character.ToString());
                select.transform.GetChild(1).GetComponent <Text> ().text      = "\n" + character.ToString();
                select.transform.GetChild(1).GetComponent <Text> ().alignment = TextAnchor.UpperRight;
                AudioSource.PlayClipAtPoint(colliding.noise, GameObject.FindGameObjectWithTag("MainCamera").transform.position);
            }
        }
    }
Exemplo n.º 2
0
    private IEnumerator MoveToLevelSelectAnimation()
    {
        float time = 0;

        Vector2 levelSelectStart = new Vector2(1600, 0);
        Vector2 homeEnd          = new Vector2(-1600, 0);
        Vector2 middle           = Vector2.zero;

        var lsRT       = LevelSelectScreen.GetComponent <RectTransform>();
        var lsMirrorRT = LevelSelectScreen.MirroredComponent.GetComponent <RectTransform>();
        var homeRT     = HomeScreen.GetComponent <RectTransform>();

        LevelSelectScreen.gameObject.SetActive(true);
        LevelSelectScreen.MirroredComponent.gameObject.SetActive(true);

        float anim_time = 0.75f;

        while (time < anim_time)
        {
            float   t = Curve.Evaluate(time / anim_time);
            Vector2 levelSelectPosition = new Vector2(1600 - t * 1600, 0);
            Vector2 homePosition        = new Vector2(0 - t * 1600, 0);

            homeRT.anchoredPosition     = homePosition;
            lsRT.anchoredPosition       = levelSelectPosition;
            lsMirrorRT.anchoredPosition = levelSelectPosition;

            time += Time.deltaTime;
            yield return(null);
        }

        MMVibrationManager.Haptic(HapticTypes.LightImpact);

        lsRT.anchoredPosition       = middle;
        lsMirrorRT.anchoredPosition = middle;
        HomeScreen.SetActive(false);
    }