コード例 #1
0
        public void Initialize(Animation animation, Vector2 position, float rotation, float aggroRange)
        {
            this.FireTime = TimeSpan.FromSeconds(ATTACK_SPEED);
            this.PreviousFireTime = TimeSpan.FromSeconds(0);
            this.AggroRange = aggroRange;
            this.Rotation = rotation;
            this.IsInAggroRange = false;
            //call base, its important to be here as we are writing over properties below
            base.Initialize(animation, position);

            this.Health = HEALTH;
            // Set the amount of damage the enemy can do
            this.Damage = DAMAGE;

            // Set how fast the enemy moves
            this.EnemyMoveSpeed = DEF_SPEED;

            // Set the score value of the enemy
            this.Value = XP_VALUE;
        }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: klimentt/KurtVonnegut
        public override void Initialize(Animation animation, Vector2 position)
        {
            // Load the enemy ship texture
            this.animation = animation;

            // Set the position of the enemy
            this.Position = position;

            // We initialize the enemy to be active so it will be update in the game
            this.Active = true;

            // Set the health of the enemy
            this.Health = HEALTH;

            // Set the amount of damage the enemy can do
            this.Damage = DAMAGE;

            // Set how fast the enemy moves
            this.EnemyMoveSpeed = DEF_SPEED;

            // Set the score value of the enemy
            this.Value = XP_VALUE;
        }
コード例 #3
0
 private void AddExplosion(Vector2 position)
 {
     Animation explosion = new Animation();
     int explosionFrameCount = 12;
     explosion.Initialize(this.explosionTexture, position, this.explosionTexture.Width / explosionFrameCount, this.explosionTexture.Height, explosionFrameCount, 45, Color.White, 1f, false);
     this.explosions.Add(explosion);
     SoundCaller explosionSound = new SoundCaller(this.roachSmashed);
     //
 }
コード例 #4
0
        private void AddEnemy()
        {
            // Create the animation object
            Animation enemyAnimation = new Animation();

            // Initialize the animation with the correct animation information
            int enemyFrameCount = 8;

            // Randomly generate the position of the enemy
            Vector2 position = new Vector2(GameplayScreen.Random.Next(250, this.ScreenManager.GraphicsDevice.Viewport.Width + this.enemyTexture.Width / 2), GameplayScreen.Random.Next(100, this.ScreenManager.GraphicsDevice.Viewport.Height - 100));

            // Create an enemy

            RotatingEnemy enemy;

            switch (Random.Next(9) % 8)
            {
                case 1:
                    enemy = new Roach();
                    this.enemyTexture = this.enemyAnimationTextures[6];
                    break;
                case 2:
                    enemy = new FireRoach();
                    this.enemyTexture = this.enemyAnimationTextures[7];
                    break;
                case 3:
                    enemy = new Fly();
                    this.enemyTexture = this.enemyAnimationTextures[2];
                    break;
                case 4:
                    enemy = new FireFly();
                    this.enemyTexture = this.enemyAnimationTextures[3];
                    break;
                //case 5:
                //    break;
                //case 6:
                //    break;
                //case 7:
                //    break;
                //case 8:
                //    break;
                default:
                    enemy = new Roach();
                    break;

            }

            enemyAnimation.Initialize(this.enemyTexture, Vector2.Zero, this.enemyTexture.Width / enemyFrameCount, this.enemyTexture.Height, enemyFrameCount, 30, Color.White, 1f, true);

            // Initialize the enemy
            enemy.Initialize(enemyAnimation, position, 0, 300);

            // Add the enemy to the active enemies list
            this.enemies.Add(enemy);
        }
コード例 #5
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (this.content == null)
                {
                    this.content = new ContentManager(this.ScreenManager.Game.Services, "Content");
                }

                this.gameFont = this.content.Load<SpriteFont>("gamefont");
                // Create a new SpriteBatch, which can be used to draw textures.
                this.spriteBatch = new SpriteBatch(this.ScreenManager.GraphicsDevice);

                this.roachSmashed = content.Load<SoundEffect>(("Sounds\\roach_smashed"));
                this.shotSound = content.Load<SoundEffect>(("Sounds\\shot"));
                this.turretSound = content.Load<SoundEffect>(("Sounds\\turretLaunch"));
                // TODO: use this.Content to load your game content here

                //player
                Animation playerAnimation = new Animation();
                string plTexture = "player_2_animation";
                if (CharacterSelectionScreen.currentRace == CharacterSelectionScreen.Race.Administrator)
                {
                    plTexture = "player_2_animation";
                }
                else if (CharacterSelectionScreen.currentRace == CharacterSelectionScreen.Race.Designer)
                {
                    plTexture = "femaleFigure_walk";
                }
                else
                {
                    plTexture = "maleFigure_walk";
                }
                Texture2D playerTexture = this.content.Load<Texture2D>(plTexture);
                int playerFrames = 1;
                playerAnimation.Initialize(playerTexture, Vector2.Zero, playerTexture.Width / playerFrames, playerTexture.Height, playerFrames, 30, Color.White, 1f, true);

                Vector2 playerPosition = new Vector2(this.ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, this.ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y +
                                                                                                                 this.ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
                this.player.Initialize(playerAnimation, playerPosition);

                //background screen
                this.mainframe = new Microsoft.Xna.Framework.Rectangle(0, 0, this.ScreenManager.GraphicsDevice.Viewport.Width, this.ScreenManager.GraphicsDevice.Viewport.Height);
                this.background = this.content.Load<Texture2D>("circuitBoard");

                //enemy
                this.enemyTexture = this.content.Load<Texture2D>("roach");
                enemyAnimationTextures = new List<Texture2D>();
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("ant"));
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("ant_ghost"));
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("fly"));
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("fly_ghost"));
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("moth"));
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("moth_ghost"));
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("roach"));
                enemyAnimationTextures.Add(this.content.Load<Texture2D>("roach_ghost"));

                //projectile
                this.projectileTexture = this.content.Load<Texture2D>("laser");
                this.turretProjTexture = this.content.Load<Texture2D>("turretProjectile");

                //effect explosions
                this.explosionTexture = this.content.Load<Texture2D>("explosion_2");

                //solid objects texture
                this.solidTexture = this.content.Load<Texture2D>("solid");
                //turret texture
                this.turretTexture = this.content.Load<Texture2D>("turret");
                InitializeSolids();

                //add turret that uses the same texture from solid
                InitializeTurrets();

                this.font = this.content.Load<SpriteFont>("gameFont");

                this.ScreenManager.Game.ResetElapsedTime();
            }
            #if WINDOWS_PHONE
            if (Microsoft.Phone.Shell.PhoneApplicationService.Current.State.ContainsKey("PlayerPosition"))
            {
            playerPosition = (Vector2)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["PlayerPosition"];
            enemyPosition = (Vector2)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["EnemyPosition"];
            }
            #endif
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: klimentt/KurtVonnegut
        //methods
        public override void Initialize(Animation animation, Vector2 position)
        {
            this.animation = animation;
            this.Inventory = new List<Item>();
            this.PlayerMoveSpeed = INIT_MOVESPEED;
            this.Rotation = 0;
            // Set the starting position of the player around the middle of the screen and to the back
            this.Position = position;
            this.initialPos = position;

            // Set the player to be active
            this.Active = true;

            // Set the player health
            this.Health = DEF_HP;

            // Set the player level
            this.Level = LVL;

            // Set the laser to fire every quarter second
            this.FireTime = TimeSpan.FromSeconds(FIRE_DELAY);
        }
コード例 #7
0
 public virtual void Initialize(Animation animation, Vector2 position)
 {
     this.animation = animation;
     this.Position = position;
     this.Active = true;
 }
コード例 #8
0
ファイル: ShieldSkill.cs プロジェクト: klimentt/KurtVonnegut
 public void Initialize(Vector2 startPosition, Animation animation, TimeSpan cooldown, TimeSpan duration)
 {
     base.Initialize(startPosition, animation, cooldown);
     this.Duration = duration;
 }
コード例 #9
0
        public void Initialize(Vector2 startPosition, Animation animation, TimeSpan cooldown, float radius)
        {
            base.Initialize(startPosition, animation, cooldown);

            this.Radius = radius;
        }
コード例 #10
0
ファイル: Skill.cs プロジェクト: klimentt/KurtVonnegut
 public virtual void Initialize(Vector2 startPosition, Animation animation, TimeSpan cooldown)
 {
     this.Animation = animation;
     this.FireTime = cooldown;
     this.StartPosition = startPosition;
 }