/// <summary> /// Calculates the influence of all units on this unit's position and the 8 unit-length, manhattan distance /// positions away from it. Also transforms influence data into tension and vulnerability values through /// simple mathematical transformations (subtraction, addition). /// </summary> void GetLocalInfluences() { float distance = 1.0f; float distance_x = distance + boundingShape.shape_corner.x; float distance_y = distance + boundingShape.shape_corner.y; surroundings = new Vector3[] { new Vector3(transform.position.x - distance_x, transform.position.y, transform.position.z + distance_y), new Vector3(transform.position.x, transform.position.y, transform.position.z + distance_y), new Vector3(transform.position.x + distance_x, transform.position.y, transform.position.z + distance_y), new Vector3(transform.position.x - distance_x, transform.position.y, transform.position.z), this.transform.position, new Vector3(transform.position.x + distance_x, transform.position.y, transform.position.z), new Vector3(transform.position.x - distance_x, transform.position.y, transform.position.z - distance_y), new Vector3(transform.position.x, transform.position.y, transform.position.z - distance_y), new Vector3(transform.position.x + distance_x, transform.position.y, transform.position.z - distance_y), }; for (int i = 0; i < local_values_num; i++) { Vector3 pos = surroundings[i]; //Debug.Log (surroundings[i]); local_friend_influence_values [i] = InfluenceMapper.FriendInfluence(this, pos); //Debug.Log (local_friend_influence_values[i]); local_foe_influence_values [i] = InfluenceMapper.FoeInfluence(this, pos); //Debug.Log (local_foe_influence_values[i]); local_influences_values [i] = InfluenceMapper.TotalInfluence(local_friend_influence_values[i], local_foe_influence_values[i]); //Debug.Log (local_influences_values[i]); local_tension_values [i] = InfluenceMapper.TotalTension(local_friend_influence_values[i], local_foe_influence_values[i]); //Debug.Log (local_tension_values[i]); local_vulnerability_values [i] = InfluenceMapper.TotalVulnerability(local_tension_values[i], local_influences_values[i]); //Debug.Log (local_vulnerability_values[i]); local_formation_vuln_values [i] = InfluenceMapper.TotalFormationVulnerability(this, pos, local_vulnerability_values[i], local_tension_values[i]); local_influence_minus_self [i] = InfluenceMapper.TotalInfluenceMinusSelf(this, pos, local_influences_values[i]); terrain_values [i] = InfluenceMapper.TerrainValue(terrain, pos); } }
protected override void GetValues() { unit = unit_obj.GetComponent <Unit>(); for (int x = 0; x < size; x++) { for (int z = 0; z < size; z++) { Vector3 pos = new Vector3(this.transform.position.x - size / 2 + x, unit_height, (int)this.transform.position.z - size / 2 + z); float friend_influence_value = InfluenceMapper.FriendInfluence(unit, pos); float foe_influence_value = InfluenceMapper.FoeInfluence(unit, pos); float influences_value = InfluenceMapper.TotalInfluence(friend_influence_value, foe_influence_value); float tension_value = InfluenceMapper.TotalTension(friend_influence_value, foe_influence_value); float vulnerability_value = InfluenceMapper.TotalVulnerability(tension_value, influences_value); float form_vuln_value = InfluenceMapper.TotalFormationVulnerability(unit, pos, vulnerability_value, tension_value); float influence_minus_self = InfluenceMapper.TotalInfluenceMinusSelf(unit, pos, influences_value); float terrain_value = InfluenceMapper.TerrainValue(terrain, pos); values[x, z] = vulnerability_value; } } }