Exemplo n.º 1
0
    private void gather()
    {
        if (inside_divine_sponge_ressource)
        {
            if (Input.GetButtonDown("ButtonA_2"))
            {
                isRecolting_divine_sponge_ressource = true;
            }

            else if (Input.GetButton("ButtonA_2"))
            {
                isRecolting_divine_sponge_ressource = true;
                if (isRecolting_divine_sponge_ressource)
                {
                    compteur += Time.fixedDeltaTime;
                    //Debug.Log("compteur " + compteur);

                    if (compteur < timer_recolte)
                    {
                        //Debug.Log("Récolte Début !");
                    }

                    else if (compteur >= timer_recolte)
                    {
                        //Debug.Log("Récolte Fin !");
                        Ressource_manager temp_ressource_manager  = ressource_recolte.GetComponent <Ressource_manager>();
                        Animator          temp_ressource_animator = ressource_recolte.GetComponent <Animator>();
                        int temp_ressource = temp_ressource_manager.get_divine_sponge();
                        //Debug.Log("there is " + temp_ressource + " divine sponge inside");

                        if (tools_recolte >= temp_ressource)
                        {
                            temp_ressource_manager.remove_divine_sponge(temp_ressource);
                            base_ressource.add_divine_sponge(temp_ressource);
                            temp_ressource_animator.SetTrigger("Gather");
                            base_Manager.update_ui();
                        }

                        else
                        {
                            temp_ressource_manager.remove_divine_sponge(tools_recolte);
                            base_ressource.add_divine_sponge(tools_recolte);
                            temp_ressource_animator.SetTrigger("Gather_not_empty");
                            base_Manager.update_ui();
                        }

                        temp_ressource_manager.get_divine_sponge();
                        isRecolting_divine_sponge_ressource = false;
                    }
                }
            }

            else
            {
                compteur = 0;
                isRecolting_divine_sponge_ressource = false;
            }
        }
    }
Exemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("enter into a trigger");
        if (collision.gameObject.CompareTag("Human_base"))
        {
            Debug.Log("enter into a human base trigger");
            base_ressource = collision.gameObject.GetComponent <Ressource_manager>();
            base_Manager   = collision.gameObject.GetComponent <Base_manager>();

            int temp_divine_sponge = ship_ressource.get_divine_sponge();
            ship_ressource.remove_divine_sponge(temp_divine_sponge);
            base_ressource.add_divine_sponge(temp_divine_sponge);

            base_Manager.display_option();
            base_Manager.update_ui();

            inside_human_base = true;
        }
        else if (collision.gameObject.CompareTag("Divine_sponge_ressource"))
        {
            // Debug.Log("hamecon contre éponge !");
            ressource_recolte = collision.gameObject;
            inside_divine_sponge_ressource = true;
        }
    }
Exemplo n.º 3
0
 public void update_ui()
 {
     Weapon_value.text        = Base_ressource.get_weapon().ToString();
     Divine_sponge_value.text = Base_ressource.get_divine_sponge().ToString();
 }