Esempio n. 1
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        //Debug.Log(hitInfo.name);

        if (hitInfo.name == "beacon" || hitInfo.name == "flamegun" || hitInfo.name == "shield" || hitInfo.name == "landmine" || hitInfo.name == "newFlare(Clone)" || hitInfo.name == "newFlare 1(Clone)")
        {
            //if bullets collides with items or other bullets, let it pass through
        }
        else
        {
            //if it hits an object set bullet speed to 0
            //Debug.Log(rb.velocity);
            rb.velocity = Vector3.zero;
        }

        if (hitInfo.name == "Fire")
        {
            //when the bullet makes contact with mine explosion get rid of it.
            Destroy(gameObject);
            GameObject player1 = GameObject.Find("player1");
            weapon     wp      = player1.GetComponent <weapon>();

            GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
            GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

            if (wp.numberBullets < settings.bullets)
            {
                wp.numberBullets += 1;
            }
        }
    }
Esempio n. 2
0
    void Update()
    {
        timeLeft -= Time.deltaTime;

        //get the velocity of the bullet
        //float x = Math.Abs(rb.velocity.x);
        //float y = Math.Abs(rb.velocity.y);

        //start the 5 second countdown for each individual bullet fired, after 5 seconds object will be destroyed.
        if (timeLeft <= 0)
        {
            GameObject player1 = GameObject.Find("player1");
            weapon     wp      = player1.GetComponent <weapon>();

            GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
            GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

            if (wp.numberBullets < settings.bullets)
            {
                wp.numberBullets += 1;
            }

            Destroy(gameObject);
        }
    }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        //Debug.Log("explosion triggered");
        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

        AudioSource asource = GetComponent <AudioSource>();

        asource.volume = settings.volume * 1.2f;
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();



        AudioSource asource = GetComponent <AudioSource>();

        asource.volume = settings.volume / 5f;
    }
Esempio n. 5
0
    public void MultiPlayerGame()
    {
        //if this is clicked, vs player mode
        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

        settings.single_player_mode = false;

        //need to create scene2 for single player survival mode
        //SceneManager.LoadScene("scene1");
    }
Esempio n. 6
0
    public void PlayGame()
    {
        //SceneManager.GetActiveScene().buildIndex + 1

        //if this is clicked, only single player mode
        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

        settings.single_player_mode = true;

        SceneManager.LoadScene("scene1");
    }
Esempio n. 7
0
    // Use this for initialization
    void Start()
    {
        rb2d      = GetComponent <Rigidbody2D>();
        inventory = new List <String>();
        //Physics2D.gravity = Vector2.zero;

        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

        weapon playerWeapon = player.GetComponent <weapon>();

        playerWeapon.numberBullets = settings.bullets;

        lives = settings.player_lives;
    }
Esempio n. 8
0
    public void ReturnMainMenu()
    {
        GameObject gObject = GameObject.Find("StartButton");

        //Set this GameObject you clicked as the currently selected in the EventSystem
        es.SetSelectedGameObject(gObject);

        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

        GameObject  canvas  = GameObject.Find("Canvas");
        AudioSource asource = canvas.GetComponent <AudioSource>();

        settings.volume = asource.volume;
    }
Esempio n. 9
0
    public void Bullets3()
    {
        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

        //set color of  lives6 and lives9 back to white "unselected"
        GameObject b3 = GameObject.Find("Bullets3");
        GameObject b6 = GameObject.Find("Bullets6");
        GameObject b9 = GameObject.Find("Bullets9");

        Image bul3 = b3.GetComponent <Image>();
        Image bul6 = b6.GetComponent <Image>();
        Image bul9 = b9.GetComponent <Image>();

        bul3.color = Color.blue;
        bul6.color = Color.white;
        bul9.color = Color.white;

        settings.bullets = 3;
    }
Esempio n. 10
0
    //public Flare flare;
    // Use this for initialization
    void Start()
    {
        rb.velocity = transform.up * speed;

        GetComponent <AudioSource> ().playOnAwake = true;


        GetComponent <AudioSource> ().clip = bulletSound;

        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();


        AudioSource asource = GetComponent <AudioSource>();

        asource.volume = settings.volume / 3f;

        AudioSource.PlayClipAtPoint(bulletSound, transform.position, settings.volume);
        //GetComponent<AudioSource> ().Play();
    }
Esempio n. 11
0
    public void Lives9()
    {
        GameObject[]       objs     = GameObject.FindGameObjectsWithTag("globalSettings");
        GlobalMenuSettings settings = objs[0].GetComponent <GlobalMenuSettings>();

        //set color of  lives6 and lives9 back to white "unselected"
        GameObject l3 = GameObject.Find("Lives3");
        GameObject l6 = GameObject.Find("Lives6");
        GameObject l9 = GameObject.Find("Lives9");

        Image but3 = l3.GetComponent <Image>();
        Image but6 = l6.GetComponent <Image>();
        Image but9 = l9.GetComponent <Image>();

        but3.color = Color.white;
        but6.color = Color.white;
        but9.color = Color.blue;


        settings.player_lives = 9;
    }