コード例 #1
0
ファイル: PistolItem.cs プロジェクト: payam-g/1302C_Game_2
 public override void Collision(Player p)
 {
     //			if(p.WList.Count > 0)
     //			{
     //				//Check if player already has weapon
     //				bool gun = false;
     //				foreach(Weapon w in p.WList)
     //				{
     //					//If the current weapon is not a pistol, it will return null.
     //					Console.WriteLine(w.GetType());
     //	//				if(pstl != null)
     //	//					gun = true;
     //				}
     //
     //				//If he/she doesn't, gives them the weapon
     //				if(!gun)
     //				{
     //					p.WList.Add(new Pistol(p.s.Position, Graphics, Col));
     //					IsAlive = false;
     //				}
     //
     //			}
     //			else
     //				p.WList.Add(new Pistol(p.s.Position, Graphics, Col));
     p.WList.Add(new Pistol(p.s.Position, Graphics, Col));
     IsAlive = false;
 }
コード例 #2
0
ファイル: Command.cs プロジェクト: olji/Zombierush
 public void execute(GameTime gametime, Player player, bool sound) {
     if (!player.iAir && !player.cDead) {
         player.JumpFunc();
         if (sound)
             player.jSound.Play();
     }
 }
コード例 #3
0
 public Saucer(GraphicsContext g, Texture2D t, Vector3 p, Player pl)
     : base(g,t,p, pl)
 {
     player = pl;
     vel= (new Vector3(.5f*(float)gen.Next(3,5),.7f*(float)gen.Next(3,5),0));
     graphics=g;
 }
コード例 #4
0
ファイル: Star.cs プロジェクト: andierocca/destructive-santa
 public Star(GraphicsContext g, Texture2D t, Vector3 p, Player pl)
     : base(g,t,p)
 {
     graphics=g;
     player = pl;
     vel= (new Vector3(.5f*(float)gen.Next(1,5),.7f*(float)gen.Next(1,5),0));
 }
コード例 #5
0
ファイル: Command.cs プロジェクト: olji/Zombierush
        public void execute(GameTime gametime, Player player, bool sound) {
            if (!player.cDead) {
                player.rCheck = true;
                player.rCheck = true;
                player.flip = false;
                if (player.runningFrame > 11)
                    player.runningFrame = 6;
                player.runningTime += gametime.ElapsedGameTime.Milliseconds;
                if (player.runningTime >= player.animSpeed) {
                    player.runningTime = 0;
                    player.runningFrame++;
                    if (player.runningFrame > 11)
                        player.runningFrame = 6;
                }

                if (player.stepsInst.State == SoundState.Stopped && !player.iAir && sound) {
                    player.stepsInst.Volume = 0.1f;
                    player.stepsInst.Play();
                }

                player.momentumX -= player.rAcc;
                if (player.momentumX < -player.pMaxSpeed)
                    player.momentumX = -player.pMaxSpeed;
            }
        }
コード例 #6
0
 public Meteor(GraphicsContext g, Texture2D t, Vector3 p, Player pl)
     : base(g,t,p, pl)
 {
     graphics=g;
     vel= (new Vector3(.5f*(float)gen.Next(1,3),.7f*(float)gen.Next(1,3),0));
     player = pl;
 }
コード例 #7
0
ファイル: Afficheur.cs プロジェクト: MrLePlow/SweetRide
 // constructeur
 public Afficheur()
 {
     Localplayer = new Player(40, 40);
     carte = new Carre(32, 32);
     Walls = new List<Wall>();
     clickdown = false;
 }
コード例 #8
0
ファイル: AppMain.cs プロジェクト: payam-g/1302C_Game_2
 public static void Initialize()
 {
     // Set up the graphics system
     Random rand = new Random();
     graphics = new GraphicsContext ();
     clock = new Stopwatch();
     clock.Start();
     col = new Collision(graphics);
     p = new Player(graphics, col);
     col.p = p;
     col.elist.Add (new Enemy1(graphics, col, new Vector3(rand.Next (0,960),rand.Next (0,544),0)));
     col.ilist.Add(new Item(graphics, col, new Vector3(rand.Next(60,901), rand.Next(44,501), 0), Item.Type.Pistol, new Vector4(1,.5f,0,1)));
     col.ilist.Add(new Item(graphics, col, new Vector3(rand.Next(60,901), rand.Next(44,501), 0), Item.Type.Shotgun, new Vector4(0,1,0,1)));
     col.ilist.Add(new Item(graphics, col, new Vector3(rand.Next(60,901), rand.Next(44,501), 0), Item.Type.Machinegun,new Vector4(0,0,1,1)));
 }
コード例 #9
0
        public static void NewGame(int sc)
        {
            gameOver = false;
            newLevel = true;
            score = sc;

            elf1Tex = new Texture2D("/Application/assets/elf1.png", false);
            elf2Tex = new Texture2D("/Application/assets/elf2.png", false);
            treeTex = new Texture2D("/Application/assets/tree.png", false);
            Texture2D bgTex = new Texture2D ("/Application/assets/snow.png", false);
            Texture2D catTex = new Texture2D ("/Application/assets/santa.png", false);
            Texture2D starTex= new Texture2D ("/Application/assets/house.png", false);
            Texture2D meteorTex= new Texture2D ("/Application/assets/car.png", false);
            Texture2D saucerTex= new Texture2D ("/Application/assets/police.png", false);
            Texture2D clawTex= new Texture2D ("/Application/assets/up_present.png", false);
            Texture2D meowTex = new Texture2D("/Application/assets/left_present.png", false);
            Texture2D hairballTex = new Texture2D("/Application/assets/right_present.png", false);
            gameOverTex = new Texture2D("/Application/assets/game_over.png", false);
            alphabetTex = new Texture2D("/Application/assets/alphabet.png", false);
            selectorTex = new Texture2D("/Application/assets/selector.png", false);

            alpha = new Sprite(graphics, alphabetTex);
            alpha.Position = new Vector3((graphics.Screen.Rectangle.Width / 2 - alpha.Width / 2)+340,
                                      graphics.Screen.Rectangle.Height / 2 - alpha.Height / 2, 0);
            selector = new Sprite(graphics, selectorTex);
            selector.Position = new Vector3((graphics.Screen.Rectangle.Width / 2 - selector.Width / 2) - 175,
                                      graphics.Screen.Rectangle.Height / 2 - selector.Height / 2, 0);

            go = new Sprite (graphics, gameOverTex);
            bg = new Sprite (graphics, bgTex);
            pieces = new List<GameObj> ();
            waiting = new List<Weapon> (); //weapons waiting to be rendered
            p = new Player (graphics, catTex, new Vector3 (30, 450, 0));
            pieces.Add (p);

            //add the enemies
            for( int i=0; i<3;i++){
                pieces.Add (new Star (graphics, starTex, new Vector3 (gen.Next(200,900),gen.Next(200,400),0), p));
                pieces.Add (new Star (graphics, starTex, new Vector3 (gen.Next(200,900),gen.Next(200,400),0), p));
                pieces.Add (new Meteor (graphics, meteorTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0), p));
            }
            pieces.Add (new Saucer (graphics, saucerTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0), p));

            //add weapons to the screne
            cl = new Claw(graphics, clawTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0));
            cl.isActive = false;
            pieces.Add (cl);

            m = new SonicMeow(graphics, meowTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0), new Vector3(0,0,0));
            m.isActive = false;
            pieces.Add (m);

            hb = new HairBall(graphics, hairballTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0));
            hb.isActive = false;
            pieces.Add (hb);

            //to display the score
            UISystem.Initialize (graphics);
            Scene scene = new Scene ();

            scoreLabel = new Label (); //current score
            scoreLabel.X = 320;
            scoreLabel.Y = 10;
            scoreLabel.Width = 300;
            scoreLabel.Text = "Score: " + score;
            scene.RootWidget.AddChildLast (scoreLabel);

            LoadHighScore ();
            hsLabel = new Label (); //high score
            hsLabel.X = 620;
            hsLabel.Y = 10;
            hsLabel.Width = 300;
            hsLabel.Text = "High Score: " + highscore;
            scene.RootWidget.AddChildLast (hsLabel);

            UISystem.SetScene (scene, null);
        }
コード例 #10
0
ファイル: Enemy.cs プロジェクト: payam-g/1302C_Game_2
 public abstract void Attack(Player p);
コード例 #11
0
ファイル: Zombies.cs プロジェクト: olji/Zombierush
        public void enemyMovement(GameTime gameTime, Player x, List<Rectangle> mapHitBoxes)
        {
            //Collisionbox made to make AI know when to jump to get to another platform
            JumpBox = new Rectangle((int)Position.X - 25, (int)Position.Y - 50, 50, 40);

            if (stopChase)
                moveState = 0;

            //Spawning animation
            if (spawning)
            {
                runningTime += gameTime.ElapsedGameTime.Milliseconds;
                if (runningTime >= spawnAnimSpeed)
                {
                    runningTime = 0;
                    spawnFrame++;
                    if (spawnFrame > 35)
                        spawning = false;
                }
            }    

            //************ZOMBIE MOVEMENT******************
            else if (!spawning)
            {
                if (!stopChase)
                {
                    if (Position.X > x.pos.X && !trapped || lockLeft)
                    {
                        //Movement and animation
                        rCheck = true;
                        flip = false;
                        if (runningFrame > 11)
                            runningFrame = 6;
                        runningTime += gameTime.ElapsedGameTime.Milliseconds;
                        if (runningTime >= animSpeed)
                        {
                            runningTime = 6;
                            runningFrame++;
                            if (runningFrame > 11)
                                runningFrame = 6;
                        }

                        momentum.X -= rAcc;

                        if (momentum.X < -pMaxSpeed)
                            momentum.X = -pMaxSpeed;

                    }

                    if (Position.X < x.pos.X && !trapped || lockRight)
                    {
                        flip = true;
                        rCheck = true;
                        if (runningFrame < 12)
                            runningFrame = 12;
                        runningTime += gameTime.ElapsedGameTime.Milliseconds;
                        if (runningTime >= animSpeed)
                        {
                            runningTime = 0;


                            runningFrame++;
                            if (runningFrame > 17)
                                runningFrame = 12;

                        }

                        momentum.X += rAcc;

                        if (momentum.X > pMaxSpeed)
                            momentum.X = pMaxSpeed;

                    }
                    //Hinders the AI from jumping when it's useless
                    if ((Position.X - x.pos.X <= 50 && Position.X - x.pos.X >= 0 && !inAir && x.iAir && x.pos.Y < Position.Y && !jumpLock) || (Position.X - x.pos.X >= -50 && Position.X - x.pos.X <= 0 && !inAir && x.iAir && x.pos.Y < Position.Y && !jumpLock))
                    {
                        JumpFunc();
                    }
                }
                foreach (Rectangle platform in mapHitBoxes)
                {
                    if (x.pos.Y < Position.Y && JumpBox.Intersects(platform) && !inAir)
                    {
                        JumpFunc();
                    }
                    if (inAir)
                        waitUntilLand = true;

                    //Makes the AI to stop chasing and jump up/fall down before chasing again
                    if (feetBox.Intersects(platform) && x.pos.Y != Position.Y && ((Position.X - x.pos.X >= -50 && Position.X - x.pos.X <= 0) || (Position.X - x.pos.X <= 50 && Position.X - x.pos.X >= 0)))
                    {
                        trapped = true;
                        if (x.pos.Y > Position.Y)
                            jumpLock = true;
                        if (Position.X - x.pos.X >= -50 && Position.X - x.pos.X <= 0 && !lockLeft)
                        {
                            lockRight = true;
                            lockLeft = false;
                            trapHeight = (int)Position.Y;
                        }
                        else if (Position.X - x.pos.X <= 50 && Position.X - x.pos.X >= 0 && !lockRight)
                        {
                            lockLeft = true;
                            lockRight = false;
                            trapHeight = (int)Position.Y;
                        }
                    }

                    if (feetBox.Intersects(platform) && waitUntilLand && Position.Y < trapHeight || x.pos.Y == trapHeight)
                    {
                        trapped = false;
                        lockRight = false;
                        lockLeft = false;
                        waitUntilLand = false;
                    }
                    if (inAir && Position.Y > trapHeight || x.pos.Y == trapHeight)
                    {
                        trapped = false;
                        lockRight = false;
                        lockLeft = false;
                    }

                }
                physics();
            }
        }
コード例 #12
0
ファイル: Command.cs プロジェクト: olji/Zombierush
 public void execute(GameTime gametime, Player player, bool sound) {
     player.stepsInst.Stop();
     player.moveState = 0;
     player.rCheck = false;
 }
コード例 #13
0
ファイル: Enemy1.cs プロジェクト: payam-g/1302C_Game_2
 public override void Attack(Player p)
 {
 }
コード例 #14
0
ファイル: Game1.cs プロジェクト: rhockett94/RogueTest
		/// <summary>
		/// LoadContent will be called once per game and is the place to load
		/// all of your content.
		/// </summary>
		protected override void LoadContent()
		{
			// Create a new SpriteBatch, which can be used to draw textures.
			spriteBatch = new SpriteBatch(GraphicsDevice);

			// TODO: use this.Content to load your game content here
			_floor = Content.Load<Texture2D>("Floor");
			_wall = Content.Load<Texture2D>("Wall");

			Cell startingCell = GetRandomEmptyCell();
			_player = new Player
			{
				X = startingCell.X,
				Y = startingCell.Y,
				Scale = 0.25f,
				Sprite = Content.Load<Texture2D>("Player")
			};
			UpdatePlayerFieldOfView();
		}
コード例 #15
0
ファイル: Game1.cs プロジェクト: Huskyhond/Space-invaders
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            base.Initialize();
            Rectangle b = GraphicsDevice.Viewport.Bounds;
            windowWidth = b.Width;
            windowHeight = b.Height;

            // Preset players:
            Player p1 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 1");
            p1.health.position = new Vector2(10.0f, (windowHeight * 95 / 100));
            p1.position = new Vector2((windowWidth/2)-80, windowHeight/2);

            Player p2 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 2");
            p2.health.position = new Vector2((windowWidth * 80 / 100), (windowHeight * 95 / 100));
            p2.position = new Vector2((windowWidth / 2) - 50, windowHeight / 2);
            Player p3 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 3");
            p3.health.position = new Vector2(10.0f, (windowHeight * 5 / 100));
            p3.position = new Vector2((windowWidth / 2) - 20, windowHeight / 2);

            Player p4 = new Player(Content.Load<Texture2D>("Fighter_small.png"), new Health(Content.Load<Texture2D>("healthBar.png")), "Player 4");
            p4.health.position = new Vector2((windowWidth * 80 / 100), (windowHeight * 5 / 100));
            p4.position = new Vector2((windowWidth / 2) + 10, windowHeight / 2);

            DefaultPlayerSettings.Add(p1);
            DefaultPlayerSettings.Add(p2);
            DefaultPlayerSettings.Add(p3);
            DefaultPlayerSettings.Add(p4);

            for (int i = 0; i < amountOfPlayers; i++)
            {
                Player ptoAdd = DefaultPlayerSettings[i];
                ptoAdd.controller = getController(PlayerControllerChoices[i]);
                ptoAdd.weapon = new SingleBlaster(Content, ptoAdd);
                Players.Add(ptoAdd);

            }

            astroidRain =
                new While(
                    new Semicolon(new Wait(100),
                        new Semicolon(
                            new For(0, (random.Next(50, 300)),
                                new Semicolon(
                                    new CreateAstroid(),
                                    new Wait(100)
                                )
                            ), new Wait(5000)
                        )
                    )
               );
        }
コード例 #16
0
ファイル: Game1.cs プロジェクト: lodossDev/gameengine
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            font1 = Content.Load<SpriteFont>("Fonts/MyFont");

            leo = new Player("Leo1");
            taskMaster = new Boss_TaskMaster();

            leo.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Actors/Leo/Stance"));
            leo.SetFrameDelay(Animation.State.STANCE, 5);


            leo.AddSprite(Animation.State.WALK_TOWARDS, new Sprite("Sprites/Actors/Leo/Walk", Animation.Type.REPEAT));
            leo.SetSpriteOffSet(Animation.State.WALK_TOWARDS, 0, 240f);

            leo.AddSprite(Animation.State.JUMP_START, new Sprite("Sprites/Actors/Leo/JumpStart", Animation.Type.ONCE));
            leo.SetSpriteOffSet(Animation.State.JUMP_START, 20, 10);
            leo.SetFrameDelay(Animation.State.JUMP_START, 5);

            leo.AddSprite(Animation.State.LAND, new Sprite("Sprites/Actors/Leo/Land", Animation.Type.ONCE));
            leo.SetSpriteOffSet(Animation.State.LAND, 30, -11);
            leo.SetFrameDelay(Animation.State.LAND, 5);

            leo.AddSprite(Animation.State.JUMP, new Sprite("Sprites/Actors/Leo/Jump", Animation.Type.REPEAT, 13));
            leo.SetFrameDelay(Animation.State.JUMP, 5);
            leo.SetSpriteOffSet(Animation.State.JUMP, 10, -80);

            leo.AddSprite(Animation.State.JUMP_TOWARDS, new Sprite("Sprites/Actors/Leo/JumpTowards", Animation.Type.REPEAT, 13));
            leo.SetFrameDelay(Animation.State.JUMP_TOWARDS, 5);
            leo.SetFrameDelay(Animation.State.JUMP_TOWARDS, 1, 6);
            leo.SetSpriteOffSet(Animation.State.JUMP_TOWARDS, 10, -80);

            leo.AddAnimationLink(new Animation.Link(Animation.State.JUMP_START, Animation.State.JUMP, leo.GetSprite(Animation.State.JUMP_START).GetFrames()));
            leo.SetTossFrame(Animation.State.JUMP, 1);
            leo.SetTossFrame(Animation.State.JUMP_TOWARDS, 1);

            leo.AddSprite(Animation.State.FALL1, new Sprite("Sprites/Actors/Leo/Falling", Animation.Type.REPEAT, 5));
            leo.SetSpriteOffSet(Animation.State.FALL1, 10, -80);

            leo.SetAnimationState(Animation.State.STANCE);
            
            
            leo.SetSpriteOffSet(Animation.State.WALK_TOWARDS, 30, -5);
            leo.SetResetFrame(Animation.State.WALK_TOWARDS, 3);
            leo.SetMoveFrame(Animation.State.WALK_TOWARDS, 3);
            leo.SetHeight(180);

            leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 5);
            leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 1, 6);
            leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 2, 6);
            leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 3, 6);

            leo.AddSprite(Animation.State.ATTACK1, new Sprite("Sprites/Actors/Leo/Attack1", Animation.Type.ONCE));
            leo.SetSpriteOffSet(Animation.State.ATTACK1, 40, -35);
            leo.SetFrameDelay(Animation.State.ATTACK1, 4);
            leo.SetFrameDelay(Animation.State.ATTACK1, 1, 5);
            leo.SetFrameDelay(Animation.State.ATTACK1, 2, 5);

            leo.AddBox(Animation.State.ATTACK1, 6, new CLNS.AttackBox(100, 80, 132, 45));
            //leo.GetAttackBox(Animation.State.ATTACK1, 6).SetComboStep(0);

            leo.AddBox(Animation.State.ATTACK1, 6, new CLNS.AttackBox(100, 80, 59, 99, 1));
            leo.AddBox(Animation.State.ATTACK1, 6, new CLNS.AttackBox(100, 80, 159, 99, 1));
            //leo.GetAttackBox(Animation.State.ATTACK1, 6).SetComboStep(1);

            leo.AddBox(Animation.State.ATTACK1, 7, new CLNS.AttackBox(150, 50, -10, 210, 1));
            leo.AddBox(Animation.State.ATTACK1, 7, new CLNS.AttackBox(150, 50, -60, 160, 1));
            leo.GetAttackBox(Animation.State.ATTACK1, 7).SetComboStep(0);


            leo.AddSprite(Animation.State.ATTACK2, new Sprite("Sprites/Actors/Leo/Attack2", Animation.Type.ONCE));
            leo.SetSpriteOffSet(Animation.State.ATTACK2, 25, -37);
            leo.SetFrameDelay(Animation.State.ATTACK2, 4);
            leo.AddBox(Animation.State.ATTACK2, 6, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK2, 6, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK2, 6, new CLNS.AttackBox(220, 230, 20, 30));

            leo.AddSprite(Animation.State.ATTACK3, new Sprite("Sprites/Actors/Leo/Attack3", Animation.Type.ONCE));
            leo.SetSpriteOffSet(Animation.State.ATTACK3, 60, -10);
            leo.SetFrameDelay(Animation.State.ATTACK3, 4);
            leo.AddBox(Animation.State.ATTACK3, 6, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK3, 6, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK3, 5, new CLNS.AttackBox(220, 230, 20, 30));

            leo.AddSprite(Animation.State.ATTACK4, new Sprite("Sprites/Actors/Leo/Attack4", Animation.Type.ONCE));
            leo.SetSpriteOffSet(Animation.State.ATTACK4, 30, 3);
            leo.SetFrameDelay(Animation.State.ATTACK4, 4);
            leo.AddBox(Animation.State.ATTACK4, 3, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK4, 5, new CLNS.AttackBox(220, 230, 20, 30));

            leo.AddSprite(Animation.State.ATTACK5, new Sprite("Sprites/Actors/Leo/Attack5", Animation.Type.ONCE));
            leo.SetSpriteOffSet(Animation.State.ATTACK5, 50, -25);
            leo.SetFrameDelay(Animation.State.ATTACK5, 4);
            leo.AddBox(Animation.State.ATTACK5, 6, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK5, 6, new CLNS.AttackBox(220, 230, 20, 30));

            leo.AddSprite(Animation.State.ATTACK6, new Sprite("Sprites/Actors/Leo/Attack6", Animation.Type.ONCE), true);
            leo.SetSpriteOffSet(Animation.State.ATTACK6, 35, -41);
            leo.SetFrameDelay(Animation.State.ATTACK6, 4);
            leo.AddBox(Animation.State.ATTACK6, 5, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK6, 6, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK6, 5, new CLNS.AttackBox(220, 230, 20, 30));
            leo.AddBox(Animation.State.ATTACK6, 5, new CLNS.AttackBox(220, 230, 20, 30));

            leo.AddSprite(Animation.State.JUMP_ATTACK1, new Sprite("Sprites/Actors/Leo/JumpAttack1", Animation.Type.ONCE), true);
            leo.SetSpriteOffSet(Animation.State.JUMP_ATTACK1, 60, -70);
            leo.SetFrameDelay(Animation.State.JUMP_ATTACK1, 4);
            leo.SetFrameDelay(Animation.State.JUMP_ATTACK1, 1, 4);
            leo.SetFrameDelay(Animation.State.JUMP_ATTACK1, 2, 4);

            leo.AddSprite(Animation.State.JUMP_TOWARD_ATTACK1, new Sprite("Sprites/Actors/Leo/JumpAttack2", Animation.Type.ONCE), true);
            leo.SetSpriteOffSet(Animation.State.JUMP_TOWARD_ATTACK1, 30, -60);
            leo.SetFrameDelay(Animation.State.JUMP_TOWARD_ATTACK1, 4);
            leo.SetFrameDelay(Animation.State.JUMP_TOWARD_ATTACK1, 1, 4);
            leo.SetFrameDelay(Animation.State.JUMP_TOWARD_ATTACK1, 2, 4);

            leo.SetTossFrame(Animation.State.JUMP_ATTACK1, 1);
            leo.SetTossFrame(Animation.State.JUMP_TOWARD_ATTACK1, 1);

            leo.AddSprite(Animation.State.JUMP_RECOVER1, new Sprite("Sprites/Actors/Leo/JumpRecover1", Animation.Type.REPEAT, 3));
            leo.SetSpriteOffSet(Animation.State.JUMP_RECOVER1, 20, -80);
            leo.SetFrameDelay(Animation.State.JUMP_RECOVER1, 5);
            leo.SetFrameDelay(Animation.State.JUMP_RECOVER1, 1, 6);
            leo.SetFrameDelay(Animation.State.JUMP_RECOVER1, 2, 6);

            leo.AddAnimationLink(new Animation.Link(Animation.State.JUMP_ATTACK1, Animation.State.JUMP_RECOVER1, 8));
            leo.AddAnimationLink(new Animation.Link(Animation.State.JUMP_TOWARD_ATTACK1, Animation.State.JUMP_RECOVER1, 9));

            leo.SetDefaultAttackChain(new ComboAttack.Chain(new List<ComboAttack.Move>{
                new ComboAttack.Move(Animation.State.ATTACK1, 222000, 7),
                new ComboAttack.Move(Animation.State.ATTACK1, 222000, 7),
                new ComboAttack.Move(Animation.State.ATTACK1, 222000, 7)/*,
                new ComboAttack.Move(Animation.State.ATTACK4, 222000, 4),
                new ComboAttack.Move(Animation.State.ATTACK4, 222000, 4),
                new ComboAttack.Move(Animation.State.ATTACK4, 222000, 4),
                new ComboAttack.Move(Animation.State.ATTACK2, 222000, 8),
                new ComboAttack.Move(Animation.State.ATTACK3, 222000, 7),
                new ComboAttack.Move(Animation.State.ATTACK3, 222000, 7),
                new ComboAttack.Move(Animation.State.ATTACK3, 222000, 7),
                new ComboAttack.Move(Animation.State.ATTACK5, 222000, 7),
                new ComboAttack.Move(Animation.State.ATTACK6, 222000, 8)*/
            }));

            /*leo.SetFrameDelay(Animation.State.ATTACK1, 1);
            leo.SetFrameDelay(Animation.State.ATTACK2, 1);
            leo.SetFrameDelay(Animation.State.ATTACK3, 1);
            leo.SetFrameDelay(Animation.State.ATTACK4, 1);
            leo.SetFrameDelay(Animation.State.ATTACK5, 1);
            leo.SetFrameDelay(Animation.State.ATTACK6, 1);*/

            leo.AddBoundsBox(new CLNS.BoundsBox(125, 283, -30, 80, 40));
            leo.SetScale(1.6f, 2.2f);
            leo.SetPostion(400, 0, 200);


            drum = new Entity(Entity.EntityType.OBSTACLE, "DRUM1");
            drum.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum"));
            drum.SetAnimationState(Animation.State.STANCE);
            //drum.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80));
            drum.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20));
            drum.SetScale(2.2f, 2.6f);
            drum.SetPostion(700, 0, 200);
            drum.SetSpriteOffSet(Animation.State.STANCE, 32, 90);
            drum.SetDepthOffset(-5);
            drum.SetDepth(20);
            drum.SetHeight(170);
            drum.SetWidth(125);

            drum2 = new Entity(Entity.EntityType.OBSTACLE, "DRUM2");
            drum2.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum"));
            drum2.SetAnimationState(Animation.State.STANCE);
            drum2.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80));
            drum2.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20));
            drum2.SetScale(2.2f, 2.6f);

            drum2.SetPostion(500, 0, 200);
            drum2.SetSpriteOffSet(Animation.State.STANCE, 32, 90);
            drum2.SetDepthOffset(-5);
            drum2.SetDepth(20);
            drum2.SetHeight(170);
            drum2.SetWidth(125);

            drum3 = new Entity(Entity.EntityType.OBSTACLE, "DRUM3");
            drum3.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum"));
            drum3.SetAnimationState(Animation.State.STANCE);
            drum3.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80));
            drum3.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20));
            drum3.SetScale(2.2f, 2.6f);
            drum3.SetPostion(290, -180, 200);
            drum3.SetGroundBase(-180);
            drum3.SetSpriteOffSet(Animation.State.STANCE, 32, 90);
            drum3.SetDepthOffset(-5);
            drum3.SetDepth(20);
            drum3.SetHeight(170);
            drum3.SetWidth(125);

            drum4 = new Entity(Entity.EntityType.OBSTACLE, "DRUM4");
            drum4.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum"));
            drum4.SetAnimationState(Animation.State.STANCE);

            drum4.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80));
            drum4.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20));

            drum4.SetScale(2.2f, 2.6f);
            drum4.SetPostion(1200, -320, 200);
            drum4.SetGroundBase(-320);
            drum4.SetSpriteOffSet(Animation.State.STANCE, 32, 90);
            drum4.SetDepthOffset(-5);
            drum4.SetDepth(20);
            drum4.SetHeight(170);
            drum4.SetWidth(125);

            drum4.SetDimension(125, 170);
            drum3.SetDimension(125, 170);
            drum2.SetDimension(125, 170);
            drum.SetDimension(125, 170);

            /*hitSpark1 = new Entity(Entity.EntityType.OTHER, "SPARK1");
            hitSpark1.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Actors/Leo/Spark1", Animation.Type.REPEAT));
            hitSpark1.SetAnimationState(Animation.State.STANCE);
            hitSpark1.SetFrameDelay(Animation.State.STANCE, 40);
            hitSpark1.SetScale(1.2f, 1.2f);
            hitSpark1.SetPostion(600, 0, 400);
            hitSpark1.SetFade(225);*/

            
            leo.SetScale(1.8f, 2.6f);
            leo.SetHeight(180);

            level1 = new Stage1();
            bar = new LifeBar(0, 0);

            renderManager = new RenderManager();
            renderManager.AddEntity(leo);
            renderManager.AddEntity(taskMaster);
            /*renderManager.AddEntity(drum);
            renderManager.AddEntity(drum2);
            renderManager.AddEntity(drum3);
            renderManager.AddEntity(drum4);
            renderManager.AddLevel(level1);
            *///renderManager.AddEntity(hitSpark1);

            collisionManager = new CollisionManager(renderManager);
            collisionManager.AddEntity(leo);
            //collisionManager.AddEntity(leo2);
            /*collisionManager.AddEntity(drum);
            collisionManager.AddEntity(drum2);
            collisionManager.AddEntity(drum3);
            collisionManager.AddEntity(drum4);
            */

            command = new InputHelper.CommandMove("TEST", Animation.State.ATTACK6, new List<InputHelper.KeyState>
            {
                new InputHelper.KeyState(InputHelper.KeyPress.A | InputHelper.KeyPress.X, InputHelper.ButtonState.Pressed),
                new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Held, (float)9, 30),
                new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Released, 30),
                new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Released, 30),
                new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Pressed),
                new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Released)
            });

            leo.AddCommandMove(command);
            leo.SetAnimationState(Animation.State.STANCE);
            leo.SetBaseOffset(-60, -30f);
            //control = new InputControl(leo, PlayerIndex.One);

            inputManager = new InputManager();
            inputManager.AddControl(leo, PlayerIndex.One);

            // TODO: use this.Content to load your game content here
        }
コード例 #17
0
ファイル: Player.cs プロジェクト: olji/Zombierush
        public virtual void groundCollisionFunc(Player Character, List<Rectangle> hitBox, GraphicsDeviceManager graphics)
        {
            foreach (Rectangle platform in hitBox)
            {
                //Sets the two first to be walls and the third to ground since that is what they are (Check the LevelCreator method in the Level class for why)
                Rectangle rightWall = hitBox[0];
                Rectangle leftWall = hitBox[1];
                Rectangle groundWall = hitBox[2];

                //Sets the momentum to zero when hitting a wall
                if (collisionBox.Intersects(rightWall))
                {
                    if (momentum.X > 0)
                        momentum.X = 0;
                    else if (momentum.X < 0)
                    { }
                }

                else if (collisionBox.Intersects(leftWall))
                {
                    if (momentum.X < 0)
                        momentum.X = 0;
                    else if (momentum.X > 0)
                    { }
                }

                //Makes sure that the character can't fall through the floor while colliding with the wall, also position the character just beside the wall and disables its ability to run towards it again
                if (collisionBox.Intersects(rightWall) && feetBox.Intersects(groundWall))
                {
                    fCheck = false;
                    jCheck = false;
                    cJump = false;
                    rightEnabled = false;
                    momentum.Y = 0;
                    Position.Y = groundWall.Y;
                    momentum.X = 0;
                    Position.X = rightWall.X - 6;
                }
                else if (collisionBox.Intersects(leftWall) && feetBox.Intersects(groundWall))
                {
                    fCheck = false;
                    jCheck = false;
                    cJump = false;
                    leftEnabled = false;
                    momentum.Y = 0;
                    Position.Y = groundWall.Y;
                    momentum.X = 0;
                    Position.X = leftWall.X + leftWall.Width + 6;
                }
                else if (collisionBox.Intersects(leftWall) && inAir)
                {
                    cJump = false;
                    leftEnabled = false;
                    momentum.X = 0;
                    Position.X = leftWall.X + leftWall.Width + 6;
                    
                    if (feetBox.Intersects(platform) && platform != leftWall)
                    {
                    airCheck = false;
                    inAir = false;
                    fCheck = false;
                    jCheck = false;
                    cJump = false;
                    momentum.Y = 0;
                    Position.Y = platform.Y + 1;
                    }
                }
                else if (collisionBox.Intersects(rightWall) && inAir)
                {
                    cJump = false;
                    rightEnabled = false;
                    momentum.X = 0;
                    Position.X = rightWall.X - 6;
                    
                    if (feetBox.Intersects(platform) && platform != rightWall)
                    {
                        airCheck = false;
                        inAir = false;
                        fCheck = false;
                        jCheck = false;
                        cJump = false;
                        momentum.Y = 0;
                        Position.Y = platform.Y + 1;
                    }
                }

                //Sets all variables to count him as on the ground
                else if (feetBox.Intersects(platform) && fallCheck)
                {
                    airCheck = false;
                    inAir = false;
                    fCheck = false;
                    jCheck = false;
                    cJump = false;
                    momentum.Y = 0;
                    Position.Y = platform.Y + 1;
                }
            }
            //Adds some further fixes for errors that occurs when using a list for hit-detection
            if (!airCheck)
            {
                airCheck = true;
                inAir = false;
            }
            else if (airCheck)
            {
                inAir = true;
            }
        }
コード例 #18
0
 public DoubleBlaster(ContentManager content, Player player)
     : base(content, player)
 {
 }
コード例 #19
0
ファイル: Weapon.cs プロジェクト: payam-g/1302C_Game_2
 //        public virtual void Spawn()
 //        {
 //        Random rand1 = new Random();
 //        Vector3 spawn = new Vector3 (rand1.Next(60, 901), rand1.Next (44,500), 0);
 //            
 //        }
 public virtual void Update(Player player, long elapsed, GamePadData gamepaddata)
 {
     s.Position = player.s.Position;
     s.Rotation = player.s.Rotation;
     Fire (gamepaddata, elapsed);
 }