Example #1
0
    public static MahjongTile Create(TileDef def)
    {
        if (!TileDef.IsValid(def.Value))
        {
            Debug.LogError("tile : " + def.Value + " is not a valid tile");
            return(null);
        }

        Transform inst = null;

        MahjongTile._Pool = PoolManager.Pools ["mahjongres"];

        int point = def.GetPoint();

        switch (def.GetKind())
        {
        case TileDef.Kind.CRAK:
            inst = MahjongTile._Pool.Spawn("Crak_" + point);
            break;

        case TileDef.Kind.BAM:
            inst = MahjongTile._Pool.Spawn("Bam_" + point);
            break;

        case TileDef.Kind.DOT:
            inst = MahjongTile._Pool.Spawn("Dot_" + point);
            break;

        default:
            Debug.LogError("UnValid kind : " + def.GetKind());
            return(null);
        }

        inst.gameObject.SetActive(true);
        inst.transform.parent   = null;
        inst.transform.rotation = Quaternion.identity;
        inst.transform.position = Vector3.one * 9999f;

        MahjongTile tile = inst.gameObject.GetComponent <MahjongTile> () ?? inst.gameObject.AddComponent <MahjongTile> ();

        tile._def       = def;
        tile.ClickCount = 0;

        BoxCollider collider = inst.gameObject.AddComponent <BoxCollider> ();

        collider.center = Vector3.zero;
        collider.size   = ColliderSize;

        return(tile);
    }
Example #2
0
    public Sprite GetMJSprite(TileDef def)
    {
        switch (def.GetKind())
        {
        case TileDef.Kind.CRAK:
            return(_wanSprites[def.GetPoint() - 1]);

        case TileDef.Kind.BAM:
            return(_tiaoSprites[def.GetPoint() - 1]);

        case TileDef.Kind.DOT:
            return(_tongSprites[def.GetPoint() - 1]);

        case TileDef.Kind.HUA:
            return(_ziSprites[def.GetPoint() - 1]);
        }
        return(null);
    }