Ejemplo n.º 1
0
    public void Group(MahjongAsset asset, int groupIndex, int index)
    {
        Transform transform = asset == null ? null : asset.transform;

        if (transform == null)
        {
            return;
        }

        transform.localEulerAngles = new Vector3(90.0f, 0.0f, 0.0f);
        transform.localPosition    = groupPosition - new Vector3((groupIndex * 3 + (index > 2 ? 1 : index)) * width + groupIndex * offset, index > 2 ? -length : 0.0f, 0.0f);
    }
Ejemplo n.º 2
0
    public void Discard(MahjongAsset asset, int index)
    {
        Transform transform = asset == null ? null : asset.transform;

        if (transform == null)
        {
            return;
        }

        transform.localPosition = discardPosition + new Vector3(width * (index % 5), 0.0f, -height * (index / 5));

        asset.Throw();
    }
Ejemplo n.º 3
0
    public void Throw(MahjongAsset asset, int index)
    {
        Transform transform = asset == null ? null : asset.transform;

        if (transform == null)
        {
            return;
        }

        transform.localPosition = scorePosition + new Vector3(width * index, 0.0f, 0.0f);

        asset.Throw();
    }
Ejemplo n.º 4
0
    public void As(MahjongAsset asset, Mahjong.Tile tile)
    {
        if (textures == null)
        {
            return;
        }

        byte code = tile;

        if (textures.Length <= code)
        {
            return;
        }

        Material material = asset == null || asset.renderer == null ? null : asset.renderer.material;

        if (material != null)
        {
            material.mainTexture = textures[code];
        }
    }
Ejemplo n.º 5
0
    public void Init(int tileCount, int index)
    {
        if (this.asset != null)
        {
            int          length = __instances == null ? 0 : __instances.Length, i;
            MahjongAsset asset;
            for (i = tileCount; i < length; ++i)
            {
                asset = __instances[i];
                if (asset != null)
                {
                    Destroy(asset.gameObject);
                }
            }

            Array.Resize(ref __instances, tileCount);

            int       count = tileCount >> 3, step = tileCount >> 2, j;
            float     offset = width * (((step + 1) >> 1) * 0.5f - 0.5f), temp;
            Transform transform;

            for (i = 0; i < count; ++i)
            {
                temp = i * width - offset;

                //Right
                j = step * 0 + (i << 1);

                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 90.0f, 0.0f);
                    transform.position    = new Vector3(size, this.length * 2.0f, -temp);
                }

                asset = __instances[++j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 90.0f, 0.0f);
                    transform.position    = new Vector3(size, this.length, -temp);
                }

                //Down
                j = step * 1 + (i << 1);

                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 180.0f, 0.0f);
                    transform.position    = new Vector3(-temp, this.length * 2.0f, -size);
                }

                asset = __instances[++j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 180.0f, 0.0f);
                    transform.position    = new Vector3(-temp, this.length, -size);
                }

                //Left
                j = step * 2 + (i << 1);

                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, -90.0f, 0.0f);
                    transform.position    = new Vector3(-size, this.length * 2.0f, temp);
                }

                asset = __instances[++j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, -90.0f, 0.0f);
                    transform.position    = new Vector3(-size, this.length, temp);
                }

                //Up
                j = step * 3 + (i << 1);

                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 0.0f, 0.0f);
                    transform.position    = new Vector3(temp, this.length * 2.0f, size);
                }

                asset = __instances[++j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 0.0f, 0.0f);
                    transform.position    = new Vector3(temp, this.length, size);
                }
            }

            if (tileCount > (count << 3))
            {
                temp = count * width - offset;

                //Right
                j = step * 1 - 1;

                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 90.0f, 0.0f);
                    transform.position    = new Vector3(size, this.length, -temp);
                }

                //Down
                j     = step * 2 - 1;
                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 180.0f, 0.0f);
                    transform.position    = new Vector3(-temp, this.length, -size);
                }

                //Left
                j     = step * 3 - 1;
                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, -90.0f, 0.0f);
                    transform.position    = new Vector3(-size, this.length, temp);
                }

                //Up
                j     = step * 4 - 1;
                asset = __instances[j];
                if (asset == null)
                {
                    asset          = Instantiate(this.asset);
                    __instances[j] = asset;
                }
                else
                {
                    asset.onDiscard  = null;
                    asset.onSelected = null;
                }

                transform = asset == null ? null : asset.transform;
                if (transform != null)
                {
                    transform.SetParent(null, false);
                    transform.eulerAngles = new Vector3(-90.0f, 0.0f, 0.0f);
                    transform.position    = new Vector3(temp, this.length, size);
                }
            }
        }

        GameObject gameObject = arrow == null ? null : arrow.gameObject;

        if (gameObject != null)
        {
            gameObject.SetActive(false);
        }

        __index = index;
    }