//系统会每帧调用这个函数
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            // ------- input handle ------
            if (Input.GetMouseButtonDown(0))
            {
                _isForceOn = true;
            }

            if (Input.GetMouseButtonUp(0))
            {
                _isForceOn = false;
            }
            _mousePos   = Camera.main.ScreenToWorldPoint(new float3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.transform.position.y));
            _mousePos.y = 0;
            // ------- end input handle ------


            //initial job
            var job = new JobProcess {
                isForceOn = _isForceOn, mousePosition = _mousePos, mouseMass = Mass
            };

            //schedule job
            return(job.Schedule(this, inputDeps));
        }
Exemple #2
0
        //系统会每帧调用这个函数
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            //初始化一个job
            var job = new JobProcess {
            };

            //开始job
            return(job.Schedule(this, inputDeps));
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var random = new Random(1);

            var job = new JobProcess {
                random = random,
            };

            return(job.Schedule(this, inputDeps));
        }
Exemple #4
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            //CommandBuff不支持burst,所以这里没有burst compiler
            EntityCommandBuffer.Concurrent entityCommandBuffer = barrier.CreateCommandBuffer().ToConcurrent();

            var job = new JobProcess {
                entityCommandBuffer = entityCommandBuffer
            };

            return(job.Schedule(this, inputDeps));
        }
Exemple #5
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            //Concurrent可以让ECB在job中使用。
            EntityCommandBuffer.Concurrent entityCommandBuffer = barrier.CreateCommandBuffer().ToConcurrent();

            var job = new JobProcess {
                entityCommandBuffer = entityCommandBuffer
            };

            return(job.Schedule(this, inputDeps));
        }
        //系统会每帧调用这个函数
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            UIManager.Instance.ChangeHomeHPText((int)_Group.home[0].health);

            //初始化一个job
            var job = new JobProcess {
                group = _Group
            };

            //开始job
            return(job.Schedule(this, inputDeps));
        }
Exemple #7
0
        //系统会每帧调用这个函数
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            //Cube计数
            UIManager.Instance.ChangeCubeNumText(_GroupCube.Cubes.Length);

            //初始化一个job
            var job = new JobProcess {
                group = _Group, groupLaser = _GroupLaser
            };

            //开始job
            return(job.Schedule(this, inputDeps));
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            EntityCommandBuffer.Concurrent entityCommandBuffer = barrier.CreateCommandBuffer().ToConcurrent();

            //初始化一个job
            var job = new JobProcess
            {
                entityCommandBuffer = entityCommandBuffer,
                deltaTime           = Time.deltaTime
            };

            //开始job
            return(job.Schedule(this, inputDeps));
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            EntityCommandBuffer.Concurrent entityCommandBuffer = barrier.CreateCommandBuffer().ToConcurrent();


            //初始化一个job
            var job = new JobProcess
            {
                entityCommandBuffer = entityCommandBuffer,
                results             = results
            };

            if (results == 1)
            {
                UIManager.Instance.ChangeHomeHPText(-1);
            }

            //开始job
            return(job.Schedule(this, inputDeps));
        }
Exemple #10
0
    //equivalent to Update method from MonoBehaviour.
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        while (_maxDistance == 0)
        {
            furthestMous = GetWorldPositionOnPlane(
                new Vector3(Camera.main.pixelWidth, Camera.main.pixelHeight, 0), 0);

            _maxDistance = math.length(furthestMous - Vector3.zero);
            Debug.Log(_maxDistance);
        }
        // ------- input handle ------
        //left - pull
        if (Input.GetMouseButtonDown(0))
        {
            _isForceOn = true;
            _forceMode = Forcefield.ForceMode.PULL;
        }

        if (Input.GetMouseButtonUp(0))
        {
            _isForceOn = false;
        }

        //right - push
        if (Input.GetMouseButtonDown(1))
        {
            _isForceOn = true;
            _forceMode = Forcefield.ForceMode.PUSH;
        }

        if (Input.GetMouseButtonUp(1))
        {
            _isForceOn = false;
        }

        mousePos   = GetWorldPositionOnPlane(Input.mousePosition, 0);
        mousePos.z = 0;
        // ------- end input handle ------

        //start a job for entity. you will access the properties of entity from here.
        //JobProcess is a struct that will implement the IJobProcessComponentData interface
        //job receives parameters and operates on data, similar to how a method call behaves.
        //you can not  have instance property or initializer inside a struct. You have to pass it from outside
        var job = new JobProcess {
            isForceOn     = _isForceOn,
            forceMode     = _forceMode,
            mousePosition = mousePos,


            deltaTime    = Time.deltaTime,
            freePos      = _freePos,
            isFreePosGot = _isFreePosGot,
            k            = _k,
            fric         = _fric,
            force        = _force,
            mVelocity    = _mVelocity,
            maxDistance  = _maxDistance
        };

        //start the job execution. This allows you to schedule a single job that runs
        //in parallel to other jobs and the main thread.
        return(job.Schedule(this, inputDeps));
    }
Exemple #11
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            ////鼠标检测
            //if (Input.GetMouseButtonDown(0))
            //{
            //    _isForceOn = true;
            //    _forceMode = ForceComponent.ForceMode.PULL;
            //}

            //if (Input.GetMouseButtonUp(0))
            //{
            //    _isForceOn = false;
            //}

            ////right - push
            //if (Input.GetMouseButtonDown(1))
            //{
            //    _isForceOn = true;
            //    _forceMode = ForceComponent.ForceMode.PUSH;
            //}

            //if (Input.GetMouseButtonUp(1))
            //{
            //    _isForceOn = false;
            //}

            //触屏检测
            if (Input.touchCount >= 1)
            {
                if (Input.touches[0].phase == TouchPhase.Stationary || Input.touches[0].phase == TouchPhase.Moved)
                {
                    _isForceOn = true;
                    _forceMode = ForceComponent.ForceMode.PULL;
                }

                if (Input.touches[0].phase == TouchPhase.Ended || Input.touches[0].phase == TouchPhase.Canceled)
                {
                    _isForceOn = false;
                }

                //right - push
                if (Input.touches[0].phase == TouchPhase.Began)
                {
                    _isForceOn = true;
                    _forceMode = ForceComponent.ForceMode.PUSH;
                }

                if (Input.touches[0].phase == TouchPhase.Ended || Input.touches[0].phase == TouchPhase.Canceled)
                {
                    _isForceOn = false;
                }
            }


            //mousePos = Camera.main.ScreenToWorldPoint(new float3(Input.touches[0].position.x, Input.touches[0].position.y,  248f/*Camera.main.transform.position.y*/));
            //mousePos.z = 248.0f;
            mousePos   = Camera.main.ScreenToWorldPoint(new float3(Input.mousePosition.x, Input.mousePosition.y, 248f /*Camera.main.transform.position.y*/));
            mousePos.z = 248.0f;


            //初始化一个job
            var job = new JobProcess {
                isForceOn = _isForceOn, forceMode = _forceMode, mousePosition = mousePos
            };

            //开始job
            return(job.Schedule(this, inputDeps));
        }
Exemple #12
0
        //系统会每帧调用这个函数
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
//#if UNITY_STANDALONE
            // ------- input handle ------
            //left - pull
            if (Input.GetMouseButtonDown(0))
            {
                _isForceOn = true;
                _forceMode = ForceComponent.ForceMode.PULL;
            }

            if (Input.GetMouseButtonUp(0))
            {
                _isForceOn = false;
            }

            //right - push
            if (Input.GetMouseButtonDown(1))
            {
                _isForceOn = true;
                _forceMode = ForceComponent.ForceMode.PUSH;
            }

            if (Input.GetMouseButtonUp(1))
            {
                _isForceOn = false;
            }

            if (Input.GetKey(KeyCode.W))
            {
                Camera.main.transform.SetPositionAndRotation(Camera.main.transform.position + Vector3.down * 5f, Camera.main.transform.rotation);
            }
            if (Input.GetKey(KeyCode.S))
            {
                Camera.main.transform.SetPositionAndRotation(Camera.main.transform.position + Vector3.up * 5f, Camera.main.transform.rotation);
            }
            mousePos   = Camera.main.ScreenToWorldPoint(new float3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.transform.position.y));
            mousePos.y = 0;
            // ------- end input handle ------
//#endif
#if UNITY_ANDROID
            if (Input.touchCount == 1)
            {
                if (Input.touches[0].phase == TouchPhase.Moved)
                {
                    _isForceOn = true;
                    mousePos   = Camera.main.ScreenToWorldPoint(new float3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, Camera.main.transform.position.y));
                    mousePos.y = 0;
                }
            }
            else
            {
                //_isForceOn = false;
            }
#endif


            //初始化一个job
            var job = new JobProcess {
                isForceOn = _isForceOn, forceMode = _forceMode, mousePosition = mousePos
            };

            //开始job
            return(job.Schedule(this, inputDeps));
        }