Пример #1
0
    private void OnTriggerEnter(Collider other)
    {
        Transform  rootT = other.gameObject.transform.root;
        GameObject go    = rootT.gameObject;

        print("Triggered: " + go.name);

        if (go == lastTriggerGo)
        {
            return;
        }
        lastTriggerGo = go;

        if (go.tag == "Enemy")
        {
            shieldLevel--;
            Destroy(go);
        }
        else if (go.tag == "Credit")
        {
            //this plays a fun noise
            SoundCon apScript = Camera.main.GetComponent <SoundCon>();
            apScript.Credited();
            //this should add credits to your credit count
            cred      += 20;
            creds.text = "Credits: " + cred.ToString();
            print("gained 20 credits");
            //this destroys the gameObject
            Destroy(go);
        }
        else
        {
            print("Triggered by non-enemy: " + go.name);
        }
    }
Пример #2
0
    void OnCollisionEnter(Collision coll)
    {
        GameObject otherGO = coll.gameObject;

        if (otherGO.tag == "ProjectileHero")
        {
            SoundCon apScript = Camera.main.GetComponent <SoundCon>();
            apScript.Destroyed();
            Destroy(otherGO);
            Destroy(gameObject);
            des++;
            enDes.text = "Enemies Destroyed " + des.ToString();
            print("Score increased");

            int cd = Random.Range(1, 10);
            if (cd < 4)
            {
                DropCredits();
            }
        }
        else
        {
            print("Enemy hit by non-ProjectileHero: " + otherGO.name);
        }
    }
Пример #3
0
    private void Awake()
    {
        ///Set this to be main Game Controller
        if (Instance)
        {
            Debug.Log("I already exist: destroying self");
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);

            engObjPool = new EngPool(maxEnergy);

            //Get Other Controllers
            secCon = gameObject.GetComponent <SecurityCon>();
            scrMan = gameObject.GetComponent <ScreenManager>();
            sndCon = gameObject.GetComponent <SoundCon>();

            //Get Each Energy Container in Eng
            //foreach (GameObject gameObj in GameObject.FindGameObjectsWithTag("EnergyBox"))
            //{
            //    EngBarCon objCon = gameObj.GetComponent<EngBarCon>();
            //    if (objCon.section == Section.Life)
            //        lsPowerCon = objCon;
            //   if (objCon.section == Section.Shields)
            //        shieldPowerCon = objCon;
            //}
        }
    }
Пример #4
0
    void Awake()
    {
        bndCheck = GetComponent <BoundsCheck>();

        SoundCon apScript = Camera.main.GetComponent <SoundCon>();

        apScript.Laser();
    }