public void FixedUpdate()
    {
        if (GameController.Instance.IsPaused)
        {
            return;
        }

        Vector3 destination = LandingCoordinates;

        if (DestinationReached && !TradeCompleted)
        {
            return;
        }

        if (TradeCompleted)
        {
            destination = LeavingCoordinates;
        }

        float distance = Vector3.Distance(transform.position, destination);

        if (distance > DestinationReachedThreshold * TimeManager.Instance.TimeScale)
        {
            // rotate the model
            Vector3    vectorToTarget = destination - transform.position;
            float      angle          = (Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg) - 90;
            Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);
            transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * Speed * TimeManager.Instance.TimeScale);

            // Direction to the next waypoint
            Vector3 dir = (destination - transform.position).normalized;
            dir *= Speed * Time.fixedDeltaTime * TimeManager.Instance.TimeScale;

            transform.position = transform.position + dir;
            AnimationFlying.Update(Time.fixedDeltaTime);
            ShowSprite(AnimationFlying.CurrentFrameName);
        }
        else
        {
            DestinationReached = true;
            if (TradeCompleted)
            {
                Destroy(this.gameObject);
            }
            else
            {
                WorldController.Instance.TradeController.ShowTradeDialogBox(this);
                AnimationIdle.Update(Time.fixedDeltaTime);
                ShowSprite(AnimationIdle.CurrentFrameName);
            }
        }
    }
 public void InitializeAnimations()
 {
     AnimRun  = new AnimationRun(RunAnimation);
     AnimIdle = new AnimationIdle(IdleAnimation);
 }
Example #3
0
        public void Copy(EssentialsObject _object)
        {
            if (_object == null)
            {
                return;
            }

            base.Copy(_object);

            DefaultRunningSpeed = _object.DefaultRunningSpeed;
            DefaultWalkingSpeed = _object.DefaultWalkingSpeed;
            DefaultTurningSpeed = _object.DefaultTurningSpeed;

            IgnoreAnimationRun = _object.IgnoreAnimationRun;
            AnimationRun.Copy(_object.AnimationRun);

            IgnoreAnimationWalk = _object.IgnoreAnimationWalk;
            AnimationWalk.Copy(_object.AnimationWalk);

            IgnoreAnimationIdle = _object.IgnoreAnimationIdle;
            AnimationIdle.Copy(_object.AnimationIdle);

            IgnoreAnimationJump = _object.IgnoreAnimationJump;
            AnimationJump.Copy(_object.AnimationJump);

            IgnoreAnimationFall = _object.IgnoreAnimationFall;
            AnimationFall.Copy(_object.AnimationFall);

            IgnoreAnimationCrawlMove = _object.IgnoreAnimationCrawlMove;
            AnimationCrawlMove.Copy(_object.AnimationCrawlMove);

            IgnoreAnimationCrawlIdle = _object.IgnoreAnimationCrawlIdle;
            AnimationCrawlIdle.Copy(_object.AnimationCrawlIdle);

            IgnoreAnimationCrouchMove = _object.IgnoreAnimationCrouchMove;
            AnimationCrouchMove.Copy(_object.AnimationCrouchMove);

            IgnoreAnimationCrouchIdle = _object.IgnoreAnimationCrouchIdle;
            AnimationCrouchIdle.Copy(_object.AnimationCrouchIdle);

            IgnoreAnimationDead = _object.IgnoreAnimationDead;
            AnimationDead.Copy(AnimationDead);

            IgnoreAnimationAttack = _object.IgnoreAnimationAttack;
            AnimationAttack.Copy(_object.AnimationAttack);

            IgnoreAnimationImpact = _object.IgnoreAnimationImpact;
            AnimationImpact.Copy(_object.AnimationImpact);

            //MotionControl = _object.MotionControl;
            GroundOrientation = _object.GroundOrientation;

            TrophicLevel = _object.TrophicLevel;
            IsCannibal   = _object.IsCannibal;

            UseAutoDetectInteractors = _object.UseAutoDetectInteractors;

            Target.Copy(_object.Target);

            BehaviourFoldout        = _object.BehaviourFoldout;
            BehaviourModeTravel     = _object.BehaviourModeTravel;
            BehaviourModeLeisure    = _object.BehaviourModeLeisure;
            BehaviourModeRendezvous = _object.BehaviourModeRendezvous;

            BehaviourModeRun  = _object.BehaviourModeRun;
            BehaviourModeIdle = _object.BehaviourModeIdle;
            BehaviourModeWalk = _object.BehaviourModeWalk;

            BehaviourModeSpawn          = _object.BehaviourModeSpawn;
            BehaviourModeSpawnEnabled   = _object.BehaviourModeSpawnEnabled;
            BehaviourModeDead           = _object.BehaviourModeDead;
            BehaviourModeDeadEnabled    = _object.BehaviourModeDeadEnabled;
            BehaviourModeWait           = _object.BehaviourModeWait;
            BehaviourModeWaitEnabled    = _object.BehaviourModeWaitEnabled;
            BehaviourModeMounted        = _object.BehaviourModeMounted;
            BehaviourModeMountedEnabled = _object.BehaviourModeMountedEnabled;



            BehaviourModeJump         = _object.BehaviourModeJump;
            BehaviourModeJumpEnabled  = _object.BehaviourModeJumpEnabled;
            BehaviourModeFall         = _object.BehaviourModeFall;
            BehaviourModeFallEnabled  = _object.BehaviourModeFallEnabled;
            BehaviourModeSlide        = _object.BehaviourModeSlide;
            BehaviourModeSlideEnabled = _object.BehaviourModeSlideEnabled;
            BehaviourModeVault        = _object.BehaviourModeVault;
            BehaviourModeVaultEnabled = _object.BehaviourModeVaultEnabled;
            BehaviourModeClimb        = _object.BehaviourModeClimb;
            BehaviourModeClimbEnabled = _object.BehaviourModeClimbEnabled;
        }
Example #4
0
    public void SetIdleTimeOffset(float offset)
    {
        AnimationIdle Idle = (AnimationIdle)fsmSystem.GetState((int)AnimationState.Animation.Idle);

        Idle.SetIdleTimeOffset(offset);
    }