コード例 #1
0
        public void MapLocationDataConstructorTest1()
        {
            MapLocationData target = new MapLocationData();

            Assert.AreEqual(0, target.Items.Count);
            Assert.AreEqual(TerrainType.OffMap, target.Terrain);
        }
コード例 #2
0
        public void AddItemTest()
        {
            MapLocationData target = new MapLocationData();
            Item            item   = new Player();

            target.AddItem(item);
            Assert.AreEqual(1, target.Items.Count);
            Assert.AreEqual(ItemType.Player, target.Items[0].ItemType);
        }
コード例 #3
0
 public void GenerateMapByName(string mapName)
 {
     mapList         = new List <GameObject>();
     mapLocationData = GameDataManager.Instance.GetLevelMap(mapName);
     GameDataManager.Instance.gameLevel.gameStageData = GameDataManager.Instance.GetGamelevelByName(mapName);
     GenerateTerrain();
     GenerateObject();
     GetSpawnPoint();
 }
コード例 #4
0
    public void GenerateMap()
    {
        mapList = new List <GameObject>();
        //Debug.Log()

        mapLocationData = GameDataManager.Instance.GetLevelMap(GameDataManager.Instance.GetStageName());
        Debug.Log("----------Level " + GameDataManager.Instance.gameLevel.theme);
        Debug.Log("----------stage " + GameDataManager.Instance.gameLevel.stage);
        GenerateTerrain();
        GenerateObject();
        GetSpawnPoint();
    }
コード例 #5
0
        public void FindItemTypeTest()
        {
            TerrainType terrain = TerrainType.HorizontalWall;
            List <Item> items   = new List <Item>()
            {
                new Player(), new Rat()
            };

            MapLocationData target = new MapLocationData(terrain, items);

            Assert.AreEqual(ItemType.Player, target.FindItemType(ItemType.Player).ItemType);
            Assert.AreEqual(ItemType.Rat, target.FindItemType(ItemType.Rat).ItemType);
        }
コード例 #6
0
ファイル: MapTest.cs プロジェクト: twobob/CSRogue
        public void MapConstructorTest()
        {
            CsRogueMap target = new CsRogueMap();

            for (int iCol = 0; iCol < target.Width; iCol++)
            {
                for (int iRow = 0; iRow < target.Height; iRow++)
                {
                    MapLocationData data = target[iCol, iRow];
                    Assert.AreEqual(0, data.Items.Count);
                    Assert.AreEqual(TerrainType.OffMap, data.Terrain);
                }
            }
        }
コード例 #7
0
        public void MapLocationDataConstructorTest()
        {
            TerrainType terrain = TerrainType.VerticalWall;
            List <Item> items   = new List <Item>()
            {
                new Player(), new Rat()
            };

            MapLocationData target = new MapLocationData(terrain, items);

            Assert.AreEqual(TerrainType.VerticalWall, target.Terrain);
            Assert.AreEqual(2, target.Items.Count);
            Assert.AreEqual(ItemType.Player, target.Items[0].ItemType);
            Assert.AreEqual(ItemType.Rat, target.Items[1].ItemType);
        }
コード例 #8
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Determine the character and color to draw from the cell contents. </summary>
        ///
        /// <remarks>	Darrellp, 10/7/2011. </remarks>
        ///
        /// <param name="column">	The column of the cell. </param>
        /// <param name="row">		The row of the cell. </param>
        ///
        /// <returns>	A Character of the correct color and glyph for this position on the map. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        private Character CharacterFromCell(int column, int row)
        {
            // Get the data at this location
            MapLocationData data = GameMap[column, row];

            // Are there items here?
            if (data.Items.Count > 0)
            {
                // Are any of them the player?
                if (data.Items.Any(i => ItemInfo.GetItemInfo(i).IsPlayer))
                {
                    // Return the smiley face
                    return(new Character(Glyph.Face, TermColor.White));
                }

                // Otherwise, use the first item in the list
                Item     itemCur = data.Items[0];
                ItemInfo info    = ItemInfo.GetItemInfo(itemCur);

                // Is it a creature?
                if (info.IsCreature)
                {
                    // Get it's color and character and return the glyph
                    return(new Character(info.Character, (TermColor)(info.CreatureInfo.Color)));
                }
            }

            // Do we know how to draw the terrain at this spot?
            if (CharacterInfo.ContainsKey(data.Terrain))
            {
                // Get the character info for this terrain
                Character character = CharacterInfo[data.Terrain];

                // Is this spot lit?
                if (data.LitState == LitState.InView)
                {
                    // Change the color to light blue
                    character = new Character(character.Glyph, TermColor.LightBlue);
                }

                // Return the character
                return(character);
            }

            // If nothing else fits, return a space
            return(_spaceChar);
        }
コード例 #9
0
    void PraseTranslation(string rawCsv)
    {
        Debug.Log("------------------------------CSV " + rawCsv);
        Debug.Assert(!string.IsNullOrEmpty(rawCsv), "Map data not Found");
        var lines  = Regex.Split(rawCsv, LINE_SPLIT_REX);
        var header = Regex.Split(lines[0], SPLIT_REX);

        for (int i = 0; i < lines.Length; i++)
        {
            Debug.Log(lines[i]);
        }
        var levelIndex         = System.Array.FindIndex(header, (item) => { return(item == headerKeys[0]); });
        var mapPositionIndex   = System.Array.FindIndex(header, (item) => { return(item == headerKeys[1]); });
        var objectTerrainIndex = System.Array.FindIndex(header, (item) => { return(item == headerKeys[2]); });
        var objectIndex        = System.Array.FindIndex(header, (item) => { return(item == headerKeys[3]); });
        var posXindex          = System.Array.FindIndex(header, (item) => { return(item == headerKeys[4]); });
        var posYindex          = System.Array.FindIndex(header, (item) => { return(item == headerKeys[5]); });
        var posZindex          = System.Array.FindIndex(header, (item) => { return(item == headerKeys[6]); });

        for (var i = 1; i < lines.Length; i++)
        {
            var values          = Regex.Split(lines[i], SPLIT_REX); //3 column
            var level           = values[levelIndex];               // level
            var mapStartPositon = values[mapPositionIndex];         //hint
            var objectTerrain   = values[objectTerrainIndex];
            var objectName      = values[objectIndex];              //hint
            var posX            = values[posXindex];                // place
            var posY            = values[posYindex];                // place
            var posZ            = values[posZindex];                // place
            Debug.Log("Level " + level);
            Debug.Log("mapStartPositon " + mapStartPositon);
            Debug.Log("objectTerrain " + objectTerrain);
            Debug.Log("objectName " + objectName);
            Debug.Log("posX " + posX);
            Debug.Log("posY " + posY);
            Debug.Log("posZ " + posZ);
            if (!string.IsNullOrEmpty(level))
            {
                targetMapLocationData         = new MapLocationData();
                targetMapLocationData.mapName = level;
                Debug.Log("Mapname " + targetMapLocationData.mapName);
                targetMapLocationData.startPositionDatas  = new List <Vector3>();
                targetMapLocationData.objectTerrainDatas  = new List <ObjectLocationData>();
                targetMapLocationData.objectLocationDatas = new List <ObjectLocationData>();
                mapLocationDatas.Add(targetMapLocationData);
                continue;
            }
            if (!string.IsNullOrEmpty(mapStartPositon))
            {
                if (string.IsNullOrEmpty(posX) || string.IsNullOrEmpty(posY) || string.IsNullOrEmpty(posZ))
                {
                    Debug.LogError("can not found position in startPosition");
                }
                else
                {
                    var position = new Vector3(float.Parse(posX), float.Parse(posY), float.Parse(posZ));
                    //Debug.Log("====>position "+position);
                    targetMapLocationData.startPositionDatas.Add(position);
                    //Debug.Log("startposition count "+targetMapLocationData.startPositionDatas.Count);
                }
            }
            if (!string.IsNullOrEmpty(objectName))
            {
                if (string.IsNullOrEmpty(posX) || string.IsNullOrEmpty(posY) || string.IsNullOrEmpty(posZ))
                {
                    Debug.LogError("can not found position in startPosition");
                }
                else
                {
                    //Debug.Log(string.Format("x {0} y {1} z {0}",posX,posY,posZ));
                    var position           = new Vector3(float.Parse(posX), float.Parse(posY), float.Parse(posZ));
                    var objectLocationData = new ObjectLocationData {
                        prefabName = objectName, position = position, rotation = Quaternion.identity
                    };
                    targetMapLocationData.objectLocationDatas.Add(objectLocationData);
                }
            }
            if (!string.IsNullOrEmpty(objectTerrain))
            {
                if (string.IsNullOrEmpty(posX) || string.IsNullOrEmpty(posY) || string.IsNullOrEmpty(posZ))
                {
                    Debug.LogError("can not found position in startPosition");
                }
                else
                {
                    Debug.Log("Objectterrain ............");
                    Debug.Log(string.Format("x {0} y {1} z {0}", posX, posY, posZ));
                    var position           = new Vector3(float.Parse(posX), float.Parse(posY), float.Parse(posZ));
                    var objectLocationData = new ObjectLocationData {
                        prefabName = objectTerrain, position = position, rotation = Quaternion.identity
                    };
                    targetMapLocationData.objectTerrainDatas.Add(objectLocationData);
                }
            }
        }
        downloadComplete(mapLocationDatas);
        Debug.Log("Total map " + mapLocationDatas.Count);
    }