Beispiel #1
0
    public void Unmask(BattleMapMonster monster)
    {
        BattleMapTile centerTile = holder.BattleMap.BattleMapTiles[monster.X, monster.Y];

        // 視界のタイルセットを取得
        List <BattleMapTile> set = MapUtils.GetRangeTileList(centerTile, monster.BattleStatus.View);

        BattleMapTileMaskGroup maskGroup = holder.BattleMap.BattleMapTileMaskGroup[monster.GetTeamIndex()];

        foreach (BattleMapTile bmt in set)
        {
            // マスクを取得
            BattleMapTileMask mask = maskGroup.BattleMapTileMask[bmt.X, bmt.Y];

            // すでにマスク解除されているならなにもしない
            if (mask.Mask == false)
            {
                continue;
            }

            mask.Mask = false;
            mask.GameObject.SetActive(false);
            mask.GameObjectShadow.SetActive(false);

            // オブジェクトが存在しない場合
            // オブジェクトを描画
            BattleMapObjectSet bmoSet = holder.BattleMap.BattleMapObjectSets[bmt.X, bmt.Y];
            if (bmoSet == null)
            {
                mapObjectGenerator.DecoreteMapTile(bmt);
            }
        }
    }
Beispiel #2
0
    private void Create(BattleMapTile bmt, BattleMapObjectSet bmoSet, IMapObjectSimpleCreatorHelper helper)
    {
        foreach (string point in helper.GetPointList())
        {
            string[] strs = point.Split(',');
            int      posX = int.Parse(strs[0]);
            int      posY = int.Parse(strs[1]);

            BattleMapObject bmo = CreateBattleMapObject(bmt, posX, posY, helper);
            bmoSet.BattleMapObjectList.Add(bmo);
        }
    }
Beispiel #3
0
    /// <summary>
    /// BattleMapObjectSetを作成
    /// </summary>
    /// <param name="bmt"></param>
    /// <returns></returns>
    public BattleMapObjectSet Create(BattleMapTile bmt)
    {
        // 新規作成
        BattleMapObjectSet bmoSet = new BattleMapObjectSet();

        bmoSet.X = bmt.X;
        bmoSet.Y = bmt.Y;

        // とりあえず全部
        List <string> pointList = creatorHelper.GetPointList();

        Create(bmt, bmoSet, creatorHelper);

        // 追加があれば作成
        IMapObjectSimpleCreatorHelper optionHelper = creatorHelper.GetOptionHelper();

        if (optionHelper != null)
        {
            Create(bmt, bmoSet, optionHelper);
        }

        return(bmoSet);
    }
    /// <summary>
    /// マップタイルを装飾
    /// </summary>
    /// <param name="bmt"></param>
    public void DecoreteMapTile(BattleMapTile bmt, MapTileType mapTileType)
    {
        // 今あるものを除去
        BattleMapObjectSet oldSet = holder.BattleMap.BattleMapObjectSets[bmt.X, bmt.Y];

        if (oldSet != null)
        {
            foreach (BattleMapObject tmpBmo in oldSet.BattleMapObjectList)
            {
                foreach (GameObject tmpGo in tmpBmo.GameObjectList)
                {
                    Destroy(tmpGo);
                }
            }
            holder.BattleMap.BattleMapObjectSets[bmt.X, bmt.Y] = null;
        }

        // 何もないなら終了
        if (mapTileType == MapTileType.NOTHING)
        {
            return;
        }

        // 新規作成
        IMapObjectCreator creator = mapObjectCreatorDictionary[mapTileType];

        // creatorがなければ何もしない
        if (creator == null)
        {
            return;
        }

        BattleMapObjectSet bmoSet = creator.Create(bmt);

        holder.BattleMap.BattleMapObjectSets[bmoSet.X, bmoSet.Y] = bmoSet;
    }
    public void Change()
    {
        int newSizeX = int.Parse(inputFieldSizeX.text);
        int newSizeY = int.Parse(inputFieldSizeY.text);

        BattleMapTile[,] oldTiles = holder.BattleMap.BattleMapTiles;
        BattleMapTile[,] newTiles = new BattleMapTile[newSizeX, newSizeY];

        int oldSizeX = oldTiles.GetLength(0);
        int oldSizeY = oldTiles.GetLength(1);

        // 同じなら何もしない
        if (newSizeX == oldSizeX && newSizeY == oldSizeY)
        {
            return;
        }

        // 両方あわせた器を作成
        int maxSizeX = oldSizeX;

        if (newSizeX > maxSizeX)
        {
            maxSizeX = newSizeX;
        }

        int maxSizeY = oldSizeY;

        if (newSizeY > maxSizeY)
        {
            maxSizeY = newSizeY;
        }

        BattleMapTile[,] maxTiles = new BattleMapTile[maxSizeX, maxSizeY];

        // 古いのを全部入れる
        foreach (BattleMapTile bmt in oldTiles)
        {
            maxTiles[bmt.X, bmt.Y] = bmt;
        }

        // 新しいのに入れる
        // 入れたのは削除しておく
        for (int x = 0; x < newTiles.GetLength(0); x++)
        {
            for (int y = 0; y < newTiles.GetLength(1); y++)
            {
                newTiles[x, y] = maxTiles[x, y];
                maxTiles[x, y] = null;
            }
        }

        // 残った古いのは破棄
        foreach (BattleMapTile bmt in maxTiles)
        {
            if (bmt != null)
            {
                Destroy(bmt.GameObject);

                // mapObjectも破棄
                BattleMapObjectSet bmoSet = holder.BattleMap.BattleMapObjectSets[bmt.X, bmt.Y];
                if (bmoSet != null)
                {
                    foreach (BattleMapObject bmo in bmoSet.BattleMapObjectList)
                    {
                        foreach (GameObject bmoGo in bmo.GameObjectList)
                        {
                            Destroy(bmoGo);
                        }
                    }
                }
            }
        }

        // 新しいのの空白に新規を埋める
        for (int x = 0; x < newTiles.GetLength(0); x++)
        {
            for (int y = 0; y < newTiles.GetLength(1); y++)
            {
                if (newTiles[x, y] == null)
                {
                    BattleMapTile bmt = new BattleMapTile(x, y, 0);

                    GameObject go = prefabHolder.Instantiate(bmt);
                    bmt.GameObject = go;

                    newTiles[x, y] = bmt;
                }
            }
        }

        holder.BattleMap.BattleMapTiles      = newTiles;
        holder.BattleMap.BattleMapObjectSets = new BattleMapObjectSet[newSizeX, newSizeY];
    }