Пример #1
0
        private void addNewBlade(Vector3 startPosition, float size, float distance, float speed, char direction)
        {
            BasicModel ToAdd = new BasicModel(Game.Content.Load <Model>(@"models\box"), startPosition, size);

            ToAdd.animation = new BladeAnimation(startPosition, distance, speed, direction);
            blades.Add(ToAdd);
        }
Пример #2
0
        private void addNewPlatform(Vector3 startPosition, float size, float distance, float speed, char direction, bool trap)
        {
            BasicModel ToAdd;

            ToAdd                  = new BasicModel(Game.Content.Load <Model>(@"models\box"), startPosition, size);
            ToAdd.animation        = new PlatformAnimation(startPosition, distance, speed, direction, ToAdd);
            ToAdd.animation.isTrap = trap;
            platforms.Add(ToAdd);
        }
Пример #3
0
 protected void restoreExplodedPlatform(GameTime gameTime)
 {
     if (explodedPlatform != null)
     {
         explodedPlatform.animation.currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
         if (explodedPlatform.animation.currentTime >= 5)
         {
             explodedPlatform.animation.currentTime = 0;
             platforms.Add(explodedPlatform);
             explodedPlatform = null;
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (((Game1)Game).currentGameState == FilodendronGame.Game1.GameState.Playing || ((Game1)Game).currentGameState == FilodendronGame.Game1.GameState.CameraRoll)
            {
                avatar.Update(gameTime);
                avatar.bullet.Update(gameTime);
                //avatar.bullet.rb.UpdateRigidBody(gameTime);
                avatar.slave.Update(gameTime);
                sektorMaszyn.Update(gameTime);

                foreach (CollectableItem item in collectableItems)
                {
                    item.Update(gameTime);
                }

                foreach (BasicModel item in platforms)
                {
                    item.Update(gameTime);
                }

                foreach (BasicModel item in blades)
                {
                    item.Update(gameTime);
                }

                ocean.Update(gameTime);
                //if the side boundry of screen reached, set the mouse on the other side
                if (Mouse.GetState().X >= Game.Window.ClientBounds.Width - 2)
                {
                    Mouse.SetPosition(1, Mouse.GetState().Y);// jak wstawia³em 0 to mi ekran przeskakiwa³ lol
                    avatar.prevMouseState = Mouse.GetState();
                }
                if (Mouse.GetState().X <= 0)
                {
                    Mouse.SetPosition(Game.Window.ClientBounds.Width, Mouse.GetState().Y);
                    avatar.prevMouseState = Mouse.GetState();
                }

                // Collision checkout
                foreach (CollectableItem item in collectableItems)
                {
                    if (avatar.rigidBody.CollidesWith(item.model, item.World))
                    {
                        // Collision! add an explosion.
                        addNewExplosion(item.Position);
                        //change avatarRespawn
                        avatar.avatarResp = item.position;
                        // delete the box
                        item.isCollected = true;
                        ((Game1)Game).numberOfCoins++;
                    }
                }
                collectableItems.RemoveAll(item => item.isCollected);

                for (int i = 0; i < platforms.Count; i++)
                {
                    if (avatar.rigidBody.CollidesWith(platforms[i].model, platforms[i].World))
                    {
                        if (platforms[i].animation.isTrap)
                        {
                            platforms[i].animation.currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
                            if (platforms[i].animation.currentTime >= 2)
                            {
                                platforms[i].animation.currentTime = 0;
                                explodedPlatform = platforms[i];
                                addNewExplosion(platforms[i].World);
                                platforms[i].boundingBoxes = null;
                                platforms.RemoveAt(i);
                                --i;
                            }
                        }
                        else
                        {
                            avatar.UpdatePosition(platforms[i].animation.avatarPositionChange);
                        }
                    }
                }
                restoreExplodedPlatform(gameTime);

                foreach (BasicModel blade in blades)
                {
                    if (avatar.rigidBody.CollidesWith(blade.model, blade.World))
                    {
                        avatar.Die(Game);
                    }
                }

                if (avatar.avatarFell == true)
                {
                    avatar.avatarFell = false;
                    avatar.Die(Game);
                }

                // woda zabija, chcesz zeby nie zabijala to zakomentuj ifa ponizej
                if (avatar.avatarPosition.X > -6253 && avatar.avatarPosition.X < 5466 &&
                    avatar.avatarPosition.Y > -5 && avatar.avatarPosition.Y < 50 &&
                    avatar.avatarPosition.Z > -254 && avatar.avatarPosition.Z < 2468)
                {
                    avatar.Die(Game);
                }

                //dotknij drzwi => wygrana
                if (avatar.avatarPosition.X > -6138 && avatar.avatarPosition.X < -6135 &&
                    avatar.avatarPosition.Y > 15 && avatar.avatarPosition.Y < 50 &&
                    avatar.avatarPosition.Z > -3409 && avatar.avatarPosition.Z < -2171)
                {
                    ((Game1)Game).win = true;
                }
                // Update explosions
                UpdateExplosions(gameTime);

                base.Update(gameTime);
            }
        }