Ejemplo n.º 1
0
        private void DoRaycast()
        {
            RaycastHit hit;
            Vector3    position = FsmUtility.GetPosition(target, origin);
            Vector3    dir      = GetDirection();

            if (Physics.Raycast(position, dir, out hit, distance.Value, layerMask))
            {
                if (!hitDistance.IsNone)
                {
                    hitDistance.Value = hit.distance;
                }
                if (!hitNormal.IsNone)
                {
                    hitNormal.Value = hit.normal;
                }
                if (!hitPoint.IsNone)
                {
                    hitPoint.Value = hit.point;
                }
                if (!hitGameObject.IsNone)
                {
                    hitGameObject.Value = hit.transform.gameObject;
                }
                if (!hitEvent.IsNone)
                {
                    this.Root.Owner.SendEvent(hitEvent.Value, null);
                }
            }
        }
Ejemplo n.º 2
0
        public override void OnUpdate()
        {
            if (Time.time > repathTime)
            {
                seeker.StartPath(seeker.transform.position, FsmUtility.GetPosition(target, destination), OnPathComplete);
                repathTime = Time.time + repathRate.Value;
            }
            if (path == null || path.vectorPath.Count <= currentWaypoint)
            {
                //We have no path to move after yet
                return;
            }

            Vector3 dir = (path.vectorPath [currentWaypoint] - seeker.transform.position);

            if (dir != Vector3.zero)
            {
                dir.y = 0;
                Quaternion wantedRotation = Quaternion.LookRotation(dir);
                seeker.transform.rotation = Quaternion.Slerp(seeker.transform.rotation, wantedRotation, Time.deltaTime * rotation.Value);
            }
            dir  = dir.normalized;
            dir *= speed.Value;

            characterController.SimpleMove(dir);
            characterController.Move(Vector3.down * 15 * Time.deltaTime);
            if (Vector3.Distance(seeker.transform.position, path.vectorPath [currentWaypoint]) < threshold.Value)
            {
                currentWaypoint++;
            }
        }
Ejemplo n.º 3
0
        public override bool Validate()
        {
            //	float distance= Vector3.Distance (FsmUtility.GetPosition(first, a),FsmUtility.GetPosition(second, b));
            float distance = Mathf.Abs(FsmUtility.GetPosition(first, a).y - FsmUtility.GetPosition(second, b).y);

            return(FsmUtility.CompareFloat(distance, value.Value, comparer));
        }
Ejemplo n.º 4
0
 private void Do()
 {
     if (!weight.IsNone)
     {
         animator.SetIKPositionWeight(goal, weight.Value);
     }
     animator.SetIKPosition(goal, FsmUtility.GetPosition(target, position));
 }
Ejemplo n.º 5
0
 public override void OnEnter()
 {
     base.OnEnter();
     store.Value = Vector3.Distance(FsmUtility.GetPosition(first, a), FsmUtility.GetPosition(second, b));
     if (!everyFrame)
     {
         Finish();
     }
 }
        private void DoGetInRange()
        {
            Vector3 position = FsmUtility.GetPosition(target, initialPosition);
            Vector3 inRange  = new Vector3(position.x + Random.Range(-range.Value, range.Value),
                                           position.y + (setY.Value?Random.Range(-range.Value, range.Value):0),
                                           position.z + Random.Range(-range.Value, range.Value)
                                           );

            store.Value = inRange;
        }
Ejemplo n.º 7
0
        private void DoLookAt()
        {
            Vector3 targetPosition = FsmUtility.GetPosition(target, position);

            Vector3 lookAt = new Vector3(targetPosition.x,
                                         (inY.Value ? transform.position.y : targetPosition.y),
                                         targetPosition.z
                                         );

            transform.LookAt(lookAt, worldUp.Value);
        }
Ejemplo n.º 8
0
        public override void OnEnter()
        {
            GameObject createdObject = new GameObject(_name.IsNone?string.Empty:_name.Value);

            createdObject.transform.position = FsmUtility.GetPosition(spawnPoint, position);
            createdObject.transform.rotation = Quaternion.Euler(rotation.Value);
            if (!storeObject.IsNone)
            {
                storeObject.Value = createdObject;
            }
            Finish();
        }
Ejemplo n.º 9
0
        public override void OnUpdate()
        {
            Vector3 targetPosition = FsmUtility.GetPosition(target, position);

            Vector3 gameObjectPosition = transform.position;

            targetPosition.y = (inY.Value ? gameObjectPosition.y : targetPosition.y);

            Vector3 diff = targetPosition - gameObjectPosition;

            if (diff != Vector3.zero && diff.sqrMagnitude > 0)
            {
                desiredRotation = Quaternion.LookRotation(diff);
            }

            lastRotation       = Quaternion.Slerp(lastRotation, desiredRotation, speed.Value * Time.deltaTime);
            transform.rotation = lastRotation;
        }
Ejemplo n.º 10
0
 private void DoOverlapSphere()
 {
     Collider[] hits = Physics.OverlapSphere(FsmUtility.GetPosition(target, origin), radius.Value, layerMask);
     if (!hitGameObjects.IsNone)
     {
         List <object> gos = new List <object> ();
         foreach (Collider hit in hits)
         {
             gos.Add(hit.gameObject);
         }
         hitGameObjects.Value = gos.ToArray();
     }
     if (!randomGameObject.IsNone)
     {
         Collider randomCollider = hits.GetRandom <Collider>();
         if (randomCollider != null)
         {
             randomGameObject.Value = randomCollider.gameObject;
         }
     }
 }
 public override void OnEnter()
 {
     base.OnEnter();
     agents = new List <UnityEngine.AI.NavMeshAgent> ();
     foreach (object obj in gameObjects.Value)
     {
         if (obj is GameObject)
         {
             UnityEngine.AI.NavMeshAgent mAgent = (obj as GameObject).GetComponent <UnityEngine.AI.NavMeshAgent>();
             if (mAgent != null)
             {
                 agents.Add(mAgent);
             }
         }
     }
     maxInRow = Mathf.CeilToInt(Mathf.Sqrt(agents.Count));
     master   = agents [0];
     SetDestination(FsmUtility.GetPosition(target, destination));
     if (!everyFrame)
     {
         Finish();
     }
 }
Ejemplo n.º 12
0
 public override void OnEnter()
 {
     base.OnEnter();
     steerForPath.MoveTo(FsmUtility.GetPosition(target.Value, position.Value), append.Value);
     Finish();
 }
Ejemplo n.º 13
0
 public override void OnEnter()
 {
     base.OnEnter();
     AudioSource.PlayClipAtPoint((AudioClip)clip.Value, FsmUtility.GetPosition(target, position), volume.Value);
     Finish();
 }
Ejemplo n.º 14
0
 private void DoInstantiate()
 {
     store.Value = BoltNetwork.Instantiate(original.Value, FsmUtility.GetPosition(target, position), target.Value != null && rotation.IsNone?target.Value.transform.rotation:Quaternion.Euler(rotation.Value)).gameObject;
 }
Ejemplo n.º 15
0
 public override void OnUpdate()
 {
     Debug.DrawRay(FsmUtility.GetPosition(fromObject, start.Value), direction.Value, color.Value);
 }
Ejemplo n.º 16
0
 private void DoInstantiate()
 {
     store.Value = (GameObject)Instantiate(originals.GetRandom <Object>(), FsmUtility.GetPosition(target, position), Quaternion.Euler(rotation.Value));
 }
Ejemplo n.º 17
0
 public override void OnUpdate()
 {
     store.Value = Vector3.Distance(FsmUtility.GetPosition(first, a), FsmUtility.GetPosition(second, b));
 }
Ejemplo n.º 18
0
 public override void OnAnimatorIK(int layer)
 {
     animator.SetLookAtPosition(FsmUtility.GetPosition(target, position));
 }
Ejemplo n.º 19
0
 private void DoInstantiate()
 {
     store.Value = PhotonNetwork.InstantiateSceneObject(prefabName.Value, FsmUtility.GetPosition(target, position), target.Value != null && euler.IsNone?target.Value.transform.rotation:Quaternion.Euler(euler.Value), group.Value, null);
 }
Ejemplo n.º 20
0
 private void DoDrawLine()
 {
     Debug.DrawLine(FsmUtility.GetPosition(fromObject, start), FsmUtility.GetPosition(toObject, end), color.Value);
 }
Ejemplo n.º 21
0
 private void DoSetDestination()
 {
     agent.SetDestination(FsmUtility.GetPosition(target, destination));
 }
 public override void OnUpdate()
 {
     SetDestination(FsmUtility.GetPosition(target, destination));
 }