Ejemplo n.º 1
0
 private void ObserveCells(CellHandler cell)
 {
     cell.ChangeButtonInteractable(true);
     cell.ChangeAvailableMarker(true);
     observedCells.Add(cell);
     cell.CellButton.OnClickAsObservable().Subscribe(_ => OnClickedCellButton(cell));
 }
Ejemplo n.º 2
0
    private void CreateCell(int column, int row)
    {
        CellHandler cell = ObjectCreator.CreateInObject(this.gameObject, cellPrefab).GetComponent <CellHandler>();

        cell.SetCell(column, row, CellType.Default);
        cells[column, row] = cell;
    }
Ejemplo n.º 3
0
    IEnumerator GenerateGrid(int columnCount)
    {
        grid.m_Column = columnCount;
        cellArray = new GameObject[columnCount*columnCount, columnCount*columnCount];
        yield return new WaitForEndOfFrame ();

        for (var i = 0; i < columnCount; i++)
        {
            for(var j = 0; j < columnCount; j++)
            {
                cellArray[i,j] = (GameObject)Instantiate(cell, new Vector3(1, 1, 1), Quaternion.identity);
                cellArray[i,j].transform.SetParent(grid.transform);
                cellArray[i,j].transform.localScale = new Vector3(1, 1, 1);
                cellArray[i,j].name = "Cell[" + i + "][" + j + "]";

                cellList.Add (cellArray[i,j]);

                cellHandler = cellArray[i,j].GetComponent<CellHandler> ();
                cellHandler.CoordX = i;
                cellHandler.CoordY = j;

                // Add color:
                var rand = Random.Range (0,2);

                if (rand == 1) {
                    cellHandler.cellStatus = CellHandler.Status.On;
                    cellArray[i,j].GetComponent<CanvasRenderer> ().SetColor (new Color32 (135, 204, 196, 255));
                } else {
                    cellHandler.cellStatus = CellHandler.Status.Off;
                    cellArray[i,j].GetComponent<CanvasRenderer>().SetColor (new Color32 (128, 128, 128, 128));
                }
            }
        }
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        buttonText = GetComponentInChildren<Text>();
        cellHandler = GameObject.Find("Cells").GetComponent<CellHandler>();

        if (buttonText == null)
            Debug.LogError("Button Text is NUll");
        else if (cellHandler == null)
            Debug.LogError("cellHandler is null");
    }
Ejemplo n.º 5
0
    private void OnClickedCellButton(CellHandler cell)
    {
        RemoveAllBtnAction();

        playerAction.NextColumn = cell.Column;
        playerAction.NextRow    = cell.Row;
        playerAction.Action     = PieceAction.Move;

        MessageBroker.Default.Publish(playerAction);
    }
Ejemplo n.º 6
0
        public static Cell GetCellForAnimal(Animal animal)
        {
            firstHandler  = new OccamyCellHandler();
            secondHandler = new ManticoreCellHandler();
            lastHandler   = new GhoulCellHandler();

            firstHandler.Successor  = secondHandler;
            secondHandler.Successor = lastHandler;

            return(firstHandler.GetCell(animal));
        }
Ejemplo n.º 7
0
    public void ForEach(CellHandler foo)
    {
        if (children != null)
        {
            foreach (Cell child in children)
            {
                child.ForEach(foo);
            }
        }

        if (true)
        {
            foo(this);
        }
    }
Ejemplo n.º 8
0
        private FolderHelper m_FolderHelper;                                    // 操作数据库的对象

        public MainPage()
        {
            InitializeComponent();

            m_FolderHelper = new FolderHelper();

            m_Extensions = new ObservableCollection <string>();
            ddlstExtension.ItemsSource = m_Extensions;
            m_Extensions.Add("ALL");

            CellHandler cellHandler = new CellHandler();

            flxFiles.CellFactory  = cellHandler;
            flxFolder.CellFactory = cellHandler;

            cellHandler.MyRowHeader = CreateRowHeader;
        }
Ejemplo n.º 9
0
        public List <string> GetAllCells()
        {
            var cells = new List <string>();

            CellHandler handler = delegate(HexCube cube, Cell cell)
            {
                if (!cell.IsEmpty())
                {
                    HexAxial axial = cube.ToAxial();
                    cells.Add(string.Format(@"{0};{1}:{2}", axial.Q, axial.R, cell));
                }
            };

            IterateCells(handler);

            return(cells);
        }
Ejemplo n.º 10
0
        private void RenderHexagonOutlines(Graphics device)
        {
            CellHandler handler = delegate(HexCube cube, Cell cell)
            {
                PointF centerOfHex = cube.HexToPixel();
                var    pos         = new PointF
                {
                    X = (centerOfHex.X + _halfMapWidth),
                    Y = (centerOfHex.Y + _halfMapHeight)
                };

                var      pen     = new Pen(Color.Black, 1);
                PointF[] corners = Hexagon.GetCorners(pos);
                device.DrawLines(pen, corners);
            };

            IterateCells(handler);
        }
Ejemplo n.º 11
0
 private void IterateCells(CellHandler handler)
 {
     for (int cellZ = -_size; cellZ <= _size; cellZ++)
     {
         for (int cellY = -_size; cellY <= _size; cellY++)
         {
             for (int cellX = -_size; cellX <= _size; cellX++)
             {
                 var  cube = new HexCube(cellX, cellY, cellZ);
                 Cell cell = GetCell(cube);
                 if (cell != null)
                 {
                     handler(cube, cell);
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
        private void RenderHexagonImages(Graphics device, ImageList[] images)
        {
            CellHandler handler = delegate(HexCube cube, Cell cell)
            {
                for (int i = 1; i <= Layers.NumberOfLayers; i++)
                {
                    CellData data = cell.GetCellData(i);
                    if (data.TerrainId >= 0)
                    {
                        PointF centerOfHex = cube.HexToPixel();
                        var    pos         = new PointF
                        {
                            X = (centerOfHex.X + _halfMapWidth) - Constants.HALF_HEX_WIDTH,
                            Y = (centerOfHex.Y + _halfMapHeight) - Constants.HALF_HEX_HEIGHT
                        };

                        int paletteId = data.PaletteId;
                        device.DrawImage(images[paletteId].Images[data.TerrainId], pos);
                    }
                }
            };

            IterateCells(handler);
        }
Ejemplo n.º 13
0
 public void Show(CellHandler clickedCell)
 {
     gameObject.SetActive(true);
     this.clickedCell = clickedCell;
     input.Select();
 }
Ejemplo n.º 14
0
 private void CheckIfCellIsRevealed(CellHandler cellAction, Position pos)
 {
     if (this.gameBoard.IsCellRevealed(pos))
     {
         this.PrintUsedCellMessage("This cell has already been revealed! Please enter new cell coordinates!");
     }
     else if (this.gameBoard.CheckIfFlagCell(pos))
     {
         this.PrintUsedCellMessage("You've already placed flag at these coordinates! Please enter new cell coordinates!");
     }
     else
     {
         cellAction(pos);
         this.userIteractor.DrawBoard(this.gameBoard.Board);
     }
 }
Ejemplo n.º 15
0
        private void ProcessCoordinates(Position coordinates)
        {
            if (this.gameBoard.CheckIfHasMine(coordinates) && !this.gameBoard.CheckIfFlagCell(coordinates))
            {
                // Memento logic
                if (this.remainingLives > 0)
                {
                    bool reverting = this.AskUserToRevert();
                    if (reverting == true)
                    {
                        this.gameBoard.RestoreMemento(this.currentBoardState.Memento);
                        return;
                    }
                }

                this.ShowEndGameMessage();
                this.gameBoard.ResetBoard();
                this.ResetLives();
                this.userIteractor.DrawBoard(this.gameBoard.Board);
            }
            else if (this.gameBoard.CheckIfHasMine(coordinates) && this.gameBoard.CheckIfFlagCell(coordinates))
            {
                this.PrintUsedCellMessage("You've already placed flag at these coordinates! Please enter new cell coordinates!");
            }
            else
            {
                var cellHandler = new CellHandler(this.gameBoard.RevealBlock);
                this.CheckIfCellIsRevealed(cellHandler, coordinates);
                this.currentBoardState.Memento = this.gameBoard.SaveMemento();
            }

            if (this.gameBoard.CheckIfGameIsWon())
            {
                this.ShowGameWonMessage();
            }
        }
Ejemplo n.º 16
0
 private void ProcessFlagCommand(Position coordinates)
 {
     var cellHandler = new CellHandler(this.gameBoard.PlaceFlag);
     this.CheckIfCellIsRevealed(cellHandler, coordinates);
 }
Ejemplo n.º 17
0
 void Start()
 {
     cellHandler = (CellHandler)GameObject.Find("Cells").GetComponent("CellHandler");
 }
Ejemplo n.º 18
0
 internal void PushAddedCellHandler(CellHandler handler)
 {
     _addedCellHandlers.Push(handler);
 }
Ejemplo n.º 19
0
 public void ShowPanel(CellHandler clickedCell)
 {
     Panel.Show(clickedCell);
 }
Ejemplo n.º 20
0
    public void render(GameObject rendererObj)
    {
        if(!isRendered()) {
            renderedGameObject = rendererObj;
            renderedGameObject.name = "Cell";
            handler = renderedGameObject.GetComponent<CellHandler> ();
            handler.Init ();

            if(WorldRenderer.WRENDERER.debugUIModeIsActive()) {
                activateUI();
            }
        }
    }
Ejemplo n.º 21
0
 public void unrender()
 {
     deactivateUI ();
     handler = null;
     renderedGameObject = null;
 }
Ejemplo n.º 22
0
 // Use this for initialization
 void Start()
 {
     singleton = this;
     //Try to load any save
     if (Save.LoadData())
     {
         readyForInput = true;
     }
     else
     {
         Restart();
     }
 }
Ejemplo n.º 23
0
 void Start()
 {
     cellHandler = GetComponentInParent <CellHandler>();
 }
Ejemplo n.º 24
0
    public void CreateInventoryOnEditor()
    {
        if (cells == null)
        {
            cells = new List <CellHandler>();
        }

        Vector2 _offset = new Vector2(-(inventorySize.x * cellSize.x - cellSize.x) / 2.0f,
                                      -(inventorySize.y * cellSize.y - cellSize.y) / 2.0f);
        bool _colorToggle = true;

        for (int i = 0; i < inventorySize.x; i++)   //Create cells inside inventory
        {
            if (inventorySize.y % 2 == 0)
            {
                _colorToggle = !_colorToggle;
            }

            for (int j = 0; j < inventorySize.y; j++)
            {
                CellHandler _ch = Instantiate(cellPf,
                                              Vector2.zero,
                                              Quaternion.identity,
                                              transform).GetComponent <CellHandler>();
                _ch.transform.localPosition = new Vector3(_offset.x + i * cellSize.x, _offset.y + j * cellSize.y); //Set position

                int        _cID        = cells.Count;                                                              //Cell ID
                List <int> _neighbours = new List <int>();                                                         //Neighbours
                //Up
                if ((_cID + 1) % inventorySize.y != 0 && _cID + 1 < inventorySize.x * inventorySize.y)
                {
                    _neighbours.Add(_cID + 1);
                }
                else
                {
                    _neighbours.Add(-1);
                }

                //Right
                if (_cID + 1 < inventorySize.x * inventorySize.y && _cID + inventorySize.y < inventorySize.x * inventorySize.y)
                {
                    _neighbours.Add(_cID + inventorySize.y);
                }
                else
                {
                    _neighbours.Add(-1);
                }

                //Down
                if (_cID % inventorySize.y != 0 && _cID > 0)
                {
                    _neighbours.Add(_cID - 1);
                }
                else
                {
                    _neighbours.Add(-1);
                }

                //Left
                if (_cID - 1 >= 0 && _cID - inventorySize.y >= 0)
                {
                    _neighbours.Add(_cID - inventorySize.y);
                }
                else
                {
                    _neighbours.Add(-1);
                }

                _ch.SetupCellLogic(_cID, ref _neighbours, _colorToggle ? Color.white : Color.grey);
                _colorToggle = !_colorToggle;

                cells.Add(_ch);
            }
        }

        EditorSceneManager.MarkSceneDirty(this.gameObject.scene);
        EditorUtility.SetDirty(this.gameObject);
    }
Ejemplo n.º 25
0
 internal void PushAddedCellHandler(CellHandler handler)
 {
     _addedCellHandlers.Push(handler);
 }