public void TriggerLocomotionAction(LocomotionActionEvent action, bool droppable)
 {
     action.SessionId = clubPenguinClient.PlayerSessionId;
     if (action.Object != null && action.Object.type == ObjectType.LOCAL)
     {
         List <string> list = new List <string>();
         list.Add(action.Object.id);
         Reward inRoomReward = definitions.GetInRoomReward(list);
         if (!inRoomReward.isEmpty())
         {
             inRoomRewards[action.Object.id] = ServerTime;
             CoroutineRunner.StartPersistent(pickupResponse(), this, "pickupResponse");
         }
     }
     if (currentConsumable != null)
     {
         currentConsumable.HandleInteraction(action);
     }
     foreach (IConsumable activeConsumable in activeConsumables)
     {
         activeConsumable.HandleInteraction(action);
     }
     if (currentRoom != null)
     {
         currentRoom.HandleInteraction(action);
     }
 }
Exemplo n.º 2
0
 public void ChargeSnowball()
 {
     if (currentState == PenguinSnowballThrowState.Throw)
     {
         isPendingChargeSnowball = true;
     }
     else if (currentState == PenguinSnowballThrowState.Idle)
     {
         isPendingChargeSnowball = false;
         if (snowballAiming != null)
         {
             snowballAiming.Init();
         }
         anim.ResetTrigger(launchAnimTrigger);
         anim.ResetTrigger(chargeAnimTrigger);
         anim.SetTrigger(chargeAnimTrigger);
         setState(PenguinSnowballThrowState.Charge);
         LocomotionActionEvent action = default(LocomotionActionEvent);
         action.Type      = LocomotionAction.ChargeThrow;
         action.Position  = base.transform.position;
         action.Direction = base.transform.forward;
         Service.Get <EventDispatcher>().DispatchEvent(new HudEvents.StartSnowballPowerMeter(mutableData.MaxChargeTime));
         sendNetworkMessage(action);
     }
 }
Exemplo n.º 3
0
 public void AnimEvent_ReleaseSnowball()
 {
     if (!base.gameObject.IsDestroyed())
     {
         if (snowballInst.Snowball == null)
         {
             AnimEvent_SpawnSnowball();
         }
         float   num     = mutableData.MinThrowSpeed + (mutableData.MaxThrowSpeed - mutableData.MinThrowSpeed) * Mathf.Clamp01(chargeTime / mutableData.MaxChargeTime);
         float   num2    = mutableData.MinLiftForce + (mutableData.MaxLiftForce - mutableData.MinLiftForce) * Mathf.Clamp01(chargeTime / mutableData.MaxChargeTime);
         Vector3 vector  = base.transform.TransformDirection(mutableData.ThrowDirection.forward) * num;
         Vector3 vector2 = Vector3.up * num2;
         snowballInst.LaunchVel  = vector + vector2;
         snowballInst.TrailAlpha = mutableData.MinTrailAlpha + (mutableData.MaxTrailAlpha - mutableData.MinTrailAlpha) * Mathf.Clamp01(chargeTime / mutableData.MaxChargeTime);
         if (mutableData.EnableAimAssist)
         {
             Vector3 position        = snowballInst.Snowball.transform.position;
             Vector3 initialVelocity = mutableData.CharVelocityFactor * charController.velocity + snowballInst.LaunchVel;
             snowballInst.LaunchVel = AimAssist(initialVelocity, position);
         }
         LocomotionActionEvent action = default(LocomotionActionEvent);
         action.Type      = LocomotionAction.LaunchThrow;
         action.Position  = base.transform.position;
         action.Velocity  = snowballInst.LaunchVel;
         action.Direction = base.transform.forward;
         sendNetworkMessage(action);
         ReleaseSnowball(snowballInst.Snowball.transform.position, snowballInst.LaunchVel, snowballInst.TrailAlpha);
     }
 }
 public override void HandleInteraction(LocomotionActionEvent action)
 {
     if (action.Type == LocomotionAction.Interact && action.Object.type == ObjectType.SERVER && action.Object.id == item.Id.Id.ToString())
     {
         (item as ActionedItem).ActionCount--;
     }
 }
Exemplo n.º 5
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;
        }
    }
Exemplo n.º 6
0
 private void sendNetworkMessage(LocomotionActionEvent action)
 {
     if (GetComponent <LocomotionBroadcaster>() != null)
     {
         Service.Get <INetworkServicesManager>().PlayerActionService.LocomotionAction(action);
     }
 }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
0
 private bool timeForPosition(LocomotionActionEvent currentPosition, LocomotionActionEvent nextPosition)
 {
     if (currentPosition.Timestamp == 0)
     {
         return(true);
     }
     return(motionSequenceStartTime + timer.ElapsedMilliseconds >= nextPosition.Timestamp);
 }
Exemplo n.º 9
0
        private void addEvent(LocomotionActionEvent evt, bool force = false)
        {
            if (evt.Type == LocomotionAction.SnapToPosition)
            {
                snapToPosition(evt.Position);
                return;
            }
            switch (state)
            {
            case SyncState.IDLE:
                addToTimeline(evt);
                break;

            case SyncState.WAITING:
                if (addToTimeline(evt) == 0)
                {
                    desiredTargetEvent = evt;
                    snapIfNeeded(desiredTargetEvent.Position);
                }
                break;

            case SyncState.INTERPOLATION:
                if (!force && desiredStartEvent.Timestamp != 0 && timeForPosition(desiredStartEvent, evt))
                {
                    break;
                }
                if (force && timeForPosition(desiredStartEvent, evt))
                {
                    triggerEventAction(evt);
                    break;
                }
                if (evt.Timestamp < desiredTargetEvent.Timestamp)
                {
                    LocomotionActionEvent locomotionActionEvent = evt;
                    evt = desiredTargetEvent;
                    desiredTargetEvent = locomotionActionEvent;
                }
                addToTimeline(evt);
                break;

            case SyncState.EXTRAPOLATION:
                if (!force && evt.Timestamp < desiredTargetEvent.Timestamp)
                {
                    break;
                }
                if (force && evt.Timestamp < desiredTargetEvent.Timestamp)
                {
                    triggerEventAction(evt);
                    break;
                }
                if (timeForPosition(desiredTargetEvent, evt))
                {
                }
                addToTimeline(evt);
                break;
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        public void RandomizePosition(Vector3 position, float radius)
        {
            LocomotionActionEvent action = default(LocomotionActionEvent);

            action.SessionId = SessionId;
            action.Type      = LocomotionAction.Move;
            Vector3 position2 = UnityEngine.Random.insideUnitSphere * radius + position;

            position2.y      = position.y;
            action.Position  = position2;
            action.Direction = Vector3.zero;
            eventDispatcher.DispatchEvent(new PlayerActionServiceEvents.LocomotionActionReceived(action.SessionId, action));
        }
Exemplo n.º 12
0
 public void HandleInteraction(LocomotionActionEvent action)
 {
     if (action.Type != LocomotionAction.Interact || action.Object == null || action.Object.type != ObjectType.SERVER)
     {
         return;
     }
     foreach (IWorldObject worldObject in worldObjects)
     {
         if (action.Object.id == worldObject.GetId())
         {
             worldObject.HandleInteraction(action);
         }
     }
 }
Exemplo n.º 13
0
        private int addToTimeline(LocomotionActionEvent evt)
        {
            bool queueTooLong;
            int  result = positionTimeline.Enqueue(evt, out queueTooLong);

            if (queueTooLong || (desiredStartEvent.Timestamp != 0 && evt.Timestamp - desiredStartEvent.Timestamp > MaxQueueTimeMS))
            {
                timer.Reset();
                timer.Start();
                motionSequenceStartTime      = positionTimeline.Peek().Timestamp;
                desiredTargetEvent.Timestamp = motionSequenceStartTime;
            }
            return(result);
        }
Exemplo n.º 14
0
    private void setLocomotionActionEvent(LocomotionAction locomotionAction, bool setDirection = false)
    {
        LocomotionActionEvent action = default(LocomotionActionEvent);

        action.Type     = locomotionAction;
        action.Position = getCurrentPosition();
        if (setDirection)
        {
            action.Direction = newSteerDirection;
        }
        if (broadcastingDisabledEvents == 0)
        {
            networkService.PlayerActionService.LocomotionAction(action);
        }
    }
    public void Launch()
    {
        Vector3 a        = base.transform.TransformDirection(Vector3.forward);
        Vector3 vector   = a * Speed;
        Vector3 position = base.transform.position;

        Create(position, vector);
        if (SynchronizeOnNetwork)
        {
            LocomotionActionEvent action = default(LocomotionActionEvent);
            action.Type     = LocomotionAction.LaunchThrow;
            action.Position = base.transform.parent.position;
            action.Velocity = vector;
            Service.Get <INetworkServicesManager>().PlayerActionService.LocomotionAction(action);
        }
    }
Exemplo n.º 16
0
            public void HandleInteraction(LocomotionActionEvent action)
            {
                usersInRace.Add(action.SessionId);
                cpItem.playerData = getPlayerData(usersInRace);
                processEvent(GameServerEvent.SERVER_ITEM_CHANGED, cpItem);
                HeldObjectEvent heldObjectEvent = default(HeldObjectEvent);

                heldObjectEvent.SessionId = action.SessionId;
                heldObjectEvent.Type      = "TubeRaceLobbyServerAdded";
                processEvent(GameServerEvent.PARTYGAME_EQUIPPED, heldObjectEvent);
                PlayerLocomotionStateEvent playerLocomotionStateEvent = default(PlayerLocomotionStateEvent);

                playerLocomotionStateEvent.SessionId = action.SessionId;
                playerLocomotionStateEvent.State     = LocomotionState.Slide;
                processEvent(GameServerEvent.USER_LOCO_STATE_CHANGED, playerLocomotionStateEvent);
            }
Exemplo n.º 17
0
        private void abortSnowball()
        {
            if (snowballInst.Lifetime != null)
            {
                snowballInst.Lifetime.KillImmediately();
            }
            if (snowballAiming != null)
            {
                snowballAiming.StopPlaying();
            }
            snowballInst.Reset();
            LocomotionActionEvent action = default(LocomotionActionEvent);

            action.Type = LocomotionAction.CancelThrow;
            sendNetworkMessage(action);
            Service.Get <EventDispatcher>().DispatchEvent(new HudEvents.StopSnowballPowerMeter(wasCancelled: true));
        }
 public override void HandleInteraction(LocomotionActionEvent action)
 {
     if (action.Type == LocomotionAction.Interact && action.Object.type == ObjectType.PLAYER)
     {
         actionCount--;
         if (actionCount <= 0)
         {
             client.DequipeHeldObject();
             return;
         }
         PlayerHeldItem playerHeldItem = new PlayerHeldItem();
         playerHeldItem.Id         = new CPMMOItemId(client.clubPenguinClient.PlayerSessionId, CPMMOItemId.CPMMOItemParent.PLAYER);
         playerHeldItem.CreatorId  = playerHeldItem.Id.Id;
         playerHeldItem.Type       = type;
         playerHeldItem.Properties = "{\"actionCount\":" + actionCount + "}";
         client.processEvent(GameServerEvent.SERVER_ITEM_CHANGED, playerHeldItem);
     }
 }
Exemplo n.º 19
0
        private IEnumerator checkPosition()
        {
            GameObject remotePlayer = null;

            while (remotePlayer == null)
            {
                yield return(new WaitForSeconds(5f));

                remotePlayer = referenceData.GameObject;
            }
            LocomotionActionEvent movement = default(LocomotionActionEvent);

            movement.SessionId = SessionId;
            movement.Type      = LocomotionAction.Move;
            movement.Position  = remotePlayer.transform.position;
            movement.Direction = Vector3.zero;
            eventDispatcher.DispatchEvent(new PlayerActionServiceEvents.LocomotionActionReceived(movement.SessionId, movement));
        }
Exemplo n.º 20
0
 private bool onIglooJoined(WorldServiceEvents.SelfRoomJoinedEvent evt)
 {
     if (!string.IsNullOrEmpty(evt.Room.zoneId.instanceId))
     {
         DataEntityHandle activeHandle = layoutManager.GetActiveHandle();
         if (!dataEntityCollection.TryGetComponent <SceneOwnerData>(activeHandle, out var component))
         {
             component = dataEntityCollection.AddComponent <SceneOwnerData>(activeHandle);
         }
         component.Name    = evt.RoomOwnerName;
         component.IsOwner = evt.IsRoomOwner;
         if (layoutManager.IsInOwnIgloo())
         {
             SavedIgloosMetaData savedIgloosMetaData = getSavedIgloosMetaData();
             if (savedIgloosMetaData.ActiveIglooId.HasValue)
             {
                 updateSavedIglooMetaData(savedIgloosMetaData.ActiveIglooId.Value, evt.ExtraLayoutData);
             }
             if (savedIgloosMetaData.IsFirstIglooLoad())
             {
                 layoutManager.AddNewActiveLayout();
                 savedIgloosMetaData.IglooVisibility = IglooVisibility.PUBLIC;
                 LocomotionActionEvent locomotionActionEvent = default(LocomotionActionEvent);
                 locomotionActionEvent.Type      = LocomotionAction.Move;
                 locomotionActionEvent.Position  = Vector3.zero;
                 locomotionActionEvent.Direction = Vector3.zero;
                 LocomotionActionEvent action = locomotionActionEvent;
                 networkServicesManager.PlayerActionService.LocomotionAction(action);
             }
             else
             {
                 layoutManager.CacheLayoutFromSceneLayout(savedIgloosMetaData.ActiveIglooId.Value, evt.ExtraLayoutData);
             }
         }
         else
         {
             layoutManager.CacheLayoutFromSceneLayout(0L, evt.ExtraLayoutData);
         }
         DataEntityHandle activeHandle2 = layoutManager.GetActiveHandle();
         stateListener = dataEntityCollection.Whenever <SceneStateData>(activeHandle2, onStateAdded, onStateRemoved);
     }
     return(false);
 }
Exemplo n.º 21
0
        private void onProximityListUpdate(BaseEvent evt)
        {
            RoomMember roomMember;

            foreach (User item in (List <User>)evt.Params["addedUsers"])
            {
                roomMember      = default(RoomMember);
                roomMember.Id   = getSessionId(item);
                roomMember.Name = item.Name;
                mt.triggerEvent(GameServerEvent.ROOM_USER_ADDED, roomMember);
                LocomotionActionEvent locomotionActionEvent = default(LocomotionActionEvent);
                locomotionActionEvent.SessionId = getSessionId(item);
                locomotionActionEvent.Type      = LocomotionAction.SnapToPosition;
                locomotionActionEvent.Position  = new Vector3(item.AOIEntryPoint.FloatX, item.AOIEntryPoint.FloatY, item.AOIEntryPoint.FloatZ);
                locomotionActionEvent.Direction = Vector3.zero;
                locomotionActionEvent.Timestamp = 0L;
                mt.triggerEvent(GameServerEvent.USER_LOCO_ACTION, locomotionActionEvent);
                broadcastUserVariables(item);
            }
            foreach (User item2 in (List <User>)evt.Params["removedUsers"])
            {
                roomMember      = default(RoomMember);
                roomMember.Id   = getSessionId(item2);
                roomMember.Name = item2.Name;
                mt.triggerEvent(GameServerEvent.ROOM_USER_REMOVED, roomMember);
                item2.UserManager.RemoveUser(item2);
            }
            foreach (IMMOItem item3 in (List <IMMOItem>)evt.Params["addedItems"])
            {
                CPMMOItem cPMMOItem = ItemFactory.Create(item3, getSessionId);
                mt.triggerEvent(GameServerEvent.SERVER_ITEM_ADDED, cPMMOItem);
                CPMMOItemPosition cPMMOItemPosition = default(CPMMOItemPosition);
                cPMMOItemPosition.Id       = cPMMOItem.Id;
                cPMMOItemPosition.Position = new Vector3(item3.AOIEntryPoint.FloatX, item3.AOIEntryPoint.FloatY, item3.AOIEntryPoint.FloatZ);
                mt.triggerEvent(GameServerEvent.SERVER_ITEM_MOVED, cPMMOItemPosition);
            }
            foreach (IMMOItem item4 in (List <IMMOItem>)evt.Params["removedItems"])
            {
                mt.triggerEvent(GameServerEvent.SERVER_ITEM_REMOVED, new CPMMOItemId(item4.Id, CPMMOItemId.CPMMOItemParent.WORLD));
            }
        }
Exemplo n.º 22
0
 private bool onFriendLocationReceived(FriendsServiceEvents.FriendLocationInRoomReceived evt)
 {
     dataEntityCollection.RemoveComponent <SpawnAtPlayerData>(dataEntityCollection.LocalPlayerHandle);
     Service.Get <EventDispatcher>().RemoveListener <FriendsServiceEvents.FriendLocationInRoomReceived>(onFriendLocationReceived);
     Service.Get <EventDispatcher>().RemoveListener <FriendsServiceEvents.FriendNotInRoom>(onFriendNotInRoom);
     if (!playerDataHandle.Handle.IsNull)
     {
         base.transform.position = evt.Location;
         LocomotionActionEvent action = default(LocomotionActionEvent);
         action.Type      = LocomotionAction.Move;
         action.Position  = base.transform.position;
         action.Direction = Vector3.zero;
         Service.Get <INetworkServicesManager>().PlayerActionService.LocomotionAction(action);
         BaseCamera baseCamera = ClubPenguin.Core.SceneRefs.Get <BaseCamera>();
         if (baseCamera != null)
         {
             baseCamera.Snap();
         }
         dataEntityCollection.RemoveComponent <SpawnAtPlayerData>(playerDataHandle.Handle);
     }
     return(false);
 }
Exemplo n.º 23
0
        private LocomotionActionEvent locomotionActionEventFromProps(int playerId, ISFSObject props)
        {
            LocomotionActionEvent result = default(LocomotionActionEvent);

            result.SessionId = getSessionId(playerId);
            result.Type      = (LocomotionAction)props.GetByte("a");
            result.Position  = SmartFoxGameServerClientShared.deserializeVec3(props, "p");
            result.Timestamp = props.GetLong("t");
            if (props.ContainsKey("d"))
            {
                result.Direction = SmartFoxGameServerClientShared.deserializeVec3(props, "d");
            }
            if (props.ContainsKey("v"))
            {
                result.Velocity = SmartFoxGameServerClientShared.deserializeVec3(props, "v");
            }
            if (props.ContainsKey("o"))
            {
                result.Object = mt.JsonService.Deserialize <ActionedObject>(props.GetUtfString("o"));
            }
            return(result);
        }
Exemplo n.º 24
0
    public void TriggerLocomotionAction(LocomotionActionEvent action, bool droppable)
    {
        Dictionary <string, SFSDataWrapper> dictionary = new Dictionary <string, SFSDataWrapper>();

        dictionary.Add("a", SmartFoxGameServerClientShared.serialize((byte)action.Type));
        dictionary.Add("p", SmartFoxGameServerClientShared.serialize(action.Position));
        dictionary.Add("t", SmartFoxGameServerClientShared.serialize(ServerTime));
        Dictionary <string, SFSDataWrapper> dictionary2 = dictionary;

        if (action.Direction.HasValue)
        {
            dictionary2.Add("d", SmartFoxGameServerClientShared.serialize(action.Direction.Value));
        }
        if (action.Velocity.HasValue)
        {
            dictionary2.Add("v", SmartFoxGameServerClientShared.serialize(action.Velocity.Value));
        }
        if (action.Object != null)
        {
            dictionary2.Add("o", SmartFoxGameServerClientShared.serialize(mt.JsonService.Serialize(action.Object)));
        }
        mt.send(SmartfoxCommand.LOCOMOTION_ACTION, dictionary2, null, droppable);
    }
Exemplo n.º 25
0
    private IEnumerator setPositionToSpawnPointWaitAFrame(SpawnPointSelector spawner)
    {
        base.transform.position = spawner.SelectSpawnPosition(CoordinateSpace.World);
        base.transform.rotation = spawner.SelectSpawnRotation(CoordinateSpace.World);
        yield return(null);

        LocomotionTracker tracker = ClubPenguin.SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponent <LocomotionTracker>();

        if (tracker != null)
        {
            tracker.SetCurrentController <RunController>();
        }
        base.transform.position = spawner.SelectSpawnPosition(CoordinateSpace.World);
        base.transform.rotation = spawner.SelectSpawnRotation(CoordinateSpace.World);
        yield return(null);

        LocomotionActionEvent movement = default(LocomotionActionEvent);

        movement.Type      = LocomotionAction.Move;
        movement.Position  = base.transform.position;
        movement.Direction = Vector3.zero;
        sendNetworkMessage(movement);
    }
Exemplo n.º 26
0
        public void OnPositionTimelineTriggerActionEvent(LocomotionActionEvent evt)
        {
            if (evt.Type != LocomotionAction.Interact || evt.Object == null || interactRequest.Active)
            {
                return;
            }
            switch (evt.Object.type)
            {
            case ObjectType.LOCAL:
            {
                GameObject gameObject = GameObject.Find(evt.Object.id);
                if (gameObject != null)
                {
                    RunActionGraph(gameObject);
                }
                break;
            }

            case ObjectType.SERVER:
            {
                long key = long.Parse(evt.Object.id);
                if (Service.Get <PropService>().propExperienceDictionary.ContainsKey(key))
                {
                    currentActionGraphGameObject = ActionSequencer.FindActionGraphObject(Service.Get <PropService>().propExperienceDictionary[key]);
                    interactRequest.Set();
                }
                break;
            }

            case ObjectType.PLAYER:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 27
0
        private void Update()
        {
            if (!receivingEnabled)
            {
                return;
            }
            switch (state)
            {
            case SyncState.IDLE:
                if (positionTimeline.Count > 0)
                {
                    desiredTargetEvent = positionTimeline.Peek();
                    snapIfNeeded(desiredTargetEvent.Position);
                    timer.Reset();
                    timer.Start();
                    state = SyncState.WAITING;
                }
                break;

            case SyncState.WAITING:
                if (timer.ElapsedMilliseconds > InterpolationDelay || positionTimeline.PeekLast().Timestamp - desiredTargetEvent.Timestamp >= InterpolationDelay)
                {
                    timer.Reset();
                    timer.Start();
                    switchToNextPosition();
                    motionSequenceStartTime = desiredStartEvent.Timestamp;
                }
                break;

            case SyncState.INTERPOLATION:
                if (!timeForPosition(desiredStartEvent, desiredTargetEvent))
                {
                    break;
                }
                triggerEventAction(desiredTargetEvent);
                if (positionTimeline.Count == 0)
                {
                    LocomotionController currentController = locomotionTracker.GetCurrentController();
                    if (currentController != null && !(currentController is SlideController))
                    {
                        currentController.Steer(lastStickDirection.normalized);
                    }
                    if (lastStickDirection == Vector3.zero)
                    {
                        timer.Stop();
                        state = SyncState.IDLE;
                    }
                    else
                    {
                        state = SyncState.EXTRAPOLATION;
                    }
                }
                else
                {
                    switchToNextPosition();
                }
                break;

            case SyncState.EXTRAPOLATION:
            {
                LocomotionController currentController = locomotionTracker.GetCurrentController();
                if (positionTimeline.Count == 0)
                {
                    if (timer.ElapsedMilliseconds > MaxExtrapolationTime)
                    {
                        if (currentController != null && !(currentController is SlideController))
                        {
                            currentController.Steer(Vector3.zero);
                        }
                        timer.Stop();
                        lastStickDirection = Vector3.zero;
                        state = SyncState.IDLE;
                    }
                }
                else
                {
                    desiredTargetEvent.Position  = ((currentController != null) ? currentController.GetPosition() : base.transform.position);
                    desiredTargetEvent.Timestamp = motionSequenceStartTime + timer.ElapsedMilliseconds;
                    switchToNextPosition();
                }
                break;
            }
            }
        }
Exemplo n.º 28
0
 public LocomotionActionReceived(long sessionId, LocomotionActionEvent action)
 {
     SessionId = sessionId;
     Action    = action;
 }
Exemplo n.º 29
0
 public void LocomotionAction(LocomotionActionEvent action, bool droppable = false)
 {
     clubPenguinClient.GameServer.TriggerLocomotionAction(action, droppable);
 }
Exemplo n.º 30
0
        private void onLocomotionAction(GameServerEvent gameServerEvent, object data)
        {
            LocomotionActionEvent action = (LocomotionActionEvent)data;

            Service.Get <EventDispatcher>().DispatchEvent(new PlayerActionServiceEvents.LocomotionActionReceived(action.SessionId, action));
        }