Esempio n. 1
0
    void SetOrientation(HorizontalDirection direction)
    {
        Vector3 scale = transform.localScale;

        scale.x *= (float)direction;
        transform.localScale = scale;
    }
    public void MoveHorizontal(HorizontalDirection direction, float plus = 0)
    {
        switch (direction)
        {
        case HorizontalDirection.None:
            Velocity = new Vector2(0, Velocity.y);
            break;

        case HorizontalDirection.Right:
            var transform1 = Transform;
            if (_ScaleHorizontal)
            {
                transform1.x    *= -1;
                Transform        = transform1;
                _ScaleHorizontal = false;
            }
            Velocity = new Vector2(Speed + plus, Velocity.y);
            break;

        case HorizontalDirection.Left:
            var transform2 = Transform;
            if (!_ScaleHorizontal)
            {
                transform2.x    *= -1;
                Transform        = transform2;
                _ScaleHorizontal = true;
            }
            Velocity = new Vector2(-(Speed + plus), Velocity.y);
            break;
        }
    }
        public Message()
        {
            this._headNumber    = 1;
            this._messageNumber = 1;
            this._messageTitle  = DateTime.Now.Ticks.ToString().Substring(0, 8);

            this._generalParametersPresent = true;
            this._messageTestPresent       = true;
            this._numberOfCounters         = 0;
            this._numberOfPostdates        = 0;
            this._presentTimeCodes         = false;
            this._numberOfBarcodes         = 0;

            this._messageDirection    = MessageDirection.Normal;
            this._horizontalDirection = HorizontalDirection.Normal;
            this._verticalDirection   = VerticalDirection.Normal;
            this._tachoMode           = TachoMode.No;
            this._manualTrigger       = ManualTrigger.Yes;
            this._triggerMode         = TriggerMode.Object;
            this._unitForMargins      = UnitForMargins.Millimeters;
            this._dinMode             = DINMode.No;

            this._mulitTopValue   = 0;
            this._objectTopFilter = 1;
            this._tachoDivision   = 1;
            this._forwardMargin   = 3;
            this._returnMargin    = 3;
            this._interval        = 3;
            this._printingSpeed   = 100;
            this._algorithmNumber = 0;

            this.Lines = new List <Line>();
        }
Esempio n. 4
0
        public Shelf(Vector2D pos, HorizontalDirection direction)
        {
            this.Components.Add(new Spatial(pos));
            this.Components.Add(new Physical()
            {
                GravityMultiplier = 0
            });

            double width  = 80;
            double height = 8;

            Rectangle platformBounds = new Rectangle(direction == HorizontalDirection.Right ? 0 : -width, 0, width, height);

            this.Components.Add(new RigidBody(new CollisionBox(platformBounds.X, platformBounds.Y, platformBounds.Width, platformBounds.Height)
            {
                LeftFaceProperties   = new CollisionFaceProperties(),
                RightFaceProperties  = new CollisionFaceProperties(),
                BottomFaceProperties = new CollisionFaceProperties()
            }));

            Rectangle platformVisibleBounds = platformBounds - new Vector2D(0, 9);

            platformVisibleBounds.Height += 9;

            this.Components.Add(new Renderable(new Sprite("lab_objects", platformVisibleBounds, platformVisibleBounds + new Vector2D(80, 73))));
            this.Components.Add(new LevelRenderable());
        }
Esempio n. 5
0
    private void AssignNewHead()
    {
        if (_centipedeTailsList.Count <= 0)
        {
            GameClient.Get <ICentipedeManager>().RemoveCentipede(this);
            _centipedeHead = null;
            return;
        }

        HorizontalDirection horizontalDirection = _centipedeHead.HorizontalDirection;
        VerticalDirection   verticalDirection   = _centipedeHead.VerticalDirection;

        // make next tail to new head
        CentipedeTail tail = _centipedeTailsList[0];

        tail.GetTailObject().name = "Head_" + CentipedeManager.CentipedeCount;

        _centipedeHead = new CentipedeHead();
        _centipedeHead.Init();
        _centipedeHead.SetNewHeadGameObject(tail.GetTailObject(), tail.LastPosition, horizontalDirection,
                                            verticalDirection);

        // remove this tail from tail list, because its a head now
        _centipedeTailsList.Remove(tail);

        //change indexing according to new head
        for (int i = 0; i < _centipedeTailsList.Count; i++)
        {
            _centipedeTailsList[i].AssignNewLeader(i == 0 ? (IBodyPart)_centipedeHead : _centipedeTailsList[i - 1], i);
            _centipedeTailsList[i].GetTailObject().name = "Head_" + CentipedeManager.CentipedeCount + "_tail_" + i;
        }
    }
        public Message()
        {
            this._headNumber = 1;
            this._messageNumber = 1;
            this._messageTitle = DateTime.Now.Ticks.ToString().Substring(0, 8);

            this._generalParametersPresent = true;
            this._messageTestPresent = true;
            this._numberOfCounters = 0;
            this._numberOfPostdates = 0;
            this._presentTimeCodes = false;
            this._numberOfBarcodes = 0;

            this._messageDirection = MessageDirection.Normal;
            this._horizontalDirection = HorizontalDirection.Normal;
            this._verticalDirection = VerticalDirection.Normal;
            this._tachoMode = TachoMode.No;
            this._manualTrigger = ManualTrigger.Yes;
            this._triggerMode = TriggerMode.Object;
            this._unitForMargins = UnitForMargins.Millimeters;
            this._dinMode = DINMode.No;

            this._mulitTopValue = 0;
            this._objectTopFilter = 1;
            this._tachoDivision = 1;
            this._forwardMargin = 3;
            this._returnMargin = 3;
            this._interval = 3;
            this._printingSpeed = 100;
            this._algorithmNumber = 0;

            this.Lines = new List<Line>();
        }
Esempio n. 7
0
    public virtual GameObject SpawnObject(Vector2 position, Vector2 offset, HorizontalDirection spawnDirection)
    {
        GameObject obj = Instantiate(objectToSpawn, new Vector2(position.x + offset.x * (float)spawnDirection,
                                                                position.y + offset.y * (float)verticalSpawnDirection), Quaternion.identity) as GameObject;

        return(obj);
    }
Esempio n. 8
0
 private void timerHorizontal_Tick(object sender, EventArgs e)
 {
     if (this._horizontalVerticalDirection == HorizontalDirection.Left)
     {
         if (this.buttonHorizontal.Left <= 0)
         {
             this._horizontalVerticalDirection = HorizontalDirection.Right;
             ++this.buttonHorizontal.Left;
         }
         else
         {
             --this.buttonHorizontal.Left;
         }
     }
     else
     {
         if (this.buttonHorizontal.Right >= this.ClientSize.Width)
         {
             this._horizontalVerticalDirection = HorizontalDirection.Left;
             --this.buttonHorizontal.Left;
         }
         else
         {
             ++this.buttonHorizontal.Left;
         }
     }
 }
 private bool CheckPointOneDimension(float point, float border, HorizontalDirection d)
 {
     if (d == HorizontalDirection.Left)
     {
         return(point <= border);
     }
     return(point >= border);
 }
Esempio n. 10
0
 public void Turn()
 {
     if (moving)
     {
         _horizontalDirection = (HorizontalDirection)((float)_horizontalDirection * -1);
         SetActiveTurnbox(_horizontalDirection);
     }
 }
Esempio n. 11
0
 public Renderer GetSideRenderer(HorizontalDirection side)
 {
     if (side == HorizontalDirection.Left)
     {
         return(LeftSide);
     }
     return(RightSide);
 }
Esempio n. 12
0
 public float GetGatePartXPositionForSize(HorizontalDirection side, float size)
 {
     if (side == HorizontalDirection.Left)
     {
         return(-size);
     }
     return(size);
 }
Esempio n. 13
0
 public Position(Vector2 coords, Vector2 halfsize, float angle, Vector2 origin, HorizontalDirection dir = HorizontalDirection.Right)
 {
     Coords         = coords;
     this.halfsize  = halfsize;
     RotationAngle  = angle;
     face_direction = dir;
     Origin         = origin;
 }
Esempio n. 14
0
 public void configure(float speed, HorizontalDirection direction, float moveDistance, float offset)
 {
     this.speed = speed;
     this.direction = direction;
     moveCycleEndPoint = transform.position + (Vector3.right * (float)direction * moveDistance);
     moveCycleStartPoint = transform.position;
     myRigidbody.MovePosition(transform.position + (Vector3.right * (float)direction * moveDistance * offset));
 }
Esempio n. 15
0
 public void SetAttributes(float moveSpeed, HorizontalDirection horizontalDirection, Rectangle destination)
 {
     position                 = new Vector2(destination.X, destination.Y);
     positionBackup           = position;
     width                    = destination.Width;
     this.moveSpeed           = moveSpeed;
     this.horizontalDirection = horizontalDirection;
 }
Esempio n. 16
0
 private void Initialize(IVisual spinningComponent, float angleAmount, HorizontalDirection direction, bool autoSpin = true, EventHandler onCicleCompleted = null)
 {
     this.spinningComponent = spinningComponent;
     this.angleAmount       = angleAmount;
     Direction             = direction;
     IsSpinning            = autoSpin;
     this.onCicleCompleted = onCicleCompleted;
 }
Esempio n. 17
0
 // used for from-position object initializers
 public Position(Position position)
 {
     Coords         = position.Coords;
     halfsize       = position.halfsize;
     Origin         = position.Origin;
     RotationAngle  = position.RotationAngle;
     face_direction = position.face_direction;
 }
Esempio n. 18
0
    public static HorizontalDirection Opposite(this HorizontalDirection direction)
    {
        switch (direction)
        {
        case HorizontalDirection.Left: return(HorizontalDirection.Right);

        default:                       return(HorizontalDirection.Left);
        }
    }
Esempio n. 19
0
        /// <summary>
        /// Moves the specified entity (given its ID) in the specified direction.
        /// </summary>
        public void Move(ulong id, HorizontalDirection direction)
        {
            Debug.Assert(Entities.ContainsKey(id));

            if (Entities.ContainsKey(id))
            {
                Physics.Move(Entities[id], direction);
            }
        }
Esempio n. 20
0
    void Update()
    {
        walkedDistanceH = Mathf.Abs(platformTransform.position.x - referencePingPongHPosition);


        walkedDistanceV = Mathf.Abs(platformTransform.position.y - referencePingPongVPosition);

        if (maxPingPong != -1 && walkedDistanceH >= maxPingPong)
        {
            if (wayH == HorizontalDirection.Left)
            {
                wayH = HorizontalDirection.Right;
            }
            else
            {
                wayH = HorizontalDirection.Left;
            }

            referencePingPongHPosition = platformTransform.position.x;
        }

        if (maxPingPong != -1 && walkedDistanceV >= maxPingPong)
        {
            if (wayV == VerticalDirection.Up)
            {
                wayV = VerticalDirection.Down;
            }
            else
            {
                wayV = VerticalDirection.Up;
            }

            referencePingPongVPosition = platformTransform.position.y;
        }


        if (wayH == HorizontalDirection.Left)
        {
            horizontalSpeed = -Mathf.Abs(horizontalSpeed);
        }
        else
        {
            horizontalSpeed = Mathf.Abs(horizontalSpeed);
        }


        if (wayV == VerticalDirection.Down)
        {
            verticalSpeed = -Mathf.Abs(verticalSpeed);
        }
        else
        {
            verticalSpeed = Mathf.Abs(verticalSpeed);
        }

        platformTransform.Translate(new Vector3(horizontalSpeed, verticalSpeed, 0) * Time.deltaTime);
    }
Esempio n. 21
0
    private void spawnEdgeTexture(HorizontalDirection horizontalDirection)
    {
        GameObject edgeInstance = spawnEdgeTexture();

        edgeInstance.GetComponent <EdgeTexture>().vertical            = false;
        edgeInstance.GetComponent <EdgeTexture>().horizontal          = true;
        edgeInstance.GetComponent <EdgeTexture>().horizontalDirection = horizontalDirection;
        edgeInstance.GetComponent <MaterialTiling>().xTile            = transform.localScale.y;
    }
Esempio n. 22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="direction">The direction in which the arrow points.</param>
 /// <param name="length">Total length of the arrow.</param>
 /// <param name="stemThickness">Thickness of the arrow's stem.</param>
 /// <param name="headBreadth">Maximum breadth of the arrow's head.</param>
 /// <param name="headLength">Length of the arrow's head, from tip to its widest part.</param>
 /// <param name="headRake">Distance from the widest part of the arrowhead to the (potentially hypothetical) point where the rear edges of the arrowhead
 ///   meet the centreline of the arrow.</param>
 public HorizontalArrow(HorizontalDirection direction, double length, double stemThickness, double headBreadth, double headLength, double headRake)
 {
     Direction     = direction;
     Length        = length;
     StemThickness = stemThickness;
     HeadBreadth   = headBreadth;
     HeadLength    = headLength;
     HeadRake      = headRake;
 }
        private void HorizontalMovementActivity()
        {
            float horizontalRatio = HorizontalRatio;


            if (horizontalRatio > 0)
            {
                mDirectionFacing = HorizontalDirection.Right;
            }
            else if (horizontalRatio < 0)
            {
                mDirectionFacing = HorizontalDirection.Left;
            }

            if (this.CurrentMovement.AccelerationTimeX <= 0)
            {
                this.XVelocity = horizontalRatio * CurrentMovement.MaxSpeedX;
            }
            else
            {
                float acceleration = CurrentMovement.MaxSpeedX / CurrentMovement.AccelerationTimeX;

                float sign      = Math.Sign(horizontalRatio);
                float magnitude = Math.Abs(horizontalRatio);

                if (sign == 0)
                {
                    sign      = -Math.Sign(XVelocity);
                    magnitude = 1;
                }

                if (XVelocity == 0 || sign == Math.Sign(XVelocity))
                {
                    this.XAcceleration = sign * magnitude * CurrentMovement.MaxSpeedX / CurrentMovement.AccelerationTimeX;
                }
                else
                {
                    float accelerationValue = magnitude * CurrentMovement.MaxSpeedX / CurrentMovement.DecelerationTimeX;


                    if (Math.Abs(XVelocity) < accelerationValue * TimeManager.SecondDifference)
                    {
                        this.XAcceleration = 0;
                        this.XVelocity     = 0;
                    }
                    else
                    {
                        // slowing down
                        this.XAcceleration = sign * accelerationValue;
                    }
                }

                XVelocity = Math.Min(XVelocity, CurrentMovement.MaxSpeedX);
                XVelocity = Math.Max(XVelocity, -CurrentMovement.MaxSpeedX);
            }
        }
 public MovingObject(string  path, Rectangle rectangle, int speed)
     : base(path, rectangle)
 {
     SetVelocity(speed);
     this.horizontalDirection = new HorizontalDirection();
     this.horizontalDirection = HorizontalDirection.NONE;
     this.verticalDirection = new VerticalDirection();
     this.verticalDirection = VerticalDirection.NONE;
     sourceRectangle = Rectangle.Empty;
 }
Esempio n. 25
0
        public void Attack(HorizontalDirection direction)
        {
            var originalDirection = _direction;

            Look(direction);
            Console.WriteLine("I did an attack.");
            var comboDirection = originalDirection == direction ? ComboDirection.Forward : ComboDirection.Back;

            _combo.Advance(comboDirection);
        }
Esempio n. 26
0
 /// <summary>
 /// Lays out elements flexibly, first horizontally, then vertically.
 /// </summary>
 /// <param name="Session">Current session</param>
 /// <param name="WidthLimit">Width limit of area</param>
 /// <param name="HorizontalDirection">Horizontal direction</param>
 /// <param name="VerticalDirection">Vertical direction</param>
 /// <param name="HorizontalAlignment">Horizontal alignment of cells in layout.</param>
 public FlexibleHorizontalCells(Variables Session, float WidthLimit,
                                HorizontalDirection HorizontalDirection, VerticalDirection VerticalDirection,
                                HorizontalAlignment HorizontalAlignment)
 {
     this.session             = Session;
     this.limitWidth          = WidthLimit;
     this.horizontalDirection = HorizontalDirection;
     this.verticalDirection   = VerticalDirection;
     this.horizontalAlignment = HorizontalAlignment;
 }
        public Particle(PlatformGame game, Vector2 position, HorizontalDirection horizontalDirection)
        {
            //spriteSheetInstance = new CustomSpriteSheetInstance(game.GameDataLoader.BulletImpactSpriteSheet, 2);

            Position            = position;
            HorizontalDirection = horizontalDirection;

            BoundingBox = new CustomBoundingBox();
            UpdateBoundingBox();
        }
        public Particle(PlatformGame game, Vector2 position, HorizontalDirection horizontalDirection)
        {
            //spriteSheetInstance = new CustomSpriteSheetInstance(game.GameDataLoader.BulletImpactSpriteSheet, 2);

            Position = position;
            HorizontalDirection = horizontalDirection;

            BoundingBox = new CustomBoundingBox();
            UpdateBoundingBox();
        }
Esempio n. 29
0
 public Position(Vector2 coords, Vector2 halfsize, float angle = 0, HorizontalDirection dir = HorizontalDirection.Right)
 {
     Coords         = coords;
     this.halfsize  = halfsize;
     RotationAngle  = angle;
     face_direction = dir;
     Origin         = Position.DefaultOrigin;
     // Origin = new Vector2(GameService.Instance.origin, GameService.Instance.origin);
     // Origin = Vector2.Zero;
 }
        public Projectile(PlatformGame game, string shooterName, Vector2 position, HorizontalDirection horizontalDirection)
        {
            this.game = game;

            Position = position;
            this.shooterName = shooterName;
            HorizontalDirection = horizontalDirection;

            BoundingBox = new CustomBoundingBox();
            UpdateBoundingBox();
        }
Esempio n. 31
0
 private HorizontalDirection GetOppositeDirection(HorizontalDirection dir)
 {
     if (dir == HorizontalDirection.Left)
     {
         return(HorizontalDirection.Right);
     }
     else
     {
         return(HorizontalDirection.Left);
     }
 }
 public void SetActiveTurnbox(HorizontalDirection direction)
 {
     if (direction == HorizontalDirection.LEFT)
     {
         turnbox.DeactivateRightmostBox();
     }
     else if (direction == HorizontalDirection.RIGHT)
     {
         turnbox.DeactiveLeftmostBox();
     }
 }
        public Projectile(PlatformGame game, string shooterName, Vector2 position, HorizontalDirection horizontalDirection)
        {
            this.game = game;

            Position            = position;
            this.shooterName    = shooterName;
            HorizontalDirection = horizontalDirection;

            BoundingBox = new CustomBoundingBox();
            UpdateBoundingBox();
        }
Esempio n. 34
0
        static public VectorF2 GetVectorF2(this HorizontalDirection item)
        {
            switch (item)
            {
            case HorizontalDirection.Right: return(VectorF2.RIGHT);

            case HorizontalDirection.Left: return(VectorF2.LEFT);
            }

            throw new UnaccountedBranchException("item", item);
        }
Esempio n. 35
0
        public static void DrawFlick(this DrawingContext dc, RectangleF rect, HorizontalDirection direction)
        {
            // 下の長方形
            using (var brush = new SolidBrush(dc.ColorProfile.Flick.DarkColor))
                using (var pen = new Pen(dc.ColorProfile.Flick.LightColor))
                {
                    float lineRate = 0.9f;
                    float centerY  = rect.Top + rect.Height / 2f;
                    dc.Graphics.FillRectangle(brush, rect);
                    dc.Graphics.DrawRectangle(pen, rect);
                    dc.Graphics.DrawLine(pen, new PointF(rect.Left + rect.Width * lineRate, centerY), new PointF(rect.Right - rect.Width * lineRate, centerY));
                }

            // 矢印
            // 一つの矢印を内包する原点中心のbox
            var box    = new RectangleF(-rect.Height * 1.2f, -rect.Height * 1.2f, rect.Height * 2.4f, rect.Height * 2.4f);
            var points = new PointF[]
            {
                new PointF(box.Left, 0),
                new PointF(0, box.Top),
                new PointF(box.Right, box.Top),
                new PointF(0, 0),
                new PointF(box.Right, box.Bottom),
                new PointF(0, box.Bottom)
            };

            using (var path = new GraphicsPath())
            {
                path.AddPolygon(points);
                var prevMatrix = dc.Graphics.Transform;
                var matrix     = prevMatrix.Clone();

                matrix.Translate(rect.Left + rect.Width / 2f, rect.Top + rect.Height / 2f + rect.Height * 2.1f);
                if (direction == HorizontalDirection.Right)
                {
                    matrix.Scale(-1, 1);
                }

                using (var brush = new SolidBrush(dc.ColorProfile.Flick.DarkColor))
                    using (var pen = new Pen(dc.ColorProfile.Flick.LightColor))
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            var arrowMatrix = matrix.Clone();
                            arrowMatrix.Translate((i - 1) * rect.Height * 2f, 0);
                            dc.Graphics.Transform = arrowMatrix;
                            dc.Graphics.FillPath(brush, path);
                            dc.Graphics.DrawPath(pen, path);
                        }
                    }

                dc.Graphics.Transform = prevMatrix;
            }
        }
 public void NoDirection(char direction)
 {
     switch (direction.ToString().ToUpper())
     {
         case "H":
         case"X":
             horizontalDirection = HorizontalDirection.NONE;
             break;
         case"Y":
         case"V":
             verticalDirection = VerticalDirection.NONE;
             break;
         case"A":
             verticalDirection = VerticalDirection.NONE;
             horizontalDirection = HorizontalDirection.NONE;
             break;
     }
 }
Esempio n. 37
0
 public void SetDirectionalMovement(HorizontalDirection h)
 {
     if (h != Player_ViewHDirection)
     {
         Player_ViewHDirection = h;
         FixWorldDirection();
     }
 }
Esempio n. 38
0
        /// <summary>
        /// Sets the Player_WorldDirection values (that is, directions in
        /// in-world coordinates) to what they are supposed to be, based
        /// on the Player_ViewDirection values (that is, directions on
        /// screen, corresponding to keyboard movement).
        /// </summary>
        private void FixWorldDirection()
        {
            switch (Player_ViewHDirection)
            {
                case HorizontalDirection.LEFT:
                    switch (Player_ViewVDirection)
                    {
                        case VerticalDirection.DOWN:
                            Player_WorldHDirection = HorizontalDirection.NEUTRAL;
                            Player_WorldVDirection = VerticalDirection.UP;
                            break;

                        case VerticalDirection.NEUTRAL:
                            Player_WorldHDirection = HorizontalDirection.LEFT;
                            Player_WorldVDirection = VerticalDirection.UP;
                            break;

                        case VerticalDirection.UP:
                            Player_WorldHDirection = HorizontalDirection.LEFT;
                            Player_WorldVDirection = VerticalDirection.NEUTRAL;
                            break;

                        default:
                            throw new NotImplementedException();
                    }
                    break;

                case HorizontalDirection.NEUTRAL:
                    switch (Player_ViewVDirection)
                    {
                        case VerticalDirection.DOWN:
                            Player_WorldHDirection = HorizontalDirection.RIGHT;
                            Player_WorldVDirection = VerticalDirection.UP;
                            break;

                        case VerticalDirection.NEUTRAL:
                            Player_WorldHDirection = HorizontalDirection.NEUTRAL;
                            Player_WorldVDirection = VerticalDirection.NEUTRAL;
                            break;

                        case VerticalDirection.UP:
                            Player_WorldHDirection = HorizontalDirection.LEFT;
                            Player_WorldVDirection = VerticalDirection.DOWN;
                            break;

                        default:
                            throw new NotImplementedException();
                    }
                    break;

                case HorizontalDirection.RIGHT:
                    switch (Player_ViewVDirection)
                    {
                        case VerticalDirection.DOWN:
                            Player_WorldHDirection = HorizontalDirection.RIGHT;
                            Player_WorldVDirection = VerticalDirection.NEUTRAL;
                            break;

                        case VerticalDirection.NEUTRAL:
                            Player_WorldHDirection = HorizontalDirection.RIGHT;
                            Player_WorldVDirection = VerticalDirection.DOWN;
                            break;

                        case VerticalDirection.UP:
                            Player_WorldHDirection = HorizontalDirection.NEUTRAL;
                            Player_WorldVDirection = VerticalDirection.DOWN;
                            break;

                        default:
                            throw new NotImplementedException();
                    }
                    break;

                default:
                    throw new NotImplementedException();
            }

            FixSourceRectangleInhabited();
        }
Esempio n. 39
0
 protected void UpdateRotation()
 {
   Quaternion rotation = this.CameraManager.Rotation;
   if (this.oldRotation == rotation && this.oldDirection == this.LookingDirection)
     return;
   this.oldRotation = rotation;
   this.oldDirection = this.LookingDirection;
   int num = -Math.Sign(FezMath.Dot(this.CameraManager.InverseView.Right, FezMath.Sign(this.Npc.DestinationOffset)));
   if (this.LookingDirection == HorizontalDirection.Left)
     num *= -1;
   if (num != 0)
     rotation *= FezMath.QuaternionFromPhi((float) (3.14159274101257 * ((double) num / 2.0 + 0.5)));
   this.Group.Rotation = rotation;
   if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint))
     return;
   this.InBackground = false;
   Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint);
   NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.Position, QueryOptions.Simple);
   TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep;
   if (trileInstance == null)
     return;
   Vector3 a = trileInstance.Center + trileInstance.TransformedSize / 2f * -b;
   this.InBackground = (double) FezMath.Dot(this.Position, b) > (double) FezMath.Dot(a, b);
 }
 public ShootMessage(string shooterName, Vector2 shotPosition, HorizontalDirection horizontalDirection)
 {
     ShooterName = shooterName;
     ShotPosition = shotPosition;
     HorizontalDirection = horizontalDirection;
 }
Esempio n. 41
0
 /// <summary>
 ///   Determines if two directions are opposite.
 /// </summary>
 /// <param name="a">The first direction.</param>
 /// <param name="b">The second direction.</param>
 /// <returns>
 ///   True if <paramref name="a" /> is in a different direction than
 ///   <paramref name="b" />.
 /// </returns>
 /// <remarks>
 ///   If either parameter is <see cref="HorizontalDirection.None" />, the
 ///   result is always False.
 /// </remarks>
 public static bool IsOppositeDirection(this HorizontalDirection a, HorizontalDirection b)
 {
     if (a == HorizontalDirection.None || b == HorizontalDirection.None) return false;
     else return a != b;
 }
 protected void MoveOnXAxis(bool negate = false)
 {
     int displacement =  xVelocity;
     if (negate)
     {
         horizontalDirection = HorizontalDirection.LEFT;
         displacement *=  -1;
     }
     else
     {
         horizontalDirection = HorizontalDirection.RIGHT;
     }
     X_Coordinate += displacement;
 }
 private static SpriteEffects GetSpriteEffects(HorizontalDirection horizontalDirection)
 {
     return horizontalDirection == HorizontalDirection.Right ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
 }
Esempio n. 44
0
 public override void Update(GameTime gameTime)
 {
   if (this.GameState.Loading || this.PlayerManager.Hidden || this.GameState.InCutscene)
     return;
   Vector3 position = this.PlayerManager.Position;
   if (!this.PlayerManager.CanControl)
   {
     this.InputManager.SaveState();
     this.InputManager.Reset();
   }
   if (this.CameraManager.Viewpoint != Viewpoint.Perspective && this.CameraManager.ActionRunning && (!this.GameState.InMenuCube && !this.GameState.Paused) && (this.CameraManager.RequestedViewpoint == Viewpoint.None && !this.GameState.InMap && !this.LevelManager.IsInvalidatingScreen))
   {
     if (ActionTypeExtensions.AllowsLookingDirectionChange(this.PlayerManager.Action) && !FezMath.AlmostEqual(this.InputManager.Movement.X, 0.0f))
     {
       this.oldLookDir = this.PlayerManager.LookingDirection;
       this.PlayerManager.LookingDirection = FezMath.DirectionFromMovement(this.InputManager.Movement.X);
     }
     Vector3 velocity = this.PlayerManager.Velocity;
     this.PhysicsManager.Update((IComplexPhysicsEntity) this.PlayerManager);
     if (this.PlayerManager.Grounded && this.PlayerManager.Ground.NearLow == null)
     {
       TrileInstance trileInstance = this.PlayerManager.Ground.FarHigh;
       Vector3 b = FezMath.RightVector(this.CameraManager.Viewpoint) * (float) FezMath.Sign(this.PlayerManager.LookingDirection);
       float num = FezMath.Dot(trileInstance.Center - trileInstance.TransformedSize / 2f * b - this.PlayerManager.Center + this.PlayerManager.Size / 2f * b, b);
       if ((double) num > -0.25)
       {
         this.PlayerManager.Position -= Vector3.UnitY * 0.01f * (float) Math.Sign(this.CollisionManager.GravityFactor);
         if (trileInstance.GetRotatedFace(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)) == CollisionType.AllSides)
         {
           this.PlayerManager.Position += num * b;
           this.PlayerManager.Velocity = velocity * Vector3.UnitY;
         }
         else
           this.PlayerManager.Velocity = velocity;
         this.PlayerManager.Ground = new MultipleHits<TrileInstance>();
       }
     }
     this.PlayerManager.RecordRespawnInformation();
     if (!ActionTypeExtensions.HandlesZClamping(this.PlayerManager.Action) && (this.oldLookDir != this.PlayerManager.LookingDirection || this.PlayerManager.LastAction == ActionType.RunTurnAround) && (this.PlayerManager.Action != ActionType.Dropping && this.PlayerManager.Action != ActionType.GrabCornerLedge && (this.PlayerManager.Action != ActionType.SuckedIn && this.PlayerManager.Action != ActionType.CrushVertical)) && this.PlayerManager.Action != ActionType.CrushHorizontal)
       this.CorrectWallOverlap(false);
   }
   if (this.PlayerManager.CarriedInstance != null && this.PlayerManager.Action != ActionType.Suffering)
   {
     this.PlayerManager.CarriedInstance.Position += this.PlayerManager.Position - position;
     this.LevelManager.UpdateInstance(this.PlayerManager.CarriedInstance);
   }
   if (this.PlayerManager.Grounded)
     this.PlayerManager.IgnoreFreefall = false;
   if (this.PlayerManager.Animation != null && this.lastFrame != this.PlayerManager.Animation.Timing.Frame)
   {
     if (this.PlayerManager.Grounded)
     {
       SurfaceType surfaceType = this.PlayerManager.Ground.First.Trile.SurfaceType;
       if (this.PlayerManager.Action == ActionType.Landing && this.PlayerManager.Animation.Timing.Frame == 0)
         this.PlaySurfaceHit(surfaceType, false);
       else if ((this.PlayerManager.Action == ActionType.PullUpBack || this.PlayerManager.Action == ActionType.PullUpFront || this.PlayerManager.Action == ActionType.PullUpCornerLedge) && this.PlayerManager.Animation.Timing.Frame == 5)
         this.PlaySurfaceHit(surfaceType, false);
       else if (ActionTypeExtensions.GetAnimationPath(this.PlayerManager.Action) == "Walk")
       {
         if (this.PlayerManager.Animation.Timing.Frame == 1 || this.PlayerManager.Animation.Timing.Frame == 4)
         {
           if (this.PlayerManager.Action != ActionType.Sliding)
           {
             SoundEffectExtensions.EmitAt(this.isLeft ? this.LeftStep : this.RightStep, this.PlayerManager.Position, RandomHelper.Between(-0.100000001490116, 0.100000001490116), RandomHelper.Between(0.899999976158142, 1.0));
             this.isLeft = !this.isLeft;
           }
           this.PlaySurfaceHit(surfaceType, false);
         }
       }
       else if (this.PlayerManager.Action == ActionType.Running)
       {
         if (this.PlayerManager.Animation.Timing.Frame == 0 || this.PlayerManager.Animation.Timing.Frame == 3)
           this.PlaySurfaceHit(surfaceType, true);
       }
       else if (this.PlayerManager.CarriedInstance != null)
       {
         if (ActionTypeExtensions.GetAnimationPath(this.PlayerManager.Action) == "CarryHeavyWalk")
         {
           if (this.PlayerManager.Animation.Timing.Frame == 0 || this.PlayerManager.Animation.Timing.Frame == 4)
             this.PlaySurfaceHit(surfaceType, true);
         }
         else if (ActionTypeExtensions.GetAnimationPath(this.PlayerManager.Action) == "CarryWalk" && (this.PlayerManager.Animation.Timing.Frame == 3 || this.PlayerManager.Animation.Timing.Frame == 7))
           this.PlaySurfaceHit(surfaceType, true);
       }
       else
         this.isLeft = false;
     }
     else
       this.isLeft = false;
     this.lastFrame = this.PlayerManager.Animation.Timing.Frame;
   }
   if (this.PlayerManager.CanControl)
     return;
   this.InputManager.RecoverState();
 }
Esempio n. 45
0
 /// <summary>
 /// Tries to move the agent in the specified horizontal and vertical direction using the specified CanAgentMoveBy method
 /// to check whether the agent can move in that direction from it's current position.
 /// </summary>
 /// <param name="hDir">Horizontal dir.</param>
 /// <param name="vDir">Vertical dir.</param>
 /// <param name="CanMove">Method that will be used to check whether the agent can move in that direction from it's current position.</param>
 public void Move(HorizontalDirection hDir, VerticalDirection vDir, CanAgentMoveByDelegate CanMove)
 {
     if(hDir == HorizontalDirection.None && vDir == VerticalDirection.None)
     {
         return;
     }
     int xInc = 0, yInc = 0, layerInc = 0;
     switch(hDir)
     {
     case HorizontalDirection.North:
         yInc = 1;
         break;
     case HorizontalDirection.NorthEast:
         yInc = 1;
         xInc = 1;
         break;
     case HorizontalDirection.East:
         xInc = 1;
         break;
     case HorizontalDirection.SouthEast:
         yInc = - 1;
         xInc = 1;
         break;
     case HorizontalDirection.South:
         yInc = - 1;
         break;
     case HorizontalDirection.SouthWest:
         yInc = - 1;
         xInc = - 1;
         break;
     case HorizontalDirection.West:
         xInc = - 1;
         break;
     case HorizontalDirection.NorthWest:
         yInc = 1;
         xInc = - 1;
         break;
     }
     switch(vDir)
     {
     case VerticalDirection.Up:
         layerInc = 1;
         break;
     case VerticalDirection.Down:
         layerInc = - 1;
         break;
     }
     // Call delegate method to determine if the agent can move to that cell
     int outX, outY, outLayer;
     if(CanMove(xInc, yInc, layerInc, out outX, out outY, out outLayer))
     {
         // Move to cell
         CellCoords += new GridPosition(outX, outY, outLayer);
         transform.position += new Vector3(outX * Grid.CellWidth, outY * Grid.CellDepth + outLayer * Grid.CellHeight, 0);
         rend.sortingOrder = CellCoords.Layer - CellCoords.Y;
     }
 }
Esempio n. 46
0
        public List<Sprite> GetCollision(List<Sprite> sprites)
        {
            List<Sprite> collisions = new List<Sprite>();
            correction = Vector2.Zero;
            this.IsCollided = false;
            GetBounds();

            foreach (Sprite sprite in sprites)
                if (sprite.IsSolid && this.IsCollidingWith(sprite))
                {

                    // The sprite is colliding
                    this.IsCollided = true;
                    collisions.Add(sprite);

                    // Gets the centers
                    Point center = this.bounds.Center;
                    Point spriteCenter = sprite.bounds.Center;
                    velocity = Vector2.Zero;

                    // Get the horizontal direction
                    if (center.X < spriteCenter.X)
                        horizontalDirection = HorizontalDirection.Left;
                    else if (center.X > spriteCenter.X)
                        horizontalDirection = HorizontalDirection.Right;
                    else
                        horizontalDirection = HorizontalDirection.Equal;
                    // Gets the vertical direction
                    if (center.Y < spriteCenter.Y)
                        verticalDirection = VerticalDirection.Up;
                    else if (center.Y > spriteCenter.Y)
                        verticalDirection = VerticalDirection.Below;
                    else
                        verticalDirection = VerticalDirection.Equal;

                    correction.X += (int)horizontalDirection;
                    correction.Y += (int)verticalDirection;
                }

            if (correction.X < 0)
                correction.X = (int)HorizontalDirection.Left;
            else if (correction.X > 0)
                correction.X = (int)HorizontalDirection.Right;
            else
                correction.X = (int)HorizontalDirection.Equal;

            if (correction.Y < 0)
                correction.Y = (int)VerticalDirection.Up;
            else if (correction.Y > 0)
                correction.Y = (int)VerticalDirection.Below;
            else
                correction.Y = (int)VerticalDirection.Equal;
            position += correction;
            return collisions;
        }
Esempio n. 47
0
 public override void Initialize()
 {
   if (this.initialized)
     return;
   this.LoadContent();
   this.Npc.Group = this.Group = this.LevelMaterializer.NpcMesh.AddFace(Vector3.One, Vector3.UnitY / 2f, FaceOrientation.Front, true, true);
   this.Group.Material = new Material();
   this.WalkStep = RandomHelper.Between(0.0, 1.0);
   this.LookingDirection = HorizontalDirection.Right;
   this.UpdatePath();
   this.OwlInvisible = !this.TimeManager.IsDayPhase(DayPhase.Night);
   this.Walk(TimeSpan.Zero);
   this.ToggleAction();
   this.CameraManager.ViewpointChanged += new Action(this.UpdateRotation);
   this.CameraManager.ViewpointChanged += new Action(this.UpdatePath);
   this.UpdateRotation();
   this.UpdateScale();
   this.SyncTextureMatrix();
   this.initialized = true;
 }
        protected void ChangeDirection(char axis)
        {
            string x = axis.ToString().ToUpper();
            switch (x)
            {
                case "X":
                    if (horizontalDirection == HorizontalDirection.LEFT)
                        horizontalDirection = HorizontalDirection.RIGHT;
                    else if(horizontalDirection == HorizontalDirection.RIGHT)
                        horizontalDirection = HorizontalDirection.LEFT;
                    break;

                case "Y":
                    if (verticalDirection == VerticalDirection.UP)
                        verticalDirection = VerticalDirection.DOWN;
                    else if(verticalDirection == VerticalDirection.DOWN)
                        verticalDirection = VerticalDirection.UP;
                    break;
            }
        }
        protected void ChangeDirection(VerticalDirection vertical = VerticalDirection.NONE, 
                                       HorizontalDirection horizontal = HorizontalDirection.NONE)
        {
            switch (horizontal)
            {
                case HorizontalDirection.LEFT:
                    horizontalDirection = HorizontalDirection.LEFT;
                    break;
                case HorizontalDirection.RIGHT:
                    horizontalDirection = HorizontalDirection.RIGHT;
                    break;
                default:
                    horizontalDirection = HorizontalDirection.NONE;
                    break;
            }

            switch (vertical)
            {
                case VerticalDirection.UP:
                    verticalDirection = VerticalDirection.UP;
                    break;

                case VerticalDirection.DOWN:
                    verticalDirection = VerticalDirection.DOWN;
                    break;

                default:
                    verticalDirection = VerticalDirection.NONE;
                    break;

            }
        }
		// ================================================================================
		//  private methods
		// --------------------------------------------------------------------------------

		// returns true when changed
		protected bool SetHorizontalInput(HorizontalDirection direction)
		{
			if (direction != _lastHorizontalDirection)
			{
				if (direction == HorizontalDirection.Left)
					InputLeft();
				else if (direction == HorizontalDirection.Right)
					InputRight();

				_lastHorizontalDirection = direction;

				return true;
			}

			return false;
		}
Esempio n. 51
0
        public void ClearDirectionalMovement()
        {
            Player_ViewHDirection = HorizontalDirection.NEUTRAL;
            Player_ViewVDirection = VerticalDirection.NEUTRAL;

            FixWorldDirection();
        }
		// ================================================================================
		//  private methods
		// --------------------------------------------------------------------------------

		protected void SetHorizontalInput(HorizontalDirection direction)
		{
			if (direction != _lastHorizontalDirection)
			{
				if (direction == HorizontalDirection.Left)
					InputLeft();
				else if (direction == HorizontalDirection.Right)
					InputRight();

				_lastHorizontalDirection = direction;
			}
		}
Esempio n. 53
0
 protected override void Begin()
 {
   this.originalLookingDirection = this.PlayerManager.LookingDirection;
   this.movementHelper.Entity = (IPhysicsEntity) this.PlayerManager;
 }
Esempio n. 54
0
 private void Turn()
 {
   this.LookingDirection = FezMath.GetOpposite(this.LookingDirection);
   this.UpdateRotation();
   this.CurrentAction = this.CanWalk ? NpcAction.Walk : NpcAction.Idle;
 }
Esempio n. 55
0
		/// <summary>
		/// Makes the specified entity move in a certain direction for the current frame.
		/// </summary>
		public void Move(IEntity entity, HorizontalDirection direction)
		{
			Debug.Assert(entity != null
			             && entity.Velocity != null);
			Debug.Assert(Utilities.MakeList(HorizontalDirection.Left, HorizontalDirection.None, HorizontalDirection.Right)
			             	.Contains(direction));

			if (direction != HorizontalDirection.None) { // we want to move
				Debug.Assert(Utilities.MakeList(HorizontalDirection.Left, HorizontalDirection.Right).Contains(direction));

				// Find in what direction we should apply the force
				float moveForce = (int)direction * entity.MoveSpeed;

				// Apply the movement
				entity.Velocity.X += moveForce;
			}
		}
        private void HorizontalMovementActivity()
        {
            float horizontalRatio = HorizontalRatio;


            if(horizontalRatio > 0)
            {
                mDirectionFacing = HorizontalDirection.Right;
            }
            else if(horizontalRatio < 0)
            {
                mDirectionFacing = HorizontalDirection.Left;
            }

            if (this.CurrentMovement.AccelerationTimeX <= 0)
            {
                this.XVelocity = horizontalRatio * CurrentMovement.MaxSpeedX;
            }
            else
            {
                float acceleration = CurrentMovement.MaxSpeedX / CurrentMovement.AccelerationTimeX;

                float sign = Math.Sign(horizontalRatio);
                float magnitude = Math.Abs(horizontalRatio);

                if(sign == 0)
                {
                    sign = -Math.Sign(XVelocity);
                    magnitude = 1;
                }

                if (XVelocity == 0 || sign == Math.Sign(XVelocity))
                {
                    this.XAcceleration = sign * magnitude * CurrentMovement.MaxSpeedX / CurrentMovement.AccelerationTimeX;
                }
                else
                {
                    float accelerationValue = magnitude * CurrentMovement.MaxSpeedX / CurrentMovement.DecelerationTimeX;


                    if (Math.Abs(XVelocity) < accelerationValue * TimeManager.SecondDifference)
                    {
                        this.XAcceleration = 0;
                        this.XVelocity = 0;
                    }
                    else
                    {

                        // slowing down
                        this.XAcceleration = sign * accelerationValue;
                    }

                }

                XVelocity = Math.Min(XVelocity, CurrentMovement.MaxSpeedX);
                XVelocity = Math.Max(XVelocity, -CurrentMovement.MaxSpeedX);
            }
        }
Esempio n. 57
0
        /// <summary>
        /// No longer moving :)
        /// </summary>
        private void ClearMovementDirections()
        {
            switch (GameMode)
            {
                case CowMouse.GameMode.ADVENTURE:
                    WorldManager.FollowTarget.ClearDirectionalMovement();
                    break;

                case CowMouse.GameMode.TOWN:
                    this.VerticalMovementDirection = VerticalDirection.NEUTRAL;
                    this.HorizontalMovementDirection = HorizontalDirection.NEUTRAL;
                    break;

                default:
                    throw new NotImplementedException();
            }
        }
Esempio n. 58
0
        private void SetDirectionalMovement(HorizontalDirection h)
        {
            switch (GameMode)
            {
                case CowMouse.GameMode.TOWN:
                    this.HorizontalMovementDirection = h;
                    break;

                case CowMouse.GameMode.ADVENTURE:
                    WorldManager.FollowTarget.SetDirectionalMovement(h);
                    break;

                default:
                    throw new NotImplementedException();
            }
        }