Exemplo n.º 1
0
    private void harpoon()
    {
        if (Input.GetButtonDown("BumperRight_2") && compteurTir <= 0 && aiming != Vector3.zero)
        {
            //Debug.Log(Input.GetJoystickNames());
            //Debug.Log("tir un harpon");
            //Debug.Log(base_ressource.get_weapon());
            if (base_ressource.get_weapon() > 0)
            {
                compteurTir = timerTir;
                //Debug.Log("Harpon !");
                GameObject T = Instantiate(Trident, gameObject.transform, true);
                T.transform.position = transform.position;
                angle = Vector2.Angle(transform.up, aiming);

                if (aiming.x >= 0)
                {
                    angle = -angle;
                }

                T.transform.eulerAngles = new Vector3(0, 0, angle);
                T.GetComponent <Rigidbody2D>().velocity = aiming * 5f;
                Destroy(T, 5);
                T.transform.parent = null;
                base_ressource.remove_weapon(1);
                base_Manager.update_ui();
            }
        }
    }
Exemplo n.º 2
0
    private void gather()
    {
        if (inside_divine_sponge_ressource)
        {
            if (Input.GetButtonDown("ButtonA_1"))
            {
                isRecolting_divine_sponge_ressource = true;
            }

            else if (Input.GetButton("ButtonA_1"))
            {
                isRecolting_divine_sponge_ressource = true;
                if (isRecolting_divine_sponge_ressource)
                {
                    compteur += Time.fixedDeltaTime;

                    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.º 3
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.º 4
0
    private void throwing(string button, GameObject throwable)
    {
        if (Input.GetButtonDown(button) && aiming != Vector3.zero)
        {
            if (base_ressource.get_weapon() > 0)
            {
                compteurTir = timerTir;
                GameObject C = Instantiate(throwable, gameObject.transform, true);
                C.transform.position = transform.position;
                angle = Vector2.Angle(transform.up, aiming);

                if (aiming.x >= 0)
                {
                    angle = -angle;
                }

                C.transform.eulerAngles = new Vector3(0, 0, angle);
                C.GetComponent <Rigidbody2D>().velocity = aiming * 5f;
                Destroy(C, 5);
                C.transform.parent = null;
                base_ressource.remove_weapon(1);
                base_Manager.update_ui();
            }
        }
    }
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;
        }
    }