Esempio n. 1
0
        public MoverSystem()
        {
            NodeFilter <ForwardMoverNode> .Setup(ForwardMoverNode.GetTypes());

            _forwardMovers = EntityController.GetNodeList <ForwardMoverNode>();
            NodeFilter <RotateToNode> .Setup(RotateToNode.GetTypes());

            _rotators = EntityController.GetNodeList <RotateToNode>();
            NodeFilter <SimpleMoverNode> .Setup(SimpleMoverNode.GetTypes());

            _simpleMovers = EntityController.GetNodeList <SimpleMoverNode>();
            NodeFilter <ArcMoverNode> .Setup(ArcMoverNode.GetTypes());

            _arcMovers = EntityController.GetNodeList <ArcMoverNode>();
        }
Esempio n. 2
0
        //private void HandleForwardTargetMover(ForwardTargetMover mover) {
        //    var entity = mover.GetEntity();
        //    if (!entity.Tags.Contain(EntityTags.Moving)) {
        //        return;
        //    }
        //    var target = entity.Get<MoveTarget>();
        //    if (target == null) {
        //        return;
        //    }
        //    var tr = entity.Tr;
        //    if (tr == null) {
        //        return;
        //    }
        //    var targetPos = target.GetTargetPosition;
        //    var dir = targetPos - tr.position;
        //    tr.position = Vector3.MoveTowards(tr.position, targetPos, mover.Get<MoveSpeed>()?.Speed ?? 1 * TimeManager.DeltaTime);
        //    var targetRotation = Quaternion.LookRotation(dir);
        //    tr.rotation = Quaternion.RotateTowards(tr.rotation, targetRotation, mover.Get<RotationSpeed>()?.Speed ?? 1 * TimeManager.DeltaTime);
        //    if (Vector3.Distance(targetPos, tr.position) < ReachedDestination) {
        //        FinishMove(entity, targetPos);
        //    }
        //}

        private void HandleArcMovement(ref ArcMoverNode mover)
        {
            var entity = mover.Entity;

            if (entity.IsDestroyed() || !entity.Tags.Contain(EntityTags.Moving))
            {
                return;
            }
            mover.ArcMover.ElapsedTime += TimeManager.DeltaTime;
            var dir = new Vector3(
                0, (mover.ArcMover.MoveVector.y - (mover.Get <MoveSpeed>()?.Speed ?? 1 * mover.ArcMover.ElapsedTime)) * TimeManager
                .DeltaTime, mover.ArcMover.MoveVector.z * TimeManager.DeltaTime);

            mover.Entity.Post(new MoveTransform(mover.Tr, dir));
            if (mover.ArcMover.ElapsedTime > mover.ArcMover.Duration)
            {
                FinishMove(entity, mover.Tr.position);
            }
        }