示例#1
0
        public override bool MakeMove(GameboardImpl gameboard)
        {
            UnitImpl new_unit = gameboard.cells[unit_place.board_x, unit_place.board_y].unit;

            GameboardCell new_cell = gameboard.cells[target_cell.board_x, target_cell.board_y];

            if (new_unit == null || new_cell.unit != null)
            {
                return(false);
            }

            OrientedCell or_cell = new OrientedCell {
                cell = new_cell, orientation = orient
            };

            new_unit.made_move = true;

            if (new_unit.notificator != null)
            {
                new_unit.notificator.PlayRunAnimation(this);
            }

            gameboard.SetUnitPlace(new_unit.oriented_cell, null);
            new_unit.oriented_cell = or_cell;
            gameboard.SetUnitPlace(new_unit.oriented_cell, new_unit);

            return(true);
        }
示例#2
0
    // Use this for initialization
    void Start()
    {
        gameboard_impl = new GameboardImpl();
        gameboard_impl.SetNotificator(this);

        instance = this;

        int X_SIZE = gameboard_impl.cells.GetLength(0);
        int Y_SIZE = gameboard_impl.cells.GetLength(1);

        //ToDo move it to CellData
        float offset_x = ((Y_SIZE - 1) * CellData.cell_width + ((X_SIZE - 1) % 2) * CellData.cell_width / 2) / 2;
        float offset_y = ((X_SIZE - 1) * CellData.cell_radius * 1.5f) / 2;

        foreach (GameboardCell cell in gameboard_impl.cells)
        {
            if (cell.active)
            {
                float x = cell.board_y * CellData.cell_width + (cell.board_x % 2) * CellData.cell_width / 2 - offset_x;
                float y = cell.board_x * CellData.cell_radius * 1.5f - offset_y;

                Vector3    offset  = new Vector3(x, 0.02f, y);
                GameObject cll_obj = Instantiate(cell_obj) as GameObject;

                CellData cell_data = cll_obj.GetComponent <CellData>();
                cll_obj.transform.position = offset;
                cell_data.cell             = cell;
                cell.notificator           = cell_data;

                cells_list.Add(cell_data);
            }
        }

        for (gameboard_impl.cur_command_idx = 0; gameboard_impl.cur_command_idx < GameboardImpl.players_qty; ++gameboard_impl.cur_command_idx)
        {
            gameboard_impl.commands[gameboard_impl.cur_command_idx] = new CommandInfo();
        }

        for (gameboard_impl.cur_command_idx = 0; gameboard_impl.cur_command_idx < GameboardImpl.players_qty; ++gameboard_impl.cur_command_idx)
        {
            Figure        boss      = DataBase.Bosses[0];
            GameboardCell cur_cell  = gameboard_impl.cells[gameboard_impl.cells.GetLength(0) / 2, (gameboard_impl.cur_command_idx == 0) ? 0 : (gameboard_impl.cells.GetLength(1) - 2)];
            var           boss_card = new CardImpl(boss);
            gameboard_impl.commands[gameboard_impl.cur_command_idx].hand.Add(boss_card);
            OnCardSelected(boss_card);
            HitCell(new ClickInfo(FindCell(cur_cell)));
        }

        ChangeCommand();

        var command = gameboard_impl.commands [gameboard_impl.cur_command_idx];

        foreach (UnitImpl unit in command.staff)
        {
            unit.made_move = true;//ToDo this is hack!
        }

        //gameboard_impl.GetCards () [0].GetMoves () [3].MakeMove (gameboard_impl);
    }
示例#3
0
        public override bool MakeMove(GameboardImpl gameboard)
        {
            GameboardCell new_cell = gameboard.cells[target_cell.board_x, target_cell.board_y];

            if (new_cell.unit != null)
            {
                return(false);
            }

            OrientedCell or_cell = new OrientedCell {
                cell = new_cell, orientation = orient
            };

            gameboard.AddUnit(gameboard.commands[gameboard.cur_command_idx].hand[card_idx], or_cell);

            return(true);
        }
示例#4
0
    //ToDo it could take a time. change cells_list to Dictionary<GameboardCell, CellData>
    public CellData FindCell(CellPlace cell_place)
    {
        CellData ret = null;

        if (cell_place != null)
        {
            GameboardCell search_cell = gameboard_impl.cells[cell_place.board_x, cell_place.board_y];
            if (search_cell != null)
            {
                if (search_cell.notificator != null && search_cell.notificator as CellData != null)
                {
                    ret = search_cell.notificator as CellData;
                }
                else
                {
                    ret = cells_list.Find(cell_data => cell_data.cell == search_cell);
                }
            }
        }

        return(ret);
    }