Beispiel #1
0
    public void createThreat(Vector2Int position, float strength, int maxDistance, float fallOfStrength, int fallOfDistance)
    {
        int        totalDistance  = maxDistance + fallOfDistance;
        iRectangle searchableRect = new iRectangle(position, totalDistance);

        for (int x = searchableRect.m_left; x <= searchableRect.m_right; ++x)
        {
            for (int y = searchableRect.m_bottom; y <= searchableRect.m_top; ++y)
            {
                if (Map.Instance.isPositionScenery(x, y))
                {
                    continue;
                }

                float sqrDistance = (new Vector2Int(x, y) - position).sqrMagnitude;
                if (sqrDistance <= maxDistance * maxDistance)
                {
                    m_map[x, y].value += strength;
                    //m_map[x, y].value = strength * (1 - ((distance / maxDistance) * (distance / maxDistance)));
                }
                else if (sqrDistance <= maxDistance * maxDistance + fallOfDistance * fallOfDistance)
                {
                    //m_map[x, y].value += strength - (strength * (distance / maxDistance));
                    m_map[x, y].value += fallOfStrength - (fallOfStrength * (sqrDistance / (totalDistance * totalDistance)));
                }
            }
        }
    }
Beispiel #2
0
 public void addScenery(iRectangle rect)
 {
     for (int x = rect.m_left; x <= rect.m_right; ++x)
     {
         for (int y = rect.m_bottom; y <= rect.m_top; ++y)
         {
             Assert.IsTrue(isInBounds(x, y));
             //Assert.IsTrue(getPoint(x, y).isEmpty());
             getPoint(x, y).scenery = true;
         }
     }
     Pathfinder.Instance.updateObstructions(m_map);
 }
Beispiel #3
0
    public void createProximity(Vector2Int position, float strength, int maxDistance)
    {
        iRectangle searchableRect = new iRectangle(position, maxDistance);

        for (int x = searchableRect.m_left; x <= searchableRect.m_right; ++x)
        {
            for (int y = searchableRect.m_bottom; y <= searchableRect.m_top; ++y)
            {
                if (Map.Instance.isPositionScenery(x, y))
                {
                    continue;
                }

                float sqrDistance = (new Vector2Int(x, y) - position).sqrMagnitude;
                if (sqrDistance <= maxDistance * maxDistance)
                {
                    m_map[x, y].value += strength - (strength * (sqrDistance / (maxDistance * maxDistance)));
                }
            }
        }
    }