Esempio n. 1
0
 public void onWallhit()
 {
     wallinstance = wallsound.play();
     if (wallinstance.playing == true && collisionTimer.IsStopped())
     {
         wallinstance.stop();
     }
 }
Esempio n. 2
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     desksound                = Globals.engine.loadSound("sounds/desk.ogg");
     surface                  = GetNode <CSGBox>("surface");
     deskinstance             = desksound.play3d(Transform.origin.x, Transform.origin.y, Transform.origin.z, loopMode.simpleLoop);
     deskinstance.maxDistance = 50;
     deskinstance.minDistance = 0.1f;
 }
Esempio n. 3
0
 public void game_over()
 {
     GetNode <Timer>("MobTimer").Stop();
     GetNode <Timer>("ScoreTimer").Stop();
     GetNode <Hud>("Hud").ShowGameOver();
     gameoverinstance = gameoversound.play(0, loopMode.noLoop);
     gamemusic.stop();
 }
Esempio n. 4
0
        /// <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);
            this.sonido      = engine.loadSound("beam.mp3");
            this.instancia   = this.sonido.play3d(0, 0, 0, loopMode.bidiLoop);
            this.yoshimusic  = engine.loadMusic("yoshi.mp3");
            this.fossilMusic = engine.loadMusic("fossil.mp3");


            // TODO: use this.Content to load your game content here
        }
//  // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        if (GetNode <CollisionShape2D>("CollisionShape2D").Disabled == true)
        {
            return;
        }
        else
        {
            var velocity = new Vector2();
            if (Input.IsActionPressed("ui_right"))
            {
                velocity.x += 1;
            }

            if (Input.IsActionPressed("ui_left"))
            {
                velocity.x -= 1;
            }

            if (Input.IsActionPressed("ui_down"))
            {
                velocity.y += 1;
            }

            if (Input.IsActionPressed("ui_up"))
            {
                velocity.y -= 1;
            }

            if (velocity.Length() > 0)
            {
                velocity = velocity.Normalized() * Speed;
            }
            Position += velocity * delta;
            distance += velocity.Length();
            if (distance >= 4500)
            {
                moveinstance = movesound.play(0, loopMode.noLoop);
                distance     = 0;
            }
            Position = new Vector2(x: Mathf.Clamp(Position.x, 0, _screenSize.x), y: Mathf.Clamp(Position.y, 0, _screenSize.y));
            globals.engine.listener.x = Position.x;
            globals.engine.listener.z = Position.y;
        }
    }
Esempio n. 6
0
 public void playstep()
 {
     stepsound    = Globals.engine.loadSound("sounds/carpet/" + random.Next(1, 9) + ".ogg");
     stepinstance = stepsound.play(0, loopMode.noLoop);
 }
Esempio n. 7
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     voicesound                = globals.engine.loadSound("sounds/" + _mobTypes[_random.Next(0, _mobTypes.Length)] + ".mp3");
     voiceinstance             = voicesound.play3d(Position.x, 0, Position.y, loopMode.simpleLoop);
     voiceinstance.maxDistance = 5000;
 }
Esempio n. 8
0
 public override void _PhysicsProcess(float delta)
 {
     Direction   = new Vector3();
     FullContact = GroundCheck.IsColliding() == true;
     if (!IsOnFloor())
     {
         GravityVec   += Vector3.Down * Gravity * delta;
         HAcceleration = AirAcceleration;
     }
     else if (IsOnFloor() && FullContact)
     {
         GravityVec    = -GetFloorNormal() * Gravity;
         HAcceleration = NormalAcceleration;
     }
     else
     {
         GravityVec    = -GetFloorNormal();
         HAcceleration = NormalAcceleration;
     }
     if (Input.IsActionJustPressed("Jump") && IsOnFloor() && GroundCheck.IsColliding())
     {
         GravityVec   = Vector3.Up * Jump;
         jumpinstance = jumpsound.play(0, loopMode.noLoop);
     }
     if (Input.IsActionPressed("MoveForward"))
     {
         Direction -= Transform.basis.z;
     }
     if (Input.IsActionPressed("MoveBackward"))
     {
         Direction += Transform.basis.z;
     }
     if (Input.IsActionPressed("MoveLeft"))
     {
         Direction -= Transform.basis.x;
     }
     if (Input.IsActionPressed("MoveRight"))
     {
         Direction += Transform.basis.x;
     }
     Direction  = Direction.Normalized();
     HVelocity  = HVelocity.LinearInterpolate(Direction * speed, HAcceleration * delta);
     Movement.z = HVelocity.z + GravityVec.z;
     Movement.x = HVelocity.x + GravityVec.x;
     Movement.y = GravityVec.y;
     MoveAndSlide(Movement, Vector3.Up);
     distance += HVelocity.Length();
     if (IsOnFloor() && GroundCheck.IsColliding() && !IsOnWall())
     {
         if (isMoving == true && HVelocity.Length() == 20)
         {
             EmitSignal("Walk");
         }
         else if (distance >= 300)
         {
             EmitSignal("Walk");
             distance = 0;
             Console.WriteLine("Posicion z actual: " + Transform.origin.z);
         }
     }
     Globals.engine.listener.x    = Transform.origin.x;
     Globals.engine.listener.y    = Transform.origin.y + Head.Transform.origin.y;
     Globals.engine.listener.z    = Transform.origin.z;
     Globals.engine.listener.velX = HVelocity.x;
     Globals.engine.listener.velY = Movement.y;
     Globals.engine.listener.velZ = HVelocity.z;
     CheckListenerRotation();
     CheckIfIsColliding();
 }