public void RefreshMovementRangeProjection(HashSet <EnvironmentNode> nodes, EnvironmentNode center) { int xMin = int.MaxValue, xMax = int.MinValue, yMin = int.MaxValue, yMax = int.MinValue; int temp; foreach (EnvironmentNode n in nodes) { temp = n.indexPosition.x - center.indexPosition.x; xMin = Mathf.Min(xMin, temp); xMax = Mathf.Max(xMax, temp); temp = n.indexPosition.y - center.indexPosition.y; yMin = Mathf.Min(yMin, temp); yMax = Mathf.Max(yMax, temp); } Vector2Int movementRangeInTiles = new Vector2Int(Mathf.Max(-xMin, xMax), Mathf.Max(-yMin, yMax)); Vector2Int delta = movementRangeInTiles - center.indexPosition; bool[,] b = new bool[movementRangeInTiles.x * 2 + 1, movementRangeInTiles.y * 2 + 1]; foreach (EnvironmentNode v in nodes) { b[v.indexPosition.x + delta.x, v.indexPosition.y + delta.y] = true; } RefreshMovementRangeProjection(b, center.indexPosition); }
/// <summary> /// Creates and positions the rock at nodeIndex and updates the status of the node. /// </summary> /// <param name="nodeIndex">Node Index of the node</param> private void PlaceRock(Vector2Int nodeIndex) { EnvironmentNode n = EnvironmentManager.nodeMap[nodeIndex.x, nodeIndex.y]; n.isAccessible = false; n.terrain.Add(TerrainType.Boulder); propsTransforms.Add(Instantiate(rocksPrefabs[Random.Range(0, rocksPrefabs.Length)], n.position, Quaternion.Euler(Vector3.up * Random.value * 360), propParent).transform); }
public override void StoreSettings() { EnvironmentNode node = (EnvironmentNode)parentNode; foreach (EnvironmentItem item in listView.Items) { node.Colors[item.arrayIndex] = item.Color; } }
public void AddEnvironmentNodeAddsNode() { AddEnvironmentNodeCommand addEnvironmentCommand = new AddEnvironmentNodeCommand(ServiceProvider); addEnvironmentCommand.Execute(ApplicationNode); EnvironmentNode environmentNode = ApplicationNode.Hierarchy.FindNodeByType(typeof(EnvironmentNode)) as EnvironmentNode; Assert.IsNotNull(environmentNode); }
public EnvironmentOptionPanel(EnvironmentNode parent) : base(parent) { SetupFromXmlFile(System.IO.Path.Combine(PropertyService.DataDirectory, @"resources\panels\HighlightingEditor\Environment.xfrm")); button = (Button)ControlDictionary["button"]; button.Click += new EventHandler(EditButtonClicked); listView = (ListView)ControlDictionary["listView"]; listView.Font = new Font(listView.Font.FontFamily, 10); }
public override void LoadSettings() { EnvironmentNode node = (EnvironmentNode)parentNode; listView.Items.Clear(); for (int i = 0; i <= EnvironmentNode.ColorNames.GetUpperBound(0); ++i) { listView.Items.Add(new EnvironmentItem(i, node.ColorDescs[i], node.Colors[i], listView.Font)); } }
/// <summary> /// Checks if a node fullfill conditions to be a TerrainType and add it /// </summary> /// <param name="node">Node to check. </param> private void DetectAndAddTerrainTypes(ref EnvironmentNode node) { if (node.position.y <= EnvironmentManager.trueWaterLevel) { node.terrain.Add(TerrainType.Water); //node.isAccessible = false; } if (node.position.y >= EnvironmentManager.trueSnowLineLevel) { node.terrain.Add(TerrainType.Mountain); } }
public void TryGoTo(EnvironmentNode n) { if (nodesInRange == null) { nodesInRange = Pathfinder.IsInRange(EnvironmentManager.allNodes, currentNode, characterClass.moveRange, PathfindingD); } if (nodesInRange.Contains(n)) { GoTo(Pathfinder.Solve(EnvironmentManager.allNodes, currentNode, n, PathfindingD, PathfindingH)); } SelectionManager.instance.Deselect(); }
public void AddEnvironmentNodeAddsNodeWithDefaultVaues() { AddEnvironmentNodeCommand addEnvironmentCommand = new AddEnvironmentNodeCommand(ServiceProvider); addEnvironmentCommand.Execute(ApplicationNode); EnvironmentNode environmentNode = ApplicationNode.Hierarchy.FindNodeByType(typeof(EnvironmentNode)) as EnvironmentNode; Assert.IsNotNull(environmentNode); Assert.AreEqual("Environment", environmentNode.Name); Assert.AreEqual("Environment.dconfig", environmentNode.EnvironmentDeltaFile); Assert.AreEqual(string.Empty, environmentNode.EnvironmentConfigurationFile); }
/// <summary> /// Creates and positins the tree at nodeIndex and updates the status of the node. /// </summary> /// <param name="nodeIndex">Node Index of the node</param> /// <param name="isBig">if the tree should be fully grown</param> private void GrowTree(Vector2Int nodeIndex, bool isBig) { EnvironmentNode n = EnvironmentManager.nodeMap[nodeIndex.x, nodeIndex.y]; n.terrain.Add(TerrainType.Trees); if (n.position.y < EnvironmentManager.trueCoastLineLevel) { propsTransforms.Add(Instantiate(isBig ? palmTreesPrefabs[1] : palmTreesPrefabs[0], n.position, Quaternion.Euler(Vector3.up * Random.value * 360), propParent).transform); } else { propsTransforms.Add(Instantiate(isBig ? treesPrefabs[1] : treesPrefabs[0], n.position, Quaternion.Euler(Vector3.up * Random.value * 360), propParent).transform); } }
public void InitCharacter(EnvironmentNode startNode, int teamId = -1) { if (characterClass.unnavigableTerrain == null) { characterClass.SetupCharacterClass(); } currentNode = startNode; this.teamId = teamId; currentHp = characterClass.hp; transform.position = currentNode.position; NotifySelectionManager(); }
private bool CanGrowTrees(EnvironmentNode node, EnvironmentNode from = null) { if (node.terrain.Contains(TerrainType.Water) || node.terrain.Contains(TerrainType.Mountain) || node.terrain.Contains(TerrainType.Boulder)) { return(false); } if (from == null) { return(true); } else { return(node.position.y <= EnvironmentManager.trueCoastLineLevel == from.position.y <= EnvironmentManager.trueCoastLineLevel); } }
private EnvironmentNode LoadConfigurationMergeFile(IConfigurationUIHierarchy mainConfigurationHierarchy, string configurationMergeFile, IServiceProvider serviceProvider) { EnvironmentNodeBuilder nodeBuilder = new EnvironmentNodeBuilder(serviceProvider); EnvironmentNode environmentNode = nodeBuilder.Build(configurationMergeFile, mainConfigurationHierarchy); EnvironmentalOverridesNode environmentNodeContainer = mainConfigurationHierarchy.FindNodeByType(typeof(EnvironmentalOverridesNode)) as EnvironmentalOverridesNode; if (environmentNodeContainer == null) { throw new ApplicationException(Resources.ErrorNoEnvironmentContainer); } environmentNodeContainer.AddNode(environmentNode); return(environmentNode); }
public void MergeAndSaveConfiguration(string configurationFile) { IConfigurationUIHierarchy mainConfigurationHierarchy = LoadMainConfiguration(mainConfigurationFile, serviceContainer); EnvironmentNode environmentNode = LoadConfigurationMergeFile(mainConfigurationHierarchy, configurationMergeFile, serviceContainer); if (!String.IsNullOrEmpty(configurationFile)) { environmentNode.EnvironmentConfigurationFile = configurationFile; } SaveMergedEnvironmentCommand saveMergedConfigurationComand = new SaveMergedEnvironmentCommand(serviceContainer); saveMergedConfigurationComand.Execute(environmentNode); mergeSucceeded = saveMergedConfigurationComand.MergeSucceeded; mergedConfigurationFile = saveMergedConfigurationComand.MergedConfigurationFile; }
public void EnvironmentalOverridesValidatesDuplicateMergeFilePaths() { EnvironmentalOverridesNode overridesNode = base.ApplicationNode.Hierarchy.FindNodeByType(typeof(EnvironmentalOverridesNode)) as EnvironmentalOverridesNode; EnvironmentNode node1 = new EnvironmentNode(); EnvironmentNode node2 = new EnvironmentNode(); overridesNode.AddNode(node1); overridesNode.AddNode(node2); node1.EnvironmentDeltaFile = "mergefile"; node2.EnvironmentDeltaFile = "mergefile"; List<ValidationError> errorList = new List<ValidationError>(); overridesNode.Validate(errorList); Assert.AreEqual(1, errorList.Count); }
public void EnvironmentalOverridesValidatesDuplicateMergeFilePaths() { EnvironmentalOverridesNode overridesNode = base.ApplicationNode.Hierarchy.FindNodeByType(typeof(EnvironmentalOverridesNode)) as EnvironmentalOverridesNode; EnvironmentNode node1 = new EnvironmentNode(); EnvironmentNode node2 = new EnvironmentNode(); overridesNode.AddNode(node1); overridesNode.AddNode(node2); node1.EnvironmentDeltaFile = "mergefile"; node2.EnvironmentDeltaFile = "mergefile"; List <ValidationError> errorList = new List <ValidationError>(); overridesNode.Validate(errorList); Assert.AreEqual(1, errorList.Count); }
public float PathfindingD(EnvironmentNode n1, EnvironmentNode n2) { float cost = Vector2.Distance(n1.indexPosition, n2.indexPosition); if (!n2.terrain.Contains(TerrainType.Water)) { cost += (n2.effortWeightage - n1.effortWeightage) * characterClass.inclinedMovementEffortMultiplier; } foreach (TerrainType terrainType in n2.terrain) { if (characterClass.unnavigableTerrain.Contains(terrainType)) { return(float.MaxValue); } if (characterClass.navigatableTerrainWeightage.ContainsKey(terrainType)) { cost *= characterClass.navigatableTerrainWeightage[terrainType]; } } return(cost); }
public void EnvironmentNodeCanNotExtendEnvironmentNode() { EnvironmentNode environmentNode = new EnvironmentNode(); Assert.IsFalse(environmentNode.CanExtend(environmentNode)); }
public float PathfindingH(EnvironmentNode n1, EnvironmentNode n2) { return(Mathf.Sqrt(Vector2.SqrMagnitude(n1.indexPosition - n2.indexPosition) + Mathf.Pow(n2.effortWeightage - n1.effortWeightage, 2))); }
public void EnvironmentNodeCanNotExtendEnvironmentNode() { EnvironmentNode environmentNode = new EnvironmentNode(); Assert.IsFalse(environmentNode.CanExtend(environmentNode)); }