예제 #1
0
        public void Initialise(SpriteAnimator animation, Vector2 startPosition, 
            enemyMode mode, Vector2 dir, Vector2 scr)
        {
            enemyAnimation = animation;

            position = startPosition;
            oldPosition = startPosition;

            // Set the enemy to be active
            active = true;

            // Set the player health
            Health = 100;

            enemyAnimation.Active = true;
            enemyAnimation.Position = position;
            EnemyMode = mode;

            direction = Vector2.Zero;
            switch(mode)
            {
                case enemyMode.UpDown:
                    direction.Y = 1f;
                    break;
                case enemyMode.LeftRight:
                    direction.X = 1f;
                    break;
                case enemyMode.Chase:
                    direction.X = 1f;
                    break;
                case enemyMode.Random:
                    timer = new Timer();
                    AssignNewDirection();
                    break;
            }

            screenLimits = scr;
        }
예제 #2
0
 private void buildAnimations()
 {
     enemyAnimation = new SpriteAnimator[levelData.numberAliens];
     for (int i = 0; i < levelData.numberAliens; i++)
     {
         SpriteAnimator enemySpriteAnimation = new SpriteAnimator();
         enemyAnimation[i] = enemySpriteAnimation;
         enemyAnimation[i].Initialize(enemyTexture1, enemyTexture2, Vector2.Zero, 50, 50, 1, 50, Color.White, 1f, true);
     }
 }