/// <summary> /// 添加纵向提示文字动画到队列 /// </summary> /// <param name="text">Text.</param> public void AddTintTextToQueue(string text) { // 角色的世界位置转化为在画布中的位置 Vector3 basePosition = MyTool.ToPointInCanvas(transform.position); // 根据分辨率不同调整屏幕位置 basePosition = new Vector3(basePosition.x * CommonData.scalerToPresetHW, basePosition.y, 0); // 生成探索文本 ExploreText ft = new ExploreText(text, MyTowards.Left, basePosition); // 将探索文本加入提示文本队列 agentUICtr.exploreTextManager.AddHintText(ft); }
/// <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); //} }
/// <summary> /// 获取上下左右中的一个随机点 /// </summary> /// <returns>The random position around.</returns> /// <param name="position">Position.</param> protected Vector3 GetRandomPositionAround(Vector3 position) { int posX = Mathf.RoundToInt(position.x); int posY = Mathf.RoundToInt(position.y); Vector3 oriIntergerPos = new Vector3(posX, posY, 0); if (!MyTool.ApproximatelySamePosition2D(position, oriIntergerPos)) { return(oriIntergerPos); } int directionSeed = Random.Range(0, 4); Vector3 randomPosition = position; switch (directionSeed) { case 0: if (posY + 1 < ExploreManager.Instance.newMapGenerator.rows) { randomPosition = new Vector3(posX, posY + 1, position.z); } break; case 1: if (posY - 1 > 0) { randomPosition = new Vector3(posX, posY - 1, position.z); } break; case 2: if (posX - 1 > 0) { randomPosition = new Vector3(posX - 1, posY, position.z); } break; case 3: if (posX + 1 < ExploreManager.Instance.newMapGenerator.columns) { randomPosition = new Vector3(posX + 1, posY, position.z); } break; } return(randomPosition); }
public void OnTriggerEnter2D(Collider2D other) { BattlePlayerController battlePlayer = other.GetComponent <BattlePlayerController> (); if (battlePlayer == null) { return; } if (!MyTool.ApproximatelySamePosition2D(battlePlayer.moveDestination, this.transform.position)) { return; } MoveToNearestPosition(other.transform); }
/// <summary> /// 加载所有本关卡怪物 /// </summary> private void LoadMonsters() { for (int i = 0; i < monsterInfos.Length; i++) { MonsterInfo info = monsterInfos [i]; string monsterName = MyTool.GetMonsterName(info.monsterId); Transform monster = GameManager.Instance.gameDataCenter.LoadMonster(monsterName).transform; for (int j = 0; j < info.monsterCount; j++) { monsters.Add(monster); } } }
/// <summary> /// 判断制定地图上的指定位置上的事件是否已经触发过 /// </summary> /// <returns><c>true</c>, if map event triggered was ised, <c>false</c> otherwise.</returns> /// <param name="mapIndex">Map index.</param> /// <param name="eventPos">Event position.</param> public bool IsMapEventTriggered(int mapIndex, Vector2 eventPos) { bool eventTriggered = false; for (int i = 0; i < GameManager.Instance.gameDataCenter.currentMapEventsRecord.triggeredEventPositions.Count; i++) { Vector2 triggeredPos = GameManager.Instance.gameDataCenter.currentMapEventsRecord.triggeredEventPositions[i]; if (MyTool.ApproximatelySameIntPosition2D(eventPos, triggeredPos)) { eventTriggered = true; break; } } return(eventTriggered); }
private void OnTriggerEnter2D(Collider2D collision) { if (isInSavingData) { return; } if (collision == null) { return; } BattlePlayerController bp = collision.GetComponent <BattlePlayerController>(); if (bp == null) { return; } if (bp.isInPosFixAfterFight) { return; } if (!MyTool.ApproximatelySameIntPosition2D(bp.singleMoveEndPos, this.transform.position)) { return; } if (Mathf.Abs(bp.transform.position.x - transform.position.x) < 0.1f && Mathf.Abs(bp.transform.position.y - transform.position.y) < 0.1f) { return; } if (autoDetectCallBack != null) { autoDetectCallBack(); } isInSavingData = false; }
/// <summary> /// 判断制定地图上的指定位置上的事件是否已经触发过 /// </summary> /// <returns><c>true</c>, if map event triggered was ised, <c>false</c> otherwise.</returns> /// <param name="mapIndex">Map index.</param> /// <param name="eventPos">Event position.</param> public static bool IsMapEventTriggered(int mapIndex, Vector2 eventPos) { bool eventTriggered = false; MapEventsRecord mapEventsRecord = GameManager.Instance.gameDataCenter.mapEventsRecords.Find(delegate(MapEventsRecord obj) { return(obj.mapIndex == mapIndex); }); for (int i = 0; i < mapEventsRecord.triggeredEventPositions.Count; i++) { Vector2 triggeredPos = mapEventsRecord.triggeredEventPositions[i]; if (MyTool.ApproximatelySameIntPosition2D(eventPos, triggeredPos)) { eventTriggered = true; break; } } return(eventTriggered); }
public void SetUpChapterSelectPlane() { int maxUnlockChapterIndex = Player.mainPlayer.maxUnlockLevelIndex / 5; for (int i = 0; i < chapterButtons.Length; i++) { Button chapterButton = chapterButtons [i]; Text chapterNameText = chapterButton.GetComponentInChildren <Text> (); if (i <= maxUnlockChapterIndex) { chapterButton.interactable = true; string chapterName = GameManager.Instance.gameDataCenter.gameLevelDatas [5 * i].chapterName; string chapterIndexInChinese = MyTool.NumberToChinese(i + 1); string fullName = string.Format("第{0}章 {1}", chapterIndexInChinese, chapterName); chapterNameText.text = fullName; } else { chapterButton.interactable = false; chapterNameText.text = "? ? ? ?"; } } chaptersContainer.localScale = new Vector3(0.1f, 0.1f, 1); chapterSelectPlane.gameObject.SetActive(true); IEnumerator chapterSelectZoomInCoroutine = ChapterSelectHUDZoomIn(); StartCoroutine(chapterSelectZoomInCoroutine); }
/// <summary> /// 用户作出选择的回调 /// </summary> /// <param name="index">Index.</param> public void OnChoiceMake(int index) { HLHWord questionWord = sourceWords[currentWordIndex]; GameManager.Instance.pronounceManager.PronounceWord(questionWord); currentWordIndex++; interactiveMask.enabled = true; learnProgressBar.InitHLHFillBar(sourceWords.Count, currentWordIndex); bool choiceCorrect = index == correctChoiceIndex; int randomSeed = Random.Range(0, 2); switch (randomSeed) { case 0: int healthGain = Mathf.RoundToInt(0.02f * Player.mainPlayer.maxHealth); healthGainTotal += healthGain; generalRewardIcon.sprite = healthSprite; generalRewardCountText.text = string.Format("+{0}", healthGain); generalRewardSingleIcon.sprite = healthSprite; generalRewardSingleCountText.text = string.Format("+{0}", healthGain); break; case 1: int manaGain = Mathf.RoundToInt(0.02f * Player.mainPlayer.maxMana); manaGainTotal += manaGain; generalRewardIcon.sprite = manaSprite; generalRewardCountText.text = string.Format("+{0}", manaGain); generalRewardSingleIcon.sprite = manaSprite; generalRewardSingleCountText.text = string.Format("+{0}", manaGain); break; } if (choiceCorrect) { GameManager.Instance.soundManager.PlayAudioClip(CommonData.correctTintAudioName); choiceTexts[index].color = Color.green; continousCorrectCount++; correctWordsCount++; if (continousCorrectCount > maxContinousHitCount) { maxContinousHitCount = continousCorrectCount; } continousHitText.text = string.Format("连击 x {0}", continousCorrectCount); if (CheckIsExtraRewardNum(continousCorrectCount)) { continousHitText.color = Color.green; continousHitText.GetComponent <Outline>().effectColor = Color.green; } else { continousHitText.color = Color.yellow; continousHitText.GetComponent <Outline>().effectColor = Color.yellow; } //continousCorrectHintZoomCoroutine = CorrectHintTextZoomIn(); //StartCoroutine(continousCorrectHintZoomCoroutine); if (rewardHintShowCoroutine != null) { StopCoroutine(rewardHintShowCoroutine); } rewardHintShowCoroutine = RewardHintShow(); StartCoroutine(rewardHintShowCoroutine); } else { //Player.mainPlayer.learnedWordsCountInCurrentExplore++; GameManager.Instance.soundManager.PlayAudioClip(CommonData.wrongTintAudioName); wrongWordsCount++; choiceTexts[correctChoiceIndex].color = Color.green; choiceTexts[index].color = Color.red; continousCorrectCount = 0; extraRewardCalSeed = 0; bool wordExistInRecord = ExploreManager.Instance.CheckWordExistInCorrectRecordList(questionWord) || ExploreManager.Instance.CheckWordExistInWrongRecordList(questionWord); if (questionWord.ungraspTimes == 0 && questionWord.learnedTimes == 0 && !wordExistInRecord) { Player.mainPlayer.totalLearnedWordCount++; Player.mainPlayer.totalUngraspWordCount++; } questionWord.isFamiliar = false; questionWord.learnedTimes++; questionWord.ungraspTimes = questionWord.learnedTimes; ExploreManager.Instance.RecordWord(questionWord, false); } // 检查是否触发额外奖励 bool extraRewardTriggered = CheckIsExtraRewardNum(continousCorrectCount); // 如果触发额外奖励,将额外奖励触发的计算基数+1 if (choiceCorrect && extraRewardTriggered) { extraRewardCalSeed++; // 这里执行额外奖励 PropertySet propertySet = GetRandomProperty(continousCorrectCount); string propertyName = MyTool.GetPropertyName(propertySet.type); string propertyValue = MyTool.GetPropertyValueString(propertySet.value); extraRewardIcon.enabled = true; switch (propertySet.type) { case PropertyType.Attack: extraRewardIcon.sprite = attackSprite; extraRewardCountText.text = string.Format("+{0}", propertySet.value); break; case PropertyType.MagicAttack: extraRewardIcon.sprite = magicAttackSprite; extraRewardCountText.text = string.Format("+{0}", propertySet.value); break; case PropertyType.Armor: extraRewardIcon.sprite = armorSprite; extraRewardCountText.text = string.Format("+{0}", propertySet.value); break; case PropertyType.MagicResist: extraRewardIcon.sprite = magicResistSprite; extraRewardCountText.text = string.Format("+{0}", propertySet.value); break; case PropertyType.Dodge: extraRewardIcon.sprite = dodgeSprite; extraRewardCountText.text = string.Format("+{0}%", ((propertySet.value + float.Epsilon) * 100).ToString("0.0")); break; case PropertyType.Crit: extraRewardIcon.sprite = critSprite; extraRewardCountText.text = string.Format("+{0}%", ((propertySet.value + float.Epsilon) * 100).ToString("0.0")); break; } extraPropertySets.Add(propertySet); generalRewardIcon.enabled = true; generalRewardCountText.enabled = true; generalRewardSingleIcon.enabled = false; generalRewardSingleCountText.enabled = false; extraRewardIcon.enabled = true; extraRewardCountText.enabled = true; } else { generalRewardIcon.enabled = false; generalRewardCountText.enabled = false; generalRewardSingleIcon.enabled = true; generalRewardSingleCountText.enabled = true; extraRewardIcon.enabled = false; extraRewardCountText.enabled = false; } // 所有本关单词已经复习完 if (currentWordIndex >= sourceWords.Count) { if (waitAndShowNextCoroutine != null) { StopCoroutine(waitAndShowNextCoroutine); } waitAndShowNextCoroutine = WaitAndShowRightOrWrong(delegate { SetUpQuizResultView(); }); StartCoroutine(waitAndShowNextCoroutine); return; } if (waitAndShowNextCoroutine != null) { StopCoroutine(waitAndShowNextCoroutine); } continousCorrectRequireText.text = string.Format("连击奖励: 需连续答对{0}单词", nextExtraRewardPoint); waitAndShowNextCoroutine = WaitAndShowRightOrWrong(delegate { HLHWord[] quizWords = GetQuizWordArray(sourceWords, 3, currentWordIndex, out correctChoiceIndex); if (quizWords == null) { SetUpQuizResultView(); return; } SetUpQuiz(quizWords, correctChoiceIndex); }); StartCoroutine(waitAndShowNextCoroutine); }
/// <summary> /// 初始化地图npc /// </summary> /// <param name="mapIndex">Map index.</param> /// <param name="attachedInfo">Attached info.</param> public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo) { transform.position = attachedInfo.position; this.moveOrigin = attachedInfo.position; this.moveDestination = attachedInfo.position; baCtr.SetSortingOrder(-(int)transform.position.y); npc = null; for (int i = 0; i < GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray.Length; i++) { Vector2 pos = GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray[i]; if (MyTool.ApproximatelySameIntPosition2D(pos, attachedInfo.position)) { npc = GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcArray[i]; break; } } if (npc == null) { npc = GameManager.Instance.gameDataCenter.LoadNpc(npcId); for (int i = 0; i < GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray.Length; i++) { Vector2 pos = GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray[i]; if (pos == -Vector2.one) { GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcPosArray[i] = transform.position; GameManager.Instance.gameDataCenter.currentMapEventsRecord.npcArray[i] = npc; break; } } } bc2d.enabled = true; gameObject.SetActive(true); baCtr.PlayRoleAnim(CommonData.roleIdleAnimName, 0, null); bc2d.enabled = true; isTriggered = false; isInAutoWalk = false; needPosFix = false; Sprite miniMapNpcSprite = GameManager.Instance.gameDataCenter.allMiniMapSprites.Find(delegate(Sprite obj) { return(obj.name == string.Format("MiniMapNPC_{0}", npc.npcId)); }); miniMapInstance.GetComponent <SpriteRenderer>().sprite = miniMapNpcSprite; }
private Vector3 GetPairedPos() { return(MyTool.ApproximatelySamePosition2D(transform.position, movePosPair [0]) ? movePosPair [1] : movePosPair [0]); }