예제 #1
1
파일: Unmhr.cs 프로젝트: Altaxo/Altaxo
 private static void ArgumentCheck(Side side, int m, int n, int k, int ilo, int ihi, Object A, int lda, Object tau, Object C, int ldc) {
   if ( A == null ) {
     throw new ArgumentNullException("A","A cannot be null.");
   }
   if ( tau == null ) {
     throw new ArgumentNullException("tau","tau cannot be null.");
   }
   if ( C == null ) {
     throw new ArgumentNullException("C","C cannot be null.");
   }
   if ( m<0 ) {
     throw new ArgumentException("m must be at least zero.", "m");
   }
   if ( n<0 ) {
     throw new ArgumentException("n must be at least zero.", "n");
   }
   if( side == Side.Left ){
     if( k < 0 || k > m ){
       throw new ArgumentException("k must be positive and less than or equal to m.", "k");
     }
     if (m>0) {
       if (ilo<1 || ilo>m || ilo>ihi)
         throw new ArgumentException("ilo must be a positive number and less than or equal to min(ihi,m) if m>0", "ilo");
       if (ihi<1 || ihi>m)
         throw new ArgumentException("ihi must be between 1 and m if m>0", "ihi");
     } else {
       if (ilo!=1)
         throw new ArgumentException("ilo must be 1 if m=0", "ilo");
       if (ihi!=0)
         throw new ArgumentException("ihi must be 0 if m=0", "ihi");
     }
   }else{
     if( k < 0 || k > n ){
       throw new ArgumentException("k must be positive and less than or equal to n.", "k");
     }
     if (n>0) {
       if (ilo<1 || ilo>n || ilo>ihi)
         throw new ArgumentException("ilo must be a positive number and less than or equal to min(ihi,n) if n>0", "ilo");
       if (ihi<1 || ihi>n)
         throw new ArgumentException("ihi must be a positive number and less than or equal to n if n>0", "ihi");
     } else {
       if (ilo!=1)
         throw new ArgumentException("ilo must be 1 if n=0", "ilo");
       if (ihi!=0)
         throw new ArgumentException("ihi must be 0 if n=0", "ihi");
     }
   }
   if( side == Side.Left ){
     if ( lda < System.Math.Max(1,m) ) {
       throw new ArgumentException("lda must be at least max(1,m)", "lda");
     }
   }else{
     if ( lda < System.Math.Max(1,n) ) {
       throw new ArgumentException("lda must be at least max(1,n)", "lda");
     }
   }
   if ( ldc < System.Math.Max(1,m) ) {
     throw new ArgumentException("ldc must be at least max(1,m)", "ldc");
   }
 }
예제 #2
0
        public EdgeNGramTokenFilter(LuceneVersion version, TokenStream input, Side side, int minGram, int maxGram)
            : base(input)
        {
            if (version == null)
            {
              throw new System.ArgumentException("version must not be null");
            }

            if (version.OnOrAfter(LuceneVersion.LUCENE_44) && side == Side.BACK)
            {
              throw new System.ArgumentException("Side.BACK is not supported anymore as of Lucene 4.4, use ReverseStringFilter up-front and afterward");
            }

            if (side == null)
            {
              throw new System.ArgumentException("sideLabel must be either front or back");
            }

            if (minGram < 1)
            {
              throw new System.ArgumentException("minGram must be greater than zero");
            }

            if (minGram > maxGram)
            {
              throw new System.ArgumentException("minGram must not be greater than maxGram");
            }

            this.version = version;
            this.charUtils = version.onOrAfter(LuceneVersion.LUCENE_44) ? CharacterUtils.getInstance(version) : CharacterUtils.Java4Instance;
            this.minGram = minGram;
            this.maxGram = maxGram;
            this.side = side;
        }
예제 #3
0
 public static Side RotateSide(Side side, int steps)
 {
     int index = Array.IndexOf(allSides, side);
     index += steps;
     index = Mathf.CeilToInt(Mathf.Repeat(index, allSides.Length));
     return allSides[index];
 }
 public Gear(String _Classname, int _UpgradeLevel, int _Price, Side _Side)
 {
     Classname = _Classname;
     UpgradeLevel = _UpgradeLevel;
     Price = _Price;
     Side = _Side;
 }
예제 #5
0
    ///<summary>Check arguments so that errors don't occur in native code</summary>
    private static void ArgumentCheck( Side side, int m, int n, object A, int lda, object B, int ldb ) {
      if ( A == null ) {
        throw new ArgumentNullException("A", "A cannot be null.");
      }
      if ( B == null ) {
        throw new ArgumentNullException("B", "B cannot be null.");
      }
      if ( m < 0) {
        throw new ArgumentException("m must be zero or greater", "m");
      }
      if ( n < 0) {
        throw new ArgumentException("n must be zero or greater", "n");
      }
    
      if (side == Side.Left) {
        if(lda < System.Math.Max(1,m)){
          throw new ArgumentException("lda must be at least max(1,m).", "lda");
        }
      }else{
        if(lda < System.Math.Max(1,n)){
          throw new ArgumentException("lda must be at least max(1,n).","lda");
        }
      }
      if(ldb < System.Math.Max(1,m)){
        throw new ArgumentException("lda must be at least max(1,m).","ldb");
      }

    }
예제 #6
0
        public void AttackedFrom_WhteRookE1KnightC3C4BlackRookA4TargetE4_ReturnsBitboardC3E1()
        {
            // arrange
            var white = new Side(
                "G1",
                new PieceSet<Queen>(),
                new PieceSet<Bishop>(),
                new PieceSet<Knight>(Bitboard.With.C3.C4),
                new PieceSet<Rook>(Bitboard.With.E1),
                new WhitePawns()
                );

            var black = new Side(
                "G8",
                new PieceSet<Queen>(),
                new PieceSet<Bishop>(),
                new PieceSet<Knight>(),
                new PieceSet<Rook>(Bitboard.With.A4),
                new BlackPawns()
                );

            var target = new Square("E4");
            var expected = Bitboard.With.C3.E1.Build();

            // act
            var result = target.AttackedFrom(white, black);

            // assert
            result.Should().Be(expected);
        }
예제 #7
0
 public Person(int helthPoint, int x, int y, Side team)
 {
     this.HelthPoint = helthPoint;
     this.x = x;
     this.y = y;
     this.Team = team;
 }
예제 #8
0
		/// <summary>
		/// Gets the orientation for the context in the given position.
		/// </summary>
		/// <param name="loc"></param>
		/// <returns></returns>
		public static Orientation ContextOrientation(Side loc)
		{
			if (loc == Side.N || loc == Side.S)
				return Orientation.Horizontal;
			else
				return Orientation.Vertical;
		}
예제 #9
0
	private IEnumerator WaitForPosition()
	{
		yield return new WaitForEndOfFrame();

		int dir = 1;
		lastSide = Side.Right;

		Vector3 viewportPosition = Camera.main.WorldToViewportPoint (transform.position);
		if((viewportPosition.x < 0 && viewportPosition.y > 0.5f) ||
		   (viewportPosition.x > 1 && viewportPosition.y < 0.5f) ||
		   (viewportPosition.y < 0 && viewportPosition.x < 0.5f) ||
		   (viewportPosition.y > 1 && viewportPosition.x > 0.5f))
		{
			dir = -1;
			lastSide = Side.Left;
		}

		sideVelocity = (Vector2)transform.up * dir;
		frontVelocity = (Vector2)transform.right;
		finalVelocity = (frontVelocity + sideVelocity).normalized;

		myAnimator.SetInteger ("State", (lastSide == Side.Right) ? 0 : 1);

		yield return new WaitForEndOfFrame();

		myAnimator.SetInteger("State", 2);

		angle = Mathf.Atan2 (finalVelocity.y, finalVelocity.x) * Mathf.Rad2Deg;
		
		StartCoroutine (ChangeDirection (timeToChangeDirection.Random ()));
	}
예제 #10
0
        /// <summary>
        /// Create a NewOrderSingle message.
        /// </summary>
        /// <param name="customFields"></param>
        /// <param name="orderType"></param>
        /// <param name="side"></param>
        /// <param name="symbol"></param>
        /// <param name="orderQty"></param>
        /// <param name="tif"></param>
        /// <param name="price">ignored if orderType=Market</param>
        /// <returns></returns>
        static public QuickFix.FIX42.NewOrderSingle NewOrderSingle(
            Dictionary<int,string> customFields,
            OrderType orderType, Side side, string symbol,
            int orderQty, TimeInForce tif, decimal price)
        {
            // hard-coded fields
            QuickFix.Fields.HandlInst fHandlInst = new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE);
            
            // from params
            QuickFix.Fields.OrdType fOrdType = FixEnumTranslator.ToField(orderType);
            QuickFix.Fields.Side fSide = FixEnumTranslator.ToField(side);
            QuickFix.Fields.Symbol fSymbol = new QuickFix.Fields.Symbol(symbol);
            QuickFix.Fields.TransactTime fTransactTime = new QuickFix.Fields.TransactTime(DateTime.Now);
            QuickFix.Fields.ClOrdID fClOrdID = GenerateClOrdID();

            QuickFix.FIX42.NewOrderSingle nos = new QuickFix.FIX42.NewOrderSingle(
                fClOrdID, fHandlInst, fSymbol, fSide, fTransactTime, fOrdType);
            nos.OrderQty = new QuickFix.Fields.OrderQty(orderQty);
            nos.TimeInForce = FixEnumTranslator.ToField(tif);

            if (orderType == OrderType.Limit)
                nos.Price = new QuickFix.Fields.Price(price);

            // add custom fields
            foreach (KeyValuePair<int,string> p in customFields)
                nos.SetField(new QuickFix.Fields.StringField(p.Key, p.Value));

            return nos;
        }
예제 #11
0
파일: Player.cs 프로젝트: peleccom/chess
 public Player(string name, Side side)
 {
     Name = name;
     Side = side;
     win = 0;
     lose = 0;
 }
예제 #12
0
파일: Bishop.cs 프로젝트: peleccom/chess
 public Bishop(Position pos, Side side, ChessField chessfield)
     : base(pos, side, chessfield)
 {
     FigureType = FigureTypes.Bishop;
     movepolitics = new MovePolitics[] {
                                 chessfield.DiagMovePolitics};
 }
예제 #13
0
파일: Game.cs 프로젝트: dtryon/tennis
        private void AdvanceState(Side side)
        {
            if (StillPlaying())
            {
                if (HasEnteredDeuce())
                {
                    this.state = GameState.Deuce;

                    if (GetPointState(side) == PointState.Advantage)
                    {
                        this.state = DetermineWinner(side);
                        return;
                    }

                    if((sideOnePoints == PointState.Deuce && sideTwoPoints == PointState.Deuce)
                        || (sideOnePoints == PointState.Forty && sideTwoPoints == PointState.Forty))
                    {
                        SetPointState(side, PointState.Advantage);
                        return;
                    }

                    sideOnePoints = PointState.Deuce;
                    sideTwoPoints = PointState.Deuce;
                    return;
                }

                RollPoints(side);

                if (((int)GetPointState(side)) > 4)
                {
                    this.state = DetermineWinner(side);
                }
            }
        }
 public bool GetSensor(Axis axis, Side side)
 {
     if (axis == Axis.X)
     {
         if (side == Side.POSITIVE && GetSensorValue(axis) >= thresholdX)
             return true;
         else if (side == Side.NEGATIVE && GetSensorValue(axis) <= -thresholdX)
             return true;
         else
             return false;
     }
     else if (axis == Axis.Y)
     {
         if (side == Side.POSITIVE && GetSensorValue(axis) >= thresholdY)
             return true;
         else if (side == Side.NEGATIVE && GetSensorValue(axis) <= -thresholdY)
             return true;
         else
             return false;
     }
     else if (axis == Axis.Z)
     {
         if (side == Side.POSITIVE && GetSensorValue(axis) >= thresholdZ)
             return true;
         else if (side == Side.NEGATIVE && GetSensorValue(axis) <= thresholdZ)
             return true;
         else
             return false;
     }
     else
         return false;
 }
예제 #15
0
 public Slot this[Side index]
 {
     // access to neighby slots on the index
     get {
         return slot.nearSlot[index];
     }
 }
예제 #16
0
        private int EvaluateOrientation(PositionInfo.LineInfo positive, PositionInfo.LineInfo negative, Side player)
        {
            if (positive.amount > 0 && negative.amount > 0)
            {
                if (positive.side == negative.side)
                {
                    int n = 1 + positive.amount + negative.amount;
                    return LineCost(n, positive.open, negative.open);
                }
                else
                {
                    int npos = positive.amount + 1;
                    int nneg = negative.amount + 1;

                    return Math.Max(LineCost(npos, positive.open, false), LineCost(nneg, negative.open, false));
                }
            }

            if (positive.amount > 0)
            {
                return LineCost(positive.amount + 1, positive.open, true);
            }

            if (negative.amount > 0)
            {
                return LineCost(negative.amount + 1, negative.open, true);
            }

            return 0;
        }
 public void ChangeVisibility(Side side, Mode mode)
 {
     Transform sideObject = this.transform.FindChild(SidesNames [(int)side]);
     Mesh leftMesh, rightMesh, midMesh;
     switch (mode)
     {
         case Mode.Full:
             leftMesh =  fullMeshLeft;
             rightMesh = fullMeshRight;
             midMesh = fullMesh;
             break;
         case Mode.Half:
             leftMesh = halfMeshLeft;
             rightMesh = halfMeshRight;
             midMesh = halfMesh;
             break;
         case Mode.Empty:
             leftMesh = null;
             rightMesh = null;
             midMesh = emptyMesh;
             break;
         default:
             throw new ArgumentException();
     }
     sideObject.FindChild("LeftSide").GetComponent<MeshFilter>().sharedMesh= leftMesh;
     sideObject.FindChild("LeftSide").GetComponent<MeshCollider>().sharedMesh = leftMesh;
     sideObject.FindChild("RightSide").GetComponent<MeshFilter>().sharedMesh = rightMesh;
     sideObject.FindChild("RightSide").GetComponent<MeshCollider>().sharedMesh = rightMesh;
     sideObject.FindChild("Middle").GetComponent<MeshFilter>().sharedMesh = midMesh;
     sideObject.FindChild("Middle").GetComponent<MeshCollider>().sharedMesh = midMesh;
 }
예제 #18
0
    public ClickRes getClickResult(Side side, ClickRes res)
    {
        float diff = preTempo.rect.width - tempo.rect.width;
        ClickRes clickRes;
        if (side == Side.Atk)
        {   // 攻擊判斷
            if (diff < 5)
                clickRes = ClickRes.Perfect;
            else if (diff < 15)
                clickRes = ClickRes.Great;
            else
                clickRes = ClickRes.Miss;
        }
        else
        {   // 防禦判斷
            if (diff < defList[res][0])
                clickRes = ClickRes.Perfect;
            else if (diff < defList[res][1])
                clickRes = ClickRes.Great;
            else
                clickRes = ClickRes.Miss;
        }

        // 更新結果顯示文字
        updateResult(clickRes);

        return clickRes;
    }
예제 #19
0
파일: Main.cs 프로젝트: KBrizzle/DJClicker
 private void bt_right_Click(object sender, EventArgs e)
 {
     bt_left.Enabled = false;
     bt_right.Enabled = false;
     _Side = Side.Right;
     lb_status.Text = "Press space to save right point";
 }
예제 #20
0
        public bool getAveragePrice(MarketData md, int qty, Side side, int leg)
        {
            long tempPrice = 0;
            long tempQty = 0;
            for (int i = 0; i < 5; ++i)
            {
                long p = md.getPrice(side, i + 1);
                long q = md.getQty(side, i + 1);

                tempPrice += p * q;
                tempQty += q;

                if (tempQty >= qty)
                    break;
            }

            if (tempQty < qty)
            {
                if (leg == 1)
                    _data.avgPriceFirstLeg = 0;
                else
                    _data.avgPriceSecondLeg = 0;
                return false;
            }
            if (leg == 1)
                _data.avgPriceFirstLeg = (int)(tempPrice / tempQty);
            else
                _data.avgPriceSecondLeg = (int)(tempPrice / tempQty);

            return true;
        }
예제 #21
0
파일: Pawn.cs 프로젝트: peleccom/chess
 public Pawn(Position pos, Side side, ChessField chessfield)
     : base(pos,side, chessfield)
 {
     FigureType = FigureTypes.Pawn;
     movepolitics = new MovePolitics[] { chessfield.VerticalMovePolitics};
     attackpolitics = new MovePolitics[] { chessfield.DiagMovePolitics};
 }
예제 #22
0
파일: IPlayer.cs 프로젝트: Phrogz/laink
        public Side side; // The side that it would be played on

        #endregion Fields

        #region Constructors

        public TurnOption(Dom inPlayed, Side inSide, List<Dom> inHand, List<int> inBoard)
        {
            played = inPlayed;
            side = inSide;
            hand = inHand;
            board = inBoard;
        }
예제 #23
0
 public override MultiOrderLeg GetLeg(Side side,string instrument)
 {
     if (side == Side.Buy)
         return Buy;
     else
         return Sell;
 }
예제 #24
0
 public Paddle(Side side, GameOfPaddles game) {
     _side = side;
     _game = game;
     _world = game.World;
     _ball = _world["ball"];
     _pixels = new PlayerMissile[Size];
     for(var i = 0; i < Size; i++) {
         _pixels[i] = new PlayerMissile(
             "paddle" +
             (_side == Side.Right ? 'R' : 'L') +
             i,
             _side == Side.Right ? 7 : 0,
             i,
             _world);
     }
     _world.Coinc +=
         (s, a) => {
             if (_ball.X == 0 && _side == Side.Left) {
                 _game.BallGoingRight = true;
             }
             if (_ball.X == 7 && _side == Side.Right) {
                 _game.BallGoingRight = false;
             }
         };
 }
예제 #25
0
 public Position getPosition(Instrument instrument, Side orderMode)
 {
     IntPtr cPtr = ContextModulePINVOKE.NetPositions_getPosition(swigCPtr, Instrument.getCPtr(instrument), (int)orderMode);
     Position ret = (cPtr == IntPtr.Zero) ? null : new Position(cPtr, false);
     if (ContextModulePINVOKE.SWIGPendingException.Pending) throw ContextModulePINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
예제 #26
0
        private async void MoveWindowOutOfScreen(Side side)
        {
            BaseWindow.Topmost = true;
            MoveOut?.Invoke(this, EventArgs.Empty);
            if (side == Side.Left)
            {
                for (var i = 0; i > -32; i--)
                {
                    await Task.Delay(1);
                    BaseWindow.Left = i * 10 + WpfScreen.MostLeftX;
                }
            }
            else
            {
                for (int i = 0; i < 32; i++)
                {
                    await Task.Delay(1);
                    BaseWindow.Left = WpfScreen.MostRightX - BaseWindow.Width + i * 10;
                }
            }

            _movedOut = true;
            BaseWindow.ShowInTaskbar = false;
            _movedOutSide = side;
            StartMagic();
        }
예제 #27
0
파일: Program.cs 프로젝트: NikitaVas/CSharp
 static void ShowSidesInfo(Side[] sides)
 {
     foreach (var side in sides)
     {
         Console.WriteLine(side.Length);
     }
 }
예제 #28
0
파일: DbWords.cs 프로젝트: hmehr/OSS
 public DbWords(int CardId, Side ListSide, WordType ListType, ParentClass parentClass)
 {
     id = CardId;
     side = ListSide;
     type = ListType;
     parent = parentClass;
 }
예제 #29
0
파일: Jugador.cs 프로젝트: Gaedr/practica2
        /// <summary>
        /// Inicializa el Jugador a partir de su <see cref="Side"/>
        /// </summary>
        /// <param name="side"></param>
        public Jugador(Side side)
        {
            //Inicializamos las variables
            paddlePosition = new Point();
            paddlePositionPast = new Point();
            position = new Point();
            this.side = side;
            score = 0;

            //Creamos el puntero para ver donde se encuentra la mano del jugador
            mark = new Ellipse();
            mark.Width = Utilities.PLAYER_ELLIPSE_RADIUS;
            mark.Height = Utilities.PLAYER_ELLIPSE_RADIUS;

            //Creamos la barra del jugador
            shape = new Rectangle();
            shape.Width = Utilities.PADDLE_WIDTH;
            shape.Height = Utilities.PADDLE_HEIGHT; ;
            shape.Stroke = new SolidColorBrush(Colors.White);
            shape.StrokeThickness = 2;

            //Coloreamos según el jugador que sea
            switch (side) {
                case Side.Player1:
                mark.Fill = new SolidColorBrush(Utilities.PLAYER1_COLOR);
                shape.Fill = new SolidColorBrush(Utilities.PLAYER1_COLOR);
                break;
                case Side.Player2:
                mark.Fill = new SolidColorBrush(Utilities.PLAYER2_COLOR);
                shape.Fill = new SolidColorBrush(Utilities.PLAYER2_COLOR);
                break;
            }
            isConnected = false;
        }
예제 #30
0
파일: Knight.cs 프로젝트: peleccom/chess
 public Knight(Position pos, Side side, ChessField chessfield)
     : base(pos, side, chessfield)
 {
     FigureType = FigureTypes.Knight;
     movepolitics = new MovePolitics[] {
                                 chessfield.KnightMovePolitics};
 }
예제 #31
0
        public async Task <OrderResponse> StopLossOrderAsync(string pair, decimal quantity, decimal price, decimal stopPrice, Side side)
        {
            Binance.NetCore.Entities.Side binanceSide = this.BinanceSideReConverter(side);

            var response = await binance.StopLossLimitAsync(pair, binanceSide, quantity, price, stopPrice, Binance.NetCore.Entities.TimeInForce.GTC);

            return(this.BinanceTradeResponseToOrderResponse(response));
        }
예제 #32
0
 public bool CanConnect(Side side)
 {
     return(IO[side]);
 }
예제 #33
0
 public void Initialize(Side side)
 {
     m_side = side;
 }
예제 #34
0
 private IEnumerable <PersonViewModel> GetPersons(Side side)
 {
     return(side == Side.Home ? homePersons : awayPersons);
 }
예제 #35
0
        public async Task <OrderResponse> LimitOrderAsync(string pair, decimal price, decimal quantity, Side side)
        {
            Binance.NetCore.Entities.Side binanceSide = this.BinanceSideReConverter(side);

            var response = await binance.LimitOrderAsync(pair, binanceSide, quantity, price);

            return(this.BinanceTradeResponseToOrderResponse(response));
        }
예제 #36
0
파일: Program.cs 프로젝트: trarck/ExcelData
        static void Main(string[] args)
        {
            string excelFile     = null;
            string dataFile      = null;
            Side   side          = Side.All;
            string headModel     = null;
            string dataFormatStr = null;
            string dataType      = "List<Dictionary<string, object>>";

            optionSet = new OptionSet()
            {
                { "excelFile=", "Excel folder path", s => excelFile = s },
                { "dataFile=", "The code out folder", s => dataFile = s },
                { "headModel=", "The last export info.", s => headModel = s },
                { "side=", "The last export info.", s => side = (Side)Enum.Parse(typeof(Side), s) },
                { "dataFormat=", "Data format", s => dataFormatStr = s },
                { "dataType=", "Data Type", s => dataType = s },
            };

            optionSet.Parse(args);

            if (string.IsNullOrEmpty(excelFile))
            {
                Console.WriteLine("Excel file is null");
                return;
            }

            if (string.IsNullOrEmpty(dataFile))
            {
                Console.WriteLine("Code out path is null");
                return;
            }

            if (!Path.IsPathRooted(excelFile))
            {
                excelFile = Path.Combine(Directory.GetCurrentDirectory(), excelFile);
            }

            if (!Path.IsPathRooted(dataFile))
            {
                dataFile = Path.Combine(Directory.GetCurrentDirectory(), dataFile);
            }

            ImportSetting setting = new ImportSetting();

            if (!string.IsNullOrEmpty(headModel))
            {
                switch (headModel)
                {
                case "Normal":
                    setting.headModel = HeadModel.CreateNormalModel();
                    break;

                case "Simple":
                    setting.headModel = HeadModel.CreateSimpleModel();
                    break;

                //use default have side
                case "All":
                default:
                    break;
                }
            }

            ExcelImport import = new ExcelImport(setting);

            import.side = side;


            DataFormat dataFormat = (DataFormat)Enum.Parse(typeof(DataFormat), dataFormatStr);

            import.dataFormat = dataFormat;
            import.dataType   = TypeInfo.Parse(dataType).ToSystemType();

            import.Import(dataFile, excelFile);
        }
예제 #37
0
    protected override void ThreadFunction()   // Function ported from Main.greedy() at https://github.com/roboleary/GreedyMesh/blob/master/src/mygame/Main.java
    {
        int  i, j, k, l, w, h, u, v, n;
        Side side = Side.TOP;

        int[] x  = new int[] { 0, 0, 0 };
        int[] q  = new int[] { 0, 0, 0 };
        int[] du = new int[] { 0, 0, 0 };
        int[] dv = new int[] { 0, 0, 0 };

        VoxelFace[] mask = new VoxelFace[Chunk.chunkSize * Chunk.chunkSize];

        VoxelFace comp1, comp2;

        VoxelFace nullFace = new VoxelFace()
        {
            srcBlock = null
        };

        for (bool backFace = true, b = false; b != backFace; backFace = backFace && b, b = !b)
        {
            for (int d = 0; d < 3; d++)
            {
                u = (d + 1) % 3;
                v = (d + 2) % 3;

                x    = new int[] { 0, 0, 0 };
                q    = new int[] { 0, 0, 0 };
                q[d] = 1;

                switch (d)
                {
                case 0:
                    side = backFace ? Side.WEST : Side.EAST;
                    break;

                case 1:
                    side = backFace ? Side.BOTTOM : Side.TOP;
                    break;

                case 2:
                    side = backFace ? Side.SOUTH : Side.NORTH;
                    break;
                }

                for (x[d] = -1; x[d] < Chunk.chunkSize;)
                {
                    // Generate Mask
                    n = 0;
                    for (x[v] = 0; x[v] < Chunk.chunkSize; x[v]++)
                    {
                        for (x[u] = 0; x[u] < Chunk.chunkSize; x[u]++)
                        {
                            comp1 = (x[d] >= 0) ? GetVoxelFace(x[0], x[1], x[2], side) : nullFace;
                            comp2 = (x[d] < Chunk.chunkSize - 1) ? GetVoxelFace(x[0] + q[0], x[1] + q[1], x[2] + q[2], side) : nullFace;

                            mask[n++] = (comp1 != nullFace && comp2 != nullFace && comp1 == comp2) ? nullFace : (backFace ? comp2 : comp1);
                        }
                    }

                    x[d]++;

                    // Generate Mesh
                    n = 0;
                    for (j = 0; j < Chunk.chunkSize; j++)
                    {
                        for (i = 0; i < Chunk.chunkSize;)
                        {
                            if (mask[n] == nullFace)
                            {
                                // Compute width
                                for (w = 1; i + w < Chunk.chunkSize && mask[n + w] != nullFace && mask[n + w] == mask[n]; w++)
                                {
                                }

                                // Compute height
                                bool done = false;
                                for (h = 1; j + h < Chunk.chunkSize; h++)
                                {
                                    for (k = 0; k < w; k++)
                                    {
                                        if (mask[n + k + h * Chunk.chunkSize] == nullFace || mask[n + k + h * Chunk.chunkSize] != mask[n])
                                        {
                                            done = true; break;
                                        }
                                    }
                                    if (done)
                                    {
                                        break;
                                    }
                                }

                                if (!mask[n].culled)  // Ensure this face hasn't been culled
                                {
                                    x[u] = i;
                                    x[v] = j;

                                    du    = new int[] { 0, 0, 0 };
                                    du[u] = w;
                                    dv    = new int[] { 0, 0, 0 };
                                    dv[v] = h;

                                    var vertexIndex = vertices.Count;

                                    vertices.AddRange(new Vector3[] {
                                        new Vector3(x[0], x[1], x[2]),
                                        new Vector3(x[0] + du[0], x[1] + du[1], x[2] + du[2]),
                                        new Vector3(x[0] + du[0] + dv[0], x[1] + du[1] + dv[1], x[2] + du[2] + dv[2]),
                                        new Vector3(x[0] + dv[0], x[1] + dv[1], x[2] + dv[2]),
                                    });

                                    var uv = mask[n].srcBlock.getUv(side);
                                    uvs.AddRange(new Vector2[] { uv, uv, uv, uv });

                                    if (backFace)
                                    {
                                        tris.AddRange(new int[] { vertexIndex + 2, vertexIndex, vertexIndex + 1,
                                                                  vertexIndex + 1, vertexIndex + 3, vertexIndex + 2 });
                                    }
                                    else
                                    {
                                        tris.AddRange(new int[] { vertexIndex + 2, vertexIndex + 3, vertexIndex + 1,
                                                                  vertexIndex + 1, vertexIndex, vertexIndex + 2 });
                                    }
                                }

                                // Empty the mask
                                for (l = 0; l < h; l++)
                                {
                                    for (k = 0; k < w; k++)
                                    {
                                        mask[n + k + l * Chunk.chunkSize] = nullFace;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
예제 #38
0
 /// <summary>
 /// Gets the characters.
 /// </summary>
 /// <param name="side">The side.</param>
 /// <returns></returns>
 public ICollection <Character> GetCharacters(Side side)
 {
     return(side == Side.LEFT ? Left : Right);
 }
        /// <summary>
        /// Stitchs the terrains.
        /// </summary>
        /// <param name="terrain">Terrain.</param>
        /// <param name="second">Second.</param>
        /// <param name="side">Side.</param>
        /// <param name="xBase">X base.</param>
        /// <param name="yBase">Y base.</param>
        /// <param name="width">Width.</param>
        /// <param name="height">Height.</param>
        /// <param name="range">Range.</param>
        /// <param name="smooth">If set to <c>true</c> smooth.</param>
        public static void StitchTerrains(Terrain terrain, Terrain second, Side side, int xBase, int yBase, int width, int height, int range, bool smooth = false)
        {
            TerrainData terrainData = terrain.terrainData;
            TerrainData secondData  = second.terrainData;



            //Debug.Log (xBase + " " + (terrainData.heightmapHeight - 1) + " " + (xBase + width) + " " + 1);

            if (side == Side.Right)
            {
                float[,] heights       = terrainData.GetHeights(terrainData.heightmapWidth - width, yBase, width, height);
                float[,] secondHeights = secondData.GetHeights(0, yBase, range > 0 ? range : 1, height);


                //Debug.Log ("Right " + heights.GetLength (0) + " " + heights.GetLength (1));
                checkLength = width;

                int y = width - 1;
                int x = 0;

                int y2 = 0;

                for (x = 0; x < heights.GetLength(0); x++)
                {
                    if (heights [x, y] == secondHeights [x, y2])
                    {
                        continue;
                    }

                    heights [x, y] = average(heights [x, y], secondHeights [x, y2]);

                    if (smooth)
                    {
                        heights [x, y] += Mathf.Abs(heights [x, y - 1] - secondHeights [x, y2 + 1]) / levelSmooth;
                    }

                    secondHeights [x, y2] = heights [x, y];

                    for (int i = 1; i < checkLength; i++)
                    {
                        heights [x, y - i] = (average(heights [x, y - i], heights [x, y - i + 1]) + Mathf.Abs(heights [x, y - i] - heights [x, y - i + 1]) / levelSmooth) * (checkLength - i) / checkLength + heights [x, y - i] * i / checkLength;
                    }
                    for (int i = 1; i < range; i++)
                    {
                        secondHeights [x, y2 + i] = (average(secondHeights [x, y2 + i], secondHeights [x, y2 + i - 1]) + Mathf.Abs(secondHeights [x, y2 + i] - secondHeights [x, y2 + i - 1]) / levelSmooth) * (range - i) / range + secondHeights [x, y2 + i] * i / range;
                    }
                }
                terrainData.SetHeightsDelayLOD(terrainData.heightmapWidth - width, yBase, heights);
                terrain.terrainData = terrainData;

                secondData.SetHeightsDelayLOD(0, yBase, secondHeights);
                second.terrainData = secondData;
            }
            else
            {
                if (side == Side.Top)
                {
                    float[,] heights = terrainData.GetHeights(xBase, terrainData.heightmapHeight - height, width, height);

                    float[,] secondHeights = secondData.GetHeights(xBase, 0, width, range > 0 ? range : 1);


                    checkLength = height;
                    int y = 0;
                    int x = height - 1;
                    //Debug.Log (x + " " + height + " " + range + " " + heights.GetLength (0) + " " + heights.GetLength (1) + " " + secondHeights.GetLength (0) + " " + secondHeights.GetLength (1));


                    int x2 = 0;

                    for (y = 0; y < heights.GetLength(1); y++)
                    {
                        if (heights [x, y] == secondHeights [x2, y])
                        {
                            continue;
                        }

                        heights [x, y] = average(heights [x, y], secondHeights [x2, y]);

                        if (smooth)
                        {
                            heights [x, y] += Mathf.Abs(heights [x - 1, y] - secondHeights [x2 + 1, y]) / levelSmooth;
                        }


                        secondHeights [x2, y] = heights [x, y];

                        for (int i = 1; i < checkLength; i++)
                        {
                            heights [x - i, y] = (average(heights [x - i, y], heights [x - i + 1, y]) + Mathf.Abs(heights [x - i, y] - heights [x - i + 1, y]) / levelSmooth) * (checkLength - i) / checkLength + heights [x - i, y] * i / checkLength;
                        }
                        for (int i = 1; i < range; i++)
                        {
                            secondHeights [x2 + i, y] = (average(secondHeights [x2 + i, y], secondHeights [x2 + i - 1, y]) + Mathf.Abs(secondHeights [x2 + i, y] - secondHeights [x2 + i - 1, y]) / levelSmooth) * (range - i) / range + secondHeights [x2 + i, y] * i / range;
                        }
                    }


                    terrainData.SetHeightsDelayLOD(xBase, terrainData.heightmapHeight - height, heights);
                    terrain.terrainData = terrainData;

                    secondData.SetHeightsDelayLOD(xBase, 0, secondHeights);
                    second.terrainData = secondData;
                }
            }



            terrain.Flush();
            second.Flush();
        }
        /// <summary>
        /// Stitchs the terrains and repairs errors.
        /// </summary>
        /// <param name="terrain">Terrain.</param>
        /// <param name="second">Second.</param>
        /// <param name="side">Side.</param>
        /// <param name="xBase">X base.</param>
        /// <param name="yBase">Y base.</param>
        /// <param name="width">Width.</param>
        /// <param name="height">Height.</param>
        public static void StitchTerrainsRepair(Terrain terrain, Terrain second, Side side, int xBase, int yBase, int width, int height)
        {
            TerrainData terrainData = terrain.terrainData;
            TerrainData secondData  = second.terrainData;



            if (side == Side.Right)
            {
                float[,] heights       = terrainData.GetHeights(terrainData.heightmapWidth - 1, yBase, 1, height);
                float[,] secondHeights = secondData.GetHeights(0, yBase, 1, height);


                int y = 0;
                int x = 0;

                int y2 = 0;

                for (x = 0; x < heights.GetLength(0); x++)
                {
                    if (heights [x, y] == secondHeights [x, y2])
                    {
                        continue;
                    }

                    heights [x, y] = average(heights [x, y], secondHeights [x, y2]);


                    secondHeights [x, y2] = heights [x, y];
                }

                terrainData.SetHeightsDelayLOD(terrainData.heightmapWidth - 1, yBase, heights);
                terrain.terrainData = terrainData;

                secondData.SetHeightsDelayLOD(0, yBase, secondHeights);
                second.terrainData = secondData;
            }
            else
            {
                if (side == Side.Top)
                {
                    //Debug.Log ("top");
                    float[,] heights = terrainData.GetHeights(xBase, terrainData.heightmapHeight - 1, width, 1);

                    float[,] secondHeights = secondData.GetHeights(xBase, 0, width, 1);

                    int y = 0;
                    int x = 0;

                    int x2 = 0;

                    for (y = 0; y < heights.GetLength(1); y++)
                    {
                        if (heights [x, y] == secondHeights [x2, y])
                        {
                            continue;
                        }

                        heights [x, y] = average(heights [x, y], secondHeights [x2, y]);


                        secondHeights [x2, y] = heights [x, y];
                    }

                    terrainData.SetHeightsDelayLOD(xBase, terrainData.heightmapHeight - 1, heights);
                    terrain.terrainData = terrainData;

                    secondData.SetHeightsDelayLOD(xBase, 0, secondHeights);
                    second.terrainData = secondData;
                }
            }



            terrain.Flush();
            second.Flush();
        }
예제 #41
0
 public Piece(Side owner, int stackLimit, params ShapeOrientation[] shapes)
 {
     Owner      = owner;
     StackLimit = stackLimit;
     Shapes     = new ShapeOrientationCollection(shapes, true);
 }
 public void Interrupt(Side side)
 {
     source.Interrupt(side);
 }
예제 #43
0
 public Piece(Side owner, int stackLimit, ShapeOrientationCollection shapes)
 {
     Owner      = owner;
     StackLimit = stackLimit;
     Shapes     = shapes;
 }
예제 #44
0
 private int GetTeamId(Side side)
 {
     return(side == Side.Home ? protocolManager.Game.homeId : protocolManager.Game.awayId);
 }
예제 #45
0
 public bool TryGetLength(int start, Side side, out int length)
 {
     return(inner.TryGetLength(start, side, out length));
 }
예제 #46
0
 public bool TrySetLength(int start, Side side, int length)
 {
     return(inner.TrySetLength(start, side, length));
 }
예제 #47
0
 public bool TryInsert(int start, Side side, int xLength, int yLength)
 {
     return(inner.TryInsert(start, side, xLength, yLength, null));
 }
예제 #48
0
 public bool TryDelete(int start, Side side)
 {
     return(inner.TryDelete(start, side));
 }
예제 #49
0
 public IEnumerable <EntryRange2List> GetRobustEnumerable(int startAt, Side side, bool forward)
 {
     return(new AdaptEnumerable <EntryRange2List, EntryRange2Map <object> >(
                inner.GetRobustEnumerable(startAt, side, forward),
                Convert));
 }
예제 #50
0
 public bool Contains(int start, Side side)
 {
     return(inner.Contains(start, side));
 }
예제 #51
0
        public bool NearestGreater(int position, Side side, out int nearestStart, out int otherStart, out int xLength, out int yLength)
        {
            object value;

            return(inner.NearestGreater(position, side, out nearestStart, out otherStart, out xLength, out yLength, out value));
        }
예제 #52
0
 public IEnumerable <EntryRange2List> GetFastEnumerable(int startAt, Side side)
 {
     return(new AdaptEnumerable <EntryRange2List, EntryRange2Map <object> >(
                inner.GetFastEnumerable(startAt, side),
                Convert));
 }
예제 #53
0
 public bool NearestLessOrEqual(int position, Side side, out int nearestStart)
 {
     return(inner.NearestLessOrEqual(position, side, out nearestStart));
 }
예제 #54
0
 public bool NearestGreater(int position, Side side, out int nearestStart)
 {
     return(inner.NearestGreater(position, side, out nearestStart));
 }
예제 #55
0
 public int AdjustLength(int start, Side side, int xAdjust, int yAdjust)
 {
     return(inner.AdjustLength(start, side, xAdjust, yAdjust));
 }
예제 #56
0
 public int GetExtent(Side side)
 {
     return(inner.GetExtent(side));
 }
예제 #57
0
        public void Get(int start, Side side, out int otherStart, out int xLength, out int yLength)
        {
            object value;

            inner.Get(start, side, out otherStart, out xLength, out yLength, out value);
        }
예제 #58
0
 public void Set(int start, Side side, int xLength, int yLength)
 {
     inner.Set(start, side, xLength, yLength, null);
 }
    protected override MapArrayTile[,] GeneratePathInto(int seed, Side side,
                                                        MapArrayGenerator otherMapArrayGenerator, out Vector2 connectorCoords, out Vector2 plugCoords)
    {
        System.Random random        = new System.Random(seed);
        int           hallThickness = random.Next((int)hallThicknessRange.x, (int)hallThicknessRange.y);
        int           hallYCoord    = random.Next((int)otherMapArrayGenerator.roomBoundingRect.min.y + hallThickness / 2,
                                                  (int)otherMapArrayGenerator.roomBoundingRect.max.y - (hallThickness + 1) / 2);
        int hallXCoord = random.Next((int)otherMapArrayGenerator.roomBoundingRect.min.x + hallThickness / 2,
                                     (int)otherMapArrayGenerator.roomBoundingRect.max.x - (hallThickness + 1) / 2);

        MapArrayTile[,] otherMapArray = otherMapArrayGenerator.mapArray;
        Rect otherRoomBoundingRect = otherMapArrayGenerator.roomBoundingRect;

        plugCoords      = Vector2.zero;
        connectorCoords = Vector2.zero;

        switch (side)
        {
        case Side.Left:
            connectorCoords = new Vector2(-0.5f, hallYCoord);
            plugCoords      = new Vector2((int)otherRoomBoundingRect.min.x - 0.5f, hallYCoord);
            break;

        case Side.Right:
            connectorCoords = new Vector2(otherMapArray.GetLength(0) - 0.5f, hallYCoord);
            plugCoords      = new Vector2((int)otherRoomBoundingRect.max.x - 0.5f, hallYCoord);
            break;

        case Side.Top:
            connectorCoords = new Vector2(hallXCoord, otherMapArray.GetLength(1) - 0.5f);
            plugCoords      = new Vector2(hallXCoord, (int)otherRoomBoundingRect.max.y - 0.5f);
            break;

        case Side.Bottom:
            connectorCoords = new Vector2(hallXCoord, -0.5f);
            plugCoords      = new Vector2(hallXCoord, (int)otherRoomBoundingRect.min.y - 0.5f);
            break;

        default:
            Debug.Log("Side does not exist");
            break;
        }

        MapArrayTile[,] pathArray = new MapArrayTile[otherMapArray.GetLength(0), otherMapArray.GetLength(1)];
        FillWith(pathArray, MapArrayTile.None);

        //Returns the position of the connector in map coords
        switch (side)
        {
        case Side.Left:
            FillBoxWith(pathArray, 0, (int)otherRoomBoundingRect.min.x,
                        hallYCoord - hallThickness / 2, hallYCoord + (hallThickness + 1) / 2, MapArrayTile.Ground);
            break;

        case Side.Right:
            FillBoxWith(pathArray, (int)otherRoomBoundingRect.max.x, pathArray.GetLength(0),
                        hallYCoord - hallThickness / 2, hallYCoord + (hallThickness + 1) / 2, MapArrayTile.Ground);
            break;

        case Side.Top:
            FillBoxWith(pathArray, hallXCoord - hallThickness / 2, hallXCoord + (hallThickness + 1) / 2,
                        (int)otherRoomBoundingRect.max.y, pathArray.GetLength(1), MapArrayTile.Ground);
            break;

        case Side.Bottom:
            FillBoxWith(pathArray, hallXCoord - hallThickness / 2, hallXCoord + (hallThickness + 1) / 2,
                        0, (int)otherRoomBoundingRect.min.y, MapArrayTile.Ground);
            break;

        default:
            Debug.Log("Side does not exist");
            break;
        }
        return(pathArray);
    }
예제 #60
0
 public void SetLength(int start, Side side, int length)
 {
     inner.SetLength(start, side, length);
 }