示例#1
0
    public override void OnMovement(OnEntityMovementEventArgs _args)
    {
        currentDirection = _args.MovementDirection;
        //Debug.LogError(_args.MovementDirection);
        if (_args.MovementDirection == new Vector3(1, 0, 0))
        {
            animator.SetBool("Front", false);
            animator.SetBool("Back", false);
            animator.SetBool("Right", true);
            animator.SetBool("Left", false);
            animator.SetBool("WavingFront", false);
            animator.SetBool("WavingBack", false);
            animator.SetBool("WavingRight", false);
            animator.SetBool("WavingLeft", false);
            return;
        }

        else if (_args.MovementDirection == new Vector3(-1, 0, 0))
        {
            animator.SetBool("Front", false);
            animator.SetBool("Back", false);
            animator.SetBool("Right", false);
            animator.SetBool("Left", true);
            animator.SetBool("WavingFront", false);
            animator.SetBool("WavingBack", false);
            animator.SetBool("WavingRight", false);
            animator.SetBool("WavingLeft", false);
            return;
        }

        if (_args.MovementDirection == new Vector3(0, 1, 0))
        {
            animator.SetBool("Front", false);
            animator.SetBool("Back", true);
            animator.SetBool("Right", false);
            animator.SetBool("Left", false);
            animator.SetBool("WavingFront", false);
            animator.SetBool("WavingBack", false);
            animator.SetBool("WavingRight", false);
            animator.SetBool("WavingLeft", false);
            return;
        }

        else if (_args.MovementDirection == new Vector3(0, -1, 0))
        {
            animator.SetBool("Front", true);
            animator.SetBool("Back", false);
            animator.SetBool("Right", false);
            animator.SetBool("Left", false);
            animator.SetBool("WavingFront", false);
            animator.SetBool("WavingBack", false);
            animator.SetBool("WavingRight", false);
            animator.SetBool("WavingLeft", false);
            return;
        }
    }
示例#2
0
    private void MoveToNextPosition(Vector3 _position)
    {
        _position.z = 0;
        direction   = GetEntity.GetFollowPathComponent.GetDirection(Time.time);
        carBody.MovePosition(_position);
        OnEntityMovementEventArgs eventArgs = new OnEntityMovementEventArgs();

        eventArgs.Entity            = movingEntity;
        eventArgs.MovementDirection = direction;
        onMovement?.Invoke(eventArgs);
    }
示例#3
0
    private void Start()
    {
        this.transform.localRotation = new Quaternion(0, 0, 0, 0);
        if (GetEntity)
        {
            direction = GetEntity.GetFollowPathComponent.GetDirection(Time.time);
        }
        else
        {
            direction = GetComponent <EntityFollowPath>().GetDirection(Time.time);
        }
        OnEntityMovementEventArgs eventArgs = new OnEntityMovementEventArgs();

        eventArgs.Entity            = movingEntity;
        eventArgs.MovementDirection = direction;
        onMovement?.Invoke(eventArgs);
    }
示例#4
0
 private void OnEntityMoved(OnEntityMovementEventArgs _args)
 {
     if (_args.Entity.GetEntityType.Equals(EntityType.Pedestrian))
     {
         if (crossingPedestrians.ContainsKey(_args.Entity))
         {
             CrossingInfo info = crossingPedestrians[_args.Entity];
             // First calculate the distance travelled since last frame.
             float distance;
             float delta = (_args.Entity.transform.position - info.lastPosition).magnitude;
             // Add to the calculated delta the stored distance to get the total.
             distance = info.distanceTravelled + delta;
             info.distanceTravelled            = distance;
             info.lastPosition                 = _args.Entity.transform.position;
             crossingPedestrians[_args.Entity] = info;
         }
         else
         {
             DebugController.LogErrorMessage(string.Format("{0} moved but it has no crossing info stored.", _args.Entity.gameObject.name));
         }
     }
     else if (_args.Entity.GetEntityType.Equals(EntityType.Vehicle))
     {
         if (crossingVehicle.ContainsKey(_args.Entity))
         {
             CrossingInfo info = crossingVehicle[_args.Entity];
             // First calculate the distance travelled since last frame.
             float distance = (_args.Entity.transform.position - info.lastPosition).magnitude;
             // Add to the calculated distance the sotored distance to get the total.
             distance += info.distanceTravelled;
             info.distanceTravelled        = distance;
             crossingVehicle[_args.Entity] = info;
         }
         else
         {
             DebugController.LogErrorMessage(string.Format("{0} moved but it has no crossing info stored.", _args.Entity.gameObject.name));
         }
     }
 }
示例#5
0
 public virtual void OnMovement(OnEntityMovementEventArgs _args)
 {
 }