We will build the VertexInfluence and InfluenceMap classes, which are used for handling vertices and the graph, respectively:
- Create the VertexInfluence class, deriving from Vertex:
using UnityEngine; using System.Collections; using System.Collections.Generic; public class VertexInfluence : Vertex { public Faction faction; public float value = 0f; }
- Implement the function for setting up values (it returns true if it was a success, and false otherwise):
public bool SetValue(Faction f, float v) { bool isUpdated = false; if (v > value) { value = v; faction = f; isUpdated = true; } return isUpdated; }
- Create the InfluenceMap class deriving from Graph (or a more specific graph implementation):
using UnityEngine; using System.Collections.Generic; ...