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

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

        if (influenceSource.influenceType == InfluenceType.Population)
        {
            PopulationMap.AddInfluenceSource(influenceSource);
        }
    }
예제 #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);
        }
    }
예제 #6
0
 public void RemoveInfluenceSource(InfluenceSource source)
 {
     influenceSources.Remove(source);
 }
예제 #7
0
 public void AddInfluenceSource(InfluenceSource source)
 {
     influenceSources.Add(source);
 }