Exemplo n.º 1
0
    private void Start()
    {
        ressource_spot_animator_1 = ressource_spot_1.GetComponent <Animator>();
        ressource_spot_manager_1  = ressource_spot_1.GetComponent <Ressource_manager>();
        ressource_spot_animator_2 = ressource_spot_2.GetComponent <Animator>();
        ressource_spot_manager_2  = ressource_spot_2.GetComponent <Ressource_manager>();
        ressource_spot_animator_3 = ressource_spot_3.GetComponent <Animator>();
        ressource_spot_manager_3  = ressource_spot_3.GetComponent <Ressource_manager>();
        ressource_spot_animator_4 = ressource_spot_4.GetComponent <Animator>();
        ressource_spot_manager_4  = ressource_spot_4.GetComponent <Ressource_manager>();
        ressource_spot_animator_5 = ressource_spot_5.GetComponent <Animator>();
        ressource_spot_manager_5  = ressource_spot_5.GetComponent <Ressource_manager>();

        coroutine_spot_1 = Generate(ressource_spot_manager_1, ressource_spot_animator_1, timer_spot_base, timer_spot_base, min_divine_sponge_generate, max_divine_sponge_generate);
        coroutine_spot_2 = Generate(ressource_spot_manager_2, ressource_spot_animator_2, timer_spot_2_min, timer_spot_2_max, min_divine_sponge_generate, max_divine_sponge_generate);
        coroutine_spot_3 = Generate(ressource_spot_manager_3, ressource_spot_animator_3, timer_spot_3_min, timer_spot_3_max, min_divine_sponge_generate, max_divine_sponge_generate);
        coroutine_spot_4 = Generate(ressource_spot_manager_4, ressource_spot_animator_4, timer_spot_4_min, timer_spot_4_max, min_divine_sponge_generate, max_divine_sponge_generate);
        coroutine_spot_5 = Generate(ressource_spot_manager_5, ressource_spot_animator_5, timer_spot_base, timer_spot_base, min_divine_sponge_generate, max_divine_sponge_generate);

        StartCoroutine(coroutine_spot_1);
        StartCoroutine(coroutine_spot_2);
        StartCoroutine(coroutine_spot_3);
        StartCoroutine(coroutine_spot_4);
        StartCoroutine(coroutine_spot_5);
    }
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
    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.º 4
0
    private IEnumerator Generate(Ressource_manager ressource_Manager, Animator animator, int timer_spot_min, int timer_spot_max, int min_divine_sponge_generate, int max_divine_sponge_generate)
    {
        while (true)
        {
            if (animator.GetCurrentAnimatorStateInfo(0).IsName("Idle_empty"))
            {
                float temp_timer = Random.Range((float)timer_spot_min, (float)timer_spot_max);

                yield return(new WaitForSeconds(temp_timer));

                //Debug.Log("Generate a new ressource");
                float temp_divine_sponge = Random.Range((float)min_divine_sponge_generate, (float)max_divine_sponge_generate);
                ressource_Manager.add_divine_sponge((int)temp_divine_sponge);
                animator.SetTrigger("Generate");
            }
            yield return(new WaitForSeconds(1));
        }
    }
Exemplo n.º 5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log("enter into a trigger");
        if (collision.gameObject.CompareTag("Jellyman_base"))
        {
            //Debug.Log("enter into a jelly base trigger");
            base_ressource = collision.gameObject.GetComponent <Ressource_manager>();
            base_Manager   = collision.gameObject.GetComponent <Base_manager>();

            int temp_divine_sponge = this.fish_ressource.get_divine_sponge();
            fish_ressource.remove_divine_sponge(temp_divine_sponge);
            base_ressource.add_divine_sponge(temp_divine_sponge);

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

            inside_jellyman_base = true;
        }
        else if (collision.gameObject.CompareTag("Divine_sponge_ressource"))
        {
            ressource_recolte = collision.gameObject;
            inside_divine_sponge_ressource = true;
        }
    }