Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        handle.Complete();

        for (int i = 0; i < targets.Length; i++)
        {
            var targetPosition = targets[i].position;
            var direction      = Vector3.down;
            var command        = new RaycastCommand(targetPosition, direction);
            commands[i] = command;
        }

        //  移動的command 設定
        UpdatePosition updatePositionJob = new UpdatePosition()
        {
            raycastResults = results,
            objVelocitys   = velocities
        };

        ApplyPosition applyPosition = new ApplyPosition()
        {
            objVelocitys = velocities
        };

        var raycastJobHandle     = RaycastCommand.ScheduleBatch(commands, results, 20);
        var updatePositionHandle = updatePositionJob.Schedule(transformArray.length, 20, raycastJobHandle);

        handle = applyPosition.Schedule(transformArray, updatePositionHandle);
    }
Exemple #2
0
 void TimerCallback(Object o)
 {
     if (audioFile != null)
     {
         UpdatePosition.Invoke((int)audioFile.CurrentTime.TotalSeconds);
     }
 }
Exemple #3
0
    void Update()
    {
        float  deltaTime    = Time.fixedDeltaTime;
        float3 deltaGravity = deltaTime * GRAVITY;
        float  damping      = .98f;
        int    batchSize    = (int)Mathf.Pow(2, JOB_SIZE_POWER_OF_TWO);
        int    count        = atoms.Length;

        copyPositionFromTransformJob = new CopyPositionFromTransform
        {
            positions = positions
        };
        applyExternalForcesJob = new ApplyExternalForces
        {
            damping      = damping,
            deltaGravity = deltaGravity,
            velocities   = velocities
        };
        estimatePositionJob = new EstimatePosition
        {
            deltaTime  = deltaTime,
            velocities = velocities,
            positions  = positions,
            predicteds = predicteds
        };
        runSolverJob = new RunSolver
        {
            iterationCount      = ITERATION_COUNT,
            restPositions       = restPositions,
            predicteds          = predicteds,
            positionConstraints = positionConstraints,
            distanceConstraints = distanceConstraints,
            shapeConstraints    = shapeConstraints
        };
        updateVelocityJob = new UpdateVelocity
        {
            deltaTime  = deltaTime,
            velocities = velocities,
            positions  = positions,
            predicted  = predicteds
        };
        updatePositionJob = new UpdatePosition
        {
            deltaTime  = deltaTime,
            positions  = positions,
            predicteds = predicteds
        };
        copyPositionToTransformJob = new CopyPositionToTransform
        {
            positions = positions
        };

        copyPositionFromTransformJobHandle = copyPositionFromTransformJob.Schedule(transformAccessArray);
        applyExternalForcesJobHandle       = applyExternalForcesJob.Schedule(count, batchSize);
        estimatePositionJobHandle          = estimatePositionJob.Schedule(count, batchSize, JobHandle.CombineDependencies(applyExternalForcesJobHandle, copyPositionFromTransformJobHandle));
        runSolverJobHandle               = runSolverJob.Schedule(estimatePositionJobHandle);
        updateVelocityJobHandle          = updateVelocityJob.Schedule(count, batchSize, runSolverJobHandle);
        updatePositionJobHandle          = updatePositionJob.Schedule(count, batchSize, updateVelocityJobHandle);
        copyPositionToTransformJobHandle = copyPositionToTransformJob.Schedule(transformAccessArray, updatePositionJobHandle);
    }
    void Update()
    {
        handle.Complete();

        // Raycastの開始点と位置を設定
        for (int i = 0; i < transformArray.length; i++)
        {
            var targetPosition = transformArray[i].position;
            var direction      = Vector3.down;
            var command        = new RaycastCommand(targetPosition, direction);
            commands[i] = command;
        }

        // 移動のコマンドを設定
        UpdatePosition updatePositionJob = new UpdatePosition()
        {
            raycastResults = results,
            velocitys      = velocity
        };

        ApplyPosition applyPosition = new ApplyPosition()
        {
            velocitys = velocity
        };

        // 並列処理を実行(即完了待ち)
        // 終わったらコマンドに使ったバッファは不要なので破棄
        var raycastJobHandle     = RaycastCommand.ScheduleBatch(commands, results, 20);
        var updatePositionHandle = updatePositionJob.Schedule(transformArray.length, 20, raycastJobHandle);

        handle = applyPosition.Schedule(transformArray, updatePositionHandle);

        JobHandle.ScheduleBatchedJobs();
    }
Exemple #5
0
        public static UpdatePosition read(BinaryReader binaryReader)
        {
            UpdatePosition newObj = new UpdatePosition();

            newObj.object_id    = binaryReader.ReadUInt32();
            newObj.positionPack = PositionPack.read(binaryReader);
            return(newObj);
        }
Exemple #6
0
 public static Tuple <float, float, float, float> GetDeltas(this UpdatePosition position)
 {
     return(new Tuple <float, float, float, float>(
                position.DeltaY / 64f,
                position.DeltaZ / 64f,
                position.DeltaX / 64f,
                position.DeltaHeading / 64f / 255f
                ));
 }
Exemple #7
0
 public static Tuple <float, float, float, float> GetPositionHeading(this UpdatePosition position)
 {
     return(new Tuple <float, float, float, float>(
                position.Y / 8f,
                position.Z / 8f,
                position.X / 8f,
                position.Heading / 8f / 255f
                ));
 }
Exemple #8
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new UpdatePosition()
        {
            Positions = _data.Positions
        };

        return(job.Schedule(_data.Transforms, inputDeps));
    }
 public void SetupPositionDetails(int position, int linePosition)
 {
     WordUnderMouse = base.GetWordFromPosition(position);
     CharUnderMouse = (char)GetCharAt(position);
     LineNumber     = LineFromPosition(position);
     LinePosition   = Lines[LineNumber].Position;
     Column         = CurrentPosition - linePosition;
     UpdatePosition?.Invoke(this, EventArgs.Empty);
 }
Exemple #10
0
    void UpdatePositionHandle(object data)
    {
        string         jsonMsg = data.ToString();
        Message        msg     = JsonConvert.DeserializeObject <Message>(jsonMsg);
        UpdatePosition handle  = JsonConvert.DeserializeObject <UpdatePosition>(msg.jsonData);

        //Debug.Log("x: " + handle.x.ToString() + "; y:" + handle.y.ToString());

        updateEventCallbacks(handle.id, handle.x, handle.y);
    }
Exemple #11
0
        public static UpdatePosition read(BinaryReader binaryReader)
        {
            UpdatePosition newObj = new UpdatePosition();

            newObj.object_id = binaryReader.ReadUInt32();
            newObj.flags     = binaryReader.ReadUInt32();
            newObj.position  = Position.readOrigin(binaryReader);

            if ((newObj.flags & 0x8) == 0)
            {
                newObj.position.frame.qw = binaryReader.ReadSingle();
            }
            if ((newObj.flags & 0x10) == 0)
            {
                newObj.position.frame.qx = binaryReader.ReadSingle();
            }
            if ((newObj.flags & 0x20) == 0)
            {
                newObj.position.frame.qy = binaryReader.ReadSingle();
            }
            if ((newObj.flags & 0x40) == 0)
            {
                newObj.position.frame.qz = binaryReader.ReadSingle();
            }

            newObj.position.frame.cache();

            if ((newObj.flags & 0x1) != 0)
            {
                newObj.velocity = Vector3.read(binaryReader);
            }

            if ((newObj.flags & 0x2) != 0)
            {
                newObj.placement_id = binaryReader.ReadUInt32();
            }

            newObj.has_contact = (newObj.flags & 0x4) != 0;

            newObj.instance_timestamp       = binaryReader.ReadUInt16();
            newObj.position_timestamp       = binaryReader.ReadUInt16();
            newObj.teleport_timestamp       = binaryReader.ReadUInt16();
            newObj.force_position_timestamp = binaryReader.ReadUInt16();

            return(newObj);
        }
    private void performAction(WebSocketReceiveResult r, ArraySegment <byte> buffer)
    {
        String      bytesToString = Encoding.UTF8.GetString(buffer.Array, 0, r.Count);
        MessageType message       = JsonUtility.FromJson <MessageType>(bytesToString);

        Debug.Log(bytesToString);

        switch (message.action)
        {
        case GameConstants.UPDATE_POSITION:
            UpdatePosition position = JsonUtility.FromJson <UpdatePosition>(bytesToString);
            //"x" is the handler, y is the addiontal data you want to pass.
            updatePlayerPosition(position);
            Debug.Log(message.action);
            break;

        //Add the Player who is playing on his Client to the game.
        case GameConstants.PLAYER_JOINED:
            PlayerJoined playerJoined = JsonUtility.FromJson <PlayerJoined>(bytesToString);
            Debug.Log("Player joined!");
            this.playerControlledPrefab.name = PLAYER_PREFAB_OBJECT_NAME + playerJoined.id;
            this.playerControlledPrefab      = Instantiate(playerControlledPrefab, new Vector3(playerJoined.position.x, playerJoined.position.y, 0), Quaternion.identity);
            players.Add(playerJoined.id, this.playerControlledPrefab);
            fetchExistingPlayers();
            break;

        //Add New Players that are not the local player.
        case GameConstants.NEW_PLAYER_JOINED:
            PlayerJoined newPlayerJoined = JsonUtility.FromJson <PlayerJoined>(bytesToString);
            Debug.Log("New Player joined!");
            this.playerPrefab.name = PLAYER_PREFAB_OBJECT_NAME + newPlayerJoined.id;
            players.Add(newPlayerJoined.id, Instantiate(playerPrefab, new Vector3(newPlayerJoined.position.x, newPlayerJoined.position.y, 0), Quaternion.identity));
            break;

        case GameConstants.REMOVE_PLAYER:
            Debug.Log("Player Removed");
            removePlayer(message.id);
            break;

        default:
            break;
        }
    }
Exemple #13
0
        private void OnUpdatePosition(RpcArgs pArgs)
        {
            if (AttachedEntity == Entity.Null || AttachedManager == null || AttachedManager.EntityManager == null)
            {
                return;
            }

            //Read the position-data to update from the stream
            UpdatePosition updatePosition = new UpdatePosition()
            {
                send     = false,
                position = new float3(pArgs.GetNext <float>(), pArgs.GetNext <float>(), pArgs.GetNext <float>())
            };

            //Get the Buffer from our Entity
            DynamicBuffer <UpdatePositionBufferComponent> buffer = AttachedManager.EntityManager.GetBuffer <UpdatePositionBufferComponent>(AttachedEntity);

            //Add the UpdatePositionBufferComponent so it can be used by the appropriate system
            buffer.Add(new UpdatePositionBufferComponent()
            {
                Value = updatePosition
            });
        }
Exemple #14
0
    void Update()
    {
        // バッファの準備
        var commands = new NativeArray <RaycastCommand>(targets.Length, Allocator.TempJob);
        var results  = new NativeArray <RaycastHit>(targets.Length, Allocator.Temp);

        // Raycastの開始点と位置を設定
        for (int i = 0; i < targets.Length; i++)
        {
            var targetPosition = targets[i].position;
            var direction      = Vector3.down;
            var command        = new RaycastCommand(targetPosition, direction);
            commands[i] = command;
        }

        // 移動のコマンドを設定
        UpdatePosition updatePositionJob = new UpdatePosition()
        {
            raycastResults = results,
            velocitys      = velocity
        };


        // 並列処理を実行(即完了待ち)
        // 終わったらコマンドに使ったバッファは不要なので破棄
        var raycastJobHandle = RaycastCommand.ScheduleBatch(commands, results, 20);

        updatePositionJob.Schedule(targets.Length, 20, raycastJobHandle).Complete();

        commands.Dispose();
        results.Dispose();

        for (int i = 0; i < targets.Length; i++)
        {
            targets[i].localPosition += Vector3.up * velocity[i];
        }
    }
Exemple #15
0
    void Update()
    {
        handle.Complete();
        hitcheckHandle.Complete();

        this.transform.Rotate(0, 10f, 0);

        for (int i = 0; i < transformArray.length; i++)
        {
            var targetPosition = transformArray[i].position;
            var direction      = Vector3.down;
            var command        = new RaycastCommand(targetPosition, direction);
            commands[i] = command;
            gs[i].transform.Rotate(0, 10f, 0);
        }

        var updatePositionJob = new UpdatePosition()
        {
            raycastResults = results,
            velocitys      = velocity
        };

        var applyPosition = new ApplyPosition()
        {
            velocitys = velocity
        };

        var raycastJobHandle = RaycastCommand.ScheduleBatch(commands, results, 20);

        hitcheckHandle = hitCheckJob.Schedule(raycastJobHandle);
        var updatePositionHandle = updatePositionJob.Schedule(transformArray.length, 20, raycastJobHandle);

        handle = applyPosition.Schedule(transformArray, updatePositionHandle);

        JobHandle.ScheduleBatchedJobs();
    }
Exemple #16
0
        public void UpdatePosition(Position position, Account loginUser)
        {
            UpdatePosition updatePosition = new UpdatePosition(position, loginUser);

            updatePosition.Excute();
        }
Exemple #17
0
    public override bool acceptMessageData(BinaryReader messageDataReader, TreeView outputTreeView)
    {
        bool handled = true;

        PacketOpcode opcode = Util.readOpcode(messageDataReader);

        switch (opcode)
        {
        // TODO: PacketOpcode.Evt_Movement__PositionAndMovement_ID
        case PacketOpcode.Evt_Movement__Jump_ID: {
            Jump message = Jump.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Movement__MoveToState_ID: {
            MoveToState message = MoveToState.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Movement__DoMovementCommand_ID: {
            DoMovementCommand message = DoMovementCommand.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        // TODO: PacketOpcode.Evt_Movement__TurnEvent_ID
        // TODO: PacketOpcode.Evt_Movement__TurnToEvent_ID
        case PacketOpcode.Evt_Movement__StopMovementCommand_ID: {
            StopMovementCommand message = StopMovementCommand.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Movement__UpdatePosition_ID: {
            UpdatePosition message = UpdatePosition.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Movement__MovementEvent_ID: {
            MovementEvent message = MovementEvent.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Movement__AutonomyLevel_ID: {
            AutonomyLevel message = AutonomyLevel.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Movement__AutonomousPosition_ID: {
            AutonomousPosition message = AutonomousPosition.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Movement__Jump_NonAutonomous_ID: {
            Jump_NonAutonomous message = Jump_NonAutonomous.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        default: {
            handled = false;
            break;
        }
        }

        return(handled);
    }
    void updatePlayerPosition(UpdatePosition updatePosition)
    {
        GameObject playerPrefabToUpdate = players[updatePosition.position.id];

        ExecuteEvents.Execute <Movemement.MovemementEvents>(playerPrefabToUpdate, null, (x, y) => { x.updatePosition(updatePosition); });
    }
Exemple #19
0
 internal void RaiseUpdatePosition(ref Vector3 p) => UpdatePosition?.Invoke(p);