void Update () {
		if (settings.game_paused) {
			return;
		}

		if (settings.already_interacting || bool_cutscene || settings.inventory_opened) {
			settings.objective_opened = open_close_objectives (false);
		}

		float_mouse_wheel = Input.GetAxisRaw ("Mouse ScrollWheel");

		if (!settings.inventory_opened) {

			settings.cutscene_skip = false;


			if (!bool_cutscene) {
				float_movexaxis = 0f;
				float_moveyaxis = 0f;
				bool_player_moves = false;
			}

			if (!settings.hotbar_hidden) {
				hotbar_canvas.enabled = !settings.objective_opened;
			} else {
				hotbar_canvas.enabled = false;
			}


			bool_action_pressed = false;
			bool_secaction_pressed = false;


			if (!bool_cutscene && is_pressed (settings.cont_crouch_hold, float_mouse_wheel, false)) {
				bool_crouching = true;
				bool_was_crouching = true;
			} else {
				if (bool_was_crouching) {
					bool_crouching = false;
					bool_was_crouching = false;
				}
			}

			if (Input.anyKey || float_mouse_wheel != 0f) {


				if (is_pressed (settings.cont_action, float_mouse_wheel, true)) {
					if (bool_cutscene || bool_roam_cutscene) {
						settings.cutscene_skip = true;
					} else {
						bool_action_pressed = true;
					}
				}

				if (!bool_cutscene) {



					if (is_pressed (settings.cont_moveup, float_mouse_wheel, false)) {
						float_moveyaxis = float_moveyaxis + 1f;
					}
					if (is_pressed (settings.cont_movedown, float_mouse_wheel, false)) {
						float_moveyaxis = float_moveyaxis - 1f;
					}
					if (is_pressed (settings.cont_moveleft, float_mouse_wheel, false)) {
						float_movexaxis = float_movexaxis - 1f;
					}
					if (is_pressed (settings.cont_moveright, float_mouse_wheel, false)) {
						float_movexaxis = float_movexaxis + 1f;
					}
	
				
					if (is_pressed (settings.cont_crouch_toggle, float_mouse_wheel, true)) {
						bool_crouching = !bool_crouching;
					}

					if (is_pressed (settings.cont_hotbar1, float_mouse_wheel, true)) {
						hotbar.set_hotbar (0);
					}
					if (is_pressed (settings.cont_hotbar2, float_mouse_wheel, true)) {
						hotbar.set_hotbar (1);
					}
					if (is_pressed (settings.cont_hotbar3, float_mouse_wheel, true)) {
						hotbar.set_hotbar (2);
					}



					if (!bool_roam_cutscene) {
					
						if (is_pressed (settings.cont_objective, float_mouse_wheel, true)) {
							if (!settings.already_interacting) {
								settings.objective_opened = open_close_objectives (!settings.objective_opened);
							}
						}

						if (is_pressed (settings.cont_secaction, float_mouse_wheel, true)) {
							bool_secaction_pressed = true;
						}

						if (is_pressed (settings.cont_inventory, float_mouse_wheel, true)) {
							inventory_setter.interactive_open = false;
							inventory_setter.open_close_inventory ();
						}
					}
				}
				
			}
				
			if (float_movexaxis != 0f || float_moveyaxis != 0f) {
				bool_player_moves = true;
				float_standX = float_movexaxis;
				float_standY = float_moveyaxis;
			}
				
			player_action_receiver.offset = new Vector2 (float_standX * 0.3f, float_standY * 0.3f);



			if (float_movexaxis != 0f && float_moveyaxis != 0f) {
				float_movexaxis = float_movexaxis * 0.7f;
				float_moveyaxis = float_moveyaxis * 0.7f;
			}

			rigidbody_player.velocity = new Vector2 (float_movexaxis * float_move_speed, float_moveyaxis * float_move_speed);
			animator_player.SetFloat ("MoveX", float_movexaxis);
			animator_player.SetFloat ("MoveY", float_moveyaxis);
			animator_player.SetFloat ("LastX", float_standX);
			animator_player.SetFloat ("LastY", float_standY);
			animator_player.SetBool ("Moving", bool_player_moves);

			animator_head.SetFloat ("LastX", float_standX);
			animator_head.SetFloat ("LastY", float_standY);
			animator_head.SetBool ("blink",false);

			animator_handR.SetFloat ("MoveX", float_movexaxis);
			animator_handR.SetFloat ("MoveY", float_moveyaxis);
			animator_handR.SetFloat ("LastX", float_standX);
			animator_handR.SetFloat ("LastY", float_standY);
			animator_handR.SetBool ("Moving", bool_player_moves);

			animator_handL.SetFloat ("MoveX", float_movexaxis);
			animator_handL.SetFloat ("MoveY", float_moveyaxis);
			animator_handL.SetFloat ("LastX", float_standX);
			animator_handL.SetFloat ("LastY", float_standY);
			animator_handL.SetBool ("Moving", bool_player_moves);

			animator_melee.SetFloat ("MoveX", float_movexaxis);
			animator_melee.SetFloat ("MoveY", float_moveyaxis);
			animator_melee.SetFloat ("LastX", float_standX);
			animator_melee.SetFloat ("LastY", float_standY);
			animator_melee.SetBool ("Moving", bool_player_moves);

			animator_ranged.SetFloat ("MoveX", float_movexaxis);
			animator_ranged.SetFloat ("MoveY", float_moveyaxis);
			animator_ranged.SetFloat ("LastX", float_standX);
			animator_ranged.SetFloat ("LastY", float_standY);
			animator_ranged.SetBool ("Moving", bool_player_moves);

			if (PreviousX != float_standX || PreviousY != float_standX) {
				v3_handR = new Vector3 ( animator_handR.gameObject.transform.localPosition.x , animator_handR.gameObject.transform.localPosition.y,  0f );
				v3_handL = new Vector3 ( animator_handL.gameObject.transform.localPosition.x, animator_handL.gameObject.transform.localPosition.y, 0f );
				v3_weapon_melee = new Vector3 ( animator_melee.gameObject.transform.localPosition.x, animator_melee.gameObject.transform.localPosition.y, -0.01f );
				v3_weapon_ranged = new Vector3 ( animator_ranged.gameObject.transform.localPosition.x, animator_ranged.gameObject.transform.localPosition.y, -0.01f );
			
				if (float_standY == 0f) {
				
					if (float_standX > 0f) {
						if (animator_melee.GetBool ("Equiped") == false) {
							v3_weapon_melee = new Vector3 ( v3_weapon_melee.x, v3_weapon_melee.y, 0.01f );
						}
						v3_handR = new Vector3 ( v3_handR.x, v3_handR.y, -0.02f );
						v3_handL = new Vector3 ( v3_handL.x, v3_handL.y, 0.02f );
					}

					if (float_standX < 0f) {
						if (animator_ranged.GetBool ("Equiped") == false) {
							v3_weapon_ranged = new Vector3 ( 0f, 0f, 0.01f );
						}
						v3_handR = new Vector3 ( v3_handR.x, v3_handR.y, 0.02f );
						v3_handL = new Vector3 ( v3_handL.x, v3_handL.y, -0.02f );
					}
				}

				animator_handR.gameObject.transform.localPosition = v3_handR;
				animator_handL.gameObject.transform.localPosition = v3_handL;
				animator_melee.gameObject.transform.localPosition = v3_weapon_melee;
				animator_ranged.gameObject.transform.localPosition = v3_weapon_ranged;
			}
		
		} else {
			//Inventory is opened
			if (Input.anyKey || float_mouse_wheel != 0f) {
				//Key pressed. Only INVENTORY, UP/DOWN/LEFT/RIGHT and ACTION/SECACTION buttons will be detected!

				if (is_pressed (settings.cont_inventory, float_mouse_wheel, true)) {
					inventory_setter.interactive_open = false;
					inventory_setter.open_close_inventory ();
					return;
				}
				if (is_pressed (settings.cont_moveup, float_mouse_wheel, true)) {
					inventory_setter.move_up_in_inventory ();
					//return;
				}
				if (is_pressed (settings.cont_movedown, float_mouse_wheel, true)) {
					inventory_setter.move_down_in_inventory ();
					//return;
				}
				if (is_pressed (settings.cont_moveleft, float_mouse_wheel, true)) {
					inventory_setter.move_left_in_inventory ();
					//return;
				}
				if (is_pressed (settings.cont_moveright, float_mouse_wheel, true)) {
					inventory_setter.move_right_in_inventory ();
					//return;
				}
				if (is_pressed (settings.cont_secaction, float_mouse_wheel, true)) {
					inventory_setter.select_secondary_action ();
					return;
				}
				if (is_pressed (settings.cont_action, float_mouse_wheel, true)) {
					inventory_setter.select_action ();
					return;
				}


			}



		}


		if (bool_crouching) {
			gameObject.transform.Find ("player_head").gameObject.transform.localPosition = new Vector3 (0f, -0.16f, 0.01f);
			animator_handR.gameObject.transform.localPosition = new Vector3 (0f, -0.16f, animator_handR.gameObject.transform.localPosition.z);
			animator_handL.gameObject.transform.localPosition = new Vector3 (0f, -0.16f, animator_handL.gameObject.transform.localPosition.z);

			animator_player.SetBool ("Crouching",true);

			if (!bool_cutscene) {
				float_move_speed = float_basic_crouching_speed;
			}
		} else {
			gameObject.transform.Find ("player_head").gameObject.transform.localPosition = new Vector3 (0f, 0f, 0.01f);
			animator_handR.gameObject.transform.localPosition = new Vector3 (0f, 0f, animator_handR.gameObject.transform.localPosition.z);
			animator_handL.gameObject.transform.localPosition = new Vector3 (0f, 0f, animator_handL.gameObject.transform.localPosition.z);
		
			animator_player.SetBool ("Crouching",false);

			if (!bool_cutscene) {
				float_move_speed = float_basic_stand_speed;
			}
		}

		blink += Time.deltaTime;
		if (blink > next_blink) {
			blink = 0f;
			next_blink= Random.Range (2f , 8f);
			animator_head.SetBool ("blink",true);
		}

		PreviousX = float_standX;
		PreviousY = float_standY;

		if (force_animation_reset) {
			force_animation_reset = false;

			animator_handL.SetBool("Moving",false);
			animator_handR.SetBool("Moving",false);
			//animator_head.SetBool("Moving",false);
			animator_melee.SetBool("Moving",false);
			animator_ranged.SetBool("Moving",false);
			animator_player.SetBool("Moving",false);
		}

	}
    IEnumerator interact()
    {
        if (settings.already_interacting)
        {
            yield break;
        }
        settings.already_interacting = true;

        playercontroller.bool_cutscene = true;

        playercontroller.bool_player_moves = false;
        playercontroller.float_movexaxis   = 0f;
        playercontroller.float_moveyaxis   = 0f;

        string say_this;
        string say_this_cze;
        float  want_time;
        float  current_time;



        say_this     = "I need a branch from this tree.";
        say_this_cze = "Potřebuji větev z tohoto stromu.";
        want_time    = 2f;

        StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

        want_time   += 0.1f;
        current_time = 0f;

        while (current_time < want_time)
        {
            current_time += Time.deltaTime;

            if (settings.GetComponent <Settings>().cutscene_skip)
            {
                break;
            }

            yield return(null);
        }
        yield return(null);


        Inventory_ui.interactive_open = true;
        if (!settings.inventory_opened)
        {
            Inventory_ui.open_close_inventory();
        }

        yield return(new WaitForSeconds(0.01f));

        int got_id = -1;

        if (Inventory_ui.interactive_open)
        {
            switch (Inventory_ui.selected_slot)
            {
            case 10:
                if (Inventory.melee_weapon != null)
                {
                    got_id = wanted_id;
                }
                break;

            case 11:
                got_id = -1;
                break;

            default:
                if (Inventory.items.Count > Inventory_ui.selected_slot)
                {
                    got_id = Inventory.items [Inventory_ui.selected_slot].ID;
                }
                break;
            }
        }
        if (got_id == wanted_id)
        {
            yield return(new WaitForSeconds(2f));

            if (Inventory.item_add(item))
            {
                say_this     = "I sucessfuly cut a branch.";
                say_this_cze = "Úspěšně jsem usekl větev.";
                want_time    = 2f;

                StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

                current_time = 0f;

                while (current_time < want_time)
                {
                    current_time += Time.deltaTime;

                    if (settings.GetComponent <Settings>().cutscene_skip)
                    {
                        break;
                    }

                    yield return(null);
                }
                yield return(null);
            }
            else
            {
                GameObject dropped_object = new GameObject(item.name);
                GameObject player         = playercontroller.gameObject;         //GameObject.Find ("player");
                dropped_object.transform.position = new Vector3(player.transform.position.x, player.transform.position.y - 0.3f, player.transform.position.z);
                dropped_object.transform.SetParent(GameObject.Find("Pickables").transform);

                SpriteRenderer dropped_object_renderer = dropped_object.AddComponent <SpriteRenderer> ();
                dropped_object_renderer.sprite           = item.icon;
                dropped_object_renderer.sortingLayerName = "Pickable";

                BoxCollider2D dropped_object_collider = dropped_object.AddComponent <BoxCollider2D> ();
                dropped_object_collider.isTrigger = true;
                dropped_object_collider.size      = new Vector2(0.5f, 0.5f);
                dropped_object_collider.offset    = new Vector2(0f, 0f);

                item_picker dropped_object_trigger = dropped_object.AddComponent <item_picker> ();
                dropped_object_trigger.item = item;

                say_this     = "I sucessfuly cut a branch, but I can't carry it now.";
                say_this_cze = "Úspěšně jsem usekl větev, ale teď ji fakt už neunesu.";
                want_time    = 3f;

                StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

                current_time = 0f;

                while (current_time < want_time)
                {
                    current_time += Time.deltaTime;

                    if (settings.GetComponent <Settings>().cutscene_skip)
                    {
                        break;
                    }

                    yield return(null);
                }
                yield return(null);
            }



            game_manager.pine01_t_interactiondone = true;
            GameObject.Find("cutscene_object").GetComponent <cutscene01> ().cutscene3_prepare();
        }
        else
        {
            yield return(new WaitForSeconds(0.5f));

            say_this     = "I need something else to cut that branch.";
            say_this_cze = "Na useknutí větve budu potřebovat něco jiného.";
            want_time    = 2.5f;

            StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

            current_time = 0f;

            while (current_time < want_time)
            {
                current_time += Time.deltaTime;

                if (settings.GetComponent <Settings>().cutscene_skip)
                {
                    break;
                }

                yield return(null);
            }
            yield return(null);
        }

        yield return(null);


        playercontroller.bool_cutscene = false;

        settings.already_interacting = false;
    }
Exemple #3
0
    IEnumerator interact()
    {
        if (settings.already_interacting)
        {
            yield break;
        }
        settings.already_interacting = true;

        playercontroller.bool_cutscene = true;

        playercontroller.bool_player_moves = false;
        playercontroller.float_movexaxis   = 0f;
        playercontroller.float_moveyaxis   = 0f;

        string say_this;
        string say_this_cze;
        float  want_time;
        float  current_time;

        if (first_interaction)
        {
            first_interaction = false;

            say_this     = "I need something to repair this fence.";
            say_this_cze = "Potřebuji něco, čím opravím ten plot.";
            want_time    = 2f;

            StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

            want_time   += 0.1f;
            current_time = 0f;

            while (current_time < want_time)
            {
                current_time += Time.deltaTime;

                if (settings.GetComponent <Settings>().cutscene_skip)
                {
                    break;
                }

                yield return(null);
            }
            yield return(null);
        }

        Inventory_ui.interactive_open = true;
        if (!settings.inventory_opened)
        {
            Inventory_ui.open_close_inventory();
        }

        yield return(new WaitForSeconds(0.01f));

        int got_id = -1;

        if (Inventory_ui.interactive_open)
        {
            switch (Inventory_ui.selected_slot)
            {
            case 10:
                if (Inventory.melee_weapon != null)
                {
                    got_id = Inventory.melee_weapon.ID;
                }
                break;

            case 11:
                if (Inventory.ranged_weapon != null)
                {
                    got_id = Inventory.ranged_weapon.ID;
                }
                break;

            default:
                if (Inventory.items.Count > Inventory_ui.selected_slot)
                {
                    got_id = Inventory.items [Inventory_ui.selected_slot].ID;
                }
                break;
            }
        }
        if (got_id == wanted_id)
        {
            Inventory.item_remove(Inventory.items [Inventory_ui.selected_slot]);

            yield return(new WaitForSeconds(2f));

            fence_animation.SetBool("repaired", true);

            say_this     = "I've repaired the fence!";
            say_this_cze = "Opravil jsem plot!";
            want_time    = 2f;

            StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

            current_time = 0f;

            while (current_time < want_time)
            {
                current_time += Time.deltaTime;

                if (settings.GetComponent <Settings>().cutscene_skip)
                {
                    break;
                }

                yield return(null);
            }
            yield return(null);


            game_manager.fence_t_repaired = true;
            GameObject.Find("cutscene_object").GetComponent <cutscene01> ().cutscene5_prepare();
        }
        else if (got_id >= 1 && got_id <= 500)
        {
            yield return(new WaitForSeconds(0.5f));

            say_this     = "Why would I want to destroy that fence? I am supposed to repair it!";
            say_this_cze = "Proč bych měl ničit ten plot? Mám ho přece opravit, a ne rozbít!";
            want_time    = 4f;

            StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

            current_time = 0f;

            while (current_time < want_time)
            {
                current_time += Time.deltaTime;

                if (settings.GetComponent <Settings>().cutscene_skip)
                {
                    break;
                }

                yield return(null);
            }
            yield return(null);
        }
        else
        {
            yield return(new WaitForSeconds(0.5f));

            say_this     = "This is not working...";
            say_this_cze = "Takhle to nefunguje...";
            want_time    = 2f;

            StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

            current_time = 0f;

            while (current_time < want_time)
            {
                current_time += Time.deltaTime;

                if (settings.GetComponent <Settings>().cutscene_skip)
                {
                    break;
                }

                yield return(null);
            }
            yield return(null);
        }

        yield return(null);


        playercontroller.bool_cutscene = false;

        settings.already_interacting = false;
    }