Esempio n. 1
0
 protected override void OnUpdate()
 {
     Entities.WithAll <CameraLink, Controller, Rotation>().ForEach((Entity e, ref CameraLink cameraLink, ref Controller controller, ref Rotation rotation) =>
     {
         if (controller.deviceID != 0)
         {
             if (World.EntityManager.Exists(cameraLink.camera))//CameraSystem.cameras.ContainsKey(cameraLink.cameraID))
             {
                 //Entity cameraEntity = CameraSystem.cameras[cameraLink.cameraID];
                 if (World.EntityManager.HasComponent <FirstPersonCamera>(cameraLink.camera))
                 {
                     FirstPersonCamera camera = World.EntityManager.GetComponentData <FirstPersonCamera>(cameraLink.camera);
                     if (camera.enabled == 1)
                     {
                         camera.rightStick = controller.Value.rightStick;
                         World.EntityManager.SetComponentData(cameraLink.camera, camera);
                         Rotation cameraRotation   = World.EntityManager.GetComponentData <Rotation>(cameraLink.camera);
                         float3 currentCameraEuler = new UnityEngine.Quaternion(cameraRotation.Value.value.x, cameraRotation.Value.value.y, cameraRotation.Value.value.z, cameraRotation.Value.value.w).eulerAngles;
                         float3 currentAngle       = new UnityEngine.Quaternion(rotation.Value.value.x, rotation.Value.value.y, rotation.Value.value.z, rotation.Value.value.w).eulerAngles;
                         currentAngle.y            = currentCameraEuler.y;
                         rotation.Value            = UnityEngine.Quaternion.Euler(currentAngle.x, currentAngle.y, currentAngle.z);
                     }
                 }
             }
         }
     });
 }
Esempio n. 2
0
        /* public void LoadGame()
         * {
         *   Entity character = Bootstrap.instance.GetPlayerMonster();
         *   LoadPlayer(character);
         * }*/

        /// <summary>
        /// Players can chose any  character in the save game folder - then it will be loaded from that
        /// </summary>
        public void LoadPlayer(Entity character)
        {
            ZoxID zoxID = EntityManager.GetComponentData <ZoxID>(character);

            LoadComponentData <Translation>(character, "Players", zoxID.id.ToString());
            LoadComponentData <Rotation>(character, "Players", zoxID.id.ToString());
            LoadComponentData <Inventory>(character, "Players", zoxID.id.ToString());
            LoadComponentData <Stats>(character, "Players", zoxID.id.ToString());
            LoadComponentData <Skills>(character, "Players", zoxID.id.ToString());
            LoadComponentData <Equipment>(character, "Players", zoxID.id.ToString());
            LoadComponentData <QuestLog>(character, "Players", zoxID.id.ToString());
            if (World.EntityManager.HasComponent <CameraLink>(character))
            {
                CameraLink cameraLink = EntityManager.GetComponentData <CameraLink>(character);
                Entity     camera     = cameraLink.camera;// CameraSystem.cameras[cameraLink.cameraID];
                LoadComponentData <FirstPersonCamera>(camera, "Players", zoxID.id.ToString());
                FirstPersonCamera firstPersonCamera = EntityManager.GetComponentData <FirstPersonCamera>(camera);
                firstPersonCamera.enabled = 1;
                EntityManager.SetComponentData(camera, firstPersonCamera);
            }
        }