Beispiel #1
0
 public void AddInfluenceSource(InfluenceSource source)
 {
     if (!sources.Contains(source))
     {
         sources.Add(source);
     }
 }
Beispiel #2
0
 public DamageMarkerInfo(Character caster, float damageChange, InfluenceSource influenced, int turnCount)
 {
     Caster       = caster;
     DamageChange = damageChange;
     InfluencedBy = influenced;
     TurnCount    = turnCount;
     Type         = MarkerType.IncreasedDamage;
 }
Beispiel #3
0
    private void InfluenceSourceDestroyed <Object>(Object influenceSourceObject)
    {
        InfluenceSource influenceSource = influenceSourceObject as InfluenceSource;

        if (influenceSource.influenceType == InfluenceType.Population)
        {
            PopulationMap.RemoveInfluenceSource(influenceSource);
        }
    }
Beispiel #4
0
    private void InfluenceSourceCreated <Object>(Object influenceSourceObject)
    {
        InfluenceSource influenceSource = influenceSourceObject as InfluenceSource;

        if (influenceSource.influenceType == InfluenceType.Population)
        {
            PopulationMap.AddInfluenceSource(influenceSource);
        }
    }
Beispiel #5
0
    void InsertNewValuesParallel(object obj)
    {
        try {
            ThreadData      data   = obj as ThreadData;
            InfluenceSource source = data.source;

            // Get middle point for angle calculation
            var middle = new Vector2Int();
            int count  = 0;
            foreach (var pos in grid.ProjectGridPos(data.bounds))
            {
                middle += pos;
                count++;
            }
            if (count == 0)
            {
                middle = data.gridPos;
            }
            else
            {
                middle.x /= count;
                middle.y /= count;
            }

            float angleCalc = 1;
            var   dir       = new Vector2(data.direction.x, data.direction.z);

            grid.BFS(grid.ProjectGridPos(data.bounds), source.range, (pos, it) => {
                if (dir != Vector2.zero)
                {
                    float dot = (Vector2.Dot(dir.normalized, new Vector2(pos.x - middle.x, pos.y - middle.y).normalized) + 1) / 2;
                    angleCalc = dot;
                }
                var addVal = source.GetValue(it, source.sourceValue, source.range) * angleCalc;
                Add(ref addMap[pos.x, pos.y], addVal);
                Interlocked.Exchange(ref decayMap[pos.x, pos.y], Mathf.Max(addMap[pos.x, pos.y], decayMap[pos.x, pos.y]));
            }, (neighbor) => {
                return(Mathf.Approximately(obstacleHeights.GetHeight(neighbor), 0));
            }, (neighbor) => {
                return(dir != Vector2.zero ? angleCalc * directionModifier * data.direction.magnitude : 0);
            });
            Interlocked.Increment(ref completed);
        } catch (Exception e) {
            Debug.LogException(e);
        }
    }
Beispiel #6
0
 public void RemoveInfluenceSource(InfluenceSource source)
 {
     influenceSources.Remove(source);
 }
Beispiel #7
0
 public void AddInfluenceSource(InfluenceSource source)
 {
     influenceSources.Add(source);
 }