Example #1
0
        void OnAffectorRemoved(object sender, EventArgs e)
        {
            HeatMapAffector affector = sender as HeatMapAffector;

            affector.AffectorUpdate  -= OnAffectorUpdate;
            affector.AffectorRemoved -= OnAffectorRemoved;
        }
Example #2
0
        void OnAffectorUpdate(object sender, EventArgs e)
        {
            HeatMapAffector affector = sender as HeatMapAffector;
            int             collumn  = Mathf.RoundToInt(affector.transform.position.x / Interval);
            int             row      = Mathf.RoundToInt(affector.transform.position.z / Interval);
            HeatNode        newNode;

            GraphNodeDict.TryGetValue(new Vector2(collumn, row), out newNode);
            if (newNode)
            {
                HeatNode oldNode;
                if (!AffectorNodeDict.TryGetValue(affector, out oldNode))
                {
                    AffectorNodeDict.Add(affector, newNode);
                }
                else
                {
                    AffectorNodeDict[affector] = newNode;
                }

                if (oldNode != newNode)
                {
                    if (oldNode)
                    {
                        oldNode.Decreaseheat(affector.Layer, affector.HeatAffectCurve.Evaluate(0));
                        oldNode.NeighborNodes[0].DecreaseHeat(affector.Layer, affector.HeatAffectCurve.Evaluate(1));
                        oldNode.NeighborNodes[1].DecreaseHeat(affector.Layer, affector.HeatAffectCurve.Evaluate(2));
                        oldNode.NeighborNodes[2].DecreaseHeat(affector.Layer, affector.HeatAffectCurve.Evaluate(3));
                    }
                    newNode.IncreaseHeat(affector.Layer, affector.HeatAffectCurve.Evaluate(0));
                    newNode.NeighborNodes[0].IncreaseHeat(affector.Layer, affector.HeatAffectCurve.Evaluate(1));
                    newNode.NeighborNodes[1].IncreaseHeat(affector.Layer, affector.HeatAffectCurve.Evaluate(2));
                    newNode.NeighborNodes[2].IncreaseHeat(affector.Layer, affector.HeatAffectCurve.Evaluate(3));
                }
                oldNode = newNode;
            }
        }