Beispiel #1
0
 public void RemoveBuildObject(BuildObject buildObject)
 {
     foreach (var cell in SearchCells(buildObject))
     {
         cell.buildObject = null;
     }
 }
Beispiel #2
0
        public bool Dropable(BuildObject buildObject)
        {
            var list  = SearchCells(buildObject);
            var count = list.Count;
            var i     = list.Count(cell => cell.buildObject == null);

            return(count == buildObject.size.x * buildObject.size.y &&
                   list.Count(cell => cell.buildObject == null) == count);
        }
Beispiel #3
0
        public void DropBuildObject(BuildObject buildObject)
        {
            var list = SearchCells(buildObject);

            foreach (var cell in list)
            {
                cell.buildObject = buildObject;
            }
        }
Beispiel #4
0
        private List <Cell> SearchCells(BuildObject buildObject)
        {
            var px        = (int)buildObject.transform.localPosition.x;
            var py        = (int)buildObject.transform.localPosition.y;
            var sx        = buildObject.size.x;
            var sy        = buildObject.size.y;
            var cellsList = new List <Cell>();

            for (var i = px; i != px + sx; i += Math.Sign(sx))
            {
                for (var j = py; j != py + sy; j += Math.Sign(sy))
                {
                    if (Enumerable.Range(0, width).Contains(i) && Enumerable.Range(0, height).Contains(j))
                    {
                        cellsList.Add(cells[i, j]);
                    }
                }
            }
            return(cellsList);
        }