/// <summary>
        /// 初始化
        /// </summary>
        /// <param name="mapIndex">Map index.</param>
        /// <param name="attachedInfo">Attached info.</param>
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            bc2d.enabled = true;

            tmPro.enabled = true;

            string dropItemIds = KVPair.GetPropertyStringWithKey("dropID", attachedInfo.properties);

            string[] dropItemIdArray = dropItemIds.Split(new char[] { '_' });
            int      randomIndex     = Random.Range(0, dropItemIdArray.Length);
            int      itemId          = int.Parse(dropItemIdArray[randomIndex]);

            item = Item.NewItemWith(itemId, 1);

            Sprite s = GameManager.Instance.gameDataCenter.GetGameItemSprite(item);

            itemTrans.GetComponent <SpriteRenderer>().sprite = s;

            oriIconPosY = itemTrans.localPosition.y;

            oriPosX = transform.position.x;
            oriPosY = transform.position.y;

            BeginFloating();

            CheckIsWordTriggeredAndShow();
        }
示例#2
0
        public static void MapDoorPairPositionCheck()
        {
            for (int i = 0; i < 50; i++)
            {
                Debug.Log("地图" + i.ToString());

                HLHMapData mapData = HLHMapData.LoadMapDataOfLevel(i);

                int mapHeight = mapData.rowCount;

                MapAttachedInfoLayer layer = mapData.attachedInfoLayers.Find(delegate(MapAttachedInfoLayer obj)
                {
                    return(obj.layerName == "GearEventLayer");
                });

                Dictionary <string, string> doorInfoDic = new Dictionary <string, string>();

                for (int j = 0; j < layer.tileDatas.Count; j++)
                {
                    MapAttachedInfoTile tile = layer.tileDatas[j];

                    if (!tile.type.Equals("doorGear") && !tile.type.Equals("keyDoorGear"))
                    {
                        continue;
                    }

                    string pairDoorPosString = KVPair.GetPropertyStringWithKey("pairDoorPos", tile.properties);

                    string[] posXY = pairDoorPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

                    int pairDoorPosY = mapHeight - int.Parse(posXY[1]) - 1;

                    pairDoorPosString = string.Format("{0}_{1}", posXY[0], pairDoorPosY);

                    string doorPosString = string.Format("{0}_{1}", Mathf.RoundToInt(tile.position.x), Mathf.RoundToInt(tile.position.y));

                    doorInfoDic.Add(doorPosString, pairDoorPosString);
                }

                IDictionaryEnumerator dictionaryEnumerator = doorInfoDic.GetEnumerator();

                while (dictionaryEnumerator.MoveNext())
                {
                    string doorPos     = dictionaryEnumerator.Key as string;
                    string pairDoorPos = dictionaryEnumerator.Value as string;

                    string pos      = string.Empty;
                    bool   posRight = doorInfoDic.TryGetValue(pairDoorPos, out pos);
                    if (!posRight)
                    {
                        Debug.LogFormat("地图序:{0},门数据有问题的位置:{1},匹配位置:{2}", i, doorPos, pairDoorPos);
                    }
                }
            }
        }
示例#3
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            isWordTrigger = false;
            isOpen        = false;

            direction = int.Parse(KVPair.GetPropertyStringWithKey("direction", attachedInfo.properties));

            unlockDifficulty = int.Parse(KVPair.GetPropertyStringWithKey("type", attachedInfo.properties));

            string pairDoorPosString = KVPair.GetPropertyStringWithKey("pairDoorPos", attachedInfo.properties);

            string[] posXY = pairDoorPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

            int posX = int.Parse(posXY[0]);
            int posY = mapHeight - int.Parse(posXY[1]) - 1;

            pairDoorPos = new Vector3(posX, posY, transform.position.z);


            if (MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position))
            {
                mapItemRenderer.sprite = null;
                isOpen = true;
                //ExploreManager.Instance.newMapGenerator.ChangeMapEventStatusAtPosition(pairDoorPos);
            }

            if (!isOpen)
            {
                mapItemRenderer.enabled = true;
                mapItemRenderer.sprite  = doorCloseSprites[direction];
            }
            else
            {
                mapItemRenderer.sprite  = null;
                mapItemRenderer.enabled = false;
            }


            bc2d.enabled = true;
            SetSortingOrder(-(int)transform.position.y);

            int wordLength = unlockDifficulty + 3;

            keyDoorWord = GetWordOfLength(wordLength);
        }
示例#4
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            hasTriggered = MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position);

            if (hasTriggered)
            {
                mapItemRenderer.sprite = pressSwitchOff;

                SetSortingOrder(-Mathf.RoundToInt(attachedInfo.position.y) - 1);

                hasTriggered = true;

                bc2d.enabled = true;

                tmPro.enabled = false;

                ExploreManager.Instance.newMapGenerator.mapWalkableInfoArray[Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y)] = 0;

                return;
            }
            else
            {
                mapItemRenderer.sprite = pressSwitchOn;
            }

            hasTriggered = false;

            string pairDoorPosString = KVPair.GetPropertyStringWithKey("pairEventPos", attachedInfo.properties);

            string[] posXY = pairDoorPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

            int posX = int.Parse(posXY [0]);
            int posY = mapHeight - int.Parse(posXY [1]) - 1;

            pairEventPos = new Vector2(posX, posY);


            bc2d.enabled = true;
            SetSortingOrder(-Mathf.RoundToInt(attachedInfo.position.y));

            CheckIsWordTriggeredAndShow();
        }
示例#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);
        }
示例#6
0
        /// <summary>
        /// 使用地图附加信息初始化怪物
        /// </summary>
        /// <param name="mapIndex">Map index.</param>
        /// <param name="attachedInfo">Attached info.</param>
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            // 地图序号
            this.mapIndex = mapIndex;

            this.oriPos = attachedInfo.position;

            this.moveOrigin = attachedInfo.position;

            this.moveDestination = attachedInfo.position;

            if (monsterSayContainer != null)
            {
                monsterSayContainer.enabled = false;
            }

            if (tmPro != null)
            {
                tmPro.text = string.Empty;
            }


            // 标记怪物是否可以移动
            canMove = bool.Parse(KVPair.GetPropertyStringWithKey("canMove", attachedInfo.properties));
            // 击败怪物对应控制的地图事件的位置信息
            string pairEventPosString = KVPair.GetPropertyStringWithKey("pairEventPos", attachedInfo.properties);

            // 击败怪物后控制地图事件的位置信息
            if (pairEventPosString != string.Empty && pairEventPosString != "-1")
            {
                string[] posXY = pairEventPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

                int posX = int.Parse(posXY [0]);
                int posY = mapHeight - int.Parse(posXY [1]) - 1;

                pairEventPos = new Vector3(posX, posY, transform.position.z);
            }
            else
            {
                pairEventPos = -Vector3.one;
            }

            this.gameObject.SetActive(true);

            for (int i = 0; i < alertAreas.Length; i++)
            {
                alertAreas [i].InitializeAlertArea();
            }

            // 隐藏所有的探测区域
            HideAllAlertAreas();

            // 随机朝向
            RandomTowards();

            // 如果可以运动,则显示探测区域
            if (canMove)
            {
                ShowAlertAreaTint();
            }

            transform.position = attachedInfo.position;

            gameObject.SetActive(true);

            GetComponent <Monster> ().ResetBattleAgentProperties(true);

            // 激活怪物
            baCtr.SetAlive();

            // 重置属性
            bc2d.enabled   = true;
            isReadyToFight = false;

            isTriggered = false;

            baCtr.isIdle = false;
            isInMoving   = false;
            isInAutoWalk = false;

            alertTint.gameObject.SetActive(false);
        }
示例#7
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            //this.hasPuzzle = true;
            this.hasPuzzle = false;


            isWordTrigger = bool.Parse(KVPair.GetPropertyStringWithKey("isWordTrigger", attachedInfo.properties));
            isOpen        = bool.Parse(KVPair.GetPropertyStringWithKey("isOpen", attachedInfo.properties));

            isSwitchControledDoor = !isWordTrigger && !isOpen;

            direction = int.Parse(KVPair.GetPropertyStringWithKey("direction", attachedInfo.properties));

            if (MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position))
            {
                OpenTheDoor(false);
            }
            else if (GameManager.Instance.gameDataCenter.currentMapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position))
            {
                OpenTheDoor(false);
            }

            if (!isOpen)
            {
                mapItemRenderer.enabled = true;
                mapItemRenderer.sprite  = doorCloseSprites [direction];
            }
            else
            {
                mapItemRenderer.sprite  = null;
                mapItemRenderer.enabled = false;
            }

            string pairDoorPosString = KVPair.GetPropertyStringWithKey("pairDoorPos", attachedInfo.properties);

            string[] posXY = pairDoorPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

            int posX = int.Parse(posXY [0]);
            int posY = mapHeight - int.Parse(posXY [1]) - 1;

            pairDoorPos = new Vector3(posX, posY, transform.position.z);

            bc2d.enabled = true;
            SetSortingOrder(-(int)transform.position.y);

            if (isWordTrigger)
            {
                bool hasValidWord = false;
                for (int i = 0; i < wordsArray.Length; i++)
                {
                    if (wordsArray[i].spell.Length <= 7)
                    {
                        hasValidWord = true;
                        word         = wordsArray[i];
                        break;
                    }
                }

                if (!hasValidWord)
                {
                    word = GetAValidWord();
                }

                GameManager.Instance.pronounceManager.DownloadPronounceCache(word);
            }
        }
示例#8
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            isGoldTreasureBox = false;


            if (KVPair.ContainsKey("type", attachedInfo.properties))
            {
                string type = KVPair.GetPropertyStringWithKey("type", attachedInfo.properties);
                isGoldTreasureBox = type == "1";
            }

            int rewardItemId = 0;

            if (!isGoldTreasureBox)
            {
                mapItemRenderer.sprite = normalTbSprite;
                treasureType           = TreasureType.NormalTreasureBox;
            }
            else
            {
                mapItemRenderer.sprite = specialTbSprite;
                treasureType           = TreasureType.GoldTreasureBox;
            }


            if (KVPair.ContainsKey("dropID", attachedInfo.properties))
            {
                rewardItemId = int.Parse(KVPair.GetPropertyStringWithKey("dropID", attachedInfo.properties));
            }
            else
            {
                rewardItemId = GetRandomItemIdFromGameLevelData();
            }

            if (isGoldTreasureBox && MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position))
            {
                AddToPool(ExploreManager.Instance.newMapGenerator.mapEventsPool);
            }


            rewardItem = Item.NewItemWith(rewardItemId, 1);


            if (rewardItem.itemType == ItemType.Equipment)
            {
                Equipment eqp = rewardItem as Equipment;

                int randomSeed = Random.Range(0, 100);

                int graySeed = 0;
                int blueSeed = 0;

                // 物品品质概率
                switch (Player.mainPlayer.luckInOpenTreasure)
                {
                case 0:
                    graySeed = 65 - Player.mainPlayer.extraLuckInOpenTreasure;
                    blueSeed = 95 - Player.mainPlayer.extraLuckInOpenTreasure;
                    break;

                case 1:
                    graySeed = 60 - Player.mainPlayer.extraLuckInOpenTreasure;
                    blueSeed = 90 - Player.mainPlayer.extraLuckInOpenTreasure;
                    break;
                }

                EquipmentQuality quality = EquipmentQuality.Gray;

                // 如果不是金色宝箱,则随机一种品质
                if (!isGoldTreasureBox)
                {
                    if (randomSeed < graySeed)
                    {
                        quality = EquipmentQuality.Gray;
                    }
                    else if (randomSeed < blueSeed)
                    {
                        quality = EquipmentQuality.Blue;
                    }
                    else
                    {
                        quality = EquipmentQuality.Gold;
                    }
                }
                else
                {
                    quality = EquipmentQuality.Gold;
                }

                eqp.ResetPropertiesByQuality(quality);
            }

            CheckIsWordTriggeredAndShow();

            bc2d.enabled = true;
            //mapItemAnimator.gameObject.SetActive (false);
            mapItemRenderer.enabled = true;
            int sortingOrder = -(int)transform.position.y;

            SetSortingOrder(sortingOrder);
            //SetAnimationSortingOrder (sortingOrder);
        }