//<summary>MapWorld内に配置された直後に呼ばれる</summary>
 public override void placed()
 {
     MapHeightUpdateSystem.updateHeight(this);
     mMovingData.mPrePosition      = mMapPosition;
     mMovingData.mDeltaPrePosition = mMovingData.mPrePosition;
     MapTriggerUpdater.initTriggerDataOfMovingData(this);
 }
Example #2
0
    //<summary>フレーム毎の更新</summary>
    public static void updateWorld(MapWorld aWorld)
    {
        //キャラの内部状態を更新して移動先決定
        foreach (MapCharacter tChara in aWorld.mCharacters)
        {
            tChara.updateInternalState();
            //移動用データ初期化
            MapCharacterMoveSystem.initFrameMovingData(tChara);
        }
        //キャラの移動
        //まだ移動可能なキャラ
        List <MapCharacter> tWaiting    = new List <MapCharacter>();
        List <MapCharacter> tProcessing = new List <MapCharacter>(aWorld.mCharacters);
        bool tExistWaiting = false;

        for (; ;)
        {
            foreach (MapCharacter tCharacter in tProcessing)
            {
                //移動
                bool tRemainedDistance;
                if (tCharacter.mMovingData.mRemainingDistance > 0)
                {
                    tRemainedDistance = MapCharacterMoveSystem.moveCharacter(tCharacter);
                    //高さ更新
                    if (MapHeightUpdateSystem.updateHeight(tCharacter))
                    {
                        //高さ更新で座標が変更された
                        if (MapCharacterMoveSystem.isCollided(tCharacter))
                        {
                            //高さ更新の結果衝突した
                            MapCharacterMoveSystem.resetMoveDelta(tCharacter);//delta移動処理をリセット
                        }
                    }
                    //trigger
                    MapTriggerUpdater.trigger(tCharacter, aWorld.mEventSystem);
                    //encount
                    if (tCharacter.isPlayer() && tCharacter.getOperation() == MapCharacter.Operation.free)
                    {
                        encountCount(tCharacter, aWorld);
                    }
                }
                else
                {
                    tRemainedDistance = false;
                }

                //まだ移動できるか
                if (tRemainedDistance)
                {
                    tWaiting.Add(tCharacter);
                    tExistWaiting = true;
                }

                //これ以上移動しない
                //画像イベント
                applyImageEvent(tCharacter);
                //影
                MapShadowUpdater.updateShadow(tCharacter);
                //移動データリセット
                MapCharacterMoveSystem.resetFrameMovingData(tCharacter);
                //delegateに移動通知
                if (tCharacter.isPlayer() && tCharacter.getOperation() == MapCharacter.Operation.free)
                {
                    aWorld.mMap.mDelegate.report("move", new Arg(new Dictionary <string, object>()
                    {
                        { "distance", (tCharacter.mMovingData.mPrePosition.vector2 - tCharacter.mMapPosition.vector2).magnitude }
                    }));
                }
            }
            if (!tExistWaiting)
            {
                break;
            }
            tProcessing = tWaiting;
            tWaiting.Clear();
            tExistWaiting = false;
        }
        //エンカウント
        if (aWorld.mMap.mEncountSystem.mIsFire)
        {
            if (aWorld.mEventSystem.encount(aWorld.mMap.mEncountSystem.mEncountKey))
            {
                aWorld.mMap.mEncountSystem.resetCount();//エンカウントイベント実行成功
            }
            else
            {
                aWorld.mMap.mEncountSystem.lastCount();//エンカウントイベント実行失敗
            }
        }
        //話しかけるor調べる
        foreach (MapCharacter tCharacter in aWorld.mCharacters)
        {
            if (!tCharacter.mMovingData.mSpeak)
            {
                continue;
            }
            MapSpeakUpdater.speak(tCharacter, aWorld.mEventSystem);
            tCharacter.mMovingData.mSpeak = false;
        }
        //待機中のイベントを実行
        aWorld.mEventSystem.runWaitingEvents();
    }