public override Vector3 GetAcceleration(MovementStatus status)
    {
        /*
         * bool HitWest = Physics.Raycast(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
         * bool HitFore = Physics.Raycast(transform.position, status.movementDirection, FieldOfViewRange, LayerMask);
         * bool HitEast = Physics.Raycast(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
         */

        bool HitWest, HitFore, HitEast;

        switch (SlotIndex)
        {
        case 2:
            HitWest = Physics.Raycast(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            HitFore = Physics.Raycast(transform.position, status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            HitEast = Physics.Raycast(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            break;

        case 1:
            HitWest = Physics.Raycast(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            HitFore = Physics.Raycast(transform.position, status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            HitEast = Physics.Raycast(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            break;

        default:
            HitWest = Physics.Raycast(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            HitFore = Physics.Raycast(transform.position, status.movementDirection, FieldOfViewRange, LayerMask);
            HitEast = Physics.Raycast(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            break;
        }

        Vector3 right = Quaternion.Euler(0f, 90f, 0f) * status.movementDirection.normalized;

        if (HitWest && !HitFore && !HitEast)
        {
            return(right * steer);
        }
        else if (HitWest && HitFore && !HitEast)
        {
            return(right * steer * 2f);
        }
        else if (HitWest && HitFore && HitEast)
        {
            return(-status.movementDirection.normalized * backpedal);
        }
        else if (!HitWest && HitFore && HitEast)
        {
            return(-right * steer * 2f);
        }
        else if (!HitWest && !HitFore && HitEast)
        {
            return(-right * steer);
        }
        else if (!HitWest && HitFore && !HitEast)
        {
            return(right * steer);
        }

        return(Vector3.zero);
    }
Example #2
0
    public void SetMovementStatus(MovementStatus movementStatus)
    {
        //keep movement to None if not in normal mode.
        if (GlobalGame.Instance.CurrentGameState != GlobalGame.GameState.Normal)
        {
            movementStatus = MovementStatus.None;
        }

        //if not changing to a new movement status then stop.
        if (movementStatus_ == movementStatus)
        {
            return;
        }

        movementStatus_ = movementStatus;

        switch (movementStatus_)
        {
        case MovementStatus.None:
            currentMovementSpeed_ = 0;
            break;

        case MovementStatus.Walk:
            currentMovementSpeed_ = walkSpeed_;
            break;
        }

        //Trigger OnMovementStatusChange event
        if (OnMovementStatusChange != null)
        {
            OnMovementStatusChange();
        }
    }
Example #3
0
    public override Vector3 GetAcceleration(MovementStatus status)
    {
        bool leftHit   = Physics.Raycast(transform.position, Quaternion.Euler(0f, -sightAngle, 0f) * status.movementDirection, sightRange);
        bool centerHit = Physics.Raycast(transform.position, status.movementDirection, sightRange);
        bool rightHit  = Physics.Raycast(transform.position, Quaternion.Euler(0f, sightAngle, 0f) * status.movementDirection, sightRange);

        Vector3 right = Quaternion.Euler(0f, 90f, 0f) * status.movementDirection.normalized;

        if (leftHit && !centerHit && !rightHit)
        {
            return(right * steer);
        }
        else if (leftHit && centerHit && !rightHit)
        {
            return(right * steer * 2f);
        }
        else if (leftHit && centerHit && rightHit)
        {
            return(-status.movementDirection.normalized * backpedal);
        }
        else if (!leftHit && centerHit && rightHit)
        {
            return(-right * steer * 2f);
        }
        else if (!leftHit && !centerHit && rightHit)
        {
            return(-right * steer);
        }
        else if (!leftHit && centerHit && !rightHit)
        {
            return(right * steer);
        }

        return(Vector3.zero);
    }
Example #4
0
    private void jump()
    {
        //canJump = Physics.OverlapSphere(groundCheckPoint.position, 0.25f, checkLayer).Length > 0; //method returns array of objects in sphere

        if (status == MovementStatus.normal)
        {
            canJump = overlapGrounded();
        }
        else
        {
            canJump = true;
        }

        if (Input.GetKeyDown(KeyCode.Space) && canJump)
        {
            transformValuesUsingInput.y = jumpForce;
            canJump    = false;                                 //once jumped, set to false
            doubleJump = true;                                  //enable double jump
            status     = MovementStatus.normal;                 //whenever a player jumps, return movement to normal (gravity, directional movement) e.g. on ladders etc
        }
        else if (Input.GetKeyDown(KeyCode.Space) && doubleJump) //will register as doubleJump is true into the next Update() frames?
        {
            transformValuesUsingInput.y = jumpForce * 1.1f;     //multiplied the jumpForce by 1.1f to add 10% extra force because it feels more natural in game
            doubleJump = false;                                 //after double jump, disable double jump
        }
    }
 private void Start()
 {
     status = new MovementStatus
     {
         movementDirection = transform.forward
     };
 }
 public MovementActionResult(int?x, int?y, FaceDirection facedirection, MovementStatus movementStatus)
 {
     LocationX = x;
     LocationY = y;
     Direction = facedirection;
     Status    = movementStatus;
 }
        public MovementStatusChange(MovementStatus status, User user)
        {
            Guard.ArgumentNotNull(() => user, user);

            User = user;
            Status = status;
            ChangeDate = new DateTimeOffset(SystemTime.UtcNow, TimeSpan.Zero);
        }
Example #8
0
 public void DownSpecialEnd()
 {
     isMetalForm = false;
     statusManager.RemoveStatus(downSpecialStatus);
     movementStatus = new MovementStatus(Vector2.zero, 20);
     statusManager.AddStatus(movementStatus);
     hurtbox.ResetSpriteColor();
 }
        public void CanOnlyComplete_FromReceived(MovementStatus status)
        {
            SetMovementStatus(status);

            Action complete = () => movement.CompleteInternally(Date, userId);

            Assert.Throws<InvalidOperationException>(complete);
        }
Example #10
0
        public MovementStatusChange(MovementStatus status, User user)
        {
            Guard.ArgumentNotNull(() => user, user);

            User       = user;
            Status     = status;
            ChangeDate = new DateTimeOffset(SystemTime.UtcNow, TimeSpan.Zero);
        }
Example #11
0
        /// <summary>
        /// Updates this sub-sprite.
        /// </summary>
        /// <param name="drawRec">The rectangle to draw in.</param>
        /// <param name="shapeStatus">The shape that the full sprite should take.</param>
        /// <param name="movementStatus">The direction the sprite is moving.</param>
        /// <param name="gameTime">For animation timers.</param>
        public void Update(Rectangle drawRec, ShapeStatus shapeStatus, MovementStatus movementStatus, GameTime gameTime)
        {
            // update and animate the base
            base.Update(drawRec, shapeStatus, gameTime);
            base.Animate(gameTime);

            // run animations
            Animate(movementStatus, gameTime);
        }
        private string GetMovementStatusText(MovementStatus status)
        {
            if (status == MovementStatus.Completed)
            {
                return NotificationType == NotificationType.Disposal ? "Disposed" : "Recovered";
            }

            return EnumHelper.GetDisplayName(status);
        }
Example #13
0
partial     void HandleW()
    {
        if(movementStatus == MovementStatus.STOPPED) {
            movementStatus = MovementStatus.MOVING;
            //movementDirection = MovementDirection.NORTH;
            movementVector = new Vector3(0, tileSize, 0);
            StartCoroutine(MovePlayer());
        }
    }
        private string GetMovementStatusText(MovementStatus status)
        {
            if (status == MovementStatus.Completed)
            {
                return(NotificationType == NotificationType.Disposal ? "Disposed" : "Recovered");
            }

            return(EnumHelper.GetDisplayName(status));
        }
Example #15
0
 public Movement(Vector2 origin, Vector2 destiny, float speed)
 {
     movementStatus = MovementStatus.StandBy;
     this.origin    = origin;
     this.position  = origin;
     this.destiny   = destiny;
     this.rawSpeed  = speed;
     Redefine();
 }
Example #16
0
        private void scroll(MovementStatus movementStatus, ref Rectangle mapView, ref List <Rectangle> cRectangles, ref List <Transition> transitions)
        {
            switch (movementStatus)
            {
            case MovementStatus.Up:
                mapView.Y += -spriteHeight;
                for (int i = 0; i < cRectangles.Count; i++)
                {
                    cRectangles[i] = new Rectangle(cRectangles[i].X, cRectangles[i].Y + spriteHeight, cRectangles[i].Width, cRectangles[i].Height);
                }
                for (int i = 0; i < transitions.Count; i++)
                {
                    transitions[i].tRect = new Rectangle(transitions[i].tRect.X, transitions[i].tRect.Y + spriteHeight, transitions[i].tRect.Width, transitions[i].tRect.Height);
                }
                break;

            case MovementStatus.Down:
                mapView.Y += spriteHeight;
                for (int i = 0; i < cRectangles.Count; i++)
                {
                    cRectangles[i] = new Rectangle(cRectangles[i].X, cRectangles[i].Y - spriteHeight, cRectangles[i].Width, cRectangles[i].Height);
                }
                for (int i = 0; i < transitions.Count; i++)
                {
                    transitions[i].tRect = new Rectangle(transitions[i].tRect.X, transitions[i].tRect.Y - spriteHeight, transitions[i].tRect.Width, transitions[i].tRect.Height);
                }
                break;

            case MovementStatus.Left:
                mapView.X += -spriteWidth;
                for (int i = 0; i < cRectangles.Count; i++)
                {
                    cRectangles[i] = new Rectangle(cRectangles[i].X + spriteWidth, cRectangles[i].Y, cRectangles[i].Width, cRectangles[i].Height);
                }
                for (int i = 0; i < transitions.Count; i++)
                {
                    transitions[i].tRect = new Rectangle(transitions[i].tRect.X + spriteWidth, transitions[i].tRect.Y, transitions[i].tRect.Width, transitions[i].tRect.Height);
                }
                break;

            case MovementStatus.Right:
                mapView.X += spriteWidth;
                for (int i = 0; i < cRectangles.Count; i++)
                {
                    cRectangles[i] = new Rectangle(cRectangles[i].X - spriteWidth, cRectangles[i].Y, cRectangles[i].Width, cRectangles[i].Height);
                }
                for (int i = 0; i < transitions.Count; i++)
                {
                    transitions[i].tRect = new Rectangle(transitions[i].tRect.X - spriteWidth, transitions[i].tRect.Y, transitions[i].tRect.Width, transitions[i].tRect.Height);
                }
                break;

            case MovementStatus.None:
                break;
            }
        }
Example #17
0
        public void Cancel()
        {
            if (!this.CancelEntryScopeIsValid())
            {
                return;
            }

            Canceled = DateTime.Now;
            Status   = MovementStatus.Canceled;
        }
        public async Task<IEnumerable<Movement>> GetMovementsByStatus(Guid notificationId, MovementStatus status)
        {
            await notificationAuthorization.EnsureAccessAsync(notificationId);

            return await context.Movements
                .Where(m =>
                    m.NotificationId == notificationId
                    && m.Status == status)
                .ToArrayAsync();
        }
        public async Task MovementStatusNotSubmitted_Throws(MovementStatus status)
        {
            var movement = new Movement(1, NotificationId, Today, AnyGuid);

            ObjectInstantiator <Movement> .SetProperty(x => x.Status, status, movement);

            var validDate = Today.AddDays(3);

            await Assert.ThrowsAsync <MovementDateException>(() =>
                                                             updatedDateValidator.EnsureDateValid(movement, validDate));
        }
Example #20
0
    private void Start()
    {
        agent = GetComponent <NavMeshAgent>();
        currentSatisfactionStatus = SatisfactionStatus.IDLE;
        currentMovementStatus     = MovementStatus.IDLE;
        currentSatisfier          = null;

        EntertainmentSatisfaction = 100f;
        FoodSatisfaction          = 100f;
        BathroomSatisfaction      = 100f;
    }
Example #21
0
    private Vector3 AvoidAcceleration(MovementStatus status)
    {
        CapsuleCollider coll = GetComponent <CapsuleCollider>();

        bool leftHit = Physics.CapsuleCast(coll.bounds.center,
                                           new Vector3(coll.bounds.center.x, coll.bounds.min.y, coll.bounds.center.z),
                                           coll.radius,
                                           Quaternion.Euler(0f, -sightAngle, 0f) * status.movementDirection,
                                           sightRange);

        bool centerHit = Physics.CapsuleCast(coll.bounds.center,
                                             new Vector3(coll.bounds.center.x, coll.bounds.min.y, coll.bounds.center.z),
                                             coll.radius,
                                             status.movementDirection,
                                             sightRange);

        bool rightHit = Physics.CapsuleCast(coll.bounds.center,
                                            new Vector3(coll.bounds.center.x, coll.bounds.min.y, coll.bounds.center.z),
                                            coll.radius,
                                            Quaternion.Euler(0f, sightAngle, 0f) * status.movementDirection,
                                            sightRange);

        Vector3 right = Quaternion.Euler(0f, 90f, 0f) * status.movementDirection.normalized;

        if (leftHit && !centerHit && !rightHit)
        {
            return(right * steer);
        }
        else if (leftHit && centerHit && !rightHit)
        {
            return(right * steer * 2f);
        }
        else if (leftHit && centerHit && rightHit)
        {
            return(-status.movementDirection.normalized * backpedal);
        }
        else if (!leftHit && centerHit && rightHit)
        {
            return(-right * steer * 2f);
        }
        else if (!leftHit && !centerHit && rightHit)
        {
            return(-right * steer);
        }
        else if (!leftHit && centerHit && !rightHit)
        {
            return(right * steer);
        }

        return(Vector3.zero);
    }
Example #22
0
    public override Vector3 GetAcceleration(MovementStatus status)
    {
        Collider collider = GetComponent <Collider> ();

        bool leftHit = Physics.BoxCast(transform.position,
                                       collider.bounds.extents,
                                       Quaternion.Euler(0f, -sightAngle, 0f) * status.movementDirection,
                                       transform.rotation,
                                       sightRange);

        bool centerHit = Physics.BoxCast(transform.position,
                                         collider.bounds.extents,
                                         status.movementDirection,
                                         transform.rotation,
                                         sightRange);

        bool rightHit = Physics.BoxCast(transform.position,
                                        collider.bounds.extents,
                                        Quaternion.Euler(0f, sightAngle, 0f) * status.movementDirection,
                                        transform.rotation,
                                        sightRange);

        Vector3 right = Quaternion.Euler(0f, 90f, 0f) * status.movementDirection.normalized;

        if (leftHit && !centerHit && !rightHit)
        {
            return(right * steer);
        }
        else if (leftHit && centerHit && !rightHit)
        {
            return(right * steer * 2f);
        }
        else if (leftHit && centerHit && rightHit)
        {
            return(-status.movementDirection.normalized * backpedal);
        }
        else if (!leftHit && centerHit && rightHit)
        {
            return(-right * steer * 2f);
        }
        else if (!leftHit && !centerHit && rightHit)
        {
            return(-right * steer);
        }
        else if (!leftHit && centerHit && !rightHit)
        {
            return(right * steer);
        }

        return(Vector3.zero);
    }
Example #23
0
    private void checkCollision()
    {
        int upperLayer = UpperCollisionScript.upperLayer;
        int lowerLayer = LowerCollisionScript.lowerLayer;

        if (upperLayer == 9)
        {
            status = MovementStatus.scale;
        }
        else // if (lowerLayer == 8)
        {
            status = MovementStatus.normal;
        }
    }
        private string DateValue(DateTime?date, MovementStatus status)
        {
            if (date.HasValue && status != MovementStatus.Cancelled)
            {
                return(date.Value.ToString("d MMM yyyy"));
            }

            if (status == MovementStatus.Cancelled)
            {
                return(string.Empty);
            }

            return("- -");
        }
 public Sequence()
 {
     seqNum            = 0;
     parentIdx         = null;
     childIdx          = null;
     animName          = "";
     parent            = "";
     closed            = 0;
     allowChildAnimAt  = 0;
     allowParentAnimAt = 1;
     minDeployLimit    = 0;
     lastAnimTime      = 0f;
     _mag           = null;
     movementStatus = MovementStatus.undef;
 }
Example #26
0
        //
        void MoveAlongPath()
        {
            if (WayPoints == null || CurrentPathStatus != PathRequestStatus.RecivedAndValid)
            {
                return;
            }

            switch (CurrentMovementStatus)
            {
            case MovementStatus.Idle:
                StopMovement();
                break;

            case MovementStatus.MovingToNextWapoint:

                switch (WaypointCheck(WaypointTolerence))
                {
                case WaypointStatus.AtTargetNode:
                    CurrentMovementStatus = MovementStatus.ArrivedAtTargetNode;
                    break;

                case WaypointStatus.AtWaypoint:
                    Debug.Log("Changing Waypoints");
                    ThisGCM.OccupiedNode = CurrentWaypoint;

                    if (CheckUpComingNodesForObstruction(5))
                    {
                        CurrentMovementStatus = MovementStatus.Idle;
                        return;
                    }

                    CurrentWaypoint       = WayPoints[CurrentWaypointIndex];
                    CurrentMovementStatus = MovementStatus.MovingToNextWapoint;
                    break;

                case WaypointStatus.BetweenWaypoints:
                    MoveToWaypoint();
                    break;
                }
                break;

            case MovementStatus.ArrivedAtTargetNode:
                StopMovement();
                ThisGCM.OccupiedNode = CurrentWaypoint;
                OnExitCommand();
                break;
            }
        }
    void OnDrawGizmos()
    {
        MovementStatus status = GetComponent <DelegatedSteering>().status;

        bool HitWest, HitFore, HitEast;

        switch (SlotIndex)
        {
        case 2:
            HitWest = Physics.Raycast(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            HitFore = Physics.Raycast(transform.position, status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            HitEast = Physics.Raycast(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            break;

        case 1:
            HitWest = Physics.Raycast(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            HitFore = Physics.Raycast(transform.position, status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            HitEast = Physics.Raycast(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange * FieldOfViewScale, LayerMask);
            break;

        default:
            HitWest = Physics.Raycast(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            HitFore = Physics.Raycast(transform.position, status.movementDirection, FieldOfViewRange, LayerMask);
            HitEast = Physics.Raycast(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection, FieldOfViewRange, LayerMask);
            break;
        }

        switch (SlotIndex)
        {
        case 2:
            Debug.DrawRay(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection * FieldOfViewRange * FieldOfViewScale, HitWest ? Color.red : Color.white);
            Debug.DrawRay(transform.position, status.movementDirection * FieldOfViewRange * FieldOfViewScale, HitFore ? Color.red : Color.white);
            Debug.DrawRay(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection * FieldOfViewRange, HitEast ? Color.red : Color.white);
            break;

        case 1:
            Debug.DrawRay(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection * FieldOfViewRange, HitWest ? Color.red : Color.white);
            Debug.DrawRay(transform.position, status.movementDirection * FieldOfViewRange * FieldOfViewScale, HitFore ? Color.red : Color.white);
            Debug.DrawRay(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection * FieldOfViewRange * FieldOfViewScale, HitEast ? Color.red : Color.white);
            break;

        default:
            Debug.DrawRay(transform.position, Quaternion.Euler(0, -FieldOfViewAngle, 0) * status.movementDirection * FieldOfViewRange, HitWest ? Color.red : Color.white);
            Debug.DrawRay(transform.position, status.movementDirection * FieldOfViewRange, HitFore ? Color.red : Color.white);
            Debug.DrawRay(transform.position, Quaternion.Euler(0, +FieldOfViewAngle, 0) * status.movementDirection * FieldOfViewRange, HitEast ? Color.red : Color.white);
            break;
        }
    }
Example #28
0
 //
 public void RecivePathRequest(PathRequest _CPR)
 {
     if (_CPR.PathIsFound == false)
     {
         CurrentPathStatus = PathRequestStatus.NoneRequested;
         StartCoroutine(Wait(0.25f));
         RequestPath(_CPR.StartingNode, _CPR.TargetNode, _CPR.Requestee);
     }
     else
     {
         WayPoints             = _CPR.CompletedPath;
         CurrentWaypoint       = WayPoints[0];
         CurrentPathStatus     = PathRequestStatus.RecivedAndValid;
         CurrentMovementStatus = MovementStatus.MovingToNextWapoint;
     }
 }
Example #29
0
        public void CanOnlyComplete_FromReceived(MovementStatus status)
        {
            movementForRecoveredTest = new TestableMovement
            {
                Id             = MovementId,
                Date           = Date,
                NotificationId = Guid.Empty,
                Receipt        = new MovementReceipt(Date, new ShipmentQuantity(10, ShipmentQuantityUnits.Kilograms), userId)
            };

            SetMovementStatusForRecovered(status);

            Action complete = () => movementForRecoveredTest.CompleteInternally(Date, userId);

            Assert.Throws <InvalidOperationException>(complete);
        }
Example #30
0
    private void UpdateSatisfiers()
    {
        if (currentSatisfier == null)
        {
            return;
        }

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

        // TODO: Move threhsold to local variable
        if (distance <= 0.1f)
        {
            currentSatisfier.QueueEmployee(this);
            currentMovementStatus = MovementStatus.SATISFYING;
        }
    }
    public override Vector3 GetAcceleration(MovementStatus status)
    {
        if (TargetPosition != null)
        {
            // TargetPosition = new Vector3(TargetPosition.x, transform.position.y, TargetPosition.z);
            Vector3 TargetPosition  = new Vector3(this.TargetPosition.position.x, transform.position.y, this.TargetPosition.position.z);
            Vector3 TargetDirection = TargetPosition - transform.position;

            float TargetDistance = TargetDirection.magnitude;

            if (TargetDistance > GoalRadius)
            {
                float speed;

                if (TargetDistance > SlowRadius)
                {
                    speed = MaxSpeed;
                }
                else
                {
                    speed = MaxSpeed * TargetDistance / SlowRadius;
                }

                Vector3 TargetVelocity    = speed * TargetDirection.normalized;
                Vector3 CharacterVelocity = status.linearSpeed * status.movementDirection;

                Vector3 LinearAcceleration = TargetVelocity - CharacterVelocity;
                LinearAcceleration /= TimeToTarget;

                if (LinearAcceleration.magnitude > MaxAcceleration)
                {
                    LinearAcceleration = MaxAcceleration * LinearAcceleration.normalized;
                }

                return(LinearAcceleration);
            }
            else
            {
                return(Vector3.zero);
            }
        }
        else
        {
            return(Vector3.zero);
        }
    }
Example #32
0
    private void Need(SatisfactionStatus need)
    {
        // Are we moving towards something? (AKA: Are we trying to satisfy a need?)
        if (currentMovementStatus == MovementStatus.MOVING || currentMovementStatus == MovementStatus.SATISFYING)
        {
            // Don't update anything.
            return;
        }

        // Set need, and move to the nearest satisfier
        currentSatisfactionStatus = need;

        // Do we need to work? if so, go to our station, no need to find nearest one.
        if (currentSatisfactionStatus == SatisfactionStatus.WORK)
        {
            if (Workstation == null)
            {
                // We didn't set workstation or it was removed...
                Debug.LogError("Workstation not found");
                currentMovementStatus = MovementStatus.CANT_REACH;
                return;
            }
            currentMovementStatus = MovementStatus.MOVING;
            currentSatisfier      = Workstation;
            MoveTo(Workstation.satisfierStandPlace.position);
            return;
        }

        // Find the nearest need satisfaction and go there
        NeedSatisfier satisfier = SatisfierLocationDictionary.Instance.GetNearestSatisfier(need, transform.position);

        if (satisfier == null)
        {
            // No satisfier available
            currentMovementStatus = MovementStatus.CANT_REACH;
            Debug.LogError("No Satisfier Available");
            FindObjectOfType <UIUpdater>().ShowHint("An employee can't reach location for " + need.ToString());
            Anger += 15;
            return;
        }

        currentMovementStatus = MovementStatus.MOVING;
        currentSatisfier      = satisfier;
        MoveTo(satisfier.waitingQueue.position);
    }
    public override Vector3 GetAcceleration(MovementStatus status)
    {
        if (destination != null)
        {
            Vector3 verticalAdj   = new Vector3(destination.position.x, transform.position.y, destination.position.z);
            Vector3 toDestination = (verticalAdj - transform.position);

            if (toDestination.magnitude > stopAt)
            {
                Vector3 tangentComponent = Vector3.Project(toDestination.normalized, status.movementDirection);
                Vector3 normalComponent  = (toDestination.normalized - tangentComponent);
                return((tangentComponent * (toDestination.magnitude > brakeAt ? gas : -brake)) + (normalComponent * steer));
            }
            else
            {
                return(Vector3.zero);
            }
        }
        else
        {
            return(Vector3.zero);
        }

        /*
         * if (position != Vector3.positiveInfinity)
         * {
         *  Vector3 verticalAdj = new Vector3(position.x, transform.position.y, position.z);
         *  Vector3 toDestination = (verticalAdj - transform.position);
         *
         *  if (toDestination.magnitude > stopAt)
         *  {
         *      Vector3 tangentComponent = Vector3.Project(toDestination.normalized, status.movementDirection);
         *      Vector3 normalComponent = (toDestination.normalized - tangentComponent);
         *      return (tangentComponent * (toDestination.magnitude > brakeAt ? gas : -brake)) + (normalComponent * steer);
         *  }
         *  else
         *  {
         *      return Vector3.zero;
         *  }
         * }
         *
         * return Vector3.zero;
         */
    }
Example #34
0
        public void MarkAsAccomplished()
        {
            Accomplished = DateTime.Now;
            Status       = MovementStatus.Accomplished;

            switch (TypeOfMovement)
            {
            case MovementType.Entry:
                Product.UpdateQuantityOnHand(Product.QuantityOnHand + Amount);
                break;

            case MovementType.Exit:
                Product.UpdateQuantityOnHand(Product.QuantityOnHand - Amount);
                break;

            default:
                throw new InvalidOperationException("Tipo de movimentação inválida");
            }
        }
    void ApplyGroundedAnimations()
    {
        var lastStatus = movementStatus;

        if (inputVelocity.x > 0)
        {
            movementStatus = MovementStatus.StrafeRight;
        }
        else if (inputVelocity.x < 0)
        {
            movementStatus = MovementStatus.StrafeLeft;
        }
        else if (inputVelocity.magnitude > 0)
        {
            movementStatus = MovementStatus.Run;
        }
        else
        {
            movementStatus = MovementStatus.Stand;
        }

        controlledUnit.Animator.SetBool("Grounded", true);

        float strafeTarget  = (Vector3.Normalize(inputVelocity).x + 1) / 2;
        float currentStrafe = controlledUnit.Animator.GetFloat("Strafe");
        float strafeDelta   = Time.deltaTime * 2 * Mathf.Sign(strafeTarget - currentStrafe);
        float resultStrafe  = Mathf.Clamp(currentStrafe + strafeDelta, 0.0f, 1.0f);

        if (Mathf.Abs(strafeTarget - currentStrafe) > Mathf.Abs(strafeDelta))
        {
            controlledUnit.Animator.SetFloat("Strafe", resultStrafe);
        }


        if (lastStatus == MovementStatus.StrafeLeft || lastStatus == MovementStatus.StrafeRight)
        {
            controlledUnit.Animator.SetFloat("Speed", 1);
        }
        else
        {
            controlledUnit.Animator.SetFloat("Speed", movementStatus == MovementStatus.Stand ? 0 : 1);
        }
    }
Example #36
0
 //
 void CheckForWayPointExistance()
 {
     if (CurrentWaypoint == null)
     {
         if (WayPoints != null)
         {
             if (WayPoints[CurrentWaypointIndex] != null)
             {
                 CurrentWaypoint = WayPoints[CurrentWaypointIndex];
             }
             else
             {
                 CurrentMovementStatus = MovementStatus.Idle;
             }
         }
         else
         {
             CurrentMovementStatus = MovementStatus.Idle;
         }
     }
 }
Example #37
0
        /// <summary>
        /// Mouth animation.
        /// </summary>
        /// <param name="movementStatus">Says whether or not this character is moving.</param>
        /// <param name="gameTime">The game time used to update the animation.</param>
        private void Animate(MovementStatus movementStatus, GameTime gameTime)
        {
            SetSprite();

            if (CurrentSpriteType == SpriteType.CHARly)
            {
                if (movementStatus != MovementStatus.Stationary)
                {
                    sourceRectangle.X = 0;
                }
                else
                {
                    sourceRectangle.X = BASE_WIDTH;
                }
            }

            else
            {
                sourceRectangle.X = 0;
            }
        }
Example #38
0
 public void OnCollisionEnter(Collision collision)
 {
     movementStatus = MovementStatus.COLLIDED;
 }
    public void Move(ConsoleKeyInfo pressedKey, GameField field)
    {
        if (pressedKey.Key == ConsoleKey.LeftArrow)
        {
            if (CurrentPositionX > 0)
            {
                if (currentPosition == CellStatus.Empty)
                {
                    this.lastPosition = CellStatus.Trail;
                }
                else if (currentPosition == CellStatus.Filled)
                {
                    this.lastPosition = CellStatus.Filled;
                }
                else if (currentPosition == CellStatus.Trail)
                {
                    this.lastPosition = currentPosition;
                }

                this.LastPositionX = this.CurrentPositionX;
                this.LastPositionY = this.CurrentPositionY;

                this.CurrentPositionX--;

                this.currentPosition = field.gameField[this.CurrentPositionY, this.CurrentPositionX];

                if (this.currentPosition == CellStatus.Empty && this.movement != MovementStatus.Left)
                {
                    this.movement = MovementStatus.Left;
                }
            }
        }
        else if (pressedKey.Key == ConsoleKey.RightArrow)
        {
            if (CurrentPositionX < field.width - 1)
            {
                if (currentPosition == CellStatus.Empty)
                {
                    this.lastPosition = CellStatus.Trail;
                }
                else if (currentPosition == CellStatus.Filled)
                {
                    this.lastPosition = CellStatus.Filled;
                }
                else if (currentPosition == CellStatus.Trail)
                {
                    this.lastPosition = currentPosition;
                }

                this.LastPositionX = this.CurrentPositionX;
                this.LastPositionY = this.CurrentPositionY;

                this.CurrentPositionX++;

                this.currentPosition = field.gameField[this.CurrentPositionY, this.CurrentPositionX];

                if (this.currentPosition == CellStatus.Empty && this.movement != MovementStatus.Right)
                {
                    this.movement = MovementStatus.Right;
                }
            }
        }
        else if (pressedKey.Key == ConsoleKey.UpArrow)
        {
            if (CurrentPositionY > 0)
            {
                if (currentPosition == CellStatus.Empty)
                {
                    this.lastPosition = CellStatus.Trail;
                }
                else if (currentPosition == CellStatus.Filled)
                {
                    this.lastPosition = CellStatus.Filled;
                }
                else if (currentPosition == CellStatus.Trail)
                {
                    this.lastPosition = currentPosition;
                }

                this.LastPositionX = this.CurrentPositionX;
                this.LastPositionY = this.CurrentPositionY;

                this.CurrentPositionY--;

                this.currentPosition = field.gameField[this.CurrentPositionY, this.CurrentPositionX];

                if (this.currentPosition == CellStatus.Empty && this.movement != MovementStatus.Up)
                {
                    this.movement = MovementStatus.Up;
                }
            }
        }
        else if (pressedKey.Key == ConsoleKey.DownArrow)
        {
            if (CurrentPositionY < field.height - 1)
            {
                if (currentPosition == CellStatus.Empty)
                {
                    this.lastPosition = CellStatus.Trail;
                }
                else if (currentPosition == CellStatus.Filled)
                {
                    this.lastPosition = CellStatus.Filled;
                }
                else if (currentPosition == CellStatus.Trail)
                {
                    this.lastPosition = currentPosition;
                }

                this.LastPositionX = this.CurrentPositionX;
                this.LastPositionY = this.CurrentPositionY;

                this.CurrentPositionY++;

                this.currentPosition = field.gameField[this.CurrentPositionY, this.CurrentPositionX];

                if (this.currentPosition == CellStatus.Empty && this.movement != MovementStatus.Down)
                {
                    this.movement = MovementStatus.Down;
                }
            }
        }

        if (this.lastPosition == CellStatus.Trail && field.gameField[this.CurrentPositionY, this.CurrentPositionX] == CellStatus.Filled)
        {
            field.isForFilling = true;
        }

        field.gameField[this.LastPositionY, this.LastPositionX] = this.lastPosition;
        field.gameField[this.CurrentPositionY, this.CurrentPositionX] = CellStatus.Head;
    }
Example #40
0
        /// <summary>
        /// Animate the shape (wiggle when moving, shape shift animation).
        /// </summary>
        /// <param name="movementStatus">The direction the shape is moving.</param>
        /// <param name="gameTime">For the ellapsed game time.</param>
        private void Animate(MovementStatus movementStatus, GameTime gameTime)
        {
            // Movement Animation
            movementTimer += gameTime.ElapsedGameTime.Milliseconds;
            if (movementTimer > MOVEMENT_UPDATE_TIME)
            {
                // reset the timer
                movementTimer = 0;

                // increment the frame
                iteration++;
                if (iteration >= maxIterations)
                {
                    iteration = 0;
                }

            }

            // check the movement state and update source rectangle
            if (movementStatus == MovementStatus.Stationary)
            {
                sourceRectangle.X = 0;
            }
            else
            {
                sourceRectangle.X = iteration * BASE_WIDTH;
            }
        }
 public MovementStatusChangeEvent(Movement movement, MovementStatus targetStatus)
 {
     TargetStatus = targetStatus;
     Movement = movement;
 }
        public void CannotCompleteNonReceivedMovement(MovementStatus status)
        {
            SetMovementStatus(status, movement);

            Assert.Throws<InvalidOperationException>(() => movement.Complete(AnyDate, AnyGuid, userId));
        }
Example #43
0
    private IEnumerator MovePlayer()
    {
        float moveTime = 0;
        Vector3 position = transform.localPosition;
        Vector3 destination = position + movementVector;

        while(moveTime < movementActionDuration && movementStatus != MovementStatus.ABORTED) {
            //if we've collided with something, abort the move and return to the start position
            if (movementStatus == MovementStatus.COLLIDED) {
                destination = position;
                position = transform.localPosition;
                movementStatus = MovementStatus.MOVING;
            }
            moveTime += Time.deltaTime;
            transform.localPosition = Vector3.Lerp(position, destination, moveTime / movementActionDuration);

            yield return new WaitForEndOfFrame();
        }

        if (movementStatus != MovementStatus.ABORTED)
            transform.localPosition = destination;

        movementSinceLastCombat++;
        movementStatus = MovementStatus.STOPPED;

        yield return new WaitForEndOfFrame();
        yield break;
    }
 private void SetMovementStatus(MovementStatus status, Movement movement)
 {
     ObjectInstantiator<Movement>.SetProperty(x => x.Status, status, movement);
 }
Example #45
0
        private void Animate(MovementStatus movementStatus, GameTime gameTime)
        {
            // if it's not moving, just use first frame of north eyes
            if (movementStatus == MovementStatus.Stationary)
            {
                // Stationary eyes
                SetPrefix();
                drawEyes = loadedEyes[currentPrefix + "EYEZNORTH"];
                sourceRectangle.X = 0;
            }
            else
            {
                // set the sub-sprite based on movement status
                SetSprite(movementStatus);

                // Movement Animation
                movementTimer += gameTime.ElapsedGameTime.Milliseconds;
                if (movementTimer > MOVEMENT_UPDATE_TIME)
                {
                    // reset the timer
                    movementTimer = 0;

                    // increment the frame
                    iteration++;
                    if (iteration >= maxIterations[currentPrefix])
                    {
                        iteration = 0;
                    }

                }

                // check the movement state and update source rectangle
                if (movementStatus == MovementStatus.Stationary)
                {
                    sourceRectangle.X = 0;
                }
                else
                {
                    sourceRectangle.X = iteration * BASE_WIDTH;
                }
            }
        }
        public void HasShipped_MovementNotSubmitted_ReturnsFalse(MovementStatus status)
        {
            ObjectInstantiator<Movement>.SetProperty(x => x.Status, status, movement);

            Assert.False(movement.HasShipped);
        }
Example #47
0
 public void AbortMove()
 {
     movementStatus = MovementStatus.ABORTED;
 }
Example #48
0
 /// <summary>
 /// Set the direction the eyes should face.
 /// </summary>
 /// <param name="movementStatus">The direction the eyes should point.</param>
 private void SetDirection(MovementStatus movementStatus)
 {
     // direction
     isFlipped = false;
     if (movementStatus == MovementStatus.North)
     {
         drawEyes = loadedEyes[currentPrefix + "EYEZNORTH"];
     }
     if (movementStatus == MovementStatus.NorthEast)
     {
         drawEyes = loadedEyes[currentPrefix + "EYEZNE"];
     }
     if (movementStatus == MovementStatus.East)
     {
         drawEyes = loadedEyes[currentPrefix + "EYEZEAST"];
     }
     if (movementStatus == MovementStatus.SouthEast)
     {
         drawEyes = loadedEyes[currentPrefix + "EYEZSE"];
     }
     if (movementStatus == MovementStatus.South)
     {
         drawEyes = loadedEyes[currentPrefix + "EYEZSOUTH"];
     }
     if (movementStatus == MovementStatus.SouthWest)
     {
         isFlipped = true;
         drawEyes = loadedEyes[currentPrefix + "EYEZSE"];
     }
     if (movementStatus == MovementStatus.West)
     {
         isFlipped = true;
         drawEyes = loadedEyes[currentPrefix + "EYEZEAST"];
     }
     if (movementStatus == MovementStatus.NorthWest)
     {
         isFlipped = true;
         drawEyes = loadedEyes[currentPrefix + "EYEZNE"];
     }
 }
Example #49
0
 private void MovementStart()
 {
     //controller = GetComponent<CharacterController>();
     movementStatus = MovementStatus.STOPPED;
 }
Example #50
0
        /// <summary>
        /// Takes the movement status and determines which eyes to use
        /// </summary>
        /// <param name="movementStatus"></param>
        private void SetSprite(MovementStatus movementStatus)
        {
            // set the prefix based on type
            SetPrefix();

            // set the direction for the eyes
            SetDirection(movementStatus);
        }
        public async Task MovementStatusNotSubmitted_Throws(MovementStatus status)
        {
            var movement = new Movement(1, NotificationId, Today, AnyGuid);
            ObjectInstantiator<Movement>.SetProperty(x => x.Status, status, movement);

            var validDate = Today.AddDays(3);

            await Assert.ThrowsAsync<MovementDateException>(() =>
                updatedDateValidator.EnsureDateValid(movement, validDate));
        }