Example #1
0
 public void Init(PathSpeed _moveSpeed, bool _turnInstantly, bool _forceDirection, CharDirection _charDirection, CharacterAnimation2DShot _activeShot)
 {
     moveSpeed      = _moveSpeed;
     forceDirection = _forceDirection;
     charDirection  = _charDirection;
     turnInstantly  = _turnInstantly;
     activeShot     = _activeShot;
 }
        /**
         * <summary>Creates a new instance of the 'Character: Move to point' Action with key variables already set.</summary>
         * <param name = "charToMove">The character to move</param>
         * <param name = "marker">The Marker to move the character to</param>
         * <param name = "pathSpeed">How fast the character moves (Walk, Run)</param>
         * <param name = "usePathfinding">If True, the character will rely on pathfinding to reach the Marker</param>
         * <param name = "waitUntilFinish">If True, the Action will wait until the character has reached the Marker</param>
         * <param name = "turnToFaceAfter">If True, and waitUntilFinish = true, then the character will face the same direction that the Marker is facing after reaching it</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCharPathFind CreateNew(Char charToMove, Marker marker, PathSpeed pathSpeed = PathSpeed.Walk, bool usePathfinding = true, bool waitUntilFinish = true, bool turnToFaceAfter = false)
        {
            ActionCharPathFind newAction = (ActionCharPathFind)CreateInstance <ActionCharPathFind>();

            newAction.charToMove = charToMove;
            newAction.marker     = marker;
            newAction.speed      = pathSpeed;
            newAction.pathFind   = usePathfinding;
            newAction.willWait   = waitUntilFinish;
            newAction.faceAfter  = turnToFaceAfter;
            return(newAction);
        }
        public void ShowGUI()
        {
            moveSpeed      = (PathSpeed)EditorGUILayout.EnumPopup("Animation when moving:", moveSpeed);
            turnInstantly  = EditorGUILayout.Toggle("Turning is instant?", turnInstantly);
            forceDirection = EditorGUILayout.Toggle("Face fixed direction?", forceDirection);
            if (forceDirection)
            {
                charDirection = (CharDirection)EditorGUILayout.EnumPopup("Direction:", charDirection);
            }

            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("This track type does not support live previewing.", MessageType.Info);
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);

            if (!isPlayer)
            {
                charToMoveParameterID = Action.ChooseParameterGUI("Character to move:", parameters, charToMoveParameterID, ParameterType.GameObject);
                if (charToMoveParameterID >= 0)
                {
                    charToMoveID = 0;
                    charToMove   = null;
                }
                else
                {
                    charToMove = (Char)EditorGUILayout.ObjectField("Character to move:", charToMove, typeof(Char), true);

                    charToMoveID = FieldToID <Char> (charToMove, charToMoveID);
                    charToMove   = IDToField <Char> (charToMove, charToMoveID, false);
                }
            }

            markerParameterID = Action.ChooseParameterGUI("Marker to reach:", parameters, markerParameterID, ParameterType.GameObject);
            if (markerParameterID >= 0)
            {
                markerID = 0;
                marker   = null;

                EditorGUILayout.HelpBox("If a Hotspot is passed to this parameter, that Hotspot's 'Walk-to Marker' will be referred to.", MessageType.Info);
            }
            else
            {
                marker = (Marker)EditorGUILayout.ObjectField("Marker to reach:", marker, typeof(Marker), true);

                markerID = FieldToID <Marker> (marker, markerID);
                marker   = IDToField <Marker> (marker, markerID, false);
            }

            speed    = (PathSpeed)EditorGUILayout.EnumPopup("Move speed:", speed);
            pathFind = EditorGUILayout.Toggle("Pathfind?", pathFind);
            if (!pathFind)
            {
                doFloat = EditorGUILayout.Toggle("Ignore gravity?", doFloat);
            }
            willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);

            AfterRunningOption();
        }
Example #5
0
    public void SetPath(Paths pathOb, PathSpeed _speed)
    {
        activePath = pathOb;
        targetNode = 0;
        prevNode   = 0;

        if (pathOb)
        {
            if (_speed == PathSpeed.Run)
            {
                isRunning = true;
            }
            else
            {
                isRunning = false;
            }
        }

        charState = CharState.Idle;
    }
Example #6
0
    override public void ShowGUI()
    {
        isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);

        if (!isPlayer)
        {
            charToMove = (Char)EditorGUILayout.ObjectField("Character to move:", charToMove, typeof(Char), true);
        }

        marker   = (Marker)EditorGUILayout.ObjectField("Marker to move to:", marker, typeof(Marker), true);
        speed    = (PathSpeed)EditorGUILayout.EnumPopup("Move speed:", speed);
        pathFind = EditorGUILayout.Toggle("Pathfind?", pathFind);

        if (!isPlayer)
        {
            willWait = EditorGUILayout.Toggle("Pause until finish?", willWait);
        }

        AfterRunningOption();
    }
        /**
         * <summary>Creates a new instance of the 'Character: Move to point' Action with key variables already set.</summary>
         * <param name = "charToMove">The character to move</param>
         * <param name = "marker">The Marker to move the character to</param>
         * <param name = "waitUntilFinish">If True, the Action will wait until the character has reached the Marker</param>
         * <param name = "pathSpeed">How fast the character moves (Walk, Run)</param>
         * <param name = "pathfind">If True, the character will rely on pathfinding to reach the Marker</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCharPathFind New(Char charToMove, Marker marker, bool waitUntilFinish = true, PathSpeed pathSpeed = PathSpeed.Walk, bool pathFind = true)
        {
            ActionCharPathFind newAction = (ActionCharPathFind)CreateInstance <ActionCharPathFind>();

            newAction.charToMove = charToMove;
            newAction.marker     = marker;
            newAction.speed      = pathSpeed;
            newAction.pathFind   = pathFind;
            newAction.willWait   = waitUntilFinish;
            return(newAction);
        }
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);

            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    playerParameterID = ChooseParameterGUI("Player ID:", parameters, playerParameterID, ParameterType.Integer);
                    if (playerParameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }
            }
            else
            {
                charToMoveParameterID = ChooseParameterGUI("Character to move:", parameters, charToMoveParameterID, ParameterType.GameObject);
                if (charToMoveParameterID >= 0)
                {
                    charToMoveID = 0;
                    charToMove   = null;
                }
                else
                {
                    charToMove = (Char)EditorGUILayout.ObjectField("Character to move:", charToMove, typeof(Char), true);

                    charToMoveID = FieldToID <Char> (charToMove, charToMoveID);
                    charToMove   = IDToField <Char> (charToMove, charToMoveID, false);
                }
            }

            markerParameterID = Action.ChooseParameterGUI("Marker to reach:", parameters, markerParameterID, ParameterType.GameObject);
            if (markerParameterID >= 0)
            {
                markerID = 0;
                marker   = null;

                EditorGUILayout.HelpBox("If a Hotspot is passed to this parameter, that Hotspot's 'Walk-to Marker' will be referred to.", MessageType.Info);
            }
            else
            {
                marker = (Marker)EditorGUILayout.ObjectField("Marker to reach:", marker, typeof(Marker), true);

                markerID = FieldToID <Marker> (marker, markerID);
                marker   = IDToField <Marker> (marker, markerID, false);
            }

            speed    = (PathSpeed)EditorGUILayout.EnumPopup("Move speed:", speed);
            pathFind = EditorGUILayout.Toggle("Pathfind?", pathFind);
            if (!pathFind)
            {
                doFloat = EditorGUILayout.Toggle("Ignore gravity?", doFloat);
            }
            willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);

            if (willWait)
            {
                EditorGUILayout.Space();
                faceAfter   = EditorGUILayout.Toggle("Copy Marker angle after?", faceAfter);
                doTimeLimit = EditorGUILayout.Toggle("Enforce time limit?", doTimeLimit);
                if (doTimeLimit)
                {
                    maxTimeParameterID = Action.ChooseParameterGUI("Time limit (s):", parameters, maxTimeParameterID, ParameterType.Float);
                    if (maxTimeParameterID < 0)
                    {
                        maxTime = EditorGUILayout.FloatField("Time limit (s):", maxTime);
                    }
                    onReachTimeLimit = (OnReachTimeLimit)EditorGUILayout.EnumPopup("On reach time limit:", onReachTimeLimit);
                }
            }

            AfterRunningOption();
        }
		override public void ShowGUI (List<ActionParameter> parameters)
		{
			isPlayer = EditorGUILayout.Toggle ("Is Player?", isPlayer);

			if (!isPlayer)
			{
				charToMoveParameterID = Action.ChooseParameterGUI ("Character to move:", parameters, charToMoveParameterID, ParameterType.GameObject);
				if (charToMoveParameterID >= 0)
				{
					charToMoveID = 0;
					charToMove = null;
				}
				else
				{
					charToMove = (Char) EditorGUILayout.ObjectField ("Character to move:", charToMove, typeof (Char), true);
					
					charToMoveID = FieldToID <Char> (charToMove, charToMoveID);
					charToMove = IDToField <Char> (charToMove, charToMoveID, false);
				}
			}

			markerParameterID = Action.ChooseParameterGUI ("Marker to reach:", parameters, markerParameterID, ParameterType.GameObject);
			if (markerParameterID >= 0)
			{
				markerID = 0;
				marker = null;
			}
			else
			{
				marker = (Marker) EditorGUILayout.ObjectField ("Marker to reach:", marker, typeof (Marker), true);
				
				markerID = FieldToID <Marker> (marker, markerID);
				marker = IDToField <Marker> (marker, markerID, false);
			}

			speed = (PathSpeed) EditorGUILayout.EnumPopup ("Move speed:" , speed);
			pathFind = EditorGUILayout.Toggle ("Pathfind?", pathFind);
			if (!pathFind)
			{
				doFloat = EditorGUILayout.Toggle ("Ignore gravity?", doFloat);
			}
			willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);

			AfterRunningOption ();
		}
Example #10
0
 public void SetPath(Paths pathOb, PathSpeed _speed)
 {
     SetPath (pathOb, _speed, 0, 0);
 }
Example #11
0
        private void SetPath(Paths pathOb, PathSpeed _speed, int _targetNode, int _prevNode)
        {
            activePath = pathOb;
            targetNode = _targetNode;
            prevNode = _prevNode;

            doExactLerp = false;
            exactDestination = pathOb.nodes [pathOb.nodes.Count-1];

            if (CanTurnBeforeMoving ())
            {
                TurnBeforeWalking ();
            }

            if (pathOb)
            {
                if (_speed == PathSpeed.Run)
                {
                    isRunning = true;
                }
                else
                {
                    isRunning = false;
                }
            }

            if (charState == CharState.Custom)
            {
                charState = CharState.Idle;
            }
        }
Example #12
0
        /**
         * <summary>Assigns the character to a Paths object to move along. This is not the same as pathfinding - this assumes a path has already been defined.</summary>
         * <param name = "pathOb">The Paths object to move along</param>
         * <param name = "_speed">The speed to move along the path (Walk, Run)</param>
         */
        public void SetPath(Paths pathOb, PathSpeed _speed)
        {
            if (pathOb != null && pathOb.nodes.Count > 0)
            {
                if (pathOb.nodes.Count == 1 && pathOb.nodes[0] == transform.position)
                {
                    return;
                }

                SetPath (pathOb, _speed, 1, 0);
            }
            else
            {
                SetPath (pathOb, _speed, 0, 0);
            }
        }
Example #13
0
		private void SetPath (Paths pathOb, PathSpeed _speed, int _targetNode, int _prevNode)
		{
			activePath = pathOb;
			targetNode = _targetNode;
			prevNode = _prevNode;
			
			if (CanTurnBeforeMoving ())
			{
				TurnBeforeWalking ();
			}
			
			if (pathOb)
			{
				if (_speed == PathSpeed.Run)
				{
					isRunning = true;
				}
				else
				{
					isRunning = false;
				}
			}
			
			charState = CharState.Idle;
		}