Exemple #1
0
 private void Awake() {
     meshFilter = GetComponent<MeshFilter>();
     meshCollider = GetComponent<MeshCollider>();
     meshRenderer = GetComponent<MeshRenderer>();
     Mesh mesh = GenerateAreaMesh();
     meshFilter.mesh = mesh;
     meshCollider.sharedMesh = mesh;
     meshCollider.isTrigger = true;
     meshRenderer.material = uncontrolledAreaMaterial;
     agentsInZone = new HashSet<ICharacter>();
     CurrentState = AreaNodeVisualisationStates.UNCONTROLLED;
 }
    // Handler functions for when characters move from zone to zone.
    private void HandleCharacterEnterAreaEvent(object sender, ICharacter character)
    {
        // DebuggingHelpers.PrintCurrentMethodName();
        AreaNodeVisualisation area = (AreaNodeVisualisation)sender;

        // Whatever the state of the area the Character was PREVIOUSLY in should become the state of the new area, unless the entered area already has a state which supersedes it.
        AreaNodeVisualisationStates state = characterStateMap[character];

        if (state.Priority() >= area.CurrentState.Priority())
        {
            area.CurrentState = state;
        }

        // ok! we better make sure we keep everything up to date.
        characterAreaMap[character] = area;
    }
    private void UpdateAreaStateBasedOnCharactersWithinIt(AreaNodeVisualisation area)
    {
        if (area == null)
        {
            return;
        }
        AreaNodeVisualisationStates state = AreaNodeVisualisationStates.UNCONTROLLED;

        foreach (ICharacter c in area.AgentsInZone)
        {
            if (characterStateMap[c].Priority() >= state.Priority())
            {
                state = characterStateMap[c];
            }
        }

        area.CurrentState = state;
    }
 public static int Priority(this AreaNodeVisualisationStates s)
 {
     return(nodeStatePriorityLevels[(int)s]);
 }