Ejemplo n.º 1
0
        protected override bool CheckActvationEvent(GameTime gameTime, Rectangle playerBoundingBox, int timeLeft, Quadtree quadtree, SGame stateGame)
        {
            camera = stateGame.Camera;
            playerPos = new Vector2(playerBoundingBox.Center.X, playerBoundingBox.Center.Y);
            bool activation = Enabled;
            List<Tile> killtiles = quadtree.GetCollision(playerBoundingBox);
            foreach (Tile tile in killtiles)
            {
                if (tile.TileType == TileType.Spike)
                {
                    Rectangle rect = tile.get_rect;
                    rect.Y += 12;
                    rect.Height -= 12;
                    if (playerBoundingBox.Intersects(rect))
                    {
                        activation = true;

                        if (!traceEffect.Enabled)
                        {
                            ActivateEffect();
                        }
                        break;
                    }
                }
            }
            return activation;
        }
Ejemplo n.º 2
0
        public List<CollisionType> Update(GameTime gametime,Vector2 new_aim,
            Quadtree quadtree,List<Input.InputKeys> inputkeys,List<Input.InputKeys> oldinputkeys,
            Input.RunDirection rundirection,float run_factor,Vector2 applyingForce)
        {
            List<CollisionType> cur_collission = new List<CollisionType>();
            List<CollisionType> return_collission = new List<CollisionType>() ;
            prev_pos = pos;
            new_aim.Y = pos.Y;
            speed = new_aim - pos;
            speed += apply_physics(gametime);
            breath_animation(gametime);
            update_hand_animation(gametime);
            speed += apply_jump(gametime, inputkeys,oldinputkeys,run_factor);
            speed += applyingForce;
            run_factor = MathHelper.Clamp(run_factor, 1.0f, 1.5f);

            Vector2 temp_pos = pos;
            update_positions(gametime, temp_pos);
            //collission = Collission_Type.NoCollission;
            if (quadtree.GetCollision(bounding_box) != null)
            {
                List<Tile> collisionTiles = quadtree.GetCollision(bounding_box);
                foreach (Tile tile in collisionTiles)
                {
                    cur_collission = collision(tile, ref cur_speed, ref temp_pos, rundirection);

                    foreach(CollisionType coltype in cur_collission)
                    {
                        return_collission.Add(coltype);
                    }
                    update_positions(gametime, temp_pos);
                }
            }
            collission = return_collission;
            if (collission.Contains(CollisionType.StandsOnIt) || is_jumping)
                physics.Y = 0;
            cur_speed.X = MathHelper.Clamp(speed.X, -MAX_SPEED, MAX_SPEED);
            cur_speed.Y = MathHelper.Clamp(speed.Y, - MAX_SPEED, MAX_SPEED);
            pos.X += speed.X * (float)gametime.ElapsedGameTime.TotalSeconds * 5;
            pos.Y += speed.Y * (float)gametime.ElapsedGameTime.TotalSeconds * 5;

            if (collission.Count != 0)
            {
                walk_animation(gametime);
                update_hand_walk_animation(gametime);
            }
            difference = pos - prev_pos;
            return return_collission;
        }