Example #1
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();
            }
        }
    }
Example #2
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();
            }
        }
    }
Example #3
0
 public void update_ui()
 {
     Weapon_value.text        = Base_ressource.get_weapon().ToString();
     Divine_sponge_value.text = Base_ressource.get_divine_sponge().ToString();
 }