// Update is called once per frame
    void Update()
    {
        //if the nitro_cylinder is active we need to increase our movement speed if the effect is still active (i.e. its time has not expired)
        if (nitro_cylinder_active && (DateTime.Now - nitro_cylinder_start).TotalSeconds < nitro_cylinder_count * nitro_cylinder_duration)
        {
            move_speed = init_move_speed * nitro_cylinder_speed_multiplier;
        }

        //if the nitro cylinder is active but exxpired we need to disable it and reset the nitro cylinder count and our move speed
        else if (nitro_cylinder_active)
        {
            move_speed            = init_move_speed;
            nitro_cylinder_active = false;
            nitro_cylinder_count  = 0;
        }

        //input handler
        check_inputs();

        //next we need to check if we are close to any gold
        //place the gold objects in an array for easy processing (tied to the boat)
        Gold[] gold_objects = boat.gold_objects.ToArray <Gold>();
        for (int i = 0; i < boat.gold_objects.Count; i++)
        {
            //if we are close to any gold
            if ((gold_objects[i].GoldObject.transform.position - sub_transform.position).magnitude < 0.5)
            {
                boat.removeGoldBar(gold_objects[i]);     //pick up the gold while removing it from the scene
                gold_bar_count += gold_objects[i].Value; //increase our gold count (in the sub)
                //set the move speed as a function of the gold_bar_count higher it is slower we go
                if (move_speed > 0.1)
                {
                    move_speed -= 0.1f * gold_objects[i].Value;
                }
            }
        }

        //now we should check if we are close to the boat
        //if we are we should drop the gold into it
        if ((sub_transform.position - boat.boat_transform.position).magnitude < 1)
        {
            boat.increase_total_gold(gold_bar_count); //increase our score by the amount of gold we are carrying
            //we also need to reset the speed of the submarine
            move_speed     = init_move_speed;         //reset our speed
            gold_bar_count = 0;                       //and set the gold we are carrying to 0
        }

        //finally we need to check if the boat is close to one of the fish
        //if it is then the player should lose a life

        //first let's check if the character should keep his immunity (if he has been immune for less than 2 seconds he should stay immune)
        if ((DateTime.Now - immune_start).TotalSeconds >= 2)
        {
            immune = false;                                           //if we are no longer immune set the flag to false
            this.GetComponent <SpriteRenderer>().color = Color.white; //remove the red coloring on the sub
        }

        else if (immune)
        {
            //if we are immune make the sprite red
            this.GetComponent <SpriteRenderer>().color = Color.red;
        }

        //if we have a nitro_cylinder available we should be green
        if (nitro_cylinder_available)
        {
            this.GetComponent <SpriteRenderer>().color = Color.green;
        }
    }