예제 #1
0
        public void CloneFrom(IDefineSpeed speedComponent)
        {
            var c = speedComponent as OneSpeed;

            if (c != null)
            {
                this.speed = c.speed;
            }
        }
        public override void CloneFrom(IDefineSpeed speedComponent)
        {
            base.CloneFrom(speedComponent);

            var gs = speedComponent as GenericSpeedComponent;

            if (gs != null)
            {
                this.defaultSpeed = gs.defaultSpeed;
            }
        }
예제 #3
0
        /// <summary>
        /// Clones from the other component.
        /// </summary>
        /// <param name="speedComponent">The component to clone from</param>
        public override void CloneFrom(IDefineSpeed speedComponent)
        {
            base.CloneFrom(speedComponent);

            var hs = speedComponent as CarSpeedComponent;

            if (hs != null)
            {
                this.sidewaysSpeedFactor = hs.sidewaysSpeedFactor;
                this.reverseMaxSpeed     = hs.reverseMaxSpeed;
            }
        }
예제 #4
0
        public override void CloneFrom(IDefineSpeed speedComponent)
        {
            base.CloneFrom(speedComponent);

            var hs = speedComponent as HumanoidSpeedComponent;
            if (hs != null)
            {
                this.crawlSpeed = hs.crawlSpeed;
                this.crouchedSpeed = hs.crouchedSpeed;
                this.walkSpeed = hs.walkSpeed;
                this.runSpeed = hs.runSpeed;
                this.strafeMaxSpeed = hs.strafeMaxSpeed;
                this.backPedalMaxSpeed = hs.backPedalMaxSpeed;
            }
        }
예제 #5
0
        /// <summary>
        /// Clones from the other component.
        /// </summary>
        /// <param name="speedComponent">The component to clone from</param>
        public override void CloneFrom(IDefineSpeed speedComponent)
        {
            base.CloneFrom(speedComponent);

            var hs = speedComponent as HumanoidSpeedComponent;

            if (hs != null)
            {
                this.crawlSpeed        = hs.crawlSpeed;
                this.crouchedSpeed     = hs.crouchedSpeed;
                this.walkSpeed         = hs.walkSpeed;
                this.runSpeed          = hs.runSpeed;
                this.strafeMaxSpeed    = hs.strafeMaxSpeed;
                this.backPedalMaxSpeed = hs.backPedalMaxSpeed;
            }
        }
예제 #6
0
        /// <summary>
        /// Clones settings from another speed component.
        /// </summary>
        /// <param name="speedComponent">The speed component to clone from.</param>
        public virtual void CloneFrom(IDefineSpeed speedComponent)
        {
            this.maxAngularAcceleration = speedComponent.maxAngularAcceleration;
            this.maximumAngularSpeed    = speedComponent.maximumAngularSpeed;

            this.maxAcceleration = speedComponent.maxAcceleration;
            this.maxDeceleration = speedComponent.maxDeceleration;
            this.minimumSpeed    = speedComponent.minimumSpeed;
            this.maximumSpeed    = speedComponent.maximumSpeed;

            var sc = speedComponent as SpeedComponent;

            if (sc != null)
            {
                _preferredSpeed = sc._preferredSpeed;
            }
        }
예제 #7
0
        public virtual void Initialize(GameObject unitObject)
        {
            _props             = unitObject.As <IUnitProperties>(false, true);
            _movable           = unitObject.As <IMovable>(false, false);
            _moving            = unitObject.As <IMovingObject>(false, true);
            _speeder           = unitObject.As <IDefineSpeed>(false, true);
            _pathFinderOptions = unitObject.As <IPathFinderOptions>(false, false) ?? new PathFinderOptions();
            _pathNavOptions    = unitObject.As <IPathNavigationOptions>(false, false) ?? new PathNavigationOptions();

            this.isMovable = _movable != null;
            if (!this.isMovable)
            {
                _movable = new MovableDummy(unitObject.name);
            }

            this.gameObject = unitObject;
            this.transform  = unitObject.transform;
            this.collider   = unitObject.GetComponent <Collider>();
        }
        /// <summary>
        /// Initializes the Unit Facade.
        /// </summary>
        /// <param name="unitObject">The unit game object.</param>
        public virtual void Initialize(GameObject unitObject)
        {
            _props = unitObject.As<IUnitProperties>(false, true);
            _movable = unitObject.As<IMovable>(false, false);
            _moving = unitObject.As<IMovingObject>(false, true);
            _speeder = unitObject.As<IDefineSpeed>(false, true);
            _pathFinderOptions = unitObject.As<IPathFinderOptions>(false, false) ?? new PathFinderOptions();
            _pathNavOptions = unitObject.As<IPathNavigationOptions>(false, false) ?? new PathNavigationOptions();

            this.isMovable = _movable != null;
            if (!this.isMovable)
            {
                _movable = new MovableDummy(unitObject.name);
            }

            this.gameObject = unitObject;
            this.transform = unitObject.transform;
            this.collider = unitObject.GetComponent<Collider>();

            this.isAlive = true;
            this.hasArrivedAtDestination = true;
        }
 void IDefineSpeed.CloneFrom(IDefineSpeed speedComponent)
 {
     _speeder.CloneFrom(speedComponent);
 }
        /// <summary>
        /// Clones settings from another speed component.
        /// </summary>
        /// <param name="speedComponent">The speed component to clone from.</param>
        public virtual void CloneFrom(IDefineSpeed speedComponent)
        {
            this.maxAngularAcceleration = speedComponent.maxAngularAcceleration;
            this.maximumAngularSpeed = speedComponent.maximumAngularSpeed;

            this.maxAcceleration = speedComponent.maxAcceleration;
            this.maxDeceleration = speedComponent.maxDeceleration;
            this.minimumSpeed = speedComponent.minimumSpeed;
            this.maximumSpeed = speedComponent.maximumSpeed;

            var sc = speedComponent as SpeedComponent;
            if (sc != null)
            {
                _preferredSpeed = sc._preferredSpeed;
            }
        }
예제 #11
0
 void IDefineSpeed.CloneFrom(IDefineSpeed speedComponent)
 {
     _speeder.CloneFrom(speedComponent);
 }
예제 #12
0
 public void CloneFrom(IDefineSpeed speedComponent)
 {
     throw new NotImplementedException();
 }
예제 #13
0
 public void CloneFrom(IDefineSpeed speedComponent)
 {
     throw new NotImplementedException();
 }
예제 #14
0
        private void Awake()
        {
            this.WarnIfMultipleInstances();

            _transform = this.transform;
            _facingOrientation = new FacingOrientation
            {
                priority = this.turnRequestPriority,
                turnSpeed = this.turnSpeed
            };

            //Get the speed source
            _speedSource = this.As<IDefineSpeed>();
            if (_speedSource == null)
            {
                Debug.LogError("A speed source component is required to steer.");
                this.enabled = false;
            }

            //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 (this.rigidbody != null)
                {
                    _mover = new RigidBodyMover(_transform, this.rigidbody);
                }
                else
                {
                    _mover = new DefaultMover(_transform);
                }
            }

            _unit = this.GetComponent<UnitComponent>();
            _steeringComponents = new List<SteeringComponent>();
            _minimumSpeedToTurnSquared = this.minimumSpeedToTurn * this.minimumSpeedToTurn;
            _stopped = true;
        }