Пример #1
0
    void Orbit()
    {
        if (side.Equals(Side.LEFT))
        {
            float angleToGo = Mathf.Min(angularVelocity, Mathf.Abs(angleToRotate));
            float dist      = Vector3.Distance(transform.position, target.transform.position);
            myAngle            += Mathf.Min(angleToGo, angularVelocity);
            transform.position += dist * transform.forward;
            transform.rotation  = Quaternion.Euler(transform.rotation.eulerAngles.x,
                                                   transform.rotation.eulerAngles.y + angleToGo, transform.rotation.eulerAngles.z);
            transform.position += dist * -transform.forward;
            if (myAngle > angleToRotate)
            {
                setState(getState("idleAttack"));
            }
        }

        if (side.Equals(Side.RIGHT))
        {
            float angleToGo = Mathf.Min(angularVelocity, Mathf.Abs(angleToRotate * -1));
            float dist      = Vector3.Distance(transform.position, target.transform.position);

            myAngle            -= Mathf.Min(angleToGo, angularVelocity);
            transform.position += dist * transform.forward;
            transform.rotation  = Quaternion.Euler(transform.rotation.eulerAngles.x,
                                                   transform.rotation.eulerAngles.y - angleToGo, transform.rotation.eulerAngles.z);
            transform.position += dist * -transform.forward;
            if (Mathf.Abs(myAngle) > angleToRotate)
            {
                setState(getState("idleAttack"));
            }
        }
    }
Пример #2
0
 public Edge(Coordinate start, Coordinate end, Side side, bool isInner = true)
 {
     this.start      = start;
     this.end        = end;
     this.isInner    = isInner;
     this.side       = side;
     this.isVertical = side.Equals(Side.LEFT) || side.Equals(Side.RIGHT);
 }
Пример #3
0
        private static void GameLoop()
        {
            Graphics.Display(_board);

            var ActivePlayer = PlayerOne.Side == _playerTurn ? PlayerOne : PlayerTwo;

            Console.WriteLine($"{ActivePlayer.Name}, It is your move.");
            var turnCommand = Console.ReadLine();

            GameCommand command = Turn.GetGameCommand(_board, ActivePlayer, turnCommand);

            if (command != null)
            {
                var executeResult = Turn.ExecuteCommand(command);
                Console.WriteLine(executeResult.Success ? executeResult.Message : executeResult.Message);

                if (command.Type.Equals(CommandType.Move) && executeResult.Success)
                {
                    _playerTurn = _playerTurn.Equals(Side.White) ? Side.Black : Side.White;
                }
            }
            else
            {
                Console.WriteLine(Help.Action().Message);
            }
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
Пример #4
0
        /// <summary>
        ///     Returns true if Order instances are equal
        /// </summary>
        /// <param name="other">Instance of Order to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Order other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return((Side == other.Side || Side != null && Side.Equals(other.Side)) &&
                   (Sv == other.Sv || Sv != null && Sv.Equals(other.Sv)) &&
                   (Pt == other.Pt || Pt != null && Pt.Equals(other.Pt)) &&
                   (Ot == other.Ot || Ot != null && Ot.Equals(other.Ot)) &&
                   (P == other.P || P != null && P.Equals(other.P)) &&
                   (Sc == other.Sc || Sc != null && Sc.Equals(other.Sc)) &&
                   (Rc == other.Rc || Rc != null && Rc.Equals(other.Rc)) &&
                   (S == other.S || S != null && S.Equals(other.S)) &&
                   (Pd == other.Pd || Pd != null && Pd.Equals(other.Pd)) &&
                   (Rac == other.Rac || Rac != null && Rac.Equals(other.Rac)) &&
                   (Md == other.Md || Md != null && Md.Equals(other.Md)) &&
                   (Sl == other.Sl || Sl != null && Sl.Equals(other.Sl)) &&
                   (Avp == other.Avp || Avp != null && Avp.Equals(other.Avp)) &&
                   (Sm == other.Sm || Sm != null && Sm.Equals(other.Sm)) &&
                   (Id == other.Id || Id != null && Id.Equals(other.Id)) &&
                   (Bsp == other.Bsp || Bsp != null && Bsp.Equals(other.Bsp)) &&
                   (Status == other.Status || Status != null && Status.Equals(other.Status)) &&
                   (Sr == other.Sr || Sr != null && Sr.Equals(other.Sr)) &&
                   (Cd == other.Cd || Cd != null && Cd.Equals(other.Cd)));
        }
Пример #5
0
    private void EnemyUpdate()
    {
        if (side.Equals(Side.Enemy))
        {
            for (int i = 0; i < troops.Count; i++)
            {
                Troop troop = troops[i].GetComponent <Troop>();
                troops[i].GetComponentInChildren <Text>().text = "E" + i;
                Slider s = troops[i].GetComponentInChildren <Slider>();
                s.value = troop.health / troop.maxHealth;
                var fill = s.GetComponentsInChildren <Image>().FirstOrDefault(t => t.name == "Fill");
                if (fill != null)
                {
                    fill.color = Color.red;
                }
            }

            foreach (GameObject obj in objectives)
            {
                Objective objective = obj.GetComponent <Objective>();
                Slider    s         = obj.GetComponentInChildren <Slider>();
                s.value = objective.health / objective.maxHealth;
                var fill = s.GetComponentsInChildren <Image>().FirstOrDefault(t => t.name == "Fill");
                if (fill != null)
                {
                    fill.color = Color.red;
                }
            }
        }
    }
Пример #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public virtual bool Equals(Material other)
 {
     if (other == null)
     {
         return(false);
     }
     return(AlphaTest.Equals(other.AlphaTest) &&
            Blending.Equals(other.Blending) &&
            ClipIntersections.Equals(other.ClipIntersections) &&
            ClipShadows.Equals(other.ClipShadows) &&
            ColorWrite.Equals(other.ColorWrite) &&
            DepthTest.Equals(other.DepthTest) &&
            DepthWrite.Equals(other.DepthWrite) &&
            Dithering.Equals(other.Dithering) &&
            FlatShading.Equals(other.FlatShading) &&
            Fog.Equals(other.Fog) &&
            Lights.Equals(other.Lights) &&
            Opacity.Equals(other.Opacity) &&
            Overdraw.Equals(other.Overdraw) &&
            PremultipliedAlpha.Equals(other.PremultipliedAlpha) &&
            Side.Equals(other.Side) &&
            Transparent.Equals(other.Transparent) &&
            VertexColors.Equals(other.VertexColors) &&
            Visible.Equals(other.Visible) &&
            UserData == other.UserData &&
            ClippingPlanes == other.ClippingPlanes &&
            string.Equals(Precision, other.Precision));
 }
Пример #7
0
        public bool Equals([AllowNull] RadialAxis other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) &&
                   (AutoRange == other.AutoRange && AutoRange != null && other.AutoRange != null && AutoRange.Equals(other.AutoRange)) &&
                   (RangeMode == other.RangeMode && RangeMode != null && other.RangeMode != null && RangeMode.Equals(other.RangeMode)) &&
                   (Equals(Range, other.Range) || Range != null && other.Range != null && Range.SequenceEqual(other.Range)) &&
                   (CategoryOrder == other.CategoryOrder && CategoryOrder != null && other.CategoryOrder != null && CategoryOrder.Equals(other.CategoryOrder)) &&
                   (Equals(CategoryArray, other.CategoryArray) || CategoryArray != null && other.CategoryArray != null && CategoryArray.SequenceEqual(other.CategoryArray)) &&
                   (Angle == other.Angle && Angle != null && other.Angle != null && Angle.Equals(other.Angle)) &&
                   (Side == other.Side && Side != null && other.Side != null && Side.Equals(other.Side)) &&
                   (Title == other.Title && Title != null && other.Title != null && Title.Equals(other.Title)) &&
                   (HoverFormat == other.HoverFormat && HoverFormat != null && other.HoverFormat != null && HoverFormat.Equals(other.HoverFormat)) &&
                   (UiRevision == other.UiRevision && UiRevision != null && other.UiRevision != null && UiRevision.Equals(other.UiRevision)) &&
                   (Color == other.Color && Color != null && other.Color != null && Color.Equals(other.Color)) &&
                   (ShowLine == other.ShowLine && ShowLine != null && other.ShowLine != null && ShowLine.Equals(other.ShowLine)) &&
                   (LineColor == other.LineColor && LineColor != null && other.LineColor != null && LineColor.Equals(other.LineColor)) &&
                   (LineWidth == other.LineWidth && LineWidth != null && other.LineWidth != null && LineWidth.Equals(other.LineWidth)) &&
                   (ShowGrid == other.ShowGrid && ShowGrid != null && other.ShowGrid != null && ShowGrid.Equals(other.ShowGrid)) &&
                   (GridColor == other.GridColor && GridColor != null && other.GridColor != null && GridColor.Equals(other.GridColor)) &&
                   (GridWidth == other.GridWidth && GridWidth != null && other.GridWidth != null && GridWidth.Equals(other.GridWidth)) &&
                   (TickMode == other.TickMode && TickMode != null && other.TickMode != null && TickMode.Equals(other.TickMode)) &&
                   (NTicks == other.NTicks && NTicks != null && other.NTicks != null && NTicks.Equals(other.NTicks)) &&
                   (Tick0 == other.Tick0 && Tick0 != null && other.Tick0 != null && Tick0.Equals(other.Tick0)) &&
                   (DTick == other.DTick && DTick != null && other.DTick != null && DTick.Equals(other.DTick)) &&
                   (Equals(TickVals, other.TickVals) || TickVals != null && other.TickVals != null && TickVals.SequenceEqual(other.TickVals)) &&
                   (Equals(TickText, other.TickText) || TickText != null && other.TickText != null && TickText.SequenceEqual(other.TickText)) &&
                   (Ticks == other.Ticks && Ticks != null && other.Ticks != null && Ticks.Equals(other.Ticks)) &&
                   (TickleN == other.TickleN && TickleN != null && other.TickleN != null && TickleN.Equals(other.TickleN)) &&
                   (TickWidth == other.TickWidth && TickWidth != null && other.TickWidth != null && TickWidth.Equals(other.TickWidth)) &&
                   (TickColor == other.TickColor && TickColor != null && other.TickColor != null && TickColor.Equals(other.TickColor)) &&
                   (ShowTickLabels == other.ShowTickLabels && ShowTickLabels != null && other.ShowTickLabels != null && ShowTickLabels.Equals(other.ShowTickLabels)) &&
                   (ShowTickPrefix == other.ShowTickPrefix && ShowTickPrefix != null && other.ShowTickPrefix != null && ShowTickPrefix.Equals(other.ShowTickPrefix)) &&
                   (TickPrefix == other.TickPrefix && TickPrefix != null && other.TickPrefix != null && TickPrefix.Equals(other.TickPrefix)) &&
                   (ShowTickSuffix == other.ShowTickSuffix && ShowTickSuffix != null && other.ShowTickSuffix != null && ShowTickSuffix.Equals(other.ShowTickSuffix)) &&
                   (TickSuffix == other.TickSuffix && TickSuffix != null && other.TickSuffix != null && TickSuffix.Equals(other.TickSuffix)) &&
                   (ShowExponent == other.ShowExponent && ShowExponent != null && other.ShowExponent != null && ShowExponent.Equals(other.ShowExponent)) &&
                   (ExponentFormat == other.ExponentFormat && ExponentFormat != null && other.ExponentFormat != null && ExponentFormat.Equals(other.ExponentFormat)) &&
                   (SeparateThousands == other.SeparateThousands && SeparateThousands != null && other.SeparateThousands != null && SeparateThousands.Equals(other.SeparateThousands)) &&
                   (TickFont == other.TickFont && TickFont != null && other.TickFont != null && TickFont.Equals(other.TickFont)) &&
                   (TickAngle == other.TickAngle && TickAngle != null && other.TickAngle != null && TickAngle.Equals(other.TickAngle)) &&
                   (TickFormat == other.TickFormat && TickFormat != null && other.TickFormat != null && TickFormat.Equals(other.TickFormat)) &&
                   (Equals(TickFormatStops, other.TickFormatStops) || TickFormatStops != null && other.TickFormatStops != null && TickFormatStops.SequenceEqual(other.TickFormatStops)) &&
                   (Layer == other.Layer && Layer != null && other.Layer != null && Layer.Equals(other.Layer)) &&
                   (Calendar == other.Calendar && Calendar != null && other.Calendar != null && Calendar.Equals(other.Calendar)) &&
                   (CategoryArraySrc == other.CategoryArraySrc && CategoryArraySrc != null && other.CategoryArraySrc != null && CategoryArraySrc.Equals(other.CategoryArraySrc)) &&
                   (TickValsSrc == other.TickValsSrc && TickValsSrc != null && other.TickValsSrc != null && TickValsSrc.Equals(other.TickValsSrc)) &&
                   (TickTextSrc == other.TickTextSrc && TickTextSrc != null && other.TickTextSrc != null && TickTextSrc.Equals(other.TickTextSrc)));
        }
Пример #8
0
        public override bool Equals(object obj)
        {
            var arg = obj as Stock;

            if (Id.Equals(arg.Id) && Side.Equals(arg.Side) && Company.Equals(arg.Company) && Quantity.Equals(arg.Quantity) && Status.Equals(arg.Status))
            {
                return(true);
            }
            return(false);
        }
Пример #9
0
        /// <summary>
        /// Comparison one figure with another.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>Return "true" if equal and "false" if not equal.</returns>
        public override bool Equals(Object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            Square r = (Square)obj;

            return(Side.Equals(r.Side));
        }
Пример #10
0
 private void ManageBouncing(AbstractGameObject gameObject, Side side)
 {
     if (gameObject is AbstractEnemy && side.Equals(Side.Bottom))
     {
         if (bouncing)
         {
             BounceCount += 1;
         }
         else
         {
             bouncing = true;
         }
     }
     else if (side.Equals(Side.Bottom))
     {
         BounceCount = 0;
         bouncing    = false;
     }
 }
Пример #11
0
        public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
        {
            if (side == Side.Bottom)
            {
                Gravity = false;
            }

            if (gameObject is Mario && !(((Mario)gameObject).PowerupState is MarioInvincibility2))
            {
                if (side.Equals(Side.Top))
                {
                    EventManager.Instance.TriggerEnemyDefeatedEvent(this, (Mario)gameObject);
                    PowerupState.BecomeDead();
                    return(true);
                }
            }
            else if (gameObject is AbstractBlock)
            {
                if (side == Side.Left)
                {
                    Velocity    = new Vector2(EnemyHorizontalMovementSpeed, Velocity.Y);
                    Orientation = Facing.Right;
                }
                else if (side == Side.Right)
                {
                    Velocity    = new Vector2(-EnemyHorizontalMovementSpeed, Velocity.Y);
                    Orientation = Facing.Left;
                }
                else if (side == Side.Bottom)
                {
                    if (((AbstractBlock)gameObject).Bumper != null)
                    {
                        EventManager.Instance.TriggerEnemyDefeatedEvent(this, ((AbstractBlock)gameObject).Bumper);
                        PowerupState.BecomeDead();
                    }
                    Velocity = new Vector2(Velocity.X, 0);
                }

                return(true);
            }
            else if (gameObject is FireBall)
            {
                var fireball = (FireBall)gameObject;
                if (fireball.Owner is Mario)
                {
                    EventManager.Instance.TriggerEnemyDefeatedEvent(this, (Mario)fireball.Owner);
                    PowerupState.BecomeDead();
                    return(true);
                }
            }
            return(false);
        }
Пример #12
0
            public ExchangeTrade ToExchangeTrade()
            {
                var isBuy = Side.Equals("buy", StringComparison.InvariantCultureIgnoreCase);

                return(new ExchangeTrade()
                {
                    Amount = Quantity,
                    Id = TradeId.ToStringInvariant(),
                    Price = Price,
                    IsBuy = isBuy,
                    Timestamp = TradeTime.UnixTimeStampToDateTimeMilliseconds(),
                    Flags = isBuy ? ExchangeTradeFlags.IsBuy : default
                });
Пример #13
0
            public ExchangeOrderResult ToExchangeOrderResult(Dictionary <string, long> symbolToIdMapping)
            {
                ExchangeAPIOrderResult orderResult;

                switch (OrderState.ToLowerInvariant())
                {
                case "unknown":
                    orderResult = ExchangeAPIOrderResult.Unknown;
                    break;

                case "working":
                    orderResult = ExchangeAPIOrderResult.Open;
                    break;

                case "rejected":
                    orderResult = ExchangeAPIOrderResult.Rejected;
                    break;

                case "canceled":
                    orderResult = ExchangeAPIOrderResult.Canceled;
                    break;

                case "expired":
                    orderResult = ExchangeAPIOrderResult.Canceled;
                    break;

                case "fullyexecuted":
                    orderResult = ExchangeAPIOrderResult.Filled;
                    break;

                default:
                    throw new NotImplementedException($"Unexpected status type: {OrderState.ToLowerInvariant()}");
                }
                ;
                var symbol = symbolToIdMapping.Where(pair => pair.Value.Equals(Instrument));

                return(new ExchangeOrderResult()
                {
                    Amount = Quantity,
                    IsBuy = Side.Equals("buy", StringComparison.InvariantCultureIgnoreCase),
                    MarketSymbol = symbol.Any() ? symbol.First().Key : null,
                    Price = Price,
                    Result = orderResult,
                    OrderDate = ReceiveTime.UnixTimeStampToDateTimeMilliseconds(),

                    OrderId = OrderId.ToStringInvariant(),
                });
            }
Пример #14
0
        /// <summary>
        /// Move monkeys
        /// </summary>
        public void MoveForward()
        {
            var to = Side.Equals(Direction.Right) ? Direction.Left : Direction.Right;

            Thread.Sleep(new TimeSpan(0, 0, 1));
            Status = State.Start.ToString() + ",";
            SetTextOnUI($"{Thread.CurrentThread.Name} enters the rope moving to: {to}");

            Status += State.Moving.ToString() + ",";
            SetTextOnUI($"{Thread.CurrentThread.Name} 1/4 of the way across the rope");
            SetTextOnUI($"{Thread.CurrentThread.Name} is in the middle of the rope");
            SetTextOnUI($"{Thread.CurrentThread.Name} 3/4 way across the rope");
            SetTextOnUI($"{Thread.CurrentThread.Name} is off the rope." + Environment.NewLine);
            Status += State.Finish.ToString();
            Thread.Sleep(new TimeSpan(0, 0, 3));
        }
Пример #15
0
 public void RecalculateTrail(Tick t)
 {
     if (Side.Equals(Position.PositionSide.Long))
     {
         if (t.BidClose - TrailSize > TriggerPrice)
         {
             TriggerPrice = t.BidClose - TrailSize;
         }
     }
     else if (Side.Equals(Position.PositionSide.Short))
     {
         if (t.AskClose + TrailSize < TriggerPrice)
         {
             TriggerPrice = t.AskClose + TrailSize;
         }
     }
 }
Пример #16
0
        public bool Equals([AllowNull] PathBar other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (Side == other.Side && Side != null && other.Side != null && Side.Equals(other.Side)) &&
                   (EdgeShape == other.EdgeShape && EdgeShape != null && other.EdgeShape != null && EdgeShape.Equals(other.EdgeShape)) &&
                   (Thickness == other.Thickness && Thickness != null && other.Thickness != null && Thickness.Equals(other.Thickness)) &&
                   (TextFont == other.TextFont && TextFont != null && other.TextFont != null && TextFont.Equals(other.TextFont)));
        }
Пример #17
0
        /// <summary>
        /// Returns true if Position instances are equal
        /// </summary>
        /// <param name="other">Instance of Position to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Position other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Instrument == other.Instrument ||
                     Instrument != null &&
                     Instrument.Equals(other.Instrument)
                 ) &&
                 (
                     Qty == other.Qty ||
                     Qty != null &&
                     Qty.Equals(other.Qty)
                 ) &&
                 (
                     Side == other.Side ||
                     Side != null &&
                     Side.Equals(other.Side)
                 ) &&
                 (
                     AvgPrice == other.AvgPrice ||
                     AvgPrice != null &&
                     AvgPrice.Equals(other.AvgPrice)
                 ) &&
                 (
                     UnrealizedPl == other.UnrealizedPl ||
                     UnrealizedPl != null &&
                     UnrealizedPl.Equals(other.UnrealizedPl)
                 ));
        }
Пример #18
0
        private void ManageFlagPoleCount(AbstractGameObject gameObject, Side side)
        {
            if (gameObject is Flagpole && side.Equals(Side.Right))
            {
                poleBottom = gameObject.BoundingBox.Dimensions.Bottom;
                poleTop    = gameObject.BoundingBox.Dimensions.Top;
                poleHeight = poleBottom - poleTop;

                increment = poleHeight / 5;

                if (Position.Y == poleTop)
                {
                    Lives++;
                }
                else if (Position.Y > poleTop && Position.Y <= poleTop + increment)
                {
                    height = 4000;
                }
                else if (Position.Y > poleTop + increment && Position.Y <= poleTop + (increment + increment))
                {
                    height = 2000;
                }
                else if ((Position.Y > (poleTop + (increment + increment))) && (Position.Y <= poleTop + (increment + increment + increment)))
                {
                    height = 800;
                }
                else if (Position.Y <= poleBottom - increment && Position.Y > poleTop + (increment + increment + increment))
                {
                    height = 400;
                }
                else if (Position.Y <= poleBottom + 5 && Position.Y > poleBottom - increment)
                {
                    height = 100;
                }

                EventManager.Instance.TriggerPlayerHitPoleEvent(height, this);
            }
        }
Пример #19
0
 public virtual bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
 {
     if (gameObject is Mario && !(((Mario)gameObject).PowerupState is MarioInvincibility2) &&
         !(Context.PowerupStateBowser is BowserInvincibility))
     {
         float whereOnHitBox = Math.Abs(gameObject.Position.X - Context.Position.X);
         if (side.Equals(Side.Top) && (whereOnHitBox < 250 && Context.Orientation is Facing.Left || whereOnHitBox > 600 && Context.Orientation is Facing.Right))
         {
             Context.Hits--;
             EventManager.Instance.TriggerEnemyDefeatedEvent(Context, (Mario)gameObject);
             if (Context.Hits == 0)
             {
                 Killer = (Mario)gameObject;
                 Context.PowerupStateBowser.BecomeDead();
                 Context.PowerupStateBowser.Killer = Killer;
                 return(true);
             }
             int shift = (gameObject.Position.X > Context.Position.X + Context.Sprite.SourceRectangle.Width / 2) ? -5 : 5;
             Context.Velocity           = new Vector2(Context.Velocity.Y + shift, Context.Velocity.X);
             Context.PowerupStateBowser = new BowserInvincibility(Context);
         }
     }
     return(false);
 }
Пример #20
0
 public bool IsBuyLimit()
 {
     return(Side.Equals(Position.PositionSide.Long));
 }
Пример #21
0
        private bool CheckDiagonal(IBoard board, Side opponentSide, int x, int y)
        {
            var isChecked = false;

            for (var dir = 0; dir < 4; dir++)
            {
                int xDir;
                int yDir;
                switch (dir)
                {
                case 0:
                    xDir = -1;
                    yDir = -1;
                    break;

                case 1:
                    xDir = 1;
                    yDir = -1;
                    break;

                case 2:
                    xDir = -1;
                    yDir = 1;
                    break;

                case 3:
                    xDir = 1;
                    yDir = 1;
                    break;

                default:
                    throw new InvalidOperationException();
                }

                var cursorX = x;
                var cursorY = y;
                var movedX  = 0;
                var movedY  = 0;

                while (cursorY >= 0 && cursorX >= 0 && cursorY < 8 && cursorX < 8 && !isChecked)
                {
                    cursorY += yDir;
                    cursorX += xDir;
                    movedY  += yDir;
                    movedX  += xDir;

                    if (cursorY < 0 || cursorX < 0 || cursorY >= 8 || cursorX >= 8)
                    {
                        continue;
                    }

                    var cursorPeice = board.GetPeice(cursorX, cursorY);

                    if (cursorPeice == null)
                    {
                        continue;
                    }

                    if (!cursorPeice.Side.Equals(opponentSide))
                    {
                        break;
                    }

                    var pawnDirection = opponentSide.Equals(Side.White) ? -1 : 1;
                    var pawnChecked   = movedY * pawnDirection == movedY &&
                                        movedY != 0 && movedX != 0 &&
                                        cursorPeice.Type.Equals(PeiceType.Pawn);

                    var onePlace  = Math.Abs(movedY) <= 1 && Math.Abs(movedX) <= 1;
                    var kingCheck = onePlace && (cursorPeice.Type.Equals(PeiceType.King));

                    var distantCheck = cursorPeice.Type.Equals(PeiceType.Bishop) || cursorPeice.Type == PeiceType.Queen;

                    isChecked = pawnChecked || kingCheck || distantCheck;
                }

                if (isChecked)
                {
                    break;
                }
            }
            return(isChecked);
        }
Пример #22
0
        /// <summary>
        /// Returns true if Order instances are equal
        /// </summary>
        /// <param name="other">Instance of Order to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Order other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Instrument == other.Instrument ||
                     Instrument != null &&
                     Instrument.Equals(other.Instrument)
                 ) &&
                 (
                     Qty == other.Qty ||
                     Qty != null &&
                     Qty.Equals(other.Qty)
                 ) &&
                 (
                     Side == other.Side ||
                     Side != null &&
                     Side.Equals(other.Side)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     FilledQty == other.FilledQty ||
                     FilledQty != null &&
                     FilledQty.Equals(other.FilledQty)
                 ) &&
                 (
                     AvgPrice == other.AvgPrice ||
                     AvgPrice != null &&
                     AvgPrice.Equals(other.AvgPrice)
                 ) &&
                 (
                     LimitPrice == other.LimitPrice ||
                     LimitPrice != null &&
                     LimitPrice.Equals(other.LimitPrice)
                 ) &&
                 (
                     StopPrice == other.StopPrice ||
                     StopPrice != null &&
                     StopPrice.Equals(other.StopPrice)
                 ) &&
                 (
                     ParentId == other.ParentId ||
                     ParentId != null &&
                     ParentId.Equals(other.ParentId)
                 ) &&
                 (
                     ParentType == other.ParentType ||
                     ParentType != null &&
                     ParentType.Equals(other.ParentType)
                 ) &&
                 (
                     Duration == other.Duration ||
                     Duration != null &&
                     Duration.Equals(other.Duration)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ));
        }
Пример #23
0
 public override string ToString()
 {
     return($"Order ({OrderID}|{ClientOrderID}): {(Side.Equals(QuickFix.Fields.Side.BUY) ? "BUY" : "SELL")} {FilledVolume.ToString("N4")}/{Volume.ToString("N4")} at {Price.ToString("N3")}$");
 }
Пример #24
0
 public bool IsSellLimit()
 {
     return(Side.Equals(Position.PositionSide.Short));
 }
Пример #25
0
        public bool Equals([AllowNull] Violin other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) &&
                   (Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (ShowLegend == other.ShowLegend && ShowLegend != null && other.ShowLegend != null && ShowLegend.Equals(other.ShowLegend)) &&
                   (LegendGroup == other.LegendGroup && LegendGroup != null && other.LegendGroup != null && LegendGroup.Equals(other.LegendGroup)) &&
                   (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) &&
                   (UId == other.UId && UId != null && other.UId != null && UId.Equals(other.UId)) &&
                   (Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids)) &&
                   (Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData)) &&
                   (Meta == other.Meta && Meta != null && other.Meta != null && Meta.Equals(other.Meta)) &&
                   (Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray)) &&
                   (SelectedPoints == other.SelectedPoints && SelectedPoints != null && other.SelectedPoints != null && SelectedPoints.Equals(other.SelectedPoints)) &&
                   (HoverInfo == other.HoverInfo && HoverInfo != null && other.HoverInfo != null && HoverInfo.Equals(other.HoverInfo)) &&
                   (Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray)) &&
                   (HoverLabel == other.HoverLabel && HoverLabel != null && other.HoverLabel != null && HoverLabel.Equals(other.HoverLabel)) &&
                   (Stream == other.Stream && Stream != null && other.Stream != null && Stream.Equals(other.Stream)) &&
                   (Equals(Transforms, other.Transforms) || Transforms != null && other.Transforms != null && Transforms.SequenceEqual(other.Transforms)) &&
                   (UiRevision == other.UiRevision && UiRevision != null && other.UiRevision != null && UiRevision.Equals(other.UiRevision)) &&
                   (Equals(Y, other.Y) || Y != null && other.Y != null && Y.SequenceEqual(other.Y)) &&
                   (Equals(X, other.X) || X != null && other.X != null && X.SequenceEqual(other.X)) &&
                   (X0 == other.X0 && X0 != null && other.X0 != null && X0.Equals(other.X0)) &&
                   (Y0 == other.Y0 && Y0 != null && other.Y0 != null && Y0.Equals(other.Y0)) &&
                   (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) &&
                   (Orientation == other.Orientation && Orientation != null && other.Orientation != null && Orientation.Equals(other.Orientation)) &&
                   (Bandwidth == other.Bandwidth && Bandwidth != null && other.Bandwidth != null && Bandwidth.Equals(other.Bandwidth)) &&
                   (ScaleGroup == other.ScaleGroup && ScaleGroup != null && other.ScaleGroup != null && ScaleGroup.Equals(other.ScaleGroup)) &&
                   (ScaleMode == other.ScaleMode && ScaleMode != null && other.ScaleMode != null && ScaleMode.Equals(other.ScaleMode)) &&
                   (SpanMode == other.SpanMode && SpanMode != null && other.SpanMode != null && SpanMode.Equals(other.SpanMode)) &&
                   (Equals(Span, other.Span) || Span != null && other.Span != null && Span.SequenceEqual(other.Span)) &&
                   (Line == other.Line && Line != null && other.Line != null && Line.Equals(other.Line)) &&
                   (FillColor == other.FillColor && FillColor != null && other.FillColor != null && FillColor.Equals(other.FillColor)) &&
                   (Points == other.Points && Points != null && other.Points != null && Points.Equals(other.Points)) &&
                   (Jitter == other.Jitter && Jitter != null && other.Jitter != null && Jitter.Equals(other.Jitter)) &&
                   (PointPos == other.PointPos && PointPos != null && other.PointPos != null && PointPos.Equals(other.PointPos)) &&
                   (Width == other.Width && Width != null && other.Width != null && Width.Equals(other.Width)) &&
                   (Marker == other.Marker && Marker != null && other.Marker != null && Marker.Equals(other.Marker)) &&
                   (Text == other.Text && Text != null && other.Text != null && Text.Equals(other.Text)) &&
                   (Equals(TextArray, other.TextArray) || TextArray != null && other.TextArray != null && TextArray.SequenceEqual(other.TextArray)) &&
                   (HoverText == other.HoverText && HoverText != null && other.HoverText != null && HoverText.Equals(other.HoverText)) &&
                   (Equals(HoverTextArray, other.HoverTextArray) || HoverTextArray != null && other.HoverTextArray != null && HoverTextArray.SequenceEqual(other.HoverTextArray)) &&
                   (HoverTemplate == other.HoverTemplate && HoverTemplate != null && other.HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate)) &&
                   (Equals(HoverTemplateArray, other.HoverTemplateArray) ||
                    HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray)) &&
                   (Box == other.Box && Box != null && other.Box != null && Box.Equals(other.Box)) &&
                   (MeanLine == other.MeanLine && MeanLine != null && other.MeanLine != null && MeanLine.Equals(other.MeanLine)) &&
                   (Side == other.Side && Side != null && other.Side != null && Side.Equals(other.Side)) &&
                   (OffsetGroup == other.OffsetGroup && OffsetGroup != null && other.OffsetGroup != null && OffsetGroup.Equals(other.OffsetGroup)) &&
                   (AlignmentGroup == other.AlignmentGroup && AlignmentGroup != null && other.AlignmentGroup != null && AlignmentGroup.Equals(other.AlignmentGroup)) &&
                   (Selected == other.Selected && Selected != null && other.Selected != null && Selected.Equals(other.Selected)) &&
                   (Unselected == other.Unselected && Unselected != null && other.Unselected != null && Unselected.Equals(other.Unselected)) &&
                   (HoverOn == other.HoverOn && HoverOn != null && other.HoverOn != null && HoverOn.Equals(other.HoverOn)) &&
                   (XAxis == other.XAxis && XAxis != null && other.XAxis != null && XAxis.Equals(other.XAxis)) &&
                   (YAxis == other.YAxis && YAxis != null && other.YAxis != null && YAxis.Equals(other.YAxis)) &&
                   (IdsSrc == other.IdsSrc && IdsSrc != null && other.IdsSrc != null && IdsSrc.Equals(other.IdsSrc)) &&
                   (CustomDataSrc == other.CustomDataSrc && CustomDataSrc != null && other.CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc)) &&
                   (MetaSrc == other.MetaSrc && MetaSrc != null && other.MetaSrc != null && MetaSrc.Equals(other.MetaSrc)) &&
                   (HoverInfoSrc == other.HoverInfoSrc && HoverInfoSrc != null && other.HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc)) &&
                   (YSrc == other.YSrc && YSrc != null && other.YSrc != null && YSrc.Equals(other.YSrc)) &&
                   (XSrc == other.XSrc && XSrc != null && other.XSrc != null && XSrc.Equals(other.XSrc)) &&
                   (TextSrc == other.TextSrc && TextSrc != null && other.TextSrc != null && TextSrc.Equals(other.TextSrc)) &&
                   (HoverTextSrc == other.HoverTextSrc && HoverTextSrc != null && other.HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc)) &&
                   (HoverTemplateSrc == other.HoverTemplateSrc && HoverTemplateSrc != null && other.HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc)));
        }
Пример #26
0
        /// <summary>
        /// Returns true if OrderRes instances are equal
        /// </summary>
        /// <param name="input">Instance of OrderRes to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrderRes input)
        {
            if (input == null)
            {
                return(false);
            }

            return((
                       OrderId == input.OrderId ||
                       (OrderId != null &&
                        OrderId.Equals(input.OrderId))
                       ) &&
                   (
                       UserId == input.UserId ||
                       (UserId != null &&
                        UserId.Equals(input.UserId))
                   ) &&
                   (
                       Symbol == input.Symbol ||
                       (Symbol != null &&
                        Symbol.Equals(input.Symbol))
                   ) &&
                   (
                       Side == input.Side ||
                       (Side != null &&
                        Side.Equals(input.Side))
                   ) &&
                   (
                       OrderType == input.OrderType ||
                       (OrderType != null &&
                        OrderType.Equals(input.OrderType))
                   ) &&
                   (
                       Price == input.Price ||
                       (Price != null &&
                        Price.Equals(input.Price))
                   ) &&
                   (
                       TimeInForce == input.TimeInForce ||
                       (TimeInForce != null &&
                        TimeInForce.Equals(input.TimeInForce))
                   ) &&
                   (
                       OrderStatus == input.OrderStatus ||
                       (OrderStatus != null &&
                        OrderStatus.Equals(input.OrderStatus))
                   ) &&
                   (
                       LastExecTime == input.LastExecTime ||
                       (LastExecTime != null &&
                        LastExecTime.Equals(input.LastExecTime))
                   ) &&
                   (
                       LastExecPrice == input.LastExecPrice ||
                       (LastExecPrice != null &&
                        LastExecPrice.Equals(input.LastExecPrice))
                   ) &&
                   (
                       LeavesQty == input.LeavesQty ||
                       (LeavesQty != null &&
                        LeavesQty.Equals(input.LeavesQty))
                   ) &&
                   (
                       CumExecQty == input.CumExecQty ||
                       (CumExecQty != null &&
                        CumExecQty.Equals(input.CumExecQty))
                   ) &&
                   (
                       CumExecValue == input.CumExecValue ||
                       (CumExecValue != null &&
                        CumExecValue.Equals(input.CumExecValue))
                   ) &&
                   (
                       CumExecFee == input.CumExecFee ||
                       (CumExecFee != null &&
                        CumExecFee.Equals(input.CumExecFee))
                   ) &&
                   (
                       RejectReason == input.RejectReason ||
                       (RejectReason != null &&
                        RejectReason.Equals(input.RejectReason))
                   ) &&
                   (
                       OrderLinkId == input.OrderLinkId ||
                       (OrderLinkId != null &&
                        OrderLinkId.Equals(input.OrderLinkId))
                   ) &&
                   (
                       CreatedAt == input.CreatedAt ||
                       (CreatedAt != null &&
                        CreatedAt.Equals(input.CreatedAt))
                   ) &&
                   (
                       UpdatedAt == input.UpdatedAt ||
                       (UpdatedAt != null &&
                        UpdatedAt.Equals(input.UpdatedAt))
                   ));
        }