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);
            }
        }
    }