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); }
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(); }
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); } }
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); }