Example #1
0
    public string ChooseColorDrop() //ativa cor da arma nova de acordo com a do player
    {
        if (playerWeapon.name != "Pistol" && playerWeapon.name != "MachineGun" && playerWeapon.name != "LaserCannon" && playerWeapon.name != "GrenadeLauncher")
        //if (playerWeapon == null || playerWeapon.name == "GrapplingHookv3" || playerWeapon.name == "Hand")
        {                      //nao colocar cor caso nao seja uma dessas
            Debug.Log("This weapon has no color available! Drop");
            return("NoColor"); //default
        }

        GameObject playerWeaponChild = playerWeapon.gameObject.transform.GetChild(0).gameObject; //pegar a arma

        GunControllerColorGray   gunColorGrayScript   = playerWeaponChild.GetComponent <GunControllerColorGray>();
        GunControllerColorBlue   gunColorBlueScript   = playerWeaponChild.GetComponent <GunControllerColorBlue>();
        GunControllerColorGreen  gunColorGreenScript  = playerWeaponChild.GetComponent <GunControllerColorGreen>();
        GunControllerColorRed    gunColorRedScript    = playerWeaponChild.GetComponent <GunControllerColorRed>();
        GunControllerColorYellow gunColorYellowScript = playerWeaponChild.GetComponent <GunControllerColorYellow>();

        if (gunColorGrayScript.enabled) //escolher cor e retornar script
        {
            return("Gray");
        }
        else if (gunColorBlueScript.enabled)
        {
            return("Blue");
        }
        else if (gunColorGreenScript.enabled)
        {
            return("Green");
        }
        else if (gunColorRedScript.enabled)
        {
            return("Red");
        }
        else if (gunColorYellowScript.enabled)
        {
            return("Yellow");
        }
        else
        {
            Debug.Log("Player weapon color? '-'");
            return("NoColor"); //default
        }
    }
Example #2
0
    public void ChooseColor(GameObject newWeapon) //ativa cor da arma nova
    {
        if (newWeapon.name != "Pistol" && newWeapon.name != "MachineGun" && newWeapon.name != "LaserCannon" && newWeapon.name != "GrenadeLauncher")
        //if (playerWeapon == null || playerWeapon.name == "GrapplingHookv3" || playerWeapon.name == "Hand")
        { //nao colocar cor caso nao seja uma dessas
            Debug.Log("This weapon has no color available!");
            return;
        }

        GameObject newWeaponChild = newWeapon.gameObject.transform.GetChild(0).gameObject; //pegar a arma

        switch (weaponHereColor)
        { //escolher cor e ativar script
        case "Gray":
            GunControllerColorGray gunColorGrayScript = newWeaponChild.GetComponent <GunControllerColorGray>();
            gunColorGrayScript.enabled = true;
            break;

        case "Blue":
            GunControllerColorBlue gunColorBlueScript = newWeaponChild.GetComponent <GunControllerColorBlue>();
            gunColorBlueScript.enabled = true;
            break;

        case "Green":
            GunControllerColorGreen gunColorGreenScript = newWeaponChild.GetComponent <GunControllerColorGreen>();
            gunColorGreenScript.enabled = true;
            break;

        case "Red":
            GunControllerColorRed gunColorRedScript = newWeaponChild.GetComponent <GunControllerColorRed>();
            gunColorRedScript.enabled = true;
            break;

        case "Yellow":
            GunControllerColorYellow gunColorYellowScript = newWeaponChild.GetComponent <GunControllerColorYellow>();
            gunColorYellowScript.enabled = true;
            break;

        default:
            Debug.Log("What color? '-', probably NoColor -> " + weaponHereColor);
            break;
        }
    }