示例#1
0
        private void Awake()
        {
            this.WarnIfMultipleInstances();

            _transform = this.transform;
            var rb = this.GetComponent <Rigidbody>();

            //Resolve the mover
            _mover = this.As <IMoveUnits>();
            if (_mover == null)
            {
                var fact           = this.As <IMoveUnitsFactory>();
                var charController = this.GetComponent <CharacterController>();

                if (fact != null)
                {
                    _mover = fact.Create();
                }
                else if (charController != null)
                {
                    _mover = new CharacterControllerMover(charController);
                }
                else if (rb != null)
                {
                    _mover = new RigidBodyMover(rb);
                }
                else
                {
                    _mover = new DefaultMover(_transform);
                }
            }

            //Make sure the rigidbody obeys the rules
            if (rb != null)
            {
                rb.constraints |= RigidbodyConstraints.FreezeRotation;
                rb.useGravity   = false;
            }

            //Height resolver
            _heights = GameServices.heightStrategy.heightSampler;

            //Assign unit ref, container for components and steering visitors
            _steeringComponents    = new List <ISteeringBehaviour>();
            _orientationComponents = new List <IOrientationBehaviour>();
            _steering      = new SteeringOutput();
            _orientation   = new OrientationOutput();
            _steeringInput = new SteeringInput();
        }
        private void Awake()
        {
            this.WarnIfMultipleInstances();

            _transform = this.transform;
            var rb = this.GetComponent <Rigidbody>();

            //Resolve the mover
            _mover = this.As <IMoveUnits>();
            if (_mover == null)
            {
                var fact           = this.As <IMoveUnitsFactory>();
                var charController = this.GetComponent <CharacterController>();

                if (fact != null)
                {
                    _mover = fact.Create();
                }
                else if (charController != null)
                {
                    _mover = new CharacterControllerMover(charController);
                }
                else if (rb != null)
                {
                    _mover = new RigidBodyMover(rb);
                }
                else
                {
                    _mover = new DefaultMover(_transform);
                }
            }

            //Height resolver
            _heights = this.As <IHeightNavigator>();
            if (_heights == null)
            {
                _heights = NoHeightNavigator.Instance;
            }

            //Assign unit ref, container for components and steering visitors
            _steeringComponents    = new List <ISteeringBehaviour>();
            _orientationComponents = new List <IOrientationBehaviour>();
            _steering      = new SteeringOutput();
            _orientation   = new OrientationOutput();
            _steeringInput = new SteeringInput();
        }
        private void Awake()
        {
            this.WarnIfMultipleInstances();

            _transform = this.transform;
            var rb = this.GetComponent<Rigidbody>();

            //Resolve the mover
            _mover = this.As<IMoveUnits>();
            if (_mover == null)
            {
                var fact = this.As<IMoveUnitsFactory>();
                var charController = this.GetComponent<CharacterController>();

                if (fact != null)
                {
                    _mover = fact.Create();
                }
                else if (charController != null)
                {
                    _mover = new CharacterControllerMover(charController);
                }
                else if (rb != null)
                {
                    _mover = new RigidBodyMover(rb);
                }
                else
                {
                    _mover = new DefaultMover(_transform);
                }
            }

            //Height resolver
            _heights = this.As<IHeightNavigator>();
            if (_heights == null)
            {
                _heights = NoHeightNavigator.Instance;
            }

            //Assign unit ref, container for components and steering visitors
            _steeringComponents = new List<ISteeringBehaviour>();
            _orientationComponents = new List<IOrientationBehaviour>();
            _steering = new SteeringOutput();
            _orientation = new OrientationOutput();
            _steeringInput = new SteeringInput();
        }
示例#4
0
 public abstract void GetOrientation(SteeringInput input, OrientationOutput output);
 /// <summary>
 /// Gets the orientation output.
 /// </summary>
 /// <param name="input">The steering input containing relevant information to use when calculating the orientation output.</param>
 /// <param name="output">The orientation output to be populated.</param>
 public abstract void GetOrientation(SteeringInput input, OrientationOutput output);
        private void Awake()
        {
            this.WarnIfMultipleInstances();

            _transform = this.transform;
            var rb = this.GetComponent<Rigidbody>();

            //Resolve the mover
            _mover = this.As<IMoveUnits>();
            if (_mover == null)
            {
                var fact = this.As<IMoveUnitsFactory>();
                var charController = this.GetComponent<CharacterController>();

                if (fact != null)
                {
                    _mover = fact.Create();
                }
                else if (charController != null)
                {
                    _mover = new CharacterControllerMover(charController);
                }
                else if (rb != null)
                {
                    _mover = new RigidBodyMover(rb);
                }
                else
                {
                    _mover = new DefaultMover(_transform);
                }
            }

            //Make sure the rigidbody obeys the rules
            if (rb != null)
            {
                rb.constraints |= RigidbodyConstraints.FreezeRotation;
                rb.useGravity = false;
            }

            //Height resolver
            _heights = GameServices.heightStrategy.heightSampler;

            //Assign unit ref, container for components and steering visitors
            _steeringComponents = new List<ISteeringBehaviour>();
            _orientationComponents = new List<IOrientationBehaviour>();
            _steering = new SteeringOutput();
            _orientation = new OrientationOutput();
            _steeringInput = new SteeringInput();
        }