コード例 #1
0
ファイル: Taozu.cs プロジェクト: stephenhou2/NewWordJourney
        private void EscapeCallBack(BattleAgentController self, BattleAgentController enemy)
        {
            int fadeStep = fixFadeStep + fadeStepGainBase * skillLevel;

            BattlePlayerController battlePlayer = self as BattlePlayerController;

            if (battlePlayer.agent.health <= 0)
            {
                return;
            }

            int oriFadeStepsLeft = battlePlayer.fadeStepsLeft;

            if (oriFadeStepsLeft == 0)
            {
                self.SetEffectAnim(selfEffectAnimName, null, 0, 0);
            }

            battlePlayer.fadeStepsLeft = Mathf.Max(oriFadeStepsLeft, fadeStep);
            enemy.QuitFight();

            ExploreManager.Instance.EnableExploreInteractivity();

            ExploreManager.Instance.currentEnteredMapEvent = null;

            BattlePlayerController bpCtr = self as BattlePlayerController;

            bpCtr.PlayRoleAnim(CommonData.roleIdleAnimName, 0, null);

            bpCtr.escapeFromFight = true;

            bpCtr.isInEscaping = false;

            bpCtr.enemy = null;

            bpCtr.FixPositionToStandard();

            MapWalkableEvent mwe = enemy.GetComponent <MapWalkableEvent> ();

            ExploreManager.Instance.MapWalkableEventsStartAction();

            mwe.RefreshWalkableInfoWhenQuit(enemy.isDead);

            if (!mwe.isInMoving)
            {
                mwe.QuitFightAndDelayMove(5);
            }

            ExploreManager.Instance.expUICtr.QuitFight();
        }
コード例 #2
0
        /// <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();
        }