コード例 #1
0
    public MapTileConfigBase GetTileConfig(int x, int y)
    {
        if (!IsValidTileCoord(x, y))
        {
            return(null);
        }
        int tileData = mTileConfigDatas [x, y];
        MapTileConfigType tileType = MapTileConfigBase.DecodeTileType(tileData);
        MapTileConfigBase ret      = null;

        switch (tileType)
        {
        case MapTileConfigType.Block:
            ret = new MapTileConfigBlock();
            break;

        case MapTileConfigType.Free:
            ret = new MapTileConfigFree();
            break;

        default:
            break;
        }
        ret.tileCoord = new IntVector2(x, y);
        ret.Decode(tileData);
        return(ret);
    }
コード例 #2
0
    protected override void DoDraw(IntVector2 pos)
    {
        MapTileConfigBlock configBlock = new MapTileConfigBlock();

        configBlock.tileCoord = pos;

        if (mModelIndex >= mModelIntArray.Length)
        {
            configBlock.SetModelkey(MapPrefabDefine.emptyBlockModelKey);
        }
        else
        {
            configBlock.SetModelkey(mModelIntArray [mModelIndex]);
        }

        MapDataManager.Instance.SeedConfigData(pos.x, pos.y, configBlock.Encode());
    }
コード例 #3
0
ファイル: MapTileBlock.cs プロジェクト: yamido001/HexagonMap
    void RefreshModel()
    {
        MapTileConfigBlock configBlock = mConfigData as MapTileConfigBlock;

        if (mCurModelKey == configBlock.GetModelKey())
        {
            return;
        }
        DestroyModel();
        mCurModelKey = configBlock.GetModelKey();
        string modelName = MapPrefabDefine.GetBlockPrefabName(mCurModelKey);

        if (null != modelName)
        {
            string     resourcePath = "Map/Prefab/Block/" + modelName;
            GameObject prefab       = Resources.Load <GameObject> (resourcePath);
            mModelObj = GameObject.Instantiate(prefab);
            Vector3 mapPos = MapLayout.Instance.GetTilePos(configBlock.tileCoord.x, configBlock.tileCoord.y);
            mModelObj.transform.SetParent(mViewTf);
            mModelObj.transform.ResetAndToWorldPos(mapPos);
            mModelObj.name = configBlock.tileCoord.ToString();
        }
    }