示例#1
0
        public Enemy(EnemyType type, Level l)
        {
            this.Type = type;
            Health = 1;
            VelocityModifier = 1.0f;

            InitializeTimer = 0;

            Alpha = 1.0f;
            alphaIncrease = 0.03f;
            level = l;

            DashCooldown = 0;

            Initialized = false;

            TwirlRotation = 0;
            SlowRotation = 0;

            ImprintSpawn = 0;

            Origin = new Vector2(Type.Texture.Width / 2, Type.Texture.Height / 2);

            if (Type.Equals(level.DashEnemy))
            {
                Animation = new Animation(Type.Texture, 40, 0.01f);
                Origin = new Vector2(Animation.FrameWidth / 2, Animation.Texture.Height / 2);
            }

            SpawnAnimation = new Animation(l.EnemySpawnTexture, 200.0f, 0.1f);
            SpawnAlpha = 0.01f;
        }
示例#2
0
        // Spawns a group of one enemy type in a corner
        public void SpawnCornerGroup(int count, EnemyType type)
        {
            // Choose a corner
            int ranCorner = r.Next(4);
            Vector2 cornerPos;
            if (ranCorner == 0)
            {
                cornerPos = new Vector2(GameRectangle.Left + 50, GameRectangle.Top + 50);
            }
            else if (ranCorner == 1)
            {
                cornerPos = new Vector2(GameRectangle.Right - 50, GameRectangle.Top + 50);
            }
            else if (ranCorner == 2)
            {
                cornerPos = new Vector2(GameRectangle.Left + 50, GameRectangle.Bottom - 50);
            }
            else
            {
                cornerPos = new Vector2(GameRectangle.Right - 50, GameRectangle.Bottom - 50);
            }

            // Spawn enemies
            for (int i = 0; i < count; i++)
            {
                if (type.Equals(ClusterEnemy))
                {
                    int ran2 = r.Next(3) + 1;
                    for (int j = 0; j < ran2; j++)
                    {
                        Vector2 spawn2 = new Vector2(cornerPos.X + r.Next(-30, 30), cornerPos.Y + r.Next(-30, 30));
                        SpawnEnemy(ClusterEnemy, spawn2);
                    }
                }
                else
                {
                    Vector2 ranPos = new Vector2(cornerPos.X + r.Next(-50, 50), cornerPos.Y + r.Next(-50, 50));
                    SpawnEnemy(type, ranPos);
                }
            }
        }