private PlayerData SavePlayerData(Player player) { PlayerData playerData = new PlayerData (); playerData.currentScene = Application.loadedLevel; playerData.currentSceneName = Application.loadedLevelName; playerData.previousScene = KickStarter.sceneChanger.previousScene; playerData.previousSceneName = KickStarter.sceneChanger.previousSceneName; playerData.playerUpLock = KickStarter.playerInput.isUpLocked; playerData.playerDownLock = KickStarter.playerInput.isDownLocked; playerData.playerLeftlock = KickStarter.playerInput.isLeftLocked; playerData.playerRightLock = KickStarter.playerInput.isRightLocked; playerData.playerRunLock = (int) KickStarter.playerInput.runLock; playerData.playerFreeAimLock = KickStarter.playerInput.freeAimLock; KickStarter.runtimeInventory.RemoveRecipes (); playerData.inventoryData = CreateInventoryData (KickStarter.runtimeInventory.localItems); if (player == null) { playerData.playerPortraitGraphic = ""; playerData.playerID = KickStarter.settingsManager.GetEmptyPlayerID (); return playerData; } playerData.playerID = player.ID; playerData.playerLocX = player.transform.position.x; playerData.playerLocY = player.transform.position.y; playerData.playerLocZ = player.transform.position.z; playerData.playerRotY = player.transform.eulerAngles.y; playerData.playerWalkSpeed = player.walkSpeedScale; playerData.playerRunSpeed = player.runSpeedScale; // Animation clips if (player.animationEngine == AnimationEngine.Sprites2DToolkit || player.animationEngine == AnimationEngine.SpritesUnity) { playerData.playerIdleAnim = player.idleAnimSprite; playerData.playerWalkAnim = player.walkAnimSprite; playerData.playerRunAnim = player.runAnimSprite; playerData.playerTalkAnim = player.talkAnimSprite; } else if (player.animationEngine == AnimationEngine.Legacy) { playerData.playerIdleAnim = AssetLoader. GetAssetInstanceID (player.idleAnim); playerData.playerWalkAnim = AssetLoader. GetAssetInstanceID (player.walkAnim); playerData.playerRunAnim = AssetLoader. GetAssetInstanceID (player.runAnim); playerData.playerTalkAnim = AssetLoader. GetAssetInstanceID (player.talkAnim); } else if (player.animationEngine == AnimationEngine.Mecanim) { playerData.playerWalkAnim = player.moveSpeedParameter; playerData.playerTalkAnim = player.talkParameter; playerData.playerRunAnim = player.turnParameter; } // Sound playerData.playerWalkSound = AssetLoader. GetAssetInstanceID (player.walkSound); playerData.playerRunSound = AssetLoader. GetAssetInstanceID (player.runSound); // Portrait graphic playerData.playerPortraitGraphic = AssetLoader. GetAssetInstanceID (player.portraitIcon.texture); playerData.playerSpeechLabel = player.speechLabel; // Rendering playerData.playerLockDirection = player.lockDirection; playerData.playerLockScale = player.lockScale; if (player.spriteChild && player.spriteChild.GetComponent <FollowSortingMap>()) { playerData.playerLockSorting = player.spriteChild.GetComponent <FollowSortingMap>().lockSorting; } else if (player.GetComponent <FollowSortingMap>()) { playerData.playerLockSorting = player.GetComponent <FollowSortingMap>().lockSorting; } else { playerData.playerLockSorting = false; } playerData.playerSpriteDirection = player.spriteDirection; playerData.playerSpriteScale = player.spriteScale; if (player.spriteChild && player.spriteChild.GetComponent <Renderer>()) { playerData.playerSortingOrder = player.spriteChild.GetComponent <Renderer>().sortingOrder; playerData.playerSortingLayer = player.spriteChild.GetComponent <Renderer>().sortingLayerName; } else if (player.GetComponent <Renderer>()) { playerData.playerSortingOrder = player.GetComponent <Renderer>().sortingOrder; playerData.playerSortingLayer = player.GetComponent <Renderer>().sortingLayerName; } playerData.playerActivePath = 0; playerData.lastPlayerActivePath = 0; if (player.GetPath (true)) { playerData.playerTargetNode = player.GetTargetNode (true); playerData.playerPrevNode = player.GetPrevNode (true); playerData.playerIsRunning = player.isRunning; playerData.playerPathAffectY = player.activePath.affectY; if (player.GetComponent <Paths>() && player.GetPath (true) == player.GetComponent <Paths>()) { playerData.playerPathData = Serializer.CreatePathData (player.GetComponent <Paths>()); playerData.playerLockedPath = false; } else { playerData.playerPathData = ""; playerData.playerActivePath = Serializer.GetConstantID (player.GetPath (true).gameObject); playerData.playerLockedPath = player.lockedPath; } } if (player.GetPath (false)) { playerData.lastPlayerTargetNode = player.GetTargetNode (false); playerData.lastPlayerPrevNode = player.GetPrevNode (false); playerData.lastPlayerActivePath = Serializer.GetConstantID (player.GetPath (false).gameObject); } playerData.playerIgnoreGravity = player.ignoreGravity; // Head target playerData.playerLockHotspotHeadTurning = player.lockHotspotHeadTurning; if (player.headFacing == HeadFacing.Manual) { playerData.isHeadTurning = true; playerData.headTargetX = player.headTurnTarget.x; playerData.headTargetY = player.headTurnTarget.y; playerData.headTargetZ = player.headTurnTarget.z; } else { playerData.isHeadTurning = false; playerData.headTargetX = 0f; playerData.headTargetY = 0f; playerData.headTargetZ = 0f; } // Camera MainCamera mainCamera = KickStarter.mainCamera; if (mainCamera.attachedCamera) { playerData.gameCamera = Serializer.GetConstantID (mainCamera.attachedCamera.gameObject); } if (mainCamera.lastNavCamera) { playerData.lastNavCamera = Serializer.GetConstantID (mainCamera.lastNavCamera.gameObject); } if (mainCamera.lastNavCamera2) { playerData.lastNavCamera2 = Serializer.GetConstantID (mainCamera.lastNavCamera2.gameObject); } mainCamera.StopShaking (); playerData.mainCameraLocX = mainCamera.transform.position.x; playerData.mainCameraLocY = mainCamera.transform.position.y; playerData.mainCameraLocZ = mainCamera.transform.position.z; playerData.mainCameraRotX = mainCamera.transform.eulerAngles.x; playerData.mainCameraRotY = mainCamera.transform.eulerAngles.y; playerData.mainCameraRotZ = mainCamera.transform.eulerAngles.z; playerData.isSplitScreen = mainCamera.isSplitScreen; if (mainCamera.isSplitScreen) { playerData.isTopLeftSplit = mainCamera.isTopLeftSplit; playerData.splitAmountMain = mainCamera.splitAmountMain; playerData.splitAmountOther = mainCamera.splitAmountOther; if (mainCamera.splitOrientation == MenuOrientation.Vertical) { playerData.splitIsVertical = true; } else { playerData.splitIsVertical = false; } if (mainCamera.splitCamera && mainCamera.splitCamera.GetComponent <ConstantID>()) { playerData.splitCameraID = mainCamera.splitCamera.GetComponent <ConstantID>().constantID; } else { playerData.splitCameraID = 0; } } return playerData; }
override public float Run() { Player player = KickStarter.player; if (KickStarter.playerInput) { if (IsSingleLockMovement()) { doLeftLock = doUpLock; doRightLock = doUpLock; doDownLock = doUpLock; } if (doUpLock == LockType.Disabled) { KickStarter.playerInput.SetUpLock(true); } else if (doUpLock == LockType.Enabled) { KickStarter.playerInput.SetUpLock(false); } if (doDownLock == LockType.Disabled) { KickStarter.playerInput.SetDownLock(true); } else if (doDownLock == LockType.Enabled) { KickStarter.playerInput.SetDownLock(false); } if (doLeftLock == LockType.Disabled) { KickStarter.playerInput.SetLeftLock(true); } else if (doLeftLock == LockType.Enabled) { KickStarter.playerInput.SetLeftLock(false); } if (doRightLock == LockType.Disabled) { KickStarter.playerInput.SetRightLock(true); } else if (doRightLock == LockType.Enabled) { KickStarter.playerInput.SetRightLock(false); } if (KickStarter.settingsManager.movementMethod != MovementMethod.PointAndClick) { if (doJumpLock == LockType.Disabled) { KickStarter.playerInput.SetJumpLock(true); } else if (doJumpLock == LockType.Enabled) { KickStarter.playerInput.SetJumpLock(false); } } if (IsInFirstPerson()) { if (freeAimLock == LockType.Disabled) { KickStarter.playerInput.SetFreeAimLock(true); } else if (freeAimLock == LockType.Enabled) { KickStarter.playerInput.SetFreeAimLock(false); } } if (cursorState == LockType.Disabled) { KickStarter.playerInput.SetInGameCursorState(false); } else if (cursorState == LockType.Enabled) { KickStarter.playerInput.SetInGameCursorState(true); } if (doRunLock != PlayerMoveLock.NoChange) { KickStarter.playerInput.runLock = doRunLock; } } if (player) { if (movePath) { player.SetLockedPath(movePath); player.SetMoveDirectionAsForward(); } else if (player.GetPath()) { player.EndPath(); } if (doGravityLock == LockType.Enabled) { player.ignoreGravity = false; } else if (doGravityLock == LockType.Disabled) { player.ignoreGravity = true; } if (AllowHeadTurning()) { if (doHotspotHeadTurnLock == LockType.Disabled) { player.SetHotspotHeadTurnLock(true); } else if (doHotspotHeadTurnLock == LockType.Enabled) { player.SetHotspotHeadTurnLock(false); } } } return(0f); }