public override void OnExit()
 {
     if (!FsmEvent.IsNullOrEmpty(finishEvent))
     {
         mComp.clipFinishCallback -= FinishCallback;
     }
 }
Beispiel #2
0
        void DoSamplePath()
        {
            if (_agent == null)
            {
                return;
            }

            UnityEngine.AI.NavMeshHit _NavMeshHit;
            bool _reachedBeforeMaxDistance = _agent.SamplePathPosition(passableMask.Value, maxDistance.Value, out _NavMeshHit);

            reachedBeforeMaxDistance.Value = _reachedBeforeMaxDistance;

            position.Value = _NavMeshHit.position;
            normal.Value   = _NavMeshHit.normal;
            distance.Value = _NavMeshHit.distance;
            mask.Value     = _NavMeshHit.mask;
            hit.Value      = _NavMeshHit.hit;

            if (_reachedBeforeMaxDistance)
            {
                if (!FsmEvent.IsNullOrEmpty(reachedBeforeMaxDistanceEvent))
                {
                    Fsm.Event(reachedBeforeMaxDistanceEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(reachedAfterMaxDistanceEvent))
                {
                    Fsm.Event(reachedAfterMaxDistanceEvent);
                }
            }
        }
Beispiel #3
0
        void DoGetDistancetoEdge()
        {
            NavMeshHit _NavMeshHit;
            bool       _nearestEdgeFound = NavMesh.FindClosestEdge(sourcePosition.Value, out _NavMeshHit, passableMask.Value);

            nearestEdgeFound.Value = _nearestEdgeFound;

            position.Value = _NavMeshHit.position;
            normal.Value   = _NavMeshHit.normal;
            distance.Value = _NavMeshHit.distance;
            mask.Value     = _NavMeshHit.mask;
            hit.Value      = _NavMeshHit.hit;

            if (_nearestEdgeFound)
            {
                if (!FsmEvent.IsNullOrEmpty(nearestEdgeFoundEvent))
                {
                    Fsm.Event(nearestEdgeFoundEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(nearestEdgeNotFoundEvent))
                {
                    Fsm.Event(nearestEdgeNotFoundEvent);
                }
            }
        }
        void DoFindClosestEdge()
        {
            if (_agent == null)
            {
                return;
            }

            NavMeshHit _NavMeshHit;

            bool _nearestEdgeFound = _agent.FindClosestEdge(out _NavMeshHit);

            nearestEdgeFound.Value = _nearestEdgeFound;

            position.Value = _NavMeshHit.position;
            normal.Value   = _NavMeshHit.normal;
            distance.Value = _NavMeshHit.distance;
            mask.Value     = _NavMeshHit.mask;
            hit.Value      = _NavMeshHit.hit;

            if (_nearestEdgeFound)
            {
                if (!FsmEvent.IsNullOrEmpty(nearestEdgeFoundEvent))
                {
                    Fsm.Event(nearestEdgeFoundEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(nearestEdgeNotFoundEvent))
                {
                    Fsm.Event(nearestEdgeNotFoundEvent);
                }
            }
        }
        void DoRaycast()
        {
            if (_agent == null)
            {
                return;
            }

            UnityEngine.AI.NavMeshHit _NavMeshHit;
            bool _reachedBeforeTargetPosition = _agent.Raycast(targetPosition.Value, out _NavMeshHit);

            reachedBeforeTargetPosition.Value = _reachedBeforeTargetPosition;

            position.Value = _NavMeshHit.position;
            normal.Value   = _NavMeshHit.normal;
            distance.Value = _NavMeshHit.distance;
            mask.Value     = _NavMeshHit.mask;
            hit.Value      = _NavMeshHit.hit;

            if (_reachedBeforeTargetPosition)
            {
                if (!FsmEvent.IsNullOrEmpty(reachedBeforeTargetPositionEvent))
                {
                    Fsm.Event(reachedBeforeTargetPositionEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(reachedAfterTargetPositionEvent))
                {
                    Fsm.Event(reachedAfterTargetPositionEvent);
                }
            }
        }
Beispiel #6
0
 // Code that runs when exiting the state.
 public override void OnExit()
 {
     if (!FsmEvent.IsNullOrEmpty(onFinishEvent))
     {
         MusicManager.instance.musicFinishCallback -= OnMusicFinish;
     }
 }
        void DoSamplePosition()
        {
            UnityEngine.AI.NavMeshHit _NavMeshHit;
            bool _nearestPointFound = UnityEngine.AI.NavMesh.SamplePosition(sourcePosition.Value, out _NavMeshHit, maxDistance.Value, allowedMask.Value);

            nearestPointFound.Value = _nearestPointFound;

            position.Value = _NavMeshHit.position;
            normal.Value   = _NavMeshHit.normal;
            distance.Value = _NavMeshHit.distance;
            mask.Value     = _NavMeshHit.mask;
            hit.Value      = _NavMeshHit.hit;

            if (_nearestPointFound)
            {
                if (!FsmEvent.IsNullOrEmpty(nearestPointFoundEvent))
                {
                    Fsm.Event(nearestPointFoundEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(nearestPointNotFoundEvent))
                {
                    Fsm.Event(nearestPointNotFoundEvent);
                }
            }
        }
Beispiel #8
0
        void DoRaycast()
        {
            UnityEngine.AI.NavMeshHit _NavMeshHit;
            bool _reachedBeforeTargetPosition = UnityEngine.AI.NavMesh.Raycast(sourcePosition.Value, targetPosition.Value, out _NavMeshHit, passableMask.Value);

            reachedBeforeTargetPosition.Value = _reachedBeforeTargetPosition;

            position.Value = _NavMeshHit.position;
            normal.Value   = _NavMeshHit.normal;
            distance.Value = _NavMeshHit.distance;
            mask.Value     = _NavMeshHit.mask;
            hit.Value      = _NavMeshHit.hit;

            if (_reachedBeforeTargetPosition)
            {
                if (!FsmEvent.IsNullOrEmpty(reachedBeforeTargetPositionEvent))
                {
                    Fsm.Event(reachedBeforeTargetPositionEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(reachedAfterTargetPositionEvent))
                {
                    Fsm.Event(reachedAfterTargetPositionEvent);
                }
            }
        }
Beispiel #9
0
        void EventUpdate()
        {
            if (input.IsNone || !input.Value)
            {
                return;
            }

            var action = (InputAction)input.Value;

            var newState = action.GetButtonState();

            //state has changed
            if (mCurState != newState)
            {
                mCurState = newState;

                switch (mCurState)
                {
                case InputAction.ButtonState.Pressed:
                    if (!FsmEvent.IsNullOrEmpty(pressedEvent))
                    {
                        Fsm.Event(pressedEvent);
                    }
                    break;

                case InputAction.ButtonState.Released:
                    if (!FsmEvent.IsNullOrEmpty(releasedEvent))
                    {
                        Fsm.Event(releasedEvent);
                    }
                    break;
                }
            }
        }
        void DoCalculatePath()
        {
            _getNavMeshPathProxy();
            if (_NavMeshPathProxy == null)
            {
                return;
            }


            UnityEngine.AI.NavMeshPath _path = new UnityEngine.AI.NavMeshPath();

            bool _found = UnityEngine.AI.NavMesh.CalculatePath(sourcePosition.Value, targetPosition.Value, passableMask.Value, _path);

            _NavMeshPathProxy.path = _path;

            resultingPathFound.Value = _found;

            if (_found)
            {
                if (!FsmEvent.IsNullOrEmpty(resultingPathFoundEvent))
                {
                    Fsm.Event(resultingPathFoundEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(resultingPathNotFoundEvent))
                {
                    Fsm.Event(resultingPathNotFoundEvent);
                }
            }
        }
Beispiel #11
0
        void DoSetPath()
        {
            if (_pathProxy == null || _agent == null)

            {
                return;
            }

            bool _ok = NewMethod();

            pathAssigned.Value = _ok;

            if (_ok)
            {
                if (!FsmEvent.IsNullOrEmpty(pathAssignedEvent))
                {
                    Fsm.Event(pathAssignedEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(pathNotAssignedEvent))
                {
                    Fsm.Event(pathNotAssignedEvent);
                }
            }
        }
Beispiel #12
0
        void OnAction(UIModalCharacterDialog dlg, int choiceIndex)
        {
            if (mCurIndex == textIndexEnd.Value)
            {
                //save to variable
                if (!choiceOutput.IsNone)
                {
                    choiceOutput.Value = choiceIndex;
                }

                //close?
                if (closeOnAction.Value && UIModalManager.instance.ModalGetTop() == GetModalRef())
                {
                    UIModalManager.instance.ModalCloseTop();
                }

                //envoke event
                if (!FsmEvent.IsNullOrEmpty(actionEvent))
                {
                    Fsm.Event(actionEvent);
                }

                Finish();
            }
            else
            {
                //go to next
                mCurIndex++;

                if (!SetDialog(false))
                {
                    Finish();
                }
            }
        }
Beispiel #13
0
        void StateCallback(string aName, SceneState.StateValue newVal)
        {
            if (!output.IsNone)
            {
                switch (output.Type)
                {
                case VariableType.Int:
                    output.SetValue(newVal.ival);
                    break;

                case VariableType.Float:
                    output.SetValue(newVal.fval);
                    break;

                case VariableType.String:
                    output.SetValue(newVal.sval);
                    break;

                case VariableType.Bool:
                    output.SetValue(newVal.ival != 0);
                    break;
                }
            }

            if (!FsmEvent.IsNullOrEmpty(changeEvent))
            {
                Fsm.Event(changeEvent);
            }

            Finish();
        }
Beispiel #14
0
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(sendEvent))
     {
         return("Action sends no events!");
     }
     return("");
 }
Beispiel #15
0
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(this.inWindow) && FsmEvent.IsNullOrEmpty(this.outOfWindow))
     {
         return("Action sends no events!");
     }
     return(string.Empty);
 }
Beispiel #16
0
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(this.isPositive) && FsmEvent.IsNullOrEmpty(this.isNegative))
     {
         return("Action sends no events!");
     }
     return(string.Empty);
 }
Beispiel #17
0
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(equal) && FsmEvent.IsNullOrEmpty(lessThan) && FsmEvent.IsNullOrEmpty(greaterThan))
     {
         return("Action sends no events!");
     }
     return("");
 }
Beispiel #18
0
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(isTrue) &&
         FsmEvent.IsNullOrEmpty(isFalse))
     {
         return("Action sends no events!");
     }
     return("");
 }
Beispiel #19
0
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(onPressEvent) &&
         FsmEvent.IsNullOrEmpty(onReleaseEvent))
     {
         return("Action sends no events!");
     }
     return("");
 }
Beispiel #20
0
 public override string ErrorCheck()
 {
     if (everyFrame.Value &&
         FsmEvent.IsNullOrEmpty(isEqual) &&
         FsmEvent.IsNullOrEmpty(isNotEqual))
     {
         return("Action sends no events!");
     }
     return("");
 }
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(equal) &&
         FsmEvent.IsNullOrEmpty(lessThan) &&
         FsmEvent.IsNullOrEmpty(greaterThan))
     {
         return("This action requires an event!");
     }
     return("");
 }
Beispiel #22
0
        void DoCalculatePath()
        {
            GameObject _sourceGameObject = Fsm.GetOwnerDefaultTarget(sourceGameObject);

            if (_sourceGameObject == null)
            {
                return;
            }
            GameObject _targetGameObject = targetGameObject.Value;

            if (_targetGameObject == null)
            {
                return;
            }

            _getNavMeshPathProxy();

            UnityEngine.AI.NavMeshPath _path = new UnityEngine.AI.NavMeshPath();

            bool _found = UnityEngine.AI.NavMesh.CalculatePath(_sourceGameObject.transform.position, _targetGameObject.transform.position, passableMask.Value, _path);

            if (_NavMeshPathProxy != null)
            {
                _NavMeshPathProxy.path = _path;
            }

            if (!calculatedPathCorners.IsNone)
            {
                calculatedPathCorners.Resize(_path.corners.Length);
                for (int i = 0; i < calculatedPathCorners.Length; i++)
                {
                    calculatedPathCorners.Set(i, _path.corners [i]);
                }

                calculatedPathCorners.SaveChanges();
            }

            resultingPathFound.Value = _found;

            if (_found)
            {
                if (!FsmEvent.IsNullOrEmpty(resultingPathFoundEvent))
                {
                    Fsm.Event(resultingPathFoundEvent);
                }
            }
            else
            {
                if (!FsmEvent.IsNullOrEmpty(resultingPathNotFoundEvent))
                {
                    Fsm.Event(resultingPathNotFoundEvent);
                }
            }
        }
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(swipeLeft) &&
         FsmEvent.IsNullOrEmpty(swipeRight) &&
         FsmEvent.IsNullOrEmpty(swipeUp) &&
         FsmEvent.IsNullOrEmpty(swipeDown))
     {
         return("Action sends no events!");
     }
     return("");
 }
 public override string ErrorCheck()
 {
     if (FsmEvent.IsNullOrEmpty(Disconnected) &&
         FsmEvent.IsNullOrEmpty(Scanning) &&
         FsmEvent.IsNullOrEmpty(Connecting) &&
         FsmEvent.IsNullOrEmpty(Connected))
     {
         return("Action sends no events!");
     }
     return("");
 }
Beispiel #25
0
 void OnSoundEnd(object param)
 {
     if (!FsmEvent.IsNullOrEmpty(onEndEvent))
     {
         Fsm.Event(onEndEvent);
     }
     else
     {
         Finish();
     }
 }
Beispiel #26
0
        public override void OnUpdate()
        {
            if (!mComp.isPlaying)
            {
                if (!FsmEvent.IsNullOrEmpty(onEndEvent))
                {
                    Fsm.Event(onEndEvent);
                }

                Finish();
            }
        }
 // Code that runs on entering the state.
 public override void OnEnter()
 {
     base.OnEnter();
     mComp.PlayOverrideClip(clip.Value);
     if (FsmEvent.IsNullOrEmpty(finishEvent))
     {
         Finish();
     }
     else
     {
         mComp.clipFinishCallback += FinishCallback;
     }
 }
Beispiel #28
0
        public override string ErrorCheck()
        {
            if (FsmEvent.IsNullOrEmpty(equal) &&
                FsmEvent.IsNullOrEmpty(notEqual))
            {
                return("Action sends no events!");
            }

            if (integers.Length < 2)
            {
                return("Action needs more than 1 int to compare");
            }
            return("");
        }
Beispiel #29
0
 void OnMusicFinish(string name)
 {
     if (name == music.Value)
     {
         if (!FsmEvent.IsNullOrEmpty(onFinishEvent))
         {
             Fsm.Event(onFinishEvent);
         }
         else
         {
             Finish();
         }
     }
 }
Beispiel #30
0
    void OnInput(InputManager.Info dat)
    {
        if (dat.state == InputManager.State.Pressed)
        {
            SetInput(false);

            if (!FsmEvent.IsNullOrEmpty(toEvent))
            {
                Fsm.Event(toEvent);
            }

            Finish();
        }
    }