void Awake() { mapGenerator = GetComponent <MapGenerator>(); Transform battlePlayer = Player.mainPlayer.transform.Find("BattlePlayer"); battlePlayer.gameObject.SetActive(true); battlePlayerCtr = Player.mainPlayer.GetComponentInChildren <BattlePlayerController> (); battlePlayerCtr.ActiveBattlePlayer(false, false, false); battlePlayerCtr.enterMonster = new ExploreEventHandler(EnterMonster); battlePlayerCtr.enterNpc = new ExploreEventHandler(EnterNPC); battlePlayerCtr.enterCrystal = new ExploreEventHandler(EnterCrystal); battlePlayerCtr.enterTreasureBox = new ExploreEventHandler(EnterTreasureBox); battlePlayerCtr.enterObstacle = new ExploreEventHandler(EnterObstacle); battlePlayerCtr.enterTrapSwitch = new ExploreEventHandler(EnterSwitch); battlePlayerCtr.enterBillboard = new ExploreEventHandler(EnterBillboard); battlePlayerCtr.enterHole = new ExploreEventHandler(EnterHole); battlePlayerCtr.enterMovableBox = new ExploreEventHandler(EnterMovableBox); battlePlayerCtr.enterTransport = new ExploreEventHandler(EnterTransport); battlePlayerCtr.enterDoor = new ExploreEventHandler(EnterDoor); battlePlayerCtr.enterPlant = new ExploreEventHandler(EnterPlant); Transform exploreCanvas = TransformManager.FindTransform("ExploreCanvas"); expUICtr = exploreCanvas.GetComponent <ExploreUICotroller> (); // GameLevelData levelData = GameManager.Instance.gameDataCenter.gameLevelDatas [Player.mainPlayer.currentLevelIndex]; // // SetUpExploreView (levelData); }
private List <HLHWord> wrongWordList = new List <HLHWord>(); //错误单词列表 void Awake() { // 绑定组件 Transform battlePlayer = Player.mainPlayer.transform.Find("BattlePlayer"); battlePlayer.gameObject.SetActive(true); battlePlayerCtr = Player.mainPlayer.GetComponentInChildren <BattlePlayerController> (); battlePlayerCtr.ActiveBattlePlayer(false, false, false); Transform exploreCanvas = TransformManager.FindTransform("ExploreCanvas"); expUICtr = exploreCanvas.GetComponent <ExploreUICotroller>(); }
public void EnterHole(MapGenerator mapGenerator, BattlePlayerController bp) { bp.ActiveBattlePlayer(false, false, false); List <Hole> allHolesInMap = mapGenerator.GetAllHolesInMap(); Hole randomOtherHole = GetRandomOtherHole(allHolesInMap); Debug.LogFormat("hole found,time:{0}", Time.realtimeSinceStartup); mapGenerator.GetComponent <ExploreManager> ().DisableInteractivity(); Vector3 otherHolePosition = new Vector3(randomOtherHole.transform.position.x, randomOtherHole.transform.position.y, 0); Vector3 moveVector = otherHolePosition - bp.transform.position; Transform background = Camera.main.transform.Find("Background"); Vector3 backgroundImageTargetPos = background.localPosition + new Vector3(moveVector.x * 0.3f, moveVector.y * 0.3f, 0); Vector3 walkablePositionAround = mapGenerator.GetARandomWalkablePositionAround(otherHolePosition); bp.SetEffectAnim("HoleFog"); // mapGenerator.PlayMapOtherAnim ("HoleFog", this.transform.position); if (randomOtherHole.transform.position.z != 0) { mapGenerator.DirectlyShowSleepingTilesAtPosition(otherHolePosition); } mapGenerator.ItemsAroundAutoIntoLifeWithBasePoint(otherHolePosition); bp.transform.DOMove(otherHolePosition, 1).OnComplete(delegate { IEnumerator WalkOutOfHoleCoroutine = WalkOutOfHole(mapGenerator, walkablePositionAround, bp, randomOtherHole); StartCoroutine(WalkOutOfHoleCoroutine); }); background.transform.DOMove(backgroundImageTargetPos, 1); }
/// <summary> /// 角色随地板一起移动到最近的可移动地板目的地 /// </summary> /// <returns>The move to position.</returns> /// <param name="startPos">Start position.</param> /// <param name="endPos">End position.</param> /// <param name="ba">Ba.</param> private IEnumerator SmoothMoveToPos(Vector3 startPos, Vector3 endPos, BattlePlayerController bp) { yield return(new WaitUntil(() => bp.isIdle)); Transform background = Camera.main.transform.Find("Background"); int[,] realMapWalkableInfo = exploreManager.GetComponent <MapGenerator> ().mapWalkableInfoArray; realMapWalkableInfo [(int)startPos.x, (int)startPos.y] = -1; bp.ActiveBattlePlayer(false, false, true); bp.PlayRoleAnim("wait", 0, null); float moveDuration = Mathf.Sqrt((endPos - startPos).sqrMagnitude) / moveSpeed; // x轴方向的移动速度 if (endPos.x > startPos.x) { bp.TowardsRight(); } else { bp.TowardsLeft(); } float myMoveSpeedX = (endPos.x - startPos.x) / moveDuration; // y轴方向的移动速度 float myMoveSpeedY = (endPos.y - startPos.y) / moveDuration; float timer = 0; bool endPosInit = false; while (timer < moveDuration) { Vector3 moveVector = new Vector3(myMoveSpeedX * Time.deltaTime, myMoveSpeedY * Time.deltaTime, 0); timer += Time.deltaTime; this.transform.position += moveVector; bp.transform.position += moveVector; background.transform.position -= 0.3f * moveVector; // 走到一半时终点位置开始初始化(地板和物品,怪物出现) if (timer / moveDuration > 0.5 && !endPosInit) { exploreManager.GetComponent <ExploreManager> ().ItemsAroundAutoIntoLifeWithBasePoint(endPos); endPosInit = true; } yield return(null); } transform.position = endPos; bp.transform.position = endPos; bp.SetSortingOrder(-(int)endPos.y); // 如果要自动走到一个可行走点,则开启下面的代码 // Vector3 walkablePositionAround = exploreManager.GetComponent<MapGenerator>().GetAWalkablePositionAround (endPos); // // yield return new WaitUntil (()=>realMapWalkableInfo [(int)walkablePositionAround.x, (int)walkablePositionAround.y] == 1); // realMapWalkableInfo [(int)endPos.x, (int)endPos.y] = 10; bp.MoveToStoredDestination(); }