private void CreateCells(BoardParameters parameter) { var prefab = parameter.ZelleVorlage; var width = prefab.transform.localScale.x; var height = prefab.transform.localScale.y; var totalWidth = width * parameter.Spalten + parameter.Abstand * (parameter.Spalten - 1); var totalHeight = height * parameter.Zeilen + parameter.Abstand * (parameter.Zeilen - 1); int order = 0; for (int row = parameter.Zeilen - 1; row >= 0; row--) { for (int column = 0; column < parameter.Spalten; column++) { (int column, int row)index = (column, row); float x = column * (width + parameter.Abstand) - totalWidth / 2; float y = row * (height + parameter.Abstand) - totalHeight / 2; var position = new Vector3(x, y); ICellComponent copyCell = UnityEngine.Object.Instantiate(prefab.GetSelfComponent(), position, Quaternion.identity, parameter.TransformParent).GetComponent <ICellComponent>(); copyCell.Index = index; copyCell.GetSelfComponent().name = parameter.RenameCell((column, row, order), copyCell.GetSelfComponent().name); parameter.TriggerCellCreated(copyCell); order++; } } }
private static void DeleteContentFromCell(ICellComponent zelle) { IContentComponent content = zelle.GetComponentInChildren <IContentComponent>(); if (content != null) { Object.Destroy(content.GameObject); } }
public bool RemoveComponent(ICellComponent component) { if (component is ISelectionComponent selectionComponent) { bool success = selectionComponents.InternalComponents.Remove(selectionComponent); if (success && selectionComponents.InternalComponents.Count == 0) { componentList.Remove(selectionComponents); } return(success); } return(componentList.Remove(component)); }
public void AddComponent(ICellComponent component) { if (component is ISelectionComponent selectionComponent) { if (selectionComponents.InternalComponents.Count == 0) { componentList.Add(selectionComponents); } selectionComponents.InternalComponents.Add(selectionComponent); } else { componentList.Add(component); } component.Parent = this; }
public void TriggerCellCreated(ICellComponent copyCell) { OnCellCreatedHandler?.Invoke(copyCell); }
protected static void Delete(ICellComponent zelle) { UnityEngine.Object.DestroyImmediate(zelle.GameObject); }