Beispiel #1
0
    public override void Update(MainSystem sys)
    {
        if (_isFirst)
        {
            _isFirst = false;
            Actor.ChangeDir(_dir);
            sys.UpdateSpot(_nextLoc);

            Room prev = sys.FindRoom(_player.Loc);
            Room next = sys.FindRoom(_nextLoc);
            if (prev != null && next != null)   // 部屋内を移動した
            {
                sys.OnRoomMoving(next, _nextLoc);
            }
            else if (prev == null && next != null)   // 部屋に入った
            {
                sys.OnRoomEntering(next, _nextLoc);
            }
            else if (prev != null && next == null)   // 部屋から通路に出た
            {
                sys.OnRoomExiting(prev, _nextLoc);
            }
            else
            {
                sys.OnPassageMoving(_nextLoc); // 通路を移動した
            }
        }

        _elapsed += Time.deltaTime;
        float t = _elapsed / Config.WalkDuration;
        float x = Mathf.Lerp(_srcPos.x, _dstPos.x, t);
        float y = Mathf.Lerp(_srcPos.y, _dstPos.y, t);

        Actor.Position = new Vector3(x, y, 0);

        _player.SyncCameraPosition();
        sys.UpdatePassageSpotlightPosition(Actor.Position);

        if (_elapsed >= Config.WalkDuration)
        {
            _animationFinished = true;
            // 位置ずれ防止
            Actor.Position = _dstPos;
            _player.SyncCameraPosition();
        }
    }