コード例 #1
0
    void SetOrientation(HorizontalDirection direction)
    {
        Vector3 scale = transform.localScale;

        scale.x *= (float)direction;
        transform.localScale = scale;
    }
コード例 #2
0
    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;
        }
    }
コード例 #3
0
        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>();
        }
コード例 #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());
        }
コード例 #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;
        }
    }
コード例 #6
0
        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>();
        }
コード例 #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);
    }
コード例 #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;
         }
     }
 }
コード例 #9
0
 private bool CheckPointOneDimension(float point, float border, HorizontalDirection d)
 {
     if (d == HorizontalDirection.Left)
     {
         return(point <= border);
     }
     return(point >= border);
 }
コード例 #10
0
 public void Turn()
 {
     if (moving)
     {
         _horizontalDirection = (HorizontalDirection)((float)_horizontalDirection * -1);
         SetActiveTurnbox(_horizontalDirection);
     }
 }
コード例 #11
0
 public Renderer GetSideRenderer(HorizontalDirection side)
 {
     if (side == HorizontalDirection.Left)
     {
         return(LeftSide);
     }
     return(RightSide);
 }
コード例 #12
0
 public float GetGatePartXPositionForSize(HorizontalDirection side, float size)
 {
     if (side == HorizontalDirection.Left)
     {
         return(-size);
     }
     return(size);
 }
コード例 #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;
 }
コード例 #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));
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #18
0
ファイル: Direction.cs プロジェクト: decax/multilang_pong
    public static HorizontalDirection Opposite(this HorizontalDirection direction)
    {
        switch (direction)
        {
        case HorizontalDirection.Left: return(HorizontalDirection.Right);

        default:                       return(HorizontalDirection.Left);
        }
    }
コード例 #19
0
ファイル: MatchState.cs プロジェクト: DrPandemic/EraParadox
        /// <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);
            }
        }
コード例 #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);
    }
コード例 #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;
    }
コード例 #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;
 }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
 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;
 }
コード例 #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);
        }
コード例 #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;
 }
コード例 #27
0
        public Particle(PlatformGame game, Vector2 position, HorizontalDirection horizontalDirection)
        {
            //spriteSheetInstance = new CustomSpriteSheetInstance(game.GameDataLoader.BulletImpactSpriteSheet, 2);

            Position            = position;
            HorizontalDirection = horizontalDirection;

            BoundingBox = new CustomBoundingBox();
            UpdateBoundingBox();
        }
コード例 #28
0
        public Particle(PlatformGame game, Vector2 position, HorizontalDirection horizontalDirection)
        {
            //spriteSheetInstance = new CustomSpriteSheetInstance(game.GameDataLoader.BulletImpactSpriteSheet, 2);

            Position = position;
            HorizontalDirection = horizontalDirection;

            BoundingBox = new CustomBoundingBox();
            UpdateBoundingBox();
        }
コード例 #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;
 }
コード例 #30
0
        public Projectile(PlatformGame game, string shooterName, Vector2 position, HorizontalDirection horizontalDirection)
        {
            this.game = game;

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

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

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

            BoundingBox = new CustomBoundingBox();
            UpdateBoundingBox();
        }
コード例 #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);
        }
コード例 #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;
            }
        }
コード例 #36
0
 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;
     }
 }
コード例 #37
0
ファイル: Person.cs プロジェクト: rodya-mirov/Cow-Mouse
 public void SetDirectionalMovement(HorizontalDirection h)
 {
     if (h != Player_ViewHDirection)
     {
         Player_ViewHDirection = h;
         FixWorldDirection();
     }
 }
コード例 #38
0
ファイル: Person.cs プロジェクト: rodya-mirov/Cow-Mouse
        /// <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();
        }
コード例 #39
0
ファイル: NpcState.cs プロジェクト: tanis2000/FEZ
 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);
 }
コード例 #40
0
 public ShootMessage(string shooterName, Vector2 shotPosition, HorizontalDirection horizontalDirection)
 {
     ShooterName = shooterName;
     ShotPosition = shotPosition;
     HorizontalDirection = horizontalDirection;
 }
コード例 #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;
 }
コード例 #42
0
 protected void MoveOnXAxis(bool negate = false)
 {
     int displacement =  xVelocity;
     if (negate)
     {
         horizontalDirection = HorizontalDirection.LEFT;
         displacement *=  -1;
     }
     else
     {
         horizontalDirection = HorizontalDirection.RIGHT;
     }
     X_Coordinate += displacement;
 }
コード例 #43
0
 private static SpriteEffects GetSpriteEffects(HorizontalDirection horizontalDirection)
 {
     return horizontalDirection == HorizontalDirection.Right ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
 }
コード例 #44
0
ファイル: PlayerActions.cs プロジェクト: tanis2000/FEZ
 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();
 }
コード例 #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;
     }
 }
コード例 #46
0
ファイル: Sprite.cs プロジェクト: Ziamor/Kraken
        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;
        }
コード例 #47
0
ファイル: NpcState.cs プロジェクト: tanis2000/FEZ
 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;
 }
コード例 #48
0
        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;
            }
        }
コード例 #49
0
        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;

            }
        }
コード例 #50
0
		// ================================================================================
		//  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;
		}
コード例 #51
0
ファイル: Person.cs プロジェクト: rodya-mirov/Cow-Mouse
        public void ClearDirectionalMovement()
        {
            Player_ViewHDirection = HorizontalDirection.NEUTRAL;
            Player_ViewVDirection = VerticalDirection.NEUTRAL;

            FixWorldDirection();
        }
コード例 #52
0
		// ================================================================================
		//  private methods
		// --------------------------------------------------------------------------------

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

				_lastHorizontalDirection = direction;
			}
		}
コード例 #53
0
ファイル: WalkTo.cs プロジェクト: Zeludon/FEZ
 protected override void Begin()
 {
   this.originalLookingDirection = this.PlayerManager.LookingDirection;
   this.movementHelper.Entity = (IPhysicsEntity) this.PlayerManager;
 }
コード例 #54
0
ファイル: NpcState.cs プロジェクト: tanis2000/FEZ
 private void Turn()
 {
   this.LookingDirection = FezMath.GetOpposite(this.LookingDirection);
   this.UpdateRotation();
   this.CurrentAction = this.CanWalk ? NpcAction.Walk : NpcAction.Idle;
 }
コード例 #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;
			}
		}
コード例 #56
0
        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);
            }
        }
コード例 #57
0
ファイル: CowMouseGame.cs プロジェクト: rodya-mirov/Cow-Mouse
        /// <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();
            }
        }
コード例 #58
0
ファイル: CowMouseGame.cs プロジェクト: rodya-mirov/Cow-Mouse
        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();
            }
        }