// Use this for initialization
    void Start()
    {
        pauseScript   = GameObject.FindGameObjectWithTag("GamePauser").GetComponent <Pause>();
        weaponScreen  = GameObject.FindGameObjectWithTag("WeaponScreen");
        weapon1APtext = GameObject.FindGameObjectWithTag("WeaponText1").GetComponent <Text>();
        weapon2APtext = GameObject.FindGameObjectWithTag("WeaponText2").GetComponent <Text>();

        canvas2 = GameObject.FindGameObjectWithTag("Canvas2").GetComponent <Canvas>();

        weaponContainer = GameObject.FindGameObjectWithTag("WeaponContainer");

        switchweaponScripts = weaponContainer.GetComponent <SwitchWeapons>();


        holdster1 = GameObject.FindGameObjectWithTag("holdster1").GetComponent <Transform>();
        holdster2 = GameObject.FindGameObjectWithTag("holdster2").GetComponent <Transform>();

        // weapon1 = switchweaponScripts.weaponZero;
        // weapon2 = switchweaponScripts.weaponOne;

        weapon1       = switchweaponScripts.weaponZero;
        weapon2       = switchweaponScripts.weaponOne;
        weaponstats1  = weapon1.GetComponent <WeaponStats>();
        weaponstats2  = weapon2.GetComponent <WeaponStats>();
        weapon1AP     = weaponstats1.WeaponStrength;
        weapon2AP     = weaponstats2.WeaponStrength;
        weapon1APtext = GameObject.FindGameObjectWithTag("WeaponText1").GetComponent <Text>();
        weapon2APtext = GameObject.FindGameObjectWithTag("WeaponText2").GetComponent <Text>();

        if (!SwitchWeapons.pickaxeActive)
        {
            switchweaponScripts.PutAwayPickaxe();
        }

        //wScreenActive = false;
        weaponScreen.SetActive(false);
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            if (!PopupManager.firstweaponfound)
            {
                StartCoroutine(GameObject.FindGameObjectWithTag("PopupManager").GetComponent <PopupManager>().firstweapon());
                PopupManager.firstweaponfound = true;
            }

            playersWeapon = switchWeaponsScript.gameObject.transform.GetChild(0).gameObject;
            //switchWeaponsScript.pickaxeActive = false;
            if (SwitchWeapons.pickaxeActive)
            {
                switchWeaponsScript.PutAwayPickaxe();
                SwitchWeapons.pickaxeActive = false;
            }


            //gameObject.transform.parent = playersWeapon.transform.parent;
            //gameObject.transform.rotation = playersWeapon.transform.rotation;
            //gameObject.transform.position = playersWeapon.transform.position;
            //Destroy(playersWeapon);
            //gameObject.transform.SetAsFirstSibling();

            //weaponZeroRW = switchWeaponsScript.weaponZero;
            //weaponOneRW = switchWeaponsScript.weaponOne;



            if (gameObject.name == "spear(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = speartransform.transform.rotation;
                gameObject.transform.position = speartransform.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("spear", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);


                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 7;

                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "lowpolysword(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = playersWeapon.transform.rotation;
                gameObject.transform.position = playersWeapon.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("sword1proto2", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);



                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 1;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();
                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "lowpolymace(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = maceTransform.rotation;
                gameObject.transform.position = maceTransform.position;

                gameObject.transform.parent = playersWeapon.transform.parent;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("lowpolymace", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);
                gameObject.GetComponent <WeaponStats>().weaponType = 2;


                //weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;
                switchWeaponsScript.ChangeWeapon();

                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;
                // gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;
                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "lowpolyhammer(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = playersWeapon.transform.rotation;
                gameObject.transform.position = playersWeapon.transform.position;

                gameObject.transform.parent = playersWeapon.transform.parent;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("lowpolyhammer", typeof(RuntimeAnimatorController)));
                //keepweapon = switchWeaponsScript.weaponOne;

                Destroy(playersWeapon);
                gameObject.GetComponent <WeaponStats>().weaponType = 3;


                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                // gameObject.AddComponent<keepWeapon>();


                Destroy(thiss);



                //switchWeaponsScript.weaponOne = keepweapon;
                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "battleaxe(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = battleaxeTransform.transform.rotation;
                gameObject.transform.position = battleaxeTransform.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("battleaxe", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);


                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 4;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "scythe(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = scytheTransform.transform.rotation;
                gameObject.transform.position = scytheTransform.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("scythe", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);


                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 5;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "lowpolypistol(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = gunTransform.transform.rotation;
                gameObject.transform.position = gunTransform.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("lowpolypistol", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);


                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 6;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "hoe(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = hoeTransform.transform.rotation;
                gameObject.transform.position = hoeTransform.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("hoe", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);


                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 8;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "fork(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = gunTransform.transform.rotation;
                gameObject.transform.position = gunTransform.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("fork", typeof(RuntimeAnimatorController)));

                Destroy(playersWeapon);


                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 9;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "dualdaggers(Clone)")
            {
                gameObject.transform.parent   = playersWeapon.transform.parent;
                gameObject.transform.rotation = dualdaggersTransform.transform.rotation;
                gameObject.transform.position = dualdaggersTransform.transform.position;
                gameObject.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                gameObject.transform.Find("dagger1").GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("dagger1", typeof(RuntimeAnimatorController)));
                gameObject.transform.Find("dagger2").GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("dagger2", typeof(RuntimeAnimatorController)));


                Destroy(playersWeapon);


                newWeapon = gameObject;
                newWeapon.GetComponent <WeaponStats>().weaponType = 11;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = gameObject;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(thiss);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
            if (gameObject.name == "hammerandsickledisplay(Clone)")
            {
                GameObject sickle = Instantiate(workingHammerandSickle, gameObject.transform.position, gameObject.transform.rotation) as GameObject;
                sickle.transform.parent   = playersWeapon.transform.parent;
                sickle.transform.rotation = hammerandsickleTransform.transform.rotation;
                sickle.transform.position = hammerandsickleTransform.transform.position;
                sickle.transform.SetAsFirstSibling();

                //switchWeaponsScript.RepopulateArray();

                sickle.gameObject.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("hammerandsickle", typeof(RuntimeAnimatorController)));



                Destroy(playersWeapon);


                newWeapon = sickle;
                newWeapon.GetComponent <WeaponStats>().weaponType = 12;


                //switchWeaponsScript.ChangeWeapon();

                //switchWeaponsScript.ChangeWeapon();

                // weaponsarray[1] = weaponsarray[0];
                //keepweapon = switchWeaponsScript.weaponOne;

                switchWeaponsScript.weaponZero = sickle;
                switchWeaponsScript.weaponOne  = weaponcontainer.transform.GetChild(1).gameObject;

                switchWeaponsScript.ChangeWeapon();
                switchWeaponsScript.fixSlot1   = true;
                SwitchWeapons.weaponZeroActive = true;

                //gameObject.AddComponent<keepWeapon>();

                Destroy(gameObject);

                //switchWeaponsScript.weaponOne = keepweapon;                //weaponsarray[1] = weaponcontainer.transform.GetChild(1).gameObject;
            }
        }
    }