Ejemplo n.º 1
0
    void Awake()
    {
        charactersOnMissionList        = GameObject.FindGameObjectWithTag(Tags.charactersOnMissionList).GetComponent <CharactersOnMissionList>();
        allCharacterOnMissionTemplates = new CharacterOnMissionTemplate[charactersOnMission];

        RectTransform prefabButtonAddRect = characterOnMissionPrefab.GetComponent <RectTransform>();
        float         sizeY = prefabButtonAddRect.anchorMax.y - prefabButtonAddRect.anchorMin.y;

        for (int i = 0; i < charactersOnMission; i++)
        {
            GameObject button = (GameObject)Instantiate(characterOnMissionPrefab);

            button.GetComponent <RectTransform>().anchorMax = new Vector2(prefabButtonAddRect.anchorMax.x, prefabButtonAddRect.anchorMax.y - (sizeY * i));
            button.GetComponent <RectTransform>().anchorMin = new Vector2(prefabButtonAddRect.anchorMin.x, prefabButtonAddRect.anchorMin.y - (sizeY * i));

            button.transform.SetParent(buttonsContainer.transform, false);


            CharacterOnMissionTemplate characterOnMissionTemplate = button.GetComponent <CharacterOnMissionTemplate>();

            allCharacterOnMissionTemplates[i] = characterOnMissionTemplate;
        }

        hardCoreModeToggle.isOn = charactersOnMissionList.getHardCoreMode();
        buttonsOnLeft.isOn      = charactersOnMissionList.getButtonsOnLeft();
    }
Ejemplo n.º 2
0
    public void charactersOnMissionReturnToAvailableList(bool savePrisoners)
    {
        GameObject[] array = charactersManager.GetAllCharacters();
        for (int i = 0; i < array.Length; i++)
        {
            PlayerStats playerStats = array[i].GetComponent <PlayerStats>();
            if (!charactersOnMissionList.getHardCoreMode())
            {
                if (!playerStats.getIsPrisoner() || savePrisoners)
                {
                    availableCharactersList.AddOneToCharacterAvailableQuantity(playerStats);
                }
            }
            else
            {
                if (!playerStats.getIsDead())
                {
                    if (!playerStats.getIsPrisoner() || savePrisoners)
                    {
                        availableCharactersList.AddOneToCharacterAvailableQuantity(playerStats);
                    }
                }
            }

            /*
             * if(savePrisoners && !playerStats.getIsDead()){
             *      PrisonersSaved prisonersSavedScript = array[i].GetComponent<PrisonersSaved>();
             *      List<GameObject> prisonersSaved = prisonersSavedScript.getPrisonersSaved();
             *      foreach(GameObject prisoner in prisonersSaved){
             *              availableCharactersList.AddOneToCharacterAvailableQuantity(prisoner.GetComponent<PlayerStats>());
             *      }
             * }
             */
            array[i] = null;
        }
    }
    void Awake()
    {
        charactersOnMissionList = GameObject.FindGameObjectWithTag(Tags.charactersOnMissionList).GetComponent<CharactersOnMissionList>();
        allCharacterOnMissionTemplates = new CharacterOnMissionTemplate[charactersOnMission];

        RectTransform prefabButtonAddRect = characterOnMissionPrefab.GetComponent<RectTransform>();
        float sizeY = prefabButtonAddRect.anchorMax.y - prefabButtonAddRect.anchorMin.y;

        for(int i=0; i<charactersOnMission; i++){
            GameObject button = (GameObject)Instantiate(characterOnMissionPrefab);

            button.GetComponent<RectTransform>().anchorMax = new Vector2(prefabButtonAddRect.anchorMax.x, prefabButtonAddRect.anchorMax.y - (sizeY*i));
            button.GetComponent<RectTransform>().anchorMin = new Vector2(prefabButtonAddRect.anchorMin.x, prefabButtonAddRect.anchorMin.y - (sizeY*i));

            button.transform.SetParent(buttonsContainer.transform, false);

            CharacterOnMissionTemplate characterOnMissionTemplate = button.GetComponent<CharacterOnMissionTemplate>();

            allCharacterOnMissionTemplates[i] = characterOnMissionTemplate;
        }

        hardCoreModeToggle.isOn = charactersOnMissionList.getHardCoreMode();
        buttonsOnLeft.isOn = charactersOnMissionList.getButtonsOnLeft();
    }