Exemple #1
0
    /// <summary>얻고자하는 건물의 청사진을 그립니다. BuildingPos를 매개변수로 청사진 건물의 위치를 얻습니다.</summary>
    public bool DrawBluePrint(BuildingBase ObjectData, Vector2 Pos, BuildingBase.Direction Dirc, ref Vector2 BuildingPos)
    {
        ObjectData.BuildingDirection = Dirc;
        bool IsCounstruct;

        IsCounstruct = true;
        DeleteGrid();
        ActiveGrids = new List <GameObject>();

        // 오브젝트 풀링 안에 있는 오브젝트가 생성할 그리드보다 적을경우
        while (Q_GridPool.Count < ObjectData.Size.x * ObjectData.Size.y)
        {
            GameObject grid = Instantiate(GridImage);
            grid.transform.parent = GridPool.transform;
            Q_GridPool.Enqueue(grid);
            grid.SetActive(false);
        }
        // 건물 청사진 생성
        TileInform ClickTile    = MapData.Instance.GetTileInform(Pos);
        Vector2    BluePrintPos = GetBuildingPos(ObjectData, ClickTile.transform.position);

        BuildingBluePrint.transform.position = BluePrintPos;
        BluePrintRender.sprite = ObjectData.GetComponent <SpriteRenderer>().sprite;
        BuildingBluePrint.transform.rotation = Quaternion.Euler(0, 0, (float)Dirc);
        BuildingBluePrint.SetActive(true);

        BuildingPos = BluePrintPos;
        // 그리드 생성
        TileInform[] UnderTiles = ObjectData.SearchUnderTile(BluePrintPos);
        foreach (TileInform Tile in UnderTiles)
        {
            GameObject grid = Q_GridPool.Dequeue();
            grid.SetActive(true);
            grid.transform.position = Tile.transform.position;
            ActiveGrids.Add(grid);
            if (Tile.Construted == false && Tile.isBuilding == true)
            {
                grid.gameObject.GetComponent <SpriteRenderer>().color = AllowGirdColor;
            }
            else
            {
                grid.gameObject.GetComponent <SpriteRenderer>().color = UnAllowGirdColor;
                IsCounstruct = false;
            }
        }
        return(IsCounstruct);
    }