public Entity AddGrid(int newType, float newFieldSize, GridState[,] newGrid)
 {
     var component = CreateComponent<GridComponent>(ComponentIds.Grid);
     component.type = newType;
     component.fieldSize = newFieldSize;
     component.grid = newGrid;
     return AddComponent(ComponentIds.Grid, component);
 }
 GridState[,] getEmptyGrid(int x, int y)
 {
     GridState[,] grid = new GridState[x, y];
     for (int i = 0; i < grid.GetLength(0); i++) {
         for (int j = 0; j < grid.GetLength(1); j++) {
             grid[i, j] = GridState.FREE;
         }
     }
     return grid;
 }
Beispiel #3
0
 static Predicate<List<int>> ByGridForWhite(GridState entry, int iStart, int iFinish)
 {
     return delegate(List<int> x)
     {
         int iIndex = x.FindIndex(ByInt(iStart));
         int iFinishIndex = x.FindIndex(ByInt(iFinish));
         bool bCanMoveForwardForWhite = (iIndex + 1 < x.Count && iIndex >= 0 && x[iIndex] < x[iIndex + 1]) && iFinishIndex < x.Count;
         bool b = iIndex != -1 && iFinishIndex != -1 && ((entry == GridState.WHITEPAWN && bCanMoveForwardForWhite) || entry == GridState.WHITEKING);
         return b;
     };
 }
 //get the state of girds, for reserved
 private GridState[] getGridsState(Coordinate[] target_locations)
 {
     MapGrid[] target_mapgrids = getMapGrids (target_locations);
     int length = target_mapgrids.Length;
     GridState[] result = new GridState[length];
     int i;
     for(i=0;i<length;i++)
     {
         result[i] = target_mapgrids[i].grid.GetComponent<Grid> ().getState();
     }
     return result;
 }
Beispiel #5
0
        public GridModel GetOrders(GridState state)
        {
            NorthwindDataContext northwind = new NorthwindDataContext();
            IQueryable<OrderDto> orders = from o in northwind.Orders
                                          select new OrderDto
                                          {
                                              OrderID = o.OrderID,
                                              ContactName = o.Customer.ContactName,
                                              ShipAddress = o.ShipAddress,
                                              OrderDate = o.OrderDate
                                          };

            return orders.ToGridModel(state);
        }
Beispiel #6
0
 void findField(GridState[,] grid, GridState state, out int x, out int y)
 {
     for (int i = 0; i < grid.GetLength(0); i++) {
         for (int j = 0; j < grid.GetLength(1); j++) {
             if (grid[i,j] == state) {
                 x = i;
                 y = j;
                 return;
             }
         }
     }
     x = 0;
     y = 0;
 }
Beispiel #7
0
 //setState, public method to change the state of grid and swap to the corresponding color
 public GridState setState(GridState _state)
 {
     state = _state;
     if (state == GridState.Move)
                     changeColor (color_move);
             else if (state == GridState.Attack)
                     changeColor (color_attack);
             else if (state == GridState.Both)
                     changeColor (color_both);
             else if (state == GridState.Sleep)
                     changeColor (color_sleep);
             else if (state == GridState.Selected)
                     changeColor (color_selected);
     return state;
 }
Beispiel #8
0
        public Move MoveISLegal(GridState Piece, int iStartIndex, int iFinishIndex)
        {
            var BoardArray = Board.ToList().OrderBy(o => o.Index).Select(s => s.Color).ToArray();
            List<List<int>> linesToEvaluate = gameLines.FindAll(ByGridForWhite(BoardArray[iStartIndex], iStartIndex, iFinishIndex));
            List<int> line = linesToEvaluate[0];
            int _moveSquare = 0;
            int _captureSquare = 0;
            GridState _finalSate = Piece;
            bool _IsMove = false;
            bool _IsCapture = false;


            bool bKing = iFinishIndex < iStartIndex && Piece == GridState.WHITEKING;


            int squareCurrentPieceIsOnIndex = line.IndexOf(iStartIndex);
            int squareToMoveToIndex = BoardArray[iStartIndex] == GridState.WHITEKING ? (bKing ? squareCurrentPieceIsOnIndex - 1 : squareCurrentPieceIsOnIndex + 1) : squareCurrentPieceIsOnIndex + 1;
            int captureIndexForWhiteIndex = BoardArray[iStartIndex] == GridState.WHITEKING ? (bKing ? squareCurrentPieceIsOnIndex - 2 : squareCurrentPieceIsOnIndex + 2) : squareCurrentPieceIsOnIndex + 2;
            GridState startingSquare = BoardArray[iStartIndex];

            if (squareToMoveToIndex >= 0 && squareToMoveToIndex < line.Count())
            {
                _moveSquare = line[squareToMoveToIndex];
                _captureSquare = captureIndexForWhiteIndex > 0 && captureIndexForWhiteIndex < line.Count() ? line[captureIndexForWhiteIndex] : -1;

                bool bHasCaptureSquareToLandOn = _captureSquare >= 0 && BoardArray[_captureSquare] == GridState.EMPTY;
                bool bHasPieceThatCanBeCaptued = BoardArray[_moveSquare] == GridState.BLACKKING || BoardArray[_moveSquare] == GridState.BLACKPAWN;
                bool bHasMoveThatCanBeMade = BoardArray[_moveSquare] == GridState.EMPTY;

                if ((bHasMoveThatCanBeMade || (bHasCaptureSquareToLandOn && bHasPieceThatCanBeCaptued)) == false)
                    return new Move { StartIndex = iStartIndex, PieceState = _finalSate, IsMove = false, IsCapture = false, CaptureIndex = _captureSquare, MoveIndex = _moveSquare };

                if (BoardArray[_moveSquare] == GridState.EMPTY)
                {
                    _finalSate = (startingSquare == GridState.WHITEPAWN && (_moveSquare == 56 || _moveSquare == 58 || _moveSquare == 60 || _moveSquare == 62)) ? GridState.WHITEKING : startingSquare;
                    _IsMove = true;
                }

                if (_captureSquare > 0 && !_IsMove)
                {
                    _finalSate = (startingSquare == GridState.WHITEPAWN && (_moveSquare == 56 || _moveSquare == 58 || _moveSquare == 60 || _moveSquare == 62)) ? GridState.WHITEKING : startingSquare;
                    _IsCapture = true;
                }
            }
            

            return new Move { StartIndex = iStartIndex, PieceState = _finalSate, IsMove = _IsMove, IsCapture = _IsCapture, CaptureIndex = _captureSquare, MoveIndex = _moveSquare };
        }
Beispiel #9
0
 void findRandomField(GridState[,] grid, GridState state, out int x, out int y)
 {
     List<Point2D> freeFields = new List<Point2D>();
     for (int i = 0; i < grid.GetLength(0); i++) {
         for (int j = 0; j < grid.GetLength(1); j++) {
             if (grid[i, j] == state) {
                 freeFields.Add(new Point2D(i, j));
             }
         }
     }
     if (freeFields.Count > 0) {
         Point2D point = freeFields[Random.Range(0, freeFields.Count - 1)];
         x = point.x;
         y = point.y;
     }
     else {
         x = 0;
         y = 0;
     }
 }
Beispiel #10
0
    ///
    /// Check the world positioning of this zone and adjust it into the
    /// world bounds if it is outside.
    ///
    void CheckZoneWorldPosition()
    {
        Vector3 backgroundPos = backgroundPlane.transform.position;

        Rect   worldBounds = Game.Instance.WorldBoundaries;
        Bounds zoneBounds  = backgroundRenderer.bounds;

        if (zoneBounds.min.x < worldBounds.min.x)
        {
            backgroundPos.x += worldBounds.min.x - zoneBounds.min.x;
        }
        else if (zoneBounds.max.x > worldBounds.max.x)
        {
            backgroundPos.x -= zoneBounds.max.x - worldBounds.max.x;
        }

        if (zoneBounds.min.z < worldBounds.min.y)
        {
            backgroundPos.z += worldBounds.min.y - zoneBounds.min.z;
        }
        else if (zoneBounds.max.z > worldBounds.max.y)
        {
            backgroundPos.z -= zoneBounds.max.z - worldBounds.max.y;
        }

        backgroundPlane.transform.position = backgroundPos;

        var newBounds = backgroundRenderer.bounds;

        for (float x = newBounds.min.x; x < newBounds.max.x; x += Game.Instance.gridWidth)
        {
            for (float z = newBounds.min.z; z < newBounds.max.z; z += Game.Instance.gridHeight)
            {
                int       gp = Game.Instance.GetGrid(new Vector3(x, 0, z));
                GridState gs = Game.Instance.GetGridState(gp);
                gs.isEnemyArea = true;
            }
        }
    }
Beispiel #11
0
 //单击某个网格,设置对应状态
 void OnGridClicked(UIGridController grid)
 {
     if (m_settingState == GridState.Player)
     {
         grid.state = GridState.Player;
         if (m_player != null)
         {
             m_player.state = GridState.Default;
         }
         m_player = grid;
         SetHint();
         m_settingState = GridState.Default;
     }
     else if (m_settingState == GridState.Destination)
     {
         grid.state = GridState.Destination;
         if (m_destination != null)
         {
             m_destination.state = GridState.Default;
         }
         m_destination = grid;
         SetHint();
         m_settingState = GridState.Default;
     }
     else if (m_settingState == GridState.Obstacle)
     {
         if (grid.state == GridState.Default)
         {
             grid.state = GridState.Obstacle;
             m_obstacleDic[grid.position] = grid;
         }
         else if (grid.state == GridState.Obstacle)
         {
             grid.state = GridState.Default;
             m_obstacleDic.Remove(grid.position);
         }
     }
 }
Beispiel #12
0
    // Update is called once per frame
    void FixedUpdate()
    {
        switch (gridState)
        {
        case GridState.DISABLED:
            break;

        case GridState.GENERATINGGRID:
            if (cardsInMovement == 0)
            {
                gridState = GridState.ROTATINGALLCARDS;
            }
            break;

        case GridState.ROTATINGALLCARDS:
            RotateAllCards();
            gridState = GridState.DISABLED;
            GetComponent <GameController>().gs = GameController.GameState.INITGAME;
            break;

        case GridState.CLEANED:
            GetComponent <GameController>().gs = GameController.GameState.CHANGEMENU;
            cardsInMovement = 0;
            gridState       = GridState.DISABLED;
            break;

        case GridState.ALLCARDSSTOPED:

            if (cardsInMovement == 0)
            {
                //Debug.Log("all cards still stoped");
                gridState = GridState.DISABLED;
                GetComponent <InputController>().DeactivateInput(true);
                GetComponent <GameController>().gs = GameController.GameState.GAMELOOP;
            }
            break;
        }
    }
Beispiel #13
0
    Grid AddGrid(int r, int c, GridState state)
    {
        GameObject gridGO = null;

        if (state == GridState.FREE)
        {
            gridGO = Instantiate(m_gridEmpty) as GameObject;
        }
        else if (state == GridState.FULL)
        {
            gridGO = Instantiate(m_girdFull) as GameObject;
        }
        gridGO.transform.SetParent(transform);
        int posX = r - row / 2;
        int posZ = c - col / 2 + 1;

        gridGO.transform.position = new Vector3(posX, 0, posZ);
        Grid grid = gridGO.AddComponent <Grid> ();

        grid.State = state;
        grid.Row   = r;
        grid.Col   = c;

        GameObject textObj = Instantiate(m_UIText) as GameObject;

        textObj.transform.SetParent(m_canvas.transform);
        Vector3 textPos = Camera.main.WorldToScreenPoint(gridGO.transform.position);

        textPos.x -= 15;
        textPos.y -= 15;
        textObj.transform.position = textPos;
        textObj.transform.SetParent(m_canvas.transform);
        Text textUI = textObj.GetComponent <Text> ();

        textUI.text = "(" + r + "," + c + ")";

        return(grid);
    }
Beispiel #14
0
    public void Initialize(Player player, Vector3 nextTetrominoPos, Vector3 spawnPoint, int width, int height)
    {
        if (!isInitialized)
        {
            this.spawnPoint    = spawnPoint;
            this.player        = player;
            this.isInitialized = true;
            this.width         = width;
            this.height        = height;
            //default values in tetris playerGrid
            minosMatrix = new Transform[width, height];
            SetPreviewTetromino(nextTetrominoPos);
            SetEvents();
            gridState = GridState.InitializingGrid;

            SpawnNewTetrominoIntoGrid();
            player.currentGrid = this;
            if (player.currentRound >= 4 && player.currentRound < 7)
            {
                //desenhar as colunas
            }
        }
    }
Beispiel #15
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal void Build(GridState pGridState, IItemVisualSettingsProvider pItemVisualSettProv)
        {
            int cols = pGridState.ItemGrid.Cols;
            int gi   = 0;

            for (int i = 0; i < pGridState.Items.Length; i++)
            {
                BaseItemState       itemState  = pGridState.Items[i];
                IItemVisualSettings visualSett = pItemVisualSettProv.GetSettings(itemState.Item);
                GameObject          itemObj    = (GameObject)itemState.Item.DisplayContainer;
                var pos = new Vector3(gi % cols, 0, (float)Math.Floor((float)gi / cols));

                UiItem uiItem = itemObj.AddComponent <UiItem>();
                uiItem.Build(itemState, visualSett);
                uiItem.transform.localPosition = pos * UiItem.Size;

                gi += (int)itemState.Item.Width;
            }

            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localRotation = Quaternion.identity;
            gameObject.transform.localScale    = Vector3.one;
        }
Beispiel #16
0
    private void FillGrid()
    {
        try
        {
            StrSql        = new StringBuilder();
            StrSql.Length = 0;
            StrSql.AppendLine("Select SM.Id,SM.StateName");
            StrSql.AppendLine(",SM.CountryId As CountryId,CntM.CountryName");
            StrSql.AppendLine("From State_Mast SM");
            StrSql.AppendLine("Inner Join Country_Mast CntM On SM.CountryId=CntM.Id");
            StrSql.AppendLine("Order By SM.StateName,CntM.CountryName");

            dtTemp = new DataTable();
            dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString());

            GridState.DataSource = dtTemp;
            GridState.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Beispiel #17
0
    private void CheckState()
    {
        if (state == GridState.Stable && isChanging)
        {
            state = GridState.Changing;
            SelectionPoint.current.Deselect();
            return;
        }

        if (state == GridState.Changing && !isChanging)
        {
            if (CheckMatches())
            {
                return;
            }
            state = GridState.Stabilizing;
            return;
        }

        if (state == GridState.Stabilizing)
        {
            state = GridState.Stable;
            SelectionPoint.current.Select();
            if (!PossibleMovesExists())
            {
                OnNoMoveMovesLeft.Raise();
            }

            if (explosionOccured)
            {
                moveCount.value++;
                OnTileMatchEnd.Raise();
                explosionOccured = false;
            }
            return;
        }
    }
Beispiel #18
0
    /// <summary>
    /// Check Grid and counts Lines that are complete
    /// </summary>
    ///
    public void CheckRowsForClear()
    {
        gridState = GridState.ProcessingRows;

        int count = 0;

        for (int y = 0; y < height; ++y)
        {
            if (CheckIfRowIsFullAt(y))
            {
                count++;
            }
        }

        if (count > 0) //if it found rows start to delete
        {
            if (count == 4)
            {
                Debug.LogError("nao existe evento de tetris");
                FullTetrisCompletedEvent(); //fires an event of full tetris
                                            //Debug.LogWarning("needs to update score");
            }
            if (gridState == GridState.ProcessingRows)
            {
                StartCoroutine(RemoveCompletedRows(count, 0)); //using recursive clear Rows so it can update the moving rows
            }
        }
        else
        {
            if (gridState == GridState.ProcessingRows)
            {
                //nao fez nennuma
                CallGridProcessed();
            }
        }
    }
Beispiel #19
0
 public void SetGrid(int x, int y, GridState state)
 {
     if (state == GridState.None)
     {
         _matrix[x + y * Core.GEM_COUNT]           = (byte)state;
         _matrix[x + 1 + y * Core.GEM_COUNT]       = (byte)state;
         _matrix[x + (y + 1) * Core.GEM_COUNT]     = (byte)state;
         _matrix[x + 1 + (y + 1) * Core.GEM_COUNT] = (byte)state;
     }
     else if (state == GridState.Way)
     {
         _matrixBackground[x + y * Core.GEM_COUNT]           = (byte)state;
         _matrixBackground[x + 1 + y * Core.GEM_COUNT]       = (byte)GridState.Placeholder;
         _matrixBackground[x + (y + 1) * Core.GEM_COUNT]     = (byte)GridState.Placeholder;
         _matrixBackground[x + 1 + (y + 1) * Core.GEM_COUNT] = (byte)GridState.Placeholder;
     }
     else
     {
         _matrix[x + y * Core.GEM_COUNT]           = (byte)state;
         _matrix[x + 1 + y * Core.GEM_COUNT]       = (byte)GridState.Placeholder;
         _matrix[x + (y + 1) * Core.GEM_COUNT]     = (byte)GridState.Placeholder;
         _matrix[x + 1 + (y + 1) * Core.GEM_COUNT] = (byte)GridState.Placeholder;
     }
 }
Beispiel #20
0
 public void UpdateState(string gameId, GridState newState)
 {
     throw new NotImplementedException();
 }
 public override bool ExecuteAction(GridState gh, IList <PriceManager.Business.Filters.IFilter> filters, params object[] parameters)
 {
     return(ControllerManager.Selection.Remove(gh, filters));
 }
Beispiel #22
0
 public GridModel Select(GridState state)
 {
     return SessionProductRepository.All().AsQueryable().ToGridModel(state);
 }
 public static FilterDescriptor TransactionDateFilters(this GridState <Sale> gridState,
                                                       Func <FilterDescriptor, bool> predicate) =>
 gridState.FilterDescriptors
 .OfType <FilterDescriptor>()
 .Where(f => f.Member == "TransactionDate")
 .First(predicate);
Beispiel #24
0
    private void LineInfo(int[] lines, GridState[] arr, GridState hope, GridState nope, List<Coordinate> player, List<Coordinate> ai)
    {
        int hopeNr = 0;
        int nopeNr = 0;

        for (int i = 0; i < arr.Length; ++i)
        {
            if (arr[i] == hope)
            {
                ++hopeNr;
            }
            else if (arr[i] == nope)
            {
                ++nopeNr;
            }
        }

        if ((hopeNr == 2 && !mToggleRole && nopeNr == 0) || (hopeNr == 3))
        {
            for (int i = 0; i < lines.Length; ++i)
            {
                ai.Add(new Coordinate(lines[i], i));
            }
        }
        if ((nopeNr == 2 && mToggleRole && hopeNr == 0) || (nopeNr == 3))
        {
            for (int i = 0; i < lines.Length; ++i)
            {
                player.Add(new Coordinate(lines[i], i));
            }
        }
    }
Beispiel #25
0
        public GridModel Insert(GridState state, EditableProduct value)
        {
            SessionProductRepository.Insert(value);

            return(SessionProductRepository.All().AsQueryable().ToGridModel(state));
        }
Beispiel #26
0
        public GridModel GetOrders(GridState state)
        {
            NorthwindDataContext northwind = new NorthwindDataContext();

            return northwind.Orders.ToGridModel(state);
        }
Beispiel #27
0
        public static GridState LoadFromFile(String file)
        {
            String directoryToLookFor = "Content/Maps/";
            try
            {
                using (StreamReader sr = new StreamReader(directoryToLookFor + file))
                {
                    String line;
                    int lineNum = -1;
                    int sizeX = 0;
                    int sizeY = 0;
                    GridState gridState = null;
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (lineNum == -1)
                        {
                            String[] sizes = line.Split(new char[] { ',' });

                            if (sizes.Length != 2)
                            {
                                throw new Exception("Size line was not 2.");
                            }
                            if (!int.TryParse(sizes[0], out sizeX))
                            {
                                throw new Exception("X was not an integer");
                            }
                            if (!int.TryParse(sizes[1], out sizeY))
                            {
                                throw new Exception("Y was not an integer");
                            }
                            gridState = new GridState(sizeX, sizeY);
                        }
                        else
                        {
                            String[] row = line.Split(new char[] { ',' });

                            if (sizeX != row.Length)
                            {
                                throw new Exception("size of data does not match specified size on file");
                            }
                            if (gridState != null)
                            {
                                for (int i = 0; i < sizeX; i++)
                                {
                                    //int val = -1;
                                    //if (!Int32.TryParse(row[i], out val))
                                    //{
                                        gridState.cells[i, lineNum] = (GridState.CellType)Int32.Parse(row[i]);
                                    //}
                                    //else
                                    //{
                                    //    throw new Exception("could not parse int. " + row[i]);
                                    //}

                                }
                            }
                        }
                        Console.WriteLine(line);
                        lineNum++;
                    }
                    return gridState;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("uh oh...I can't read that map file..." + e.Message);
                return null;
            }
        }
Beispiel #28
0
 /// <summary>
 /// 定义当前表格的状态:'visible'(默认) or 'hidden'
 /// </summary>
 /// <param name="gridState"></param>
 /// <returns></returns>
 public Grid SetGridState(GridState gridState)
 {
     _gridstate = gridState;
     return this;
 }
        public GridModel Insert(EditableProduct value, GridState state)
        {
            SessionProductRepository.Insert(value);

            return SessionProductRepository.All().AsQueryable().ToGridModel(state);
        }
 //set the state of grids at multipple target loactions, MapGrid, list
 private void setGridsState(MapGrid[] target_mapgrids, GridState[] target_states)
 {
     int length = target_mapgrids.Length;
     int i;
     for (i=0; i<length; i++) {
         target_mapgrids[i].grid.GetComponent<Grid> ().setState (target_states[i]);
     }
 }
 //set the state of grid at target loaction
 private void setGridState(Coordinate target_location, GridState target_state)
 {
     MapGrid target_mapgrid = getMapGrid (target_location);
     target_mapgrid.grid.GetComponent<Grid> ().setState (target_state);
 }
        public GridModel Insert(EditableCustomer value, GridState state)
        {
            SessionCustomerRepository.Insert(value);

            return SessionCustomerRepository.All().AsQueryable().ToGridModel(state);
        }
Beispiel #33
0
        public GridModel Update(GridState state, EditableCustomer value)
        {
            SessionCustomerRepository.Update(value);

            return SessionCustomerRepository.All().AsQueryable().ToGridModel(state);
        }
 //set the state of grids at multipple target loactions, Coordinate, list
 private void setGridsState(Coordinate[] target_locations, GridState[] target_states)
 {
     int length = target_locations.Length;
     MapGrid[] target_mapgrids = getMapGrids (target_locations);
     int i;
     for (i=0; i<length; i++) {
         target_mapgrids[i].grid.GetComponent<Grid> ().setState (target_states[i]);
     }
 }
Beispiel #35
0
        [WebMethod(EnableSession = true)] //Session required by SessionCustomerRepository
        public GridModel Delete(EditableProduct value, GridState state)
        {
            SessionProductRepository.Delete(value);

            return(SessionProductRepository.All().AsQueryable().ToGridModel(state));
        }
 //set all grid to target state, base of refresh map, ignore the grid in ignore list
 private void setAllGridState(GridState target_state)
 {
     int i, j;
     for (i=0; i<8; i++) {
         for (j=0; j<6; j++) {
             setGridState(new Coordinate(i, j), target_state);
         }
     }
 }
Beispiel #37
0
 public abstract IEnumerable <CellState> Select(GridState grid);
Beispiel #38
0
        /// <summary>
        /// Dessine un bateau
        /// </summary>
        /// <param name="img">image</param>
        /// <param name="ImgState">état de la grille</param>
        private void DrawSingleShip(Image img, GridState ImgState)
        {
            if (EtatGrille == ImgState) // si dans le même état que l'image dessine un preview
            {
                FPoint pos = GetGridCoordOfMouse();
                if (OCurrentShip == PosShips.Orientation.Verticale)
                {
                    Image carry = (Image)img.Clone();
                    carry.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    switch (ImgState)
                    {
                        case GridState.PlacementPorteAvions:
                            DrawImage(carry, pos.X * GridRectWidth, pos.Y * GridRectHeight, 1 * GridRectWidth, SizePorteAvions * GridRectHeight);
                            break;
                        case GridState.PlacementCroiseur:
                            DrawImage(carry, pos.X * GridRectWidth, pos.Y * GridRectHeight, 1 * GridRectWidth, SizeCroiseur * GridRectHeight);
                            break;
                        case GridState.PlacementContreTorpilleur:
                            DrawImage(carry, pos.X * GridRectWidth, pos.Y * GridRectHeight, 1 * GridRectWidth, SizeContreTorpilleur * GridRectHeight);
                            break;
                        case GridState.PlacementSousMarin:
                            DrawImage(carry, pos.X * GridRectWidth, pos.Y * GridRectHeight, 1 * GridRectWidth, SizeSousMarin * GridRectHeight);
                            break;
                        case GridState.PlacementTorpilleur:
                            DrawImage(carry, pos.X * GridRectWidth, pos.Y * GridRectHeight, 1 * GridRectWidth, SizeTorpilleur * GridRectHeight);
                            break;
                        default:
                            break;
                    }

                }
                else
                {
                    switch (ImgState)
                    {
                        case GridState.PlacementPorteAvions:
                            DrawImage(img, pos.X * GridRectWidth, pos.Y * GridRectHeight, SizePorteAvions * GridRectWidth, 1 * GridRectHeight);
                            break;
                        case GridState.PlacementCroiseur:
                            DrawImage(img, pos.X * GridRectWidth, pos.Y * GridRectHeight, SizeCroiseur * GridRectWidth, 1 * GridRectHeight);
                            break;
                        case GridState.PlacementContreTorpilleur:
                            DrawImage(img, pos.X * GridRectWidth, pos.Y * GridRectHeight, SizeContreTorpilleur * GridRectWidth, 1 * GridRectHeight);
                            break;
                        case GridState.PlacementSousMarin:
                            DrawImage(img, pos.X * GridRectWidth, pos.Y * GridRectHeight, SizeSousMarin * GridRectWidth, 1 * GridRectHeight);
                            break;
                        case GridState.PlacementTorpilleur:
                            DrawImage(img, pos.X * GridRectWidth, pos.Y * GridRectHeight, SizeTorpilleur * GridRectWidth, 1 * GridRectHeight);
                            break;
                        default:
                            break;
                    }
                    DrawImage(img, pos.X * GridRectWidth, pos.Y * GridRectHeight, SizeTorpilleur * GridRectWidth, 1 * GridRectHeight);
                }

            }
            else // si pas dans le même état
            {
                switch (ImgState)
                {
                    case GridState.PlacementPorteAvions:
                        if (PositionBateau.OPorteAvion == PosShips.Orientation.Verticale)
                        {
                            Image carry = (Image)img.Clone();
                            carry.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            DrawImage(carry, PositionBateau.PPorteAvion.X * GridRectWidth, PositionBateau.PPorteAvion.Y * GridRectHeight, 1 * GridRectWidth, SizePorteAvions * GridRectHeight);
                        }
                        else
                        {
                            DrawImage(img, PositionBateau.PPorteAvion.X * GridRectWidth, PositionBateau.PPorteAvion.Y * GridRectHeight, SizePorteAvions * GridRectWidth, 1 * GridRectHeight);
                        }
                        break;
                    case GridState.PlacementCroiseur:
                        if (PositionBateau.OCroiseur == PosShips.Orientation.Verticale)
                        {
                            Image carry = (Image)img.Clone();
                            carry.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            DrawImage(carry, PositionBateau.PCroiseur.X * GridRectWidth, PositionBateau.PCroiseur.Y * GridRectHeight, 1 * GridRectWidth, SizeCroiseur * GridRectHeight);
                        }
                        else
                        {
                            DrawImage(img, PositionBateau.PCroiseur.X * GridRectWidth, PositionBateau.PCroiseur.Y * GridRectHeight, SizeCroiseur * GridRectWidth, 1 * GridRectHeight);
                        }
                        break;
                    case GridState.PlacementContreTorpilleur:
                        if (PositionBateau.OContreTorpilleur == PosShips.Orientation.Verticale)
                        {
                            Image carry = (Image)img.Clone();
                            carry.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            DrawImage(carry, PositionBateau.PContreTorpilleur.X * GridRectWidth, PositionBateau.PContreTorpilleur.Y * GridRectHeight, 1 * GridRectWidth, SizeContreTorpilleur * GridRectHeight);
                        }
                        else
                        {
                            DrawImage(img, PositionBateau.PContreTorpilleur.X * GridRectWidth, PositionBateau.PContreTorpilleur.Y * GridRectHeight, SizeContreTorpilleur * GridRectWidth, 1 * GridRectHeight);
                        }
                        break;
                    case GridState.PlacementSousMarin:
                        if (PositionBateau.OSousMarin == PosShips.Orientation.Verticale)
                        {
                            Image carry = (Image)img.Clone();
                            carry.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            DrawImage(carry, PositionBateau.PSousMarin.X * GridRectWidth, PositionBateau.PSousMarin.Y * GridRectHeight, 1 * GridRectWidth, SizeSousMarin * GridRectHeight);
                        }
                        else
                        {
                            DrawImage(img, PositionBateau.PSousMarin.X * GridRectWidth, PositionBateau.PSousMarin.Y * GridRectHeight, SizeSousMarin * GridRectWidth, 1 * GridRectHeight);
                        }
                        break;
                    case GridState.PlacementTorpilleur:
                        if (PositionBateau.OTorpilleur == PosShips.Orientation.Verticale)
                        {
                            Image carry = (Image)img.Clone();
                            carry.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            DrawImage(carry, PositionBateau.PTorpilleur.X * GridRectWidth, PositionBateau.PTorpilleur.Y * GridRectHeight, 1 * GridRectWidth, SizeTorpilleur * GridRectHeight);
                        }
                        else
                        {
                            DrawImage(img, PositionBateau.PTorpilleur.X * GridRectWidth, PositionBateau.PTorpilleur.Y * GridRectHeight, SizeTorpilleur * GridRectWidth, 1 * GridRectHeight);
                        }
                        break;
                    default:
                        break;
                }
            }
        }
Beispiel #39
0
 public void Step(int x, int y, GridState gs)
 {
     if (x > mChess.Length)
     {
         return;
     }
     else if (y > mChess[x].Length)
     {
         return;
     }
     if (mChess[x][y] == GridState.None)
     {
         mChess[x][y] = gs;
     }
 }
Beispiel #40
0
 public Board(GridState[] valuesForBoardArray, bool turnForPlayerBlack)
 {
     m_TurnForPlayerBlack = turnForPlayerBlack;
     BoardArray = valuesForBoardArray;
     ComputerScore();
 }
Beispiel #41
0
 public WellGame(GridState player)
 {
     mPlayer = player;
     mAI = (player == GridState.Circle) ? GridState.Cross : GridState.Circle;
 }
Beispiel #42
0
        static void Method(string[] args)
        {
            string[] input;
            bs       = new int[2, 3];
            input    = Console.ReadLine().Split(' ');
            bs[0, 0] = int.Parse(input[0]);
            bs[0, 1] = int.Parse(input[1]);
            bs[0, 2] = int.Parse(input[2]);
            input    = Console.ReadLine().Split(' ');
            bs[1, 0] = int.Parse(input[0]);
            bs[1, 1] = int.Parse(input[1]);
            bs[1, 2] = int.Parse(input[2]);

            cs       = new int[3, 2];
            input    = Console.ReadLine().Split(' ');
            cs[0, 0] = int.Parse(input[0]);
            cs[0, 1] = int.Parse(input[1]);
            input    = Console.ReadLine().Split(' ');
            cs[1, 0] = int.Parse(input[0]);
            cs[1, 1] = int.Parse(input[1]);
            input    = Console.ReadLine().Split(' ');
            cs[2, 0] = int.Parse(input[0]);
            cs[2, 1] = int.Parse(input[1]);

            /*int allPat = 1 << 9;
             * for (int i = 0; i < allPat; i++)
             * {
             *  bool[,] chokudaiGrid = new bool[3, 3];
             *  int chokudaiCnt = 0;
             *  for (int j = 0; j < 9; j++)
             *  {
             *      if (((i >> j) & 1) == 1)
             *      {
             *          chokudaiGrid[j / 3, j % 3] = true;
             *          chokudaiCnt++;
             *      }
             *  }
             *  if (chokudaiCnt != 5) continue;
             *
             *  int chokudai = 0, naoko = 0;
             *  for(int j = 0; j < 2; j++)
             *  {
             *      for(int k = 0; k < 3; k++)
             *      {
             *          if (chokudaiGrid[j, k] && chokudaiGrid[j + 1, k])
             *          {
             *              chokudai += bs[j, k];
             *          }
             *          else
             *          {
             *              naoko += bs[j, k];
             *          }
             *      }
             *  }
             *  for (int j = 0; j < 3; j++)
             *  {
             *      for (int k = 0; k < 2; k++)
             *      {
             *          if (chokudaiGrid[j, k] && chokudaiGrid[j, k+1])
             *          {
             *              chokudai += cs[j, k];
             *          }
             *          else
             *          {
             *              naoko += cs[j, k];
             *          }
             *      }
             *  }
             *  Console.WriteLine(chokudai.ToString() + " " + naoko.ToString());
             * }*/
            var gridInfo = new GridState[3, 3];

            for (int i = 0; i < 9; i++)
            {
                gridInfo[i / 3, i % 3] = GridState.undefined;
            }
            int[] score = DFS(1, gridInfo);
            Console.WriteLine(score[0]);
            Console.WriteLine(score[1]);
        }
Beispiel #43
0
        public GridModel GetOrders(GridState state)
        {
            NorthwindDataContext northwind = new NorthwindDataContext();

            return(northwind.Orders.ToGridModel(state));
        }
Beispiel #44
0
        public IList <Distributor> GetDistributors(string name, Country country, PriceList priceList, Lookup paymentTerm, DistributorStatus?status, GridState gridState, out int totalRecords, Lookup saleCondition, Lookup type, CatalogPage page, IList priceListIds, bool isActive)
        {
            int pageNumber = gridState.PageNumber;
            int pageSize   = gridState.PageSize;

            ICriteria crit = GetDistributorsCriteria(name, country, priceList, paymentTerm, status, gridState, saleCondition, type, page, priceListIds, isActive);

            crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("ID")));

            totalRecords = crit.UniqueResult <int>();
            if (totalRecords == 0)
            {
                return(new List <Distributor>());
            }

            pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords);

            crit = GetDistributorsCriteria(name, country, priceList, paymentTerm, status, gridState, saleCondition, type, page, priceListIds, isActive);

            if (gridState.PageSize > 0)
            {
                crit.SetMaxResults(gridState.PageSize);
            }
            if (pageNumber > 0)
            {
                if (pageNumber == 1)
                {
                    crit.SetFirstResult(0);
                }
                else
                {
                    crit.SetFirstResult((pageNumber - 1) * gridState.PageSize);
                }
            }

            string[] sort = gridState.SortField.Split('.');

            ICriteria critSort  = crit;
            string    sortField = gridState.SortField;

            if (!sortField.Contains("TimeStamp") && sort.Length > 1)
            {
                critSort  = crit.CreateCriteria(sort[0], JoinType.LeftOuterJoin);
                sortField = sort[1];
            }

            critSort.AddOrder(new Order(sortField, gridState.SortAscending));

            return(crit.List <Distributor>());
        }
Beispiel #45
0
        public GridModel Update(GridState state, EditableProduct value)
        {
            SessionProductRepository.Update(value);

            return SessionProductRepository.All().AsQueryable().ToGridModel(state);
        }
Beispiel #46
0
 public Grid(Vector2Int boardPosition, GameObject go, GridState gridState)
 {
     BoardPosition = boardPosition;
     gameObject    = go;
     GridState     = gridState;
 }
Beispiel #47
0
 public void CreateGame(string gameId, GridState initialState, List<int> playerInvolved)
 {
     throw new NotImplementedException();
 }
 public override bool ExecuteAction(GridState gs, IList <IFilter> filters, params object[] parameters)
 {
     return(ControllerManager.PriceBase.RemoveFromPriceGroup(gs, filters, FilterHelper.FindObjectFromFilter(filters, typeof(PriceGroup), "ID") as PriceGroup));
 }
Beispiel #49
0
        private ICriteria GetDistributorsCriteria(string name, Country country, PriceList priceList, Lookup paymentTerm, DistributorStatus?status, GridState gridState, Lookup saleCondition, Lookup type, CatalogPage page, IList priceListIds, bool isActive)
        {
            ICriteria crit = GetCriteria();

            if (priceListIds != null)
            {
                int[] intPriceListIds = new int[priceListIds.Count];
                for (int i = 0; i < priceListIds.Count; i++)
                {
                    intPriceListIds[i] = Convert.ToInt32(priceListIds[i]);
                }

                ICriteria critDistributor = crit.CreateCriteria("PriceList");
                critDistributor.Add(Expression.In("ID", intPriceListIds));
            }


            if (!string.IsNullOrEmpty(name))
            {
                Disjunction d = new Disjunction();
                d.Add(Expression.InsensitiveLike("Name", name, MatchMode.Anywhere));
                d.Add(Expression.InsensitiveLike("Code", name, MatchMode.Anywhere));
                crit.Add(d);
            }


            if (country != null)
            {
                ICriteria critCountry = crit.CreateCriteria("Country");
                critCountry.Add(Expression.Eq("ID", country.ID));
            }
            if (priceList != null)
            {
                ICriteria critPriceList = crit.CreateCriteria("PriceList");
                critPriceList.Add(Expression.Eq("ID", priceList.ID));
            }
            if (paymentTerm != null)
            {
                crit.Add(Expression.Eq("PaymentTerm", paymentTerm));
            }

            if (status != null)
            {
                crit.Add(Expression.Eq("DistributorStatus", status));
            }
            else
            if (isActive == false)
            {
                crit.Add(Expression.Eq("DistributorStatus", DistributorStatus.Active));
            }

            if (saleCondition != null)
            {
                crit.Add(Expression.Eq("SaleConditions", saleCondition));
            }

            if (type != null)
            {
                crit.Add(Expression.Eq("Type", type));
            }

            if (page != null)
            {
                crit.CreateCriteria("PriceList").CreateCriteria("CategoryPages").Add(Expression.Eq("ID", page.ID));
            }

            return(crit);
        }
        public JsonResult Index(GridState colorMovingPiece, string FromPosition, string toPosition, GameState gameState)
        {
            var jResult = new JsonResult();
            var game = new Game();
            if (gameState == (GameState)Enum.Parse(typeof(GameState), "DEFAULTGAME"))
            {
                Board = new Game().InitBoard();
                var gState = Board.ToList().OrderBy(o => o.Index).Select(s => s.Color).ToArray();
                CheckGame cGame = new CheckGame(gState);
                var aIBoard = cGame.ComputerMakeMove(5);
                Board = aIBoard.BoardArray.Select((s, i) => new GamePieceViewModel { Color = s, Index = i, Position = "sq_" + i });
                var startModel = new BoardViewModel
                {
                    Pieces = Board,
                    IsLegalMove = true,
                    Message = "White Turn",
                    GameState = GameState.WHITETURN
                };

                jResult = Json(startModel);
            }
            else if(gameState == (GameState)Enum.Parse(typeof(GameState), "BLACKTURN"))
            {
                var gState = Board.ToList().OrderBy(o => o.Index).Select(s => s.Color).ToArray();
                CheckGame cGame = new CheckGame(gState);
                var aIBoard = cGame.ComputerMakeMove(5);
                Board = aIBoard.BoardArray.Select((s, i) => new GamePieceViewModel { Color = s, Index = i, Position = "sq_" + i });
                var currentState = CheckersWeb.Classes.Board.WhiteHasMove(Board.Select(s => s.Color).ToArray()) ? GameState.WHITETURN : GameState.BLACKWIN;
                var model = new BoardViewModel
                {
                    Pieces = Board,
                    IsLegalMove = true,
                    Message = "White Turn",
                    GameState = currentState
                };
                jResult = Json(model);
            }
            else if (gameState == (GameState)Enum.Parse(typeof(GameState), "WHITETURN"))
            {
                try
                {
                    if (colorMovingPiece.ToString().Contains("WHITE") == false) return Json(new BoardViewModel { IsLegalMove = false, Pieces = Board });
                    PlayerMoves pMoves = new PlayerMoves(Board);

                    var pos = Board.ToList();

                    if (pos.FirstOrDefault(f => f.Color == colorMovingPiece && f.Index == int.Parse(FromPosition)) == null || string.IsNullOrWhiteSpace(toPosition))
                        return Json(new BoardViewModel { IsLegalMove = false, Pieces = pos });

                    var islegal = pMoves.MoveISLegal(colorMovingPiece, int.Parse(FromPosition), int.Parse(toPosition));
                    if ((islegal.IsMove || islegal.IsCapture) == false)
                        return Json(new BoardViewModel { IsLegalMove = false, Pieces = pos });

                    pos.FirstOrDefault(f => f.Index == islegal.StartIndex).Color = GridState.EMPTY;
                    if(islegal.IsMove)
                    {
                        pos.FirstOrDefault(f => f.Index == islegal.MoveIndex).Color = islegal.PieceState;
                    }
                    else
                    {
                        pos.FirstOrDefault(f => f.Index == islegal.MoveIndex).Color = GridState.EMPTY;
                        pos.FirstOrDefault(f => f.Index == islegal.CaptureIndex).Color = islegal.PieceState;
                    }
                    Board = pos;
                    var currentState = CheckersWeb.Classes.Board.BlackHasMove(Board.Select(s => s.Color).ToArray()) ? GameState.BLACKTURN : GameState.WHITEWIN;
                    var model = new BoardViewModel
                    {
                        Pieces = pos,
                        IsLegalMove = true,
                        Message = "Black Turn",
                        GameState = currentState
                    };
                    jResult = Json(model);
                }
                catch (Exception ex)
                {
                    return Json(new BoardViewModel { IsLegalMove = false, Pieces = Board, Message = ex.Message });
                }
            }

            return jResult;
        }
Beispiel #51
0
 public Grid(Vector2Int boardPosition, GameObject go)
 {
     BoardPosition = boardPosition;
     gameObject    = go;
     GridState     = GridState.Empty;
 }
Beispiel #52
0
        public void OnMouseDown()
        {
            GridState.MouseDown = true;
            if (GridState.Draw == GridState.DrawState.Wall)
            {
                MyNode.IsFinish = false;
                MyNode.IsStart  = false;
                MyNode.IsBomb   = false;
                MyNode.Weight   = 0;

                MyNode.IsWall = !MyNode.IsWall;

                StateHasChanged();
            }
            else if (GridState.Draw == GridState.DrawState.Start)
            {
                MyNode.IsFinish = false;
                MyNode.IsWall   = false;
                MyNode.IsBomb   = false;
                MyNode.Weight   = 0;

                GridState.Grid[GridState.StartNodeRow][GridState.StartNodeColumn].IsStart = false;

                MyNode.IsStart            = true;
                GridState.StartNodeRow    = MyNode.Row;
                GridState.StartNodeColumn = MyNode.Column;

                GridState.RerenderEventInvoke(new EventArgs());
            }
            else if (GridState.Draw == GridState.DrawState.Finish)
            {
                MyNode.IsStart = false;
                MyNode.IsWall  = false;
                MyNode.IsBomb  = false;
                MyNode.Weight  = 0;

                GridState.Grid[GridState.FinishNodeRow][GridState.FinishNodeColumn].IsFinish = false;

                MyNode.IsFinish            = true;
                GridState.FinishNodeRow    = MyNode.Row;
                GridState.FinishNodeColumn = MyNode.Column;

                GridState.RerenderEventInvoke(new EventArgs());
            }
            else if (GridState.Draw == GridState.DrawState.Weight)
            {
                MyNode.IsFinish = false;
                MyNode.IsStart  = false;
                MyNode.IsWall   = false;
                MyNode.IsBomb   = false;

                if (MyNode.Weight != 2)
                {
                    MyNode.Weight = 2;
                }
                else
                {
                    MyNode.Weight = 0;
                }

                StateHasChanged();
            }
            else if (GridState.Draw == GridState.DrawState.Bomb)
            {
                MyNode.IsFinish = false;
                MyNode.IsStart  = false;
                MyNode.IsWall   = false;
                MyNode.Weight   = 0;

                if (MyNode.IsBomb)
                {
                    GridState.Bombs.Remove(MyNode);
                    MyNode.IsBomb    = false;
                    MyNode.BombOrder = 0;
                }
                else
                {
                    GridState.Bombs.Add(MyNode);
                    MyNode.IsBomb    = true;
                    MyNode.BombOrder = GridState.Bombs.Count;
                }

                StateHasChanged();
            }
        }
Beispiel #53
0
 public GroundGrid(Vector2Int boardPosition, GameObject go, GridState gridState) : base(boardPosition, go, gridState)
 {
 }
Beispiel #54
0
 public override IEnumerable <CellState> Select(GridState grid)
 {
     return(grid.TopStartCell.Value);
 }
Beispiel #55
0
 [WebMethod(EnableSession = true)] //Session required by SessionCustomerRepository
 public GridModel Select(GridState state)
 {
     return(SessionProductRepository.All().AsQueryable().ToGridModel(state));
 }
Beispiel #56
0
 public void SetGridState(GridState s)
 {
     gridState = s;
 }
Beispiel #57
0
 public static GridModel ToGridModel(this IQueryable queryable, GridState state)
 {
     return(queryable.ToGridModel(state.Page, state.Size, state.OrderBy, state.GroupBy, state.Filter));
 }
Beispiel #58
0
 public GridPoint(Point location, GridState state)
 {
     this.location = location;
     this.state    = state;
 }
Beispiel #59
0
 private void changeState(GridState state)
 {
     gridState = state;
 }
Beispiel #60
0
 public override IEnumerable <CellState> Select(GridState grid)
 {
     return(grid.AllCells.Value);
 }