public override void OnInspectorGUI() { DrawDefaultInspector(); VisibleGrid script = (VisibleGrid)target; if (GUILayout.Button("Build Grid")) { script.CreateGrid(); } if (GUILayout.Button("Destroy Grid")) { script.DestroyGridInEditor(); } }
public override void DTRMUpdate() { List <Visible> myNewCell = VisibleGrid.GetCell(myPosition.position); if (myCell == myNewCell) { return; } if (myCell != null) { myCell.Remove(this); } myNewCell.Add(this); myCell = myNewCell; }
public override void DTRMStart() { visible = visibleOnStart; myCell = VisibleGrid.GetCell(myPosition.position); myCell.Add(this); }
public override void DTRMUpdate() { List <Visible> neighbors = VisibleGrid.GetNeighbors(myPosition.position); // checking visibles in sight for (int i = 0; i < VISION_LIMIT; i++) { Visible visible = visiblesInSight[i]; if (visible == null) { continue; } if (myPosition.SqrDistance(visible.myPosition) > sqrVisionDistance) { visiblesInSight[i] = null; visible.inRangeOfVisions.Remove(this); if (visible.visible) { SendLostMessage(visible); } } if (neighbors.Contains(visible)) { neighbors.Remove(visible); } } // checking invisibles in sight for (int i = 0; i < VISION_LIMIT; i++) { Visible visible = invisiblesInSight[i]; if (visible == null) { continue; } if (myPosition.SqrDistance(visible.myPosition) > sqrVisionDistance) { visible.inRangeOfVisions.Remove(this); invisiblesInSight[i] = null; } if (neighbors.Contains(visible)) { neighbors.Remove(visible); } } // checking the rest of the neighbours foreach (Visible visible in neighbors) { if (myPosition.SqrDistance(visible.myPosition) > sqrVisionDistance) { continue; } visible.inRangeOfVisions.Add(this); if (visible.visible) { AddVisible(visible); SendNoticedMessage(visible); } else { AddInvisible(visible); } } }