Пример #1
0
    public void GenButtons(TypeButtonVisualAspect[] buttonAspects)
    {
        pvgPub.listOfButtons = new ButtonVisualAspect[buttonAspects.Length];
        for(int btnIdx = 0; btnIdx < buttonAspects.Length; btnIdx++)
        {
            Control newControl = null;
            switch(buttonAspects[btnIdx])
            {
            case TypeButtonVisualAspect.Size1x1:
                newControl = GameObject.Instantiate<Control>(control1x1Prefab);
                break;
            case TypeButtonVisualAspect.Size1x2:
                newControl = GameObject.Instantiate<Control>(control1x2Prefab);
                break;
            case TypeButtonVisualAspect.Size2x1:
                newControl = GameObject.Instantiate<Control>(control2x1Prefab);
                break;
            case TypeButtonVisualAspect.Size2x2:
                newControl = GameObject.Instantiate<Control>(control2x2Prefab);
                break;
            }

            int controlSubType = Random.Range(0, newControl.controlSprites.Length);
            newControl.subType = controlSubType;

            newControl.id = btnIdx + 1;
            newControl.transform.parent = transform;
            newControl.transform.localPosition = new Vector3(0.0f, 0.0f, -1.0f);
            pvgPub.listOfButtons[btnIdx] = newControl.GetComponent<ButtonVisualAspect>();
        }
    }
Пример #2
0
    void Init()
    {
        if(Player.GetLocalPlayer().isTutorial)
            completeSequence = completeSequenceTutorial;
        //buttonCount = FindObjectOfType<NetMgr>().controlCount;
        TypeButtonVisualAspect[] buttonArr;

        MatchMgr matchMgr = FindObjectOfType<MatchMgr>();
        if(!matchMgr.isTutorialMatch)
        {
            buttonArr = new TypeButtonVisualAspect[buttonCount];
            switch(buttonCount)
            {
            case 2:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size2x2;
                break;
            case 3:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x1;
                buttonArr[2] = TypeButtonVisualAspect.Size2x2;
                break;
            case 4:
                buttonArr[0] = TypeButtonVisualAspect.Size1x2;
                buttonArr[1] = TypeButtonVisualAspect.Size2x2;
                buttonArr[2] = TypeButtonVisualAspect.Size1x1;
                buttonArr[3] = TypeButtonVisualAspect.Size2x2;
                break;
            case 5:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x2;
                buttonArr[2] = TypeButtonVisualAspect.Size2x1;
                buttonArr[3] = TypeButtonVisualAspect.Size1x1;
                buttonArr[4] = TypeButtonVisualAspect.Size2x2;
                break;
            case 6:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x1;
                buttonArr[2] = TypeButtonVisualAspect.Size2x1;
                buttonArr[3] = TypeButtonVisualAspect.Size1x2;
                buttonArr[4] = TypeButtonVisualAspect.Size2x1;
                buttonArr[5] = TypeButtonVisualAspect.Size1x2;
                break;
            case 7:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x1;
                buttonArr[2] = TypeButtonVisualAspect.Size2x1;
                buttonArr[3] = TypeButtonVisualAspect.Size1x2;
                buttonArr[4] = TypeButtonVisualAspect.Size2x2;
                buttonArr[5] = TypeButtonVisualAspect.Size1x1;
                buttonArr[6] = TypeButtonVisualAspect.Size2x1;
                break;
            }
        }
        else
        {
            buttonCount = 3;
            buttonArr = new TypeButtonVisualAspect[buttonCount];
            buttonArr[0] = TypeButtonVisualAspect.Size2x2;
            buttonArr[1] = TypeButtonVisualAspect.Size2x2;
            buttonArr[2] = TypeButtonVisualAspect.Size2x2;
            tutorialSource.clip = tutorialClips[id - 1];
        }

        GenButtons(buttonArr);

        if(isServer)
        {
            SetUpPanel();
            if(matchMgr.isTutorialMatch)
            {
                for(int btnIdx = 0; btnIdx < pvgPub.listOfButtons.Length; btnIdx++)
                {
                    ButtonVisualAspect curButton = pvgPub.listOfButtons[btnIdx];
                    curButton.transform.localPosition = new Vector3(posList[btnIdx * 3], posList[btnIdx * 3 + 1], -1.0f);
                    curButton.GetComponent<Control>().offSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].offSprite;
                    curButton.GetComponent<Control>().onSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].onSprite;
                }
            }
        }
        else
        {
            for(int btnIdx = 0; btnIdx < pvgPub.listOfButtons.Length; btnIdx++)
            {
                ButtonVisualAspect curButton = pvgPub.listOfButtons[btnIdx];
                curButton.transform.localPosition = new Vector3(posList[btnIdx * 3], posList[btnIdx * 3 + 1], -1.0f);
                curButton.GetComponent<Control>().offSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].offSprite;
                curButton.GetComponent<Control>().onSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].onSprite;
            }
        }
        /*
        PanelVisualGenerator pvgen1 = GetComponent<PanelVisualGenerator>();
        for(int btnIdx = 0; btnIdx < pvgen1.listOfButtons.Length; btnIdx++)
        {
            ButtonVisualAspect curButton = pvgen1.listOfButtons[btnIdx];
            curButton.GetComponent<Control>().offSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 2 + 2]].offSprite;
            curButton.GetComponent<Control>().onSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 2 + 2]].onSprite;
        }
        */

        GetComponent<SpriteRenderer>().sprite = panelSprites[id - 1];
        // Obtain reference to audio source.
        if(audioSource == null)
            audioSource = GetComponent<AudioSource>();
        // Decode correct sequence string.
        DecodeCorrectSequence();
    }
Пример #3
0
    void Init()
    {
        if (Player.GetLocalPlayer().isTutorial)
        {
            completeSequence = completeSequenceTutorial;
        }
        //buttonCount = FindObjectOfType<NetMgr>().controlCount;
        TypeButtonVisualAspect[] buttonArr;

        MatchMgr matchMgr = FindObjectOfType <MatchMgr>();

        if (!matchMgr.isTutorialMatch)
        {
            buttonArr = new TypeButtonVisualAspect[buttonCount];
            switch (buttonCount)
            {
            case 2:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size2x2;
                break;

            case 3:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x1;
                buttonArr[2] = TypeButtonVisualAspect.Size2x2;
                break;

            case 4:
                buttonArr[0] = TypeButtonVisualAspect.Size1x2;
                buttonArr[1] = TypeButtonVisualAspect.Size2x2;
                buttonArr[2] = TypeButtonVisualAspect.Size1x1;
                buttonArr[3] = TypeButtonVisualAspect.Size2x2;
                break;

            case 5:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x2;
                buttonArr[2] = TypeButtonVisualAspect.Size2x1;
                buttonArr[3] = TypeButtonVisualAspect.Size1x1;
                buttonArr[4] = TypeButtonVisualAspect.Size2x2;
                break;

            case 6:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x1;
                buttonArr[2] = TypeButtonVisualAspect.Size2x1;
                buttonArr[3] = TypeButtonVisualAspect.Size1x2;
                buttonArr[4] = TypeButtonVisualAspect.Size2x1;
                buttonArr[5] = TypeButtonVisualAspect.Size1x2;
                break;

            case 7:
                buttonArr[0] = TypeButtonVisualAspect.Size2x2;
                buttonArr[1] = TypeButtonVisualAspect.Size1x1;
                buttonArr[2] = TypeButtonVisualAspect.Size2x1;
                buttonArr[3] = TypeButtonVisualAspect.Size1x2;
                buttonArr[4] = TypeButtonVisualAspect.Size2x2;
                buttonArr[5] = TypeButtonVisualAspect.Size1x1;
                buttonArr[6] = TypeButtonVisualAspect.Size2x1;
                break;
            }
        }
        else
        {
            buttonCount         = 3;
            buttonArr           = new TypeButtonVisualAspect[buttonCount];
            buttonArr[0]        = TypeButtonVisualAspect.Size2x2;
            buttonArr[1]        = TypeButtonVisualAspect.Size2x2;
            buttonArr[2]        = TypeButtonVisualAspect.Size2x2;
            tutorialSource.clip = tutorialClips[id - 1];
        }

        GenButtons(buttonArr);

        if (isServer)
        {
            SetUpPanel();
            if (matchMgr.isTutorialMatch)
            {
                for (int btnIdx = 0; btnIdx < pvgPub.listOfButtons.Length; btnIdx++)
                {
                    ButtonVisualAspect curButton = pvgPub.listOfButtons[btnIdx];
                    curButton.transform.localPosition            = new Vector3(posList[btnIdx * 3], posList[btnIdx * 3 + 1], -1.0f);
                    curButton.GetComponent <Control>().offSprite = curButton.GetComponent <Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].offSprite;
                    curButton.GetComponent <Control>().onSprite  = curButton.GetComponent <Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].onSprite;
                }
            }
        }
        else
        {
            for (int btnIdx = 0; btnIdx < pvgPub.listOfButtons.Length; btnIdx++)
            {
                ButtonVisualAspect curButton = pvgPub.listOfButtons[btnIdx];
                curButton.transform.localPosition            = new Vector3(posList[btnIdx * 3], posList[btnIdx * 3 + 1], -1.0f);
                curButton.GetComponent <Control>().offSprite = curButton.GetComponent <Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].offSprite;
                curButton.GetComponent <Control>().onSprite  = curButton.GetComponent <Control>().controlSprites[(int)posList[btnIdx * 3 + 2]].onSprite;
            }
        }

        /*
         * PanelVisualGenerator pvgen1 = GetComponent<PanelVisualGenerator>();
         * for(int btnIdx = 0; btnIdx < pvgen1.listOfButtons.Length; btnIdx++)
         * {
         *  ButtonVisualAspect curButton = pvgen1.listOfButtons[btnIdx];
         *  curButton.GetComponent<Control>().offSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 2 + 2]].offSprite;
         *  curButton.GetComponent<Control>().onSprite = curButton.GetComponent<Control>().controlSprites[(int)posList[btnIdx * 2 + 2]].onSprite;
         * }
         */

        GetComponent <SpriteRenderer>().sprite = panelSprites[id - 1];
        // Obtain reference to audio source.
        if (audioSource == null)
        {
            audioSource = GetComponent <AudioSource>();
        }
        // Decode correct sequence string.
        DecodeCorrectSequence();
    }