예제 #1
0
        //-----------------------------------------------------------------------------------
        // Update is called once per frame
        //-----------------------------------------------------------------------------------
        protected override void UpdateImpl()
        {
            Logic.GlassLocal glass = (Logic.GlassLocal)m_glass;
            //TODO: Move to Callback form glass
            if (glass == null || m_block == null)
            {
                return;
            }

            RectTransform tf = GetComponent <RectTransform>();

            const int PREVIEW_SIZE = 4;
            float     fSizeX       = tf.rect.width / PREVIEW_SIZE;
            float     fSizeY       = tf.rect.height / PREVIEW_SIZE;

            Logic.Figure fig     = glass.nextFigure;
            var          mtx     = fig.matrix;
            VecInt2      vCenter = fig.GetCenterPoint();

            for (int x = 0; x < PREVIEW_SIZE; x++)
            {
                if (x > mtx.GetLength(0) - 1)
                {
                    continue;
                }
                for (int y = 0; y < PREVIEW_SIZE; y++)
                {
                    if (y > mtx.GetLength(1) - 1)
                    {
                        continue;
                    }
                    int nVal = mtx[x, y];
                    if (nVal != 0)
                    {
                        GameObject block = GetNextBlock();
                        //Vector3 vPos = new Vector3(fSizeX*(x - fCenterX), fSizeY*(y - fCenterY), 0.0f);

                        RectTransform btf = block.GetComponent <RectTransform>();

                        btf.anchoredPosition = new Vector3(fSizeX * (x - vCenter.x), fSizeY * (y - vCenter.y));
                        btf.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, fSizeX);
                        btf.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, fSizeY);
                    }
                }
            }
        }
예제 #2
0
        //-----------------------------------------------------------------------------------
        void OnEnable()
        {
            if (photonView.isMine)
            {
                Logic.GlassLocal glass = new Logic.GlassLocal();
                glass.m_delNewFigure    += OnGlassNewFigure;
                glass.m_delChangePos    += OnGlassChangePos;
                glass.m_delFigurePlaced += OnGlassFigurePlaced;
                glass.m_delLineAdded    += OnGlassLineAdded;
                glass.m_delGameEnd      += OnGlassGameEnd;
                m_glass = glass;
            }
            else
            {
                m_glass = new Logic.GlassRemote();
            }
            m_glass.Init();

            m_inputProvider = GetComponent <InputProvider>();
            if (m_inputProvider != null)
            {
                m_inputProvider.m_delEvent += m_glass.ProcessInput;

                if (photonView.isMine)
                {
                    m_inputProvider.local = true;
                    m_inputProvider.m_delNewInputState += OnInputNewState;
                }
                else
                {
                    m_inputProvider.local = false;
                }
            }

            Game.instance.netMan.players.Add(this);
        }