コード例 #1
0
ファイル: Moves.cs プロジェクト: DKirikov/Unity3D_CFG
        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
        static private bool AreCellsInRow(OrientedCell prev_cell, OrientedCell next_cell)
        {
            if (next_cell.orientation != OrientedCell.CellOrientation.Default ||
                prev_cell.orientation != OrientedCell.CellOrientation.Default)
            {
                return(false);               //ToDo join cells for giant
            }
            //{ { 0, 1 }, { 1, ymax }, { 1, ymin }, { 0, -1 }, { -1, ymin }, { -1, ymax } };
            int dx = Math.Abs(next_cell.cell.board_x - prev_cell.cell.board_x);
            int dy = Math.Abs(next_cell.cell.board_y - prev_cell.cell.board_y);

            return((dx == 0 && dy == 2) || (dx == 2 && dy == 1));
        }
コード例 #3
0
ファイル: Moves.cs プロジェクト: DKirikov/Unity3D_CFG
        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
ファイル: GameBoard.cs プロジェクト: DKirikov/Unity3D_CFG
    public Vector2 FindCellPlace(OrientedCell cell)
    {
        Vector2 ret = new Vector2(0, 0);

        var occu = gameboard_impl.GetOccupatedCells(cell);
        int cnt  = 0;

        Array.ForEach(occu, oc_cell => {
            if (oc_cell != null)               //ToDo change to return Vector3 and rotate board to be xy instead of xz
            {
                Vector3 pos3d = FindCell(oc_cell).gameObject.transform.position;
                ret          += new Vector2(pos3d.x, pos3d.z);
                ++cnt;
            }
        });

        if (cnt > 0)
        {
            ret /= cnt;
        }

        return(ret);
    }