Exemplo n.º 1
0
    public void Emit(Bunker.Game.Grid startGrid, Bunker.Game.Grid destGrid)
    {
        var startpos = _bfm.Field.GetWorldPos(startGrid.ColID, startGrid.RowID);

        var dir = new Vector2Int(
            destGrid.ColID - startGrid.ColID,
            destGrid.RowID - startGrid.RowID
            );

        Emit(startpos, destGrid, dir);
    }
Exemplo n.º 2
0
    public void Emit(Bunker.Game.Grid startGrid, Vector2Int dir)
    {
        var startpos = _bfm.Field.GetWorldPos(startGrid.ColID, startGrid.RowID);

        var destGrid = _bfm.Field.GetGrid(startGrid.ColID + dir.x, startGrid.RowID + dir.y);

        if (destGrid == null)
        {
            return;
        }

        Emit(startpos, destGrid, dir);
    }
Exemplo n.º 3
0
        void AddToList(Bunker.Game.Grid g, ref List <BaseTile> tiles)
        {
            if (g == null || g.AttachTile == null)
            {
                return;
            }
            foreach (var t in tiles)
            {
                if (t == g.AttachTile)
                {
                    return;
                }
                if (!g.AttachTile.CanBreak())
                {
                    return;
                }
            }

            tiles.Add(g.AttachTile);
        }
Exemplo n.º 4
0
    public void Emit(Vector3 strartpos, Bunker.Game.Grid destGrid, Vector2Int dir)
    {
        float dist = maxlength;

        //两个起始点,进行向前扫描
        if (dir.x == 0)
        {
            var gridY = destGrid.RowID;
            var gridX = destGrid.ColID;

            var grid = destGrid;

            _destGrid = null;
            while (grid != null)
            {
                if (grid != null && grid.AttachTile != null)
                {
                    var tile = grid.AttachTile;

                    if (CanBlockLazer(tile))
                    {
                        dist = Mathf.Abs(tile.Node.transform.position.y -
                                         strartpos.y) + Bias;
                        _destGrid = grid;

                        break;
                    }

                    gridY += dir.y;

                    grid = _bfm.Field.GetGrid(gridX, gridY);
                }
            }
        }
        else if (dir.y == 0)
        {
            var gridY = destGrid.RowID;
            var gridX = destGrid.ColID;

            var grid = destGrid;

            _destGrid = null;
            while (grid != null)
            {
                if (grid != null && grid.AttachTile != null)
                {
                    var tile = grid.AttachTile;

                    if (CanBlockLazer(tile))
                    {
                        dist = Mathf.Abs(tile.Node.transform.position.x -
                                         strartpos.x) + Bias;
                        _destGrid = grid;

                        break;
                    }
                }
                gridX += dir.x;

                grid = _bfm.Field.GetGrid(gridX, gridY);
            }
        }
        var dist_time = dist / LazerSpeed;

        Debug.Log("dist_time: " + dist_time);
        Sequence mySequence = DOTween.Sequence();

        mySequence.Append(DOTween.To(CB_GetHeightUpdate, CB_Lazer_HeightUpdate, dist, dist_time))
        .AppendInterval(.5f).AppendCallback(CB_Lazer_Shoot_Finish);

        //DOTween.To(CB_GetHeightUpdate, CB_Lazer_HeightUpdate, dist, dist_time);

        //StartCoroutine(StepDist(CB_Lazer_HeightUpdate, 0, dist, dist_time, CB_Lazer_Shoot_Finish));
    }