Exemplo n.º 1
0
        /// <summary>
        /// Test mover collisions.
        /// </summary>
        private void TestMoverCollision()
        {
            if (Exists(EntityType.Test))
            {
                List <Entity> tests  = GetEntities(EntityType.Test);
                List <Entity> npcs   = new List <Entity>();
                TestMover     player = null;

                foreach (Entity e in tests)
                {
                    if (e is TestMover)
                    {
                        if (((TestMover)e).PlayerControl)
                        {
                            player = (TestMover)e;
                        }
                        else
                        {
                            npcs.Add(e);
                        }
                    }
                }

                if (player != null)
                {
                    foreach (Entity e in tests)
                    {
                        TestMover test = (TestMover)e;

                        if (test.Collision(player))
                        {
                            // test.DrawColor = Color.Red;
                            test.Randomize();
                        }
                        else if (test.Proximity(player))
                        {
                            // test.DrawColor = Color.LimeGreen;
                        }
                        else
                        {
                            // test.DrawColor = Color.White;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Faciliate the addition of entities to a given state.
        /// </summary>
        /// <param name="textures">Texture2D hashtable.</param>
        public override void LoadEntities(Dictionary <TextureIDs, Texture2D> textures)
        {
            // Set up of anything needed of entities.
            // Asteroid textures set up.
            List <Texture2D> asteroidTextures = new List <Texture2D>();

            asteroidTextures.Add(textures[TextureIDs.Asteroid1]);
            asteroidTextures.Add(textures[TextureIDs.Asteroid2]);
            asteroidTextures.Add(textures[TextureIDs.Asteroid3]);

            TestMover test = new TestMover(this, textures[TextureIDs.Test], Color.LimeGreen, _size: new Vector2(15, 15));

            test.PlayerControl = true;

            // TODO: Replace with manager code. Pass in list of asteroid textures.

            // Load the entities.
            LoadEntities(new Asteroid(this, asteroidTextures[0], "Asteroid"),
                         new TestMover(this, textures[TextureIDs.Test], Color.LimeGreen, _size: new Vector2(15, 15)),
                         test);
        }