public override void ShowGUI() { if (IsSingleLockMovement ()) { doUpLock = (LockType) EditorGUILayout.EnumPopup ("Movement:", doUpLock); } else { doUpLock = (LockType) EditorGUILayout.EnumPopup ("Up movement:", doUpLock); doDownLock = (LockType) EditorGUILayout.EnumPopup ("Down movement:", doDownLock); doLeftLock = (LockType) EditorGUILayout.EnumPopup ("Left movement:", doLeftLock); doRightLock = (LockType) EditorGUILayout.EnumPopup ("Right movement:", doRightLock); } if (IsInFirstPerson ()) { freeAimLock = (LockType) EditorGUILayout.EnumPopup ("Free-aiming:", freeAimLock); } if (!IsUltimateFPS ()) { doRunLock = (PlayerMoveLock) EditorGUILayout.EnumPopup ("Walk / run:", doRunLock); doGravityLock = (LockType) EditorGUILayout.EnumPopup ("Affected by gravity?", doGravityLock); movePath = (Paths) EditorGUILayout.ObjectField ("Move path:", movePath, typeof (Paths), true); } if (AllowHeadTurning ()) { doHotspotHeadTurnLock = (LockType) EditorGUILayout.EnumPopup ("Hotspot head-turning?", doHotspotHeadTurnLock); } AfterRunningOption (); }
/** * <summary>Creates a new instance of the 'Player: Constrain' Action</summary> * <param name = "upMovementLock">Whether or not to constrain movement in the Up direction</param> * <param name = "downMovementLock">Whether or not to constrain movement in the Down direction</param> * <param name = "leftMovementLock">Whether or not to constrain movement in the Left direction</param> * <param name = "rightMovementLock">Whether or not to constrain movement in the Right direction</param> * <param name = "jumpLock">Whether or not to constrain jumping</param> * <param name = "freeAimLock">Whether or not to constrain free-aiming</param> * <param name = "cursorLock">Whether or not to constrain the cursor</param> * <param name = "movementSpeedLock">Whether or not to constrain movement speed</param> * <param name = "hotspotHeadTurnLock">Whether or not to constrain Hotspot head-turning</param> * <param name = "limitToPath">If set, a Path to constrain movement along, if using Direct movement</param> * <returns>The generated Action</returns> */ public static ActionPlayerLock CreateNew(LockType upMovementLock, LockType downMovementLock, LockType leftMovementLock, LockType rightMovementLock, LockType jumpLock = LockType.NoChange, LockType freeAimLock = LockType.NoChange, LockType cursorLock = LockType.NoChange, PlayerMoveLock movementSpeedLock = PlayerMoveLock.NoChange, LockType gravityLock = LockType.NoChange, LockType hotspotHeadTurnLock = LockType.NoChange, Paths limitToPath = null) { ActionPlayerLock newAction = (ActionPlayerLock)CreateInstance <ActionPlayerLock>(); newAction.doUpLock = upMovementLock; newAction.doLeftLock = leftMovementLock; newAction.doRightLock = rightMovementLock; newAction.doDownLock = downMovementLock; newAction.doJumpLock = jumpLock; newAction.freeAimLock = freeAimLock; newAction.cursorState = cursorLock; newAction.doRunLock = movementSpeedLock; newAction.movePath = limitToPath; newAction.doHotspotHeadTurnLock = hotspotHeadTurnLock; return(newAction); }
/** * <summary>Updates its own variables from a PlayerData class.</summary> * <param name = "playerData">The PlayerData class to load from</param> */ public void LoadPlayerData(PlayerData playerData) { SetUpLock (playerData.playerUpLock); isDownLocked = playerData.playerDownLock; isLeftLocked = playerData.playerLeftlock; isRightLocked = playerData.playerRightLock; runLock = (PlayerMoveLock) playerData.playerRunLock; SetFreeAimLock (playerData.playerFreeAimLock); }
/** * <summary>Updates its own variables from a PlayerData class.</summary> * <param name = "playerData">The PlayerData class to load from</param> */ public void LoadData(PlayerData playerData) { upMovementLocked = playerData.playerUpLock; downMovementLocked = playerData.playerDownLock; leftMovementLocked = playerData.playerLeftlock; rightMovementLocked = playerData.playerRightLock; runningLocked = (PlayerMoveLock)playerData.playerRunLock; freeAimLocked = playerData.playerFreeAimLock; charState = (playerData.inCustomCharState) ? CharState.Custom : CharState.Idle; playerData.UpdateFromTempPosition(this); Teleport(new Vector3(playerData.playerLocX, playerData.playerLocY, playerData.playerLocZ)); SetRotation(playerData.playerRotY); SetMoveDirectionAsForward(); walkSpeedScale = playerData.playerWalkSpeed; runSpeedScale = playerData.playerRunSpeed; // Animation clips GetAnimEngine().LoadPlayerData(playerData, this); // Sound walkSound = AssetLoader.RetrieveAsset(walkSound, playerData.playerWalkSound); runSound = AssetLoader.RetrieveAsset(runSound, playerData.playerRunSound); // Portrait graphic portraitIcon.ReplaceTexture(AssetLoader.RetrieveAsset(portraitIcon.texture, playerData.playerPortraitGraphic)); // Speech label SetName(playerData.playerSpeechLabel, playerData.playerDisplayLineID); // Rendering lockDirection = playerData.playerLockDirection; lockScale = playerData.playerLockScale; if (spriteChild && spriteChild.GetComponent <FollowSortingMap>()) { spriteChild.GetComponent <FollowSortingMap>().lockSorting = playerData.playerLockSorting; } else if (GetComponent <FollowSortingMap>()) { GetComponent <FollowSortingMap>().lockSorting = playerData.playerLockSorting; } else { ReleaseSorting(); } if (playerData.playerLockDirection) { spriteDirection = playerData.playerSpriteDirection; UpdateFrameFlipping(true); } if (playerData.playerLockScale) { spriteScale = playerData.playerSpriteScale; } if (playerData.playerLockSorting) { if (spriteChild && spriteChild.GetComponent <Renderer>()) { spriteChild.GetComponent <Renderer>().sortingOrder = playerData.playerSortingOrder; spriteChild.GetComponent <Renderer>().sortingLayerName = playerData.playerSortingLayer; } else if (GetComponent <Renderer>()) { GetComponent <Renderer>().sortingOrder = playerData.playerSortingOrder; GetComponent <Renderer>().sortingLayerName = playerData.playerSortingLayer; } } // Inactive following AC.Char charToFollow = null; if (playerData.followTargetID != 0) { RememberNPC followNPC = ConstantID.GetComponent <RememberNPC> (playerData.followTargetID); if (followNPC.GetComponent <AC.Char> ()) { charToFollow = followNPC.GetComponent <AC.Char> (); } } if (charToFollow != null || (playerData.followTargetIsPlayer && KickStarter.player)) { FollowAssign(charToFollow, playerData.followTargetIsPlayer, playerData.followFrequency, playerData.followDistance, playerData.followDistanceMax, playerData.followFaceWhenIdle, playerData.followRandomDirection, playerData.followAcrossScenes); } else { StopFollowing(); } // Active path Halt(); ForceIdle(); if (!string.IsNullOrEmpty(playerData.playerPathData) && ownPath) { Paths savedPath = ownPath; savedPath = Serializer.RestorePathData(savedPath, playerData.playerPathData); SetPath(savedPath, playerData.playerTargetNode, playerData.playerPrevNode, playerData.playerPathAffectY); isRunning = playerData.playerIsRunning; lockedPath = false; } else if (playerData.playerActivePath != 0) { Paths savedPath = ConstantID.GetComponent <Paths> (playerData.playerActivePath); if (savedPath) { lockedPath = playerData.playerLockedPath; if (lockedPath) { SetLockedPath(savedPath); } else { SetPath(savedPath, playerData.playerTargetNode, playerData.playerPrevNode); } } else { Halt(); ForceIdle(); } } else { Halt(); ForceIdle(); } // Previous path if (playerData.lastPlayerActivePath != 0) { Paths savedPath = ConstantID.GetComponent <Paths> (playerData.lastPlayerActivePath); if (savedPath) { SetLastPath(savedPath, playerData.lastPlayerTargetNode, playerData.lastPlayerPrevNode); } } // Head target lockHotspotHeadTurning = playerData.playerLockHotspotHeadTurning; if (playerData.isHeadTurning) { ConstantID _headTargetID = ConstantID.GetComponent <ConstantID> (playerData.headTargetID); if (_headTargetID) { SetHeadTurnTarget(_headTargetID.transform, new Vector3(playerData.headTargetX, playerData.headTargetY, playerData.headTargetZ), true); } else { ClearHeadTurnTarget(true); } } else { ClearHeadTurnTarget(true); } ignoreGravity = playerData.playerIgnoreGravity; if (GetComponentsInChildren <FollowSortingMap>() != null) { FollowSortingMap[] followSortingMaps = GetComponentsInChildren <FollowSortingMap>(); SortingMap customSortingMap = ConstantID.GetComponent <SortingMap> (playerData.customSortingMapID); foreach (FollowSortingMap followSortingMap in followSortingMaps) { followSortingMap.followSortingMap = playerData.followSortingMap; if (!playerData.followSortingMap && customSortingMap) { followSortingMap.SetSortingMap(customSortingMap); } else { followSortingMap.SetSortingMap(KickStarter.sceneSettings.sortingMap); } } } ignoreGravity = playerData.playerIgnoreGravity; if (GetAnimEngine() != null && GetAnimEngine().IKEnabled) { LeftHandIKController.LoadData(playerData.leftHandIKState); RightHandIKController.LoadData(playerData.rightHandIKState); } _spriteDirectionData.LoadData(playerData.spriteDirectionData); // Remember scripts if (!IsLocalPlayer()) { KickStarter.levelStorage.LoadPlayerData(this, playerData); } }