Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        this.Choices = GameObject.Find("ChoosenWeapons");
        this.Weapons = GameObject.Find("Weapons");
        this.snipper = Weapons.transform.Find("SnipperRiffel").gameObject;
        this.assault = Weapons.transform.Find("AssultRiffel").gameObject;
        this.gun     = Weapons.transform.Find("ShotGun").gameObject;
        this.rocket  = Weapons.transform.Find("RPG7").gameObject;
        this.grenade = Weapons.transform.Find("TGL").gameObject;

        this.isSnipper = Choices.GetComponent <WeaponChoose>().getData()[0];
        this.isAssault = Choices.GetComponent <WeaponChoose>().getData()[1];
        this.isGun     = Choices.GetComponent <WeaponChoose>().getData()[2];
        this.isRocket  = Choices.GetComponent <WeaponChoose>().getData()[3];
        this.isGrenade = Choices.GetComponent <WeaponChoose>().getData()[4];

        //Snipper riffel
        if (isSnipper)
        {
            sr = this.snipper.GetComponent <sniperRifle>();
        }
        else
        {
            Destroy(this.snipper);
            this.assault.SetActive(true);
        }
        //assult riffel
        if (isAssault)
        {
            ar = this.assault.GetComponent <assaultRifle>();
        }
        else
        {
            Destroy(this.assault);
            this.gun.SetActive(true);
        }
        //shot gun
        if (isGun)
        {
            sg = this.gun.GetComponent <shotgun>();
        }
        else
        {
            Debug.Log("Destroying the shootgun");
            Destroy(this.gun);
        }
        //RocketLauncher
        if (isRocket)
        {
            rl = this.rocket.GetComponent <RocketLauncher>();
        }
        else
        {
            Destroy(this.rocket);
        }
        //GrenadeLauncher
        if (isGrenade)
        {
            gl = this.grenade.GetComponent <GrenadeLauncher>();
        }
        else
        {
            Destroy(this.grenade);
        }

        /*if (isSnipper)
         * {
         *  Debug.Log("Setting snipper");
         *  sr = Weapons.GetComponent<sniperRifle>();
         *  GameObject test = Weapons.transform.Find("SnipperRiffel").gameObject;
         *  sr = (sniperRifle)test;
         *
         * }
         * else
         * {
         *  // DestroyImmediate(Weapons.GetComponent<sniperRifle>().gameObject);
         *  Destroy(Weapons.transform.Find("SnipperRiffel").gameObject);
         * }
         * //assult riffel
         * if (isAssault)
         * {
         *  //ar = Weapons.GetComponent<assaultRifle>();
         *  ar = (assaultRifle)Weapons.transform.Find("AssultRiffel").gameObject;
         *
         * }
         * else
         * {
         *  //DestroyImmediate(Weapons.GetComponent<assaultRifle>().gameObject);
         *  Destroy(Weapons.transform.Find("AssultRiffel").gameObject);
         * }
         * //shot gun
         * if (isGun)
         * {
         *
         *  //sg = Weapons.GetComponent<shotgun>();
         *  sg = (shotgun)Weapons.transform.Find("ShotGun").gameObject;
         * }
         * else
         * {
         *  Debug.Log("Destroying the shootgun");
         *  //DestroyImmediate(Weapons.GetComponent<shotgun>().gameObject);
         *  Destroy(Weapons.transform.Find("ShotGun").gameObject);
         * }
         * //RocketLauncher
         * if (isRocket)
         * {
         *  //rl = Weapons.GetComponent<RocketLauncher>();
         *  rl = (RocketLauncher)Weapons.transform.Find("RPG7").gameObject;
         * }
         * else
         * {
         *  //DestroyImmediate(Weapons.GetComponent<RocketLauncher>().gameObject);
         *  Destroy(Weapons.transform.Find("RPG7").gameObject);
         * }*/
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        ChoosenWeapons = GameObject.Find("ChoosenWeapons").GetComponent <WeaponChoose>().getData();
        //SnipperRiffel
        if (ChoosenWeapons[0])
        {
            sr = transform.GetChild(0).GetComponent <sniperRifle>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(0).gameObject);
            this.GetComponent <Transform>().GetChild(1).gameObject.SetActive(true);
        }

        //AssultRiffel
        if (ChoosenWeapons[1])
        {
            ar = transform.GetChild(1).GetComponent <assaultRifle>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(1).gameObject);
            GetComponent <Transform>().GetChild(2).gameObject.SetActive(true);
        }

        //Shotgun
        if (ChoosenWeapons[2])
        {
            sg = transform.GetChild(2).GetComponent <shotgun>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(2).gameObject);
        }

        //RocketLauncher
        if (ChoosenWeapons[3])
        {
            rl = GetComponent <Transform>().GetChild(3).GetComponent <RocketLauncher>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(3).gameObject);
        }

        //GrenadeLauncher
        if (ChoosenWeapons[4])
        {
            gl = GetComponent <Transform>().GetChild(4).GetComponent <GrenadeLauncher>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(4).gameObject);
        }

        //weapon Titan Legon
        if (ChoosenWeapons[5])
        {
            lw = GetComponent <Transform>().GetChild(5).GetComponent <LegionWeapon>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(5).gameObject);
        }

        //weapon Titan Ion
        if (ChoosenWeapons[6])
        {
            ion = GetComponent <Transform>().GetChild(6).GetComponent <IonScript>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(6).gameObject);
        }
    }