public void MoveUnit(Type type, Point curPoint, Point newPoint) { switch (type) { case Type.Envrionment: if (!EnvironmentCollection.ContainsKey(curPoint) || EnvironmentCollection.ContainsKey(newPoint)) { Debug.LogError("[EnvironmentManager] Failed to set unit to new position"); return; } EnviromentalUnit temp = EnvironmentCollection[curPoint]; EnvironmentCollection.Remove(curPoint); EnvironmentCollection.Add(newPoint, temp); break; case Type.Enemy: if (!EnemyCollection.ContainsKey(curPoint) || EnemyCollection.ContainsKey(newPoint)) { Debug.LogError("[EnvironmentManager] Failed to set unit to new position"); return; } EnemyUnit enemyTemp = EnemyCollection[curPoint]; EnemyCollection.Remove(curPoint); EnemyCollection.Add(newPoint, enemyTemp); break; default: break; } }
public void AddSpawnedEnvironment(Point point, EnviromentalUnit unit) { if (EnvironmentCollection.ContainsKey(point) || EnvironmentCollection.ContainsValue(unit)) { Debug.LogError($"[EnvironmentManager] Envrionmental Unit Already Exists. {unit.name} {unit.WorldPosition}, Conflicting Unit: {EnvironmentCollection[point].name} {EnvironmentCollection[point].WorldPosition}", unit); return; } if (AddUnitToMap(point, unit)) { EnvironmentCollection.Add(point, unit); return; } Debug.LogError("[EnvironmentManager] Failed setting environment"); }