예제 #1
0
        public Thinner(ContentManager content)
        {
            // Load the texture
            texture = content.Load<Texture2D>(ASSET);

            // Choose a random polygon and draw the thinner there
            int id = GameMode.random.Next(GameMode.polygons.Count);
            position = new Vector3(GameMode.polygons[id].center.X, GameMode.polygons[id].center.Y, 0);

            // Initialize the bounding box
            bound = new BoundingSphere(position, Math.Max(texture.Height, texture.Width));

            // Add a scent to the graph
            Scent s = new Scent(id, 1, null, 0);
            GameMode.smells.nodes[id].AddSignal(s);
            s.Propagate();
        }
예제 #2
0
파일: Scent.cs 프로젝트: jennydvr/ColorWars
        /// <summary>
        /// Propagates a given signal
        /// </summary>
        public void Propagate()
        {
            if (intensity <= 0.1f)
                return;

            for (int i = 0; i != graph.nodes.Count; ++i)
            {
                // If the nodes are not neighboors, continue
                if (float.IsPositiveInfinity(graph.arcs[id, i]))
                    continue;

                // Calculate the intensity of the new signal
                float newIntensity = MathHelper.Min(intensity * factor / graph.arcs[id, i], 0.9f);

                // Now check the signals in the node
                bool ok = true;

                foreach (Scent scent in graph.nodes[i].signals)
                {
                    // If there is a scent with less intensity, replace it
                    if (scent.intensity < newIntensity)
                    {
                        scent.intensity = newIntensity;
                        scent.endInterval = maxtime * newIntensity * 3.5f;
                    //    scent.origin = graph.nodes[id];
                        scent.origin = origin;
                        scent.Propagate();
                    }

                    ok = false;
                }

                // If there wasn't a scent in the node, add one
                if (ok)
                {
                 //   Scent s = new Scent(i, newIntensity, graph.nodes[id], i);
                    Scent s = new Scent(i, newIntensity, origin, i);
                    graph.nodes[i].AddSignal(s);
                    s.Propagate();
                }
            }
        }