Exemplo n.º 1
0
        /// <summary>
        /// 从本层地图数据中随机读取出一个物品id
        /// </summary>
        /// <returns>The random item identifier from game level data.</returns>
        protected int GetRandomItemIdFromGameLevelData()
        {
            HLHGameLevelData levelData = GameManager.Instance.gameDataCenter.gameLevelDatas [Player.mainPlayer.currentLevelIndex];

            List <int> possibleItemIds = null;

            switch (treasureType)
            {
            case TreasureType.Pot:
                possibleItemIds = levelData.itemIdsInPot;
                break;

            case TreasureType.Bucket:
                possibleItemIds = levelData.itemIdsInBucket;
                break;

            case TreasureType.NormalTreasureBox:
                possibleItemIds = levelData.itemIdsInNormalTreasureBox;
                break;

            case TreasureType.GoldTreasureBox:
                break;
            }

            int randomSeed = Random.Range(0, possibleItemIds.Count);

            return(possibleItemIds [randomSeed]);
        }
Exemplo n.º 2
0
        public HLHGameLevelData InitGameLevelDatas(string dataString)
        {
            dataString = dataString.Replace("\r", "");

            string[] dataStrings = dataString.Split(new char[] { ',' }, System.StringSplitOptions.None);

            int gameLevelIndex = int.Parse(dataStrings [0]);

            Debug.LogFormat("{0}####瓦罐", dataStrings [1]);
            List <int> itemIdsInPot = InitIntAndCountArrayWithString(dataStrings [1]);

            Debug.LogFormat("{0}####木桶", dataStrings [2]);
            List <int> itemIdsInBucket = InitIntAndCountArrayWithString(dataStrings [2]);

            Debug.LogFormat("{0}####普通宝箱", dataStrings [3]);
            List <int> itemIdsInNormalTreasureBox = InitIntAndCountArrayWithString(dataStrings [3]);

            //Debug.LogFormat("{0}####金色宝箱", dataStrings[4]);
            //List<int> itemIdsInGoldTreasureBox = InitIntArrayWithString(dataStrings[4]);

            Debug.LogFormat("{0}####怪物", dataStrings [4]);
            List <int> monsterIds = InitIntAndCountArrayWithString(dataStrings [4]);

            int bossId = int.Parse(dataStrings [5]);

            Debug.LogFormat("{0}####钱袋", dataStrings [6]);
            Count goldAmountRange = InitCountWithString(dataStrings [6]);

            Debug.LogFormat("{0}####本层怪物id", dataStrings[7]);
            List <int> monsterIdsOfCurrentLevel = InitIntArrayWithString(dataStrings[7]);

            HLHGameLevelData levelData = new HLHGameLevelData(gameLevelIndex, itemIdsInPot, itemIdsInBucket, itemIdsInNormalTreasureBox, monsterIds, bossId, goldAmountRange, monsterIdsOfCurrentLevel);

            return(levelData);
        }
Exemplo n.º 3
0
        public void LoadGameDatas()
        {
            string gameDataSource = DataHandler.LoadDataString("/Users/houlianghong/Desktop/MyGameData/关卡原始数据.csv");

            string[] gameLevelDataStrings = gameDataSource.Split(new string[] { "\n" }, System.StringSplitOptions.RemoveEmptyEntries);

            for (int i = 1; i < gameLevelDataStrings.Length; i++)
            {
                Debug.LogFormat("第{0}层", i - 1);
                HLHGameLevelData gameLevelData = InitGameLevelDatas(gameLevelDataStrings [i]);
                gameLevelDatas.Add(gameLevelData);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取本层怪物UI龙骨
        /// </summary>
        private void GetMonstersDataAndUI()
        {
            HLHGameLevelData   levelData    = GameManager.Instance.gameDataCenter.gameLevelDatas[Player.mainPlayer.currentLevelIndex];
            List <MonsterData> monsterDatas = GameManager.Instance.gameDataCenter.monsterDatas;

            for (int i = 0; i < levelData.monsterIdsOfCurrentLevel.Count; i++)
            {
                int       monsterId     = levelData.monsterIdsOfCurrentLevel[i];
                string    monsterUIName = MyTool.GetMonsterUIName(monsterId);
                Transform monsterUI     = monsterUIPool.GetInstanceWithName <Transform>(monsterUIName);
                if (monsterUI == null)
                {
                    monsterUI = GameManager.Instance.gameDataCenter.LoadMonsterUI(monsterUIName).transform;
                }

                monsterUI.gameObject.SetActive(false);

                MonsterData monsterData = monsterDatas.Find(delegate(MonsterData obj)
                {
                    return(obj.monsterId == monsterId);
                });

                MonsterUIInfo monsterUIInfo = monsterUI.GetComponent <MonsterUIInfo>();

                MonsterDataWithUIDipslay monsterDataWithUIDipslay = new MonsterDataWithUIDipslay(monsterData, monsterUI, monsterUIInfo);

                monstersInfoWithDisplayUI.Add(monsterDataWithUIDipslay);
            }

            //if(HLHGameLevelData.IsBossLevel()){

            //	int monsterId = levelData.bossId;
            //	string monsterUIName = MyTool.GetMonsterUIName(monsterId);
            //	Transform monsterUI = monsterUIPool.GetInstanceWithName<Transform>(monsterUIName);
            //	if(monsterUI == null){
            //		monsterUI = GameManager.Instance.gameDataCenter.LoadMonsterUI(monsterUIName).transform;
            //	}

            //	MonsterData monsterData = monsterDatas.Find(delegate (MonsterData obj)
            //             {
            //                 return obj.monsterId == monsterId;

            //             });

            //	MonsterUIInfo monsterUIInfo = monsterUI.GetComponent<MonsterUIInfo>();
            //	MonsterDataWithUIDipslay monsterDataWithUIDipslay = new MonsterDataWithUIDipslay(monsterData, monsterUI,monsterUIInfo);

            //	monstersInfoWithDisplayUI.Add(monsterDataWithUIDipslay);
            //}
        }
Exemplo n.º 5
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            transform.position = attachedInfo.position;

            sealAnimBoss.gameObject.SetActive(false);
            sealAnimReturn.gameObject.SetActive(false);


            if (exitType == ExitType.ToNextLevel)
            {
                direction = int.Parse(KVPair.GetPropertyStringWithKey("direction", attachedInfo.properties));
                switch (direction)
                {
                case 0:
                    sealAnimBoss.localRotation = Quaternion.Euler(Vector3.zero);
                    break;

                case 1:
                    sealAnimBoss.localRotation = Quaternion.Euler(new Vector3(0, 0, 180));
                    break;

                case 2:
                    sealAnimBoss.localRotation = Quaternion.Euler(new Vector3(0, 0, -90));
                    break;

                case 3:
                    sealAnimBoss.localRotation = Quaternion.Euler(new Vector3(0, 0, 90));
                    break;
                }
            }


            isOpen = !HLHGameLevelData.IsBossLevel();

            bc2d.enabled = true;

            SetSortingOrder(-(int)transform.position.y);
        }