示例#1
0
        private void LateUpdate()
        {
            SyncState syncState = state;

            if (syncState != SyncState.INTERPOLATION || desiredStartEvent.Timestamp == desiredTargetEvent.Timestamp)
            {
                return;
            }
            LocomotionController currentController = locomotionTracker.GetCurrentController();
            float   t      = (float)(motionSequenceStartTime + timer.ElapsedMilliseconds - desiredStartEvent.Timestamp) / (float)(desiredTargetEvent.Timestamp - desiredStartEvent.Timestamp);
            Vector3 vector = Vector3.Lerp(startPosition, desiredTargetEvent.Position, t);

            if (!Allow3DMovement)
            {
                vector.y = ((currentController != null) ? currentController.GetPosition().y : base.transform.position.y);
            }
            if (currentController != null)
            {
                currentController.RemoteSetPosition(vector);
                if (currentController is SlideController && desiredTargetEvent.Velocity.HasValue)
                {
                    Vector3 newFacing = Vector3.Slerp(startFacing, desiredTargetEvent.Velocity.Value, t);
                    currentController.RemoteSetFacing(newFacing);
                }
            }
            else
            {
                base.transform.position = vector;
            }
        }
示例#2
0
 private void Update()
 {
     for (int i = 0; i < colliders.Count; i++)
     {
         Collider collider = colliders[i];
         if (collider == null)
         {
             colliders.RemoveAt(i);
             i--;
             continue;
         }
         Vector3 direction = Vector3.up;
         if (capsCollider.direction == 0)
         {
             direction = Vector3.right;
         }
         else if (capsCollider.direction == 2)
         {
             direction = Vector3.forward;
         }
         direction = base.transform.TransformDirection(direction);
         float num    = capsCollider.height;
         float radius = capsCollider.radius;
         if (num < radius * 2f)
         {
             num = radius * 2f;
         }
         Vector3 a         = base.transform.TransformPoint(capsCollider.center);
         Vector3 vector    = a - direction * (num * 0.5f);
         Vector3 vector2   = vector + direction * Mathf.Max(0f, num - radius);
         Vector3 position  = collider.transform.position;
         Vector3 vector3   = position - vector;
         float   magnitude = Vector3.Cross(direction, vector3).magnitude;
         float   num2      = Vector3.Dot(Vector3.Project(vector3 + vector, direction) - vector2, direction);
         float   num3      = 0f;
         if (num2 > 0f)
         {
             Debug.DrawLine(position, vector2, Color.yellow);
             num3 = (position - vector2).magnitude / radius;
         }
         else
         {
             Debug.DrawLine(position, vector, Color.yellow);
             num3 = magnitude / radius;
         }
         num3 = Mathf.Clamp01(1f - num3) * Magnitude;
         Vector3   vector4           = direction * num3;
         Rigidbody attachedRigidbody = collider.attachedRigidbody;
         if (attachedRigidbody != null)
         {
             attachedRigidbody.AddForce(vector4, ForceMode.Impulse);
             continue;
         }
         LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject);
         if (currentController != null && (!IgnoreIfRunController || !(currentController is RunController)))
         {
             currentController.AddForce(vector4, base.gameObject);
         }
     }
 }
示例#3
0
        private void switchToNextPosition()
        {
            LocomotionActionEvent locomotionActionEvent = positionTimeline.Dequeue();
            LocomotionController  currentController     = locomotionTracker.GetCurrentController();
            Vector3 vector       = ((currentController != null) ? currentController.GetPosition() : base.transform.position);
            Vector3 wsSteerInput = locomotionActionEvent.Position - vector;

            wsSteerInput.y = 0f;
            if (locomotionActionEvent.Direction.HasValue)
            {
                wsSteerInput = locomotionActionEvent.Direction.Value;
                if (locomotionActionEvent.Type.IsMovement())
                {
                    lastStickDirection = wsSteerInput;
                }
            }
            if (currentController != null && !(currentController is SlideController))
            {
                if (locomotionActionEvent.Type.IsMovement())
                {
                    currentController.Steer(wsSteerInput);
                }
                else if (locomotionActionEvent.Type == LocomotionAction.Rotate)
                {
                    currentController.SteerRotation(wsSteerInput);
                }
            }
            desiredStartEvent  = desiredTargetEvent;
            desiredTargetEvent = locomotionActionEvent;
            startPosition      = vector;
            startFacing        = ((currentController != null) ? currentController.GetFacing() : base.transform.forward);
            state = SyncState.INTERPOLATION;
        }
示例#4
0
    private void sendLocomotionUpdate(Vector3 direction, LocomotionAction type)
    {
        LocomotionActionEvent action = default(LocomotionActionEvent);

        action.Type      = type;
        action.Position  = getCurrentPosition();
        action.Direction = direction;
        LocomotionController currentController = locomotionTracker.GetCurrentController();

        if (currentController is SlideController)
        {
            action.Velocity = currentController.GetFacing();
        }
        if (broadcastingDisabledEvents == 0)
        {
            networkService.PlayerActionService.LocomotionAction(action, droppable: true);
        }
        AvatarDataHandle component = GetComponent <AvatarDataHandle>();

        if (!(component == null) && broadcastingDisabledEvents == 0 && Service.Get <CPDataEntityCollection>().TryGetComponent(component.Handle, out PositionData component2))
        {
            component2.Position = action.Position;
            if (!Service.Get <CPDataEntityCollection>().TryGetComponent(component.Handle, out PausedStateData component3))
            {
                component3 = Service.Get <CPDataEntityCollection>().AddComponent <PausedStateData>(component.Handle);
            }
            component3.Position = component2.Position;
        }
    }
示例#5
0
        private void onControllerChanged(LocomotionController newController)
        {
            bool flag = false;

            switch (StateToCheck)
            {
            case LocomotionState.Run:
                flag = newController is RunController;
                break;

            case LocomotionState.Sit:
                flag = newController is SitController;
                break;

            case LocomotionState.Slide:
                flag = newController is SlideController;
                break;

            case LocomotionState.Swim:
                flag = newController is SwimController;
                break;

            case LocomotionState.Zipline:
                flag = newController is ZiplineController;
                break;
            }
            if (flag)
            {
                playerObject.GetComponent <LocomotionEventBroadcaster>().OnControllerChangedEvent -= onControllerChanged;
                base.Fsm.Event(StateMatchesEvent);
            }
        }
示例#6
0
 private void onControllerChanged(LocomotionController newController)
 {
     if (runController != null && runController.enabled)
     {
         runController.Behaviour.SetStyle(walkModifier ? PlayerLocoStyle.Style.Walk : PlayerLocoStyle.Style.Run);
     }
 }
示例#7
0
 private void Update()
 {
     for (int i = 0; i < colliders.Count; i++)
     {
         Collider collider  = colliders[i];
         Vector3  vector    = collider.transform.position - base.transform.position;
         float    magnitude = vector.magnitude;
         float    num       = Magnitude;
         if (MaxDist > 0f)
         {
             num = Mathf.Clamp01(1f - magnitude / MaxDist) * Magnitude;
         }
         Vector3   vector2           = vector.normalized * num;
         Rigidbody attachedRigidbody = collider.attachedRigidbody;
         if (attachedRigidbody != null)
         {
             attachedRigidbody.AddForce(vector2, ForceMode.Impulse);
             continue;
         }
         LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject);
         if (currentController != null && (!IgnoreIfRunController || !(currentController is RunController)))
         {
             currentController.AddForce(vector2, base.gameObject);
         }
     }
 }
示例#8
0
    // Use this for initialization
    void Start()
    {
        if (this.avatar == null)
        {
            Debug.LogError("The 'avatar' object has not been specified");
            Debug.Break();
        }

        if (this.body == null)
        {
            Debug.LogError("The 'body' object has not been specified");
            Debug.Break();
        }

        this.gazescript    = this.body.GetComponent <EyeHeadGazeController>();
        this.ttsController = this.body.GetComponent <MaryTTSController>();
        this.facialExpressionsController = this.body.GetComponent <FacialExpressionsController>();
        this.locomotionController        = this.avatar.GetComponent <LocomotionController>();


        // Look at the target
        if (this.gazeTarget != null)
        {
            this.gazescript.LookAtObject(this.gazeTarget.name);
        }
    }
 private void onControllerChangedEvent(LocomotionController newController)
 {
     if (!(newController is SitController) && !consuming)
     {
         Change(onoff: false);
     }
 }
示例#10
0
        private void onPromptButtonPressed(DPrompt.ButtonFlags pressed)
        {
            if (pressed != DPrompt.ButtonFlags.YES)
            {
                return;
            }
            LocomotionController currentController = LocomotionHelper.GetCurrentController(base.gameObject);

            if (currentController is SitController)
            {
                LocomotionHelper.SetCurrentController <SwimController>(base.gameObject);
            }
            bubbleState = BubbleState.TransitionToHidden;
            playAudioEvent(mutableData.AirCriticalAudioEvent, EventAction.StopSound);
            GameObject gameObject = GameObject.FindWithTag(UIConstants.Tags.UI_Tray_Root);

            if (gameObject != null)
            {
                StateMachineContext component = gameObject.GetComponent <StateMachineContext>();
                if (component != null)
                {
                    component.SendEvent(new ExternalEvent("Root", "noUI"));
                }
            }
            Invoke("startBubbleScreenWipe", 0.7f);
            swimController.ResurfaceAccepted();
            dispatcher.DispatchEvent(default(DivingEvents.PlayerResurfaced));
        }
示例#11
0
 private void onControllerChanged(LocomotionController newController)
 {
     if (Run && newController is RunController)
     {
         Change(onoff: true);
     }
     else if (Sit && newController is SitController)
     {
         Change(onoff: true);
     }
     else if (Tube && newController is SlideController)
     {
         Change(onoff: true);
     }
     else if (Swim && newController is SwimController)
     {
         Change(onoff: true);
     }
     else if (Zipline && newController is ZiplineController)
     {
         Change(onoff: true);
     }
     else
     {
         Change(onoff: false);
     }
 }
 void Awake()
 {
     PathController = GetComponentInChildren <AbstractPathMind>();
     PathController.SetCharacter(this);
     LocomotionController = GetComponent <Locomotion>();
     LocomotionController.SetCharacter(this);
 }
    private void logLocomotionAction(string locomotionType)
    {
        LocomotionController currentController = locomotionTracker.GetCurrentController();
        string tier   = (currentController != null) ? currentController.GetType().Name.Replace("Controller", "") : "undefined";
        string callID = $"locomotion_{locomotionType}";

        Service.Get <ICPSwrveService>().ActionSingular(callID, locomotionType, tier);
    }
示例#14
0
    public void Initialize()
    {
        agent = this.GetComponent<NavMeshAgent> ();
        animator = this.GetComponent<Animator> ();
        desiredOrientation = transform.rotation;

        /*put together with locomotion*/
        locomotion = new LocomotionController(animator);
    }
 public void DisableAllControllers()
 {
     LocomotionController[] components = GetComponents <LocomotionController>();
     for (int i = 0; i < components.Length; i++)
     {
         components[i].enabled = false;
     }
     curController = null;
 }
示例#16
0
    public void Initialize()
    {
        agent              = this.GetComponent <NavMeshAgent> ();
        animator           = this.GetComponent <Animator> ();
        desiredOrientation = transform.rotation;

        /*put together with locomotion*/
        locomotion = new LocomotionController(animator);
    }
示例#17
0
    // Finds components and attaches to them. Basically, setting up. Better instead of manually attaching each component
    private void Awake()
    {
        _agent           = GetComponent <NavMeshAgent>();
        _agent.isStopped = true;
        _controller      = GetComponent <LocomotionController>();

        targetHealth = FollowTarget.gameObject.GetComponent <HealthController>();

        path = new NavMeshPath();
    }
示例#18
0
        private void triggerEventAction(LocomotionActionEvent targetEvent)
        {
            snapIfNeeded(targetEvent.Position);
            LocomotionController currentController = locomotionTracker.GetCurrentController();

            switch (targetEvent.Type)
            {
            case LocomotionAction.Torpedo:
                lastJumpPosition = targetEvent.Position;
                if (currentController != null)
                {
                    currentController.DoAction(LocomotionController.LocomotionAction.Torpedo);
                }
                break;

            case LocomotionAction.Jump:
                lastJumpPosition = targetEvent.Position;
                if (currentController != null)
                {
                    currentController.DoAction(LocomotionController.LocomotionAction.Jump);
                }
                break;

            case LocomotionAction.Interact:
                snapToGround(targetEvent.Position);
                if (currentController != null)
                {
                    currentController.DoAction(LocomotionController.LocomotionAction.Interact);
                }
                break;

            case LocomotionAction.ChargeThrow:
                remoteSnowballLauncher.ChargeSnowball();
                break;

            case LocomotionAction.LaunchThrow:
                remoteSnowballLauncher.LaunchSnowball(targetEvent.Velocity.Value);
                break;

            case LocomotionAction.CancelThrow:
                remoteSnowballLauncher.CancelChargeSnowball();
                break;

            case LocomotionAction.Action1:
            case LocomotionAction.Action2:
            case LocomotionAction.Action3:
                locomotionStateSetter.ActionButton(targetEvent.Type);
                break;
            }
            if (this.OnTriggerActionEvent != null)
            {
                this.OnTriggerActionEvent(targetEvent);
            }
        }
示例#19
0
 private void onControllerChanged(LocomotionController controller)
 {
     if (controller is SlideController)
     {
         changeState(isSliding: true);
     }
     else
     {
         changeState(isSliding: false);
     }
 }
 void Update()
 {
     if (BoardManager == null)
     {
         return;
     }
     if (LocomotionController.MoveNeed)
     {
         LocomotionController.SetNewDirection(PathController.GetNextMove(BoardManager.boardInfo, LocomotionController.CurrentEndPosition(), null));
     }
 }
示例#21
0
    void Start()
    {
        _animator            = GetComponent <Animator>();
        _model               = this.gameObject;
        _locomotionScript    = GetComponent <LocomotionController>();
        _feetController      = new FeetController(_animator);
        _leftFeetController  = new FeetController(_animator);
        _predictor           = new FeetPredictor(_animator);
        _characterController = GetComponent <CharacterController>();

        _prevRightPos = rightFootT.transform.position;
    }
示例#22
0
    private void Init()
    {
        if (!startPosition)
        {
            Debug.LogError("start position needs to be set for game to start");
        }

        if (!uiLooseGamePrefab)
        {
            Debug.LogError("uiLooseGamePrefab in GameHandler is not set");
        }

        if (!uiWinGamePrefab)
        {
            Debug.LogError("uiWinGamePrefab in GameHandler is not set");
        }

        // Find and set the player character.
        var playerObject = GameObject.FindGameObjectWithTag("Player");

        Player = playerObject != null?playerObject.GetComponent <Character>() : null;

        PlayerController = playerObject != null?playerObject.GetComponent <OVRPlayerController>() : null;

        LocomotionController = GameObject.Find("PlayerController/LocomotionController").GetComponent <LocomotionController>();
        if (!LocomotionController)
        {
            Debug.LogError("LocomotionController cannot be found for GameHandler");
        }

        if (!lobbyLevel)
        {
            Debug.LogWarning("Main room reference cannot be found for GameHandler");
        }

        if (Player == null)
        {
            Debug.LogError("Player character not found!");
        }
        else if (PlayerController == null)
        {
            Debug.LogError("player controller not found!");
        }
        else if (LocomotionController == null)
        {
            Debug.LogError("locomotion controller not found!");
        }

        InitReferences();

        DontDestroyOnLoad(gameObject);
    }
    public void DisallowController <T>(float delay) where T : LocomotionController
    {
        LocomotionController component = GetComponent <T>();

        if (disallowedControllers.ContainsKey(component))
        {
            disallowedControllers[component] = Time.time + delay;
        }
        else
        {
            disallowedControllers.Add(component, Time.time + delay);
        }
    }
示例#24
0
    void Start()
    {
        Controller = gameObject.GetComponent <LocomotionController>();

        Controller.OnLocomotionEvent += HandleLocomotionEvent;

        addState(PlayerStateType.IDLE, new PlayerIdleState(this));
        addState(PlayerStateType.MOVING, new PlayerMoveState(this));
        addState(PlayerStateType.FALLING, new PlayerFallState(this));
        addState(PlayerStateType.JUMPING, new PlayerJumpState(this));

        CurrentState = PlayerStateType.IDLE;
    }
示例#25
0
        private void resetLocomotionState()
        {
            GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject;

            if (localPlayerGameObject != null)
            {
                LocomotionController currentController = LocomotionHelper.GetCurrentController(localPlayerGameObject);
                if (currentController != null)
                {
                    currentController.ResetState();
                }
            }
        }
示例#26
0
        public override void OnEnter()
        {
            GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject;

            if (localPlayerGameObject != null)
            {
                LocomotionController currentController = LocomotionHelper.GetCurrentController(localPlayerGameObject);
                if (currentController != null)
                {
                    currentController.ResetState();
                }
            }
            Finish();
        }
示例#27
0
    void Start()
    {
        Target = PlayerManager.instance.GetPlayer().GetComponent <PlayerRanged>();
        locomotionController = GetComponent <LocomotionController>();
        combatController     = GetComponent <MeleeCombatController>();

        GameObject bus = GameObject.Find("Bus");

        if (bus == null)
        {
            Debug.LogError("AggroableEnemy could not find Bus object. Destroying gameObject");
            Destroy(gameObject);
        }
        SaveTransform = bus.transform;
    }
 private void onLocomotionControllerChanged(LocomotionController newController)
 {
     if (!IsValidSwimming && newController is SwimController && (newController as SwimController).IsInShallowWater)
     {
         isValidLocomotionController = false;
     }
     else if (!IsValidDiving && newController is SwimController && !(newController as SwimController).IsInShallowWater)
     {
         isValidLocomotionController = false;
     }
     else
     {
         isValidLocomotionController = true;
     }
 }
示例#29
0
    void Start()
    {
        animator            = GetComponent <Animator>();
        characterController = GetComponent <CharacterController>();
        locomotionScript    = GetComponent <LocomotionController>();
        model = this.gameObject;

        foreach (AnimationClip ac in animator.runtimeAnimatorController.animationClips)
        {
            RetrieveAnimationFlightTime(ac);
        }

        prevPos    = characterController.transform.position;
        prevPos.y += 0.5f;
    }
示例#30
0
    protected override void Update()
    {
        ChairProperties component = SceneRefs.ActionSequencer.GetTrigger(GetTarget()).GetComponent <ChairProperties>();

        if (component != null)
        {
            LocomotionHelper.SetCurrentController <SitController>(GetTarget());
            LocomotionController currentController = LocomotionHelper.GetCurrentController(GetTarget());
            if (currentController is SitController)
            {
                SitController sitController = (SitController)currentController;
                sitController.SetChair(component);
            }
        }
        Completed();
    }
示例#31
0
    public void OnTriggerEnter(Collider collider)
    {
        Vector3   vector            = (collider.transform.position - base.transform.position).normalized * Magnitude;
        Rigidbody attachedRigidbody = collider.attachedRigidbody;

        if (attachedRigidbody != null)
        {
            attachedRigidbody.AddForce(vector, ForceMode.VelocityChange);
            return;
        }
        LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject);

        if (currentController != null)
        {
            currentController.SetForce(vector, base.gameObject);
        }
    }