The previous influence computation is good when dealing with a simple influence that is based on individual units helping a faction. However, this could lead to holes in the map instead of covering a whole section. One technique to resolve that problem is flooding, based on the Dijkstra algorithm.
In this case, we will blend the faction capability for tagging a vertex, with the unit's logic for having a drop-off function, into a class called Guild
. This is a component to include in the game object; one for each desired guild:
using UnityEngine; using System; using System.Collections; public class Guild : MonoBehaviour { public string guildName; public int maxStrength; public GameObject baseObject; [HideInInspector] public int strenghth public virtual void Awake() { strength = maxStrength; } }
It also needs a drop-off function. However, this time we wanted to create an example using Euclidean distance...