示例#1
0
    // Token: 0x0600096C RID: 2412 RVA: 0x00028C34 File Offset: 0x00027034
    public void Init(DataTiles.DataTile dataTile)
    {
        this._dataTile = dataTile;
        this._renderer = base.GetComponent <SpriteRenderer>();
        float x = (float)dataTile.indexX * AppConfig.GRID_UNIT_LENGTH;
        float y = (float)dataTile.indexY * AppConfig.GRID_UNIT_LENGTH;

        base.transform.position = new Vector3(x, y, 0f);
        this._renderer.color    = this._dataTile.colorTile.greyColor;
    }
    // Token: 0x06000826 RID: 2086 RVA: 0x00022A0C File Offset: 0x00020E0C
    public void Load(string name, JSONNode json)
    {
        this.TID = name;
        DataImage image = DataManager.Instance.dataImageGroup.GetImage(this.TID);

        this.price        = image.price;
        this.canvasLength = image.canvasLength;
        this.tag          = json["tag"];
        JSONNode jsonnode = json["colorRank"];
        int      count    = jsonnode.Count;

        for (int i = 1; i <= count; i++)
        {
            DataTiles.ColorTile colorTile = new DataTiles.ColorTile();
            colorTile.trueColor = new Color(0f, 0f, 0f, 1f);
            colorTile.greyColor = new Color(0f, 0f, 0f, 1f);
            colorTile.count     = 0;
            string   aKey      = i + string.Empty;
            JSONNode jsonnode2 = jsonnode[aKey];
            colorTile.trueColor.r = (float)jsonnode2[0].AsInt / 255f;
            colorTile.trueColor.g = (float)jsonnode2[1].AsInt / 255f;
            colorTile.trueColor.b = (float)jsonnode2[2].AsInt / 255f;
            float greyscaleWeight  = DataManager.Instance.dataConfig.greyscaleWeight;
            float greyscaleWeight2 = DataManager.Instance.dataConfig.greyscaleWeight2;
            float greyValue        = ColorHelper.GetGreyValue(colorTile.trueColor, greyscaleWeight, greyscaleWeight2);
            colorTile.greyColor.r = greyValue;
            colorTile.greyColor.g = greyValue;
            colorTile.greyColor.b = greyValue;
            this._colorRank.Add(i, colorTile);
        }
        JSONNode jsonnode3 = json["dataList"];

        foreach (JSONNode jsonnode4 in jsonnode3.Childs)
        {
            DataTiles.DataTile dataTile = new DataTiles.DataTile();
            dataTile.Init();
            dataTile.indexX     = jsonnode4[0].AsInt;
            dataTile.indexY     = jsonnode4[1].AsInt;
            dataTile.colorIndex = JsonReader.Int(jsonnode4[2]);
            if (dataTile.colorIndex == 0)
            {
                dataTile.isWhite             = true;
                dataTile.colorTile           = new DataTiles.ColorTile();
                dataTile.colorTile.trueColor = Color.white;
                dataTile.colorTile.greyColor = Color.white;
            }
            else
            {
                this._colorRank.TryGetValue(dataTile.colorIndex, out dataTile.colorTile);
                this._colorRank[dataTile.colorIndex].count++;
            }
            string key = dataTile.indexX + "_" + dataTile.indexY;
            this._dataTileDic.Add(key, dataTile);
        }
    }
    // Token: 0x0600095E RID: 2398 RVA: 0x000286AC File Offset: 0x00026AAC
    private void GenTile(DataTiles.DataTile dataTile)
    {
        Transform byPoolManager = this.GetByPoolManager();

        byPoolManager.transform.SetParent(GameManager.Instance.gameTilesLayer.transform);
        Tile component = byPoolManager.GetComponent <Tile>();

        component.Init(ref dataTile);
        string key = dataTile.indexX + "_" + dataTile.indexY;

        this._dicGameTiles.Add(key, component);
    }
示例#4
0
    // Token: 0x06000888 RID: 2184 RVA: 0x00024BAC File Offset: 0x00022FAC
    public Dictionary <string, DataTiles.DataTile> GetLevelData(string TID)
    {
        Dictionary <string, DataTiles.DataTile> dictionary = new Dictionary <string, DataTiles.DataTile>();
        string key     = "LEVEL_" + TID;
        string @string = PlayerPrefs.GetString(key);

        if (@string.CompareTo(string.Empty) == 0)
        {
            return(dictionary);
        }
        string[] array = @string.Split(new char[]
        {
            ';'
        });
        int num = array.Length;

        for (int i = 0; i < num; i++)
        {
            string[] array2 = array[i].Split(new char[]
            {
                ','
            });
            DataTiles.DataTile dataTile = new DataTiles.DataTile();
            if (array2[2].CompareTo("1") == 0)
            {
                dataTile.isTouchRight = true;
                dataTile.isTouched    = true;
            }
            else if (array2[2].CompareTo("2") == 0)
            {
                dataTile.isTouchWrong = true;
                dataTile.isTouched    = true;
            }
            dataTile.wrongColorIndex = int.Parse(array2[3]);
            string key2 = array2[0] + "_" + array2[1];
            dictionary.Add(key2, dataTile);
        }
        return(dictionary);
    }
示例#5
0
    // Token: 0x0600093B RID: 2363 RVA: 0x00027918 File Offset: 0x00025D18
    public void Init(ref DataTiles.DataTile dataTile)
    {
        this._dataTile        = dataTile;
        this._colorNumber     = this._dataTile.colorIndex;
        this._isHoldClickOnce = false;
        float x = (float)this._dataTile.indexX * AppConfig.GRID_UNIT_LENGTH;
        float y = (float)this._dataTile.indexY * AppConfig.GRID_UNIT_LENGTH;

        base.transform.position = new Vector3(x, y, 0f);
        this._mainRenderer      = base.GetComponent <SpriteRenderer>();
        this._highLightRenderer = base.transform.Find("HighLight").GetComponent <SpriteRenderer>();
        this._highLightRenderer.sortingOrder = 0;
        this._highLightRenderer.color        = new Color(0f, 0f, 0f, 0f);
        if (this._dataTile.colorIndex == 0)
        {
            this._highLightRenderer.gameObject.SetActive(false);
        }
        else
        {
            this._highLightRenderer.gameObject.SetActive(true);
        }
        if (!this._dataTile.isWhite)
        {
            this.AddNumber();
        }
        if (this._dataTile.isTouchRight)
        {
            this.SetRightColor();
        }
        else if (this._dataTile.isTouchWrong)
        {
            Color penColor = GameUIManager.Instance.GetPenColor(this._dataTile.wrongColorIndex);
            this.SetWrongColor(penColor);
        }
        else
        {
            this.SetGreyColor();
        }
    }
    // Token: 0x0600095C RID: 2396 RVA: 0x00028578 File Offset: 0x00026978
    private void LoadTiles()
    {
        bool flag = false;
        Dictionary <string, DataTiles.DataTile> levelData = PlayerManager.Instance.GetLevelData(this._TID);

        if (levelData.Values.Count > 0)
        {
            flag = true;
        }
        if (this._dataTiles != null)
        {
            Dictionary <string, DataTiles.DataTile> dataTileDic = this._dataTiles.dataTileDic;
            for (int i = 0; i < this._dataTiles.canvasLength; i++)
            {
                for (int j = 0; j < this._dataTiles.canvasLength; j++)
                {
                    string             key = i + "_" + j;
                    DataTiles.DataTile dataTile;
                    dataTileDic.TryGetValue(key, out dataTile);
                    if (dataTile == null)
                    {
                        dataTile         = new DataTiles.DataTile();
                        dataTile.indexX  = i;
                        dataTile.indexY  = j;
                        dataTile.isValid = false;
                    }
                    DataTiles.DataTile dataTile2;
                    if (flag && levelData.TryGetValue(key, out dataTile2))
                    {
                        dataTile.isTouchRight    = dataTile2.isTouchRight;
                        dataTile.isTouchWrong    = dataTile2.isTouchWrong;
                        dataTile.wrongColorIndex = dataTile2.wrongColorIndex;
                        dataTile.isTouched       = dataTile2.isTouched;
                    }
                    this.GenTile(dataTile);
                }
            }
        }
    }