public void SetMission(Mission mission)
    {
        // Initialize mission info.
        this.mission          = mission;
        this.missionName.text = mission.name;
        this.missionDesc.text = mission.desc;

        // Initialize objectives info.
        this.objectiveUIElements = new ObjectiveUI[mission.objectives.Length];
        for (int i = 0; i < mission.objectives.Length; i++)
        {
            // Create new button for char in inventory.
            GameObject gobj = GameObject.Instantiate(this.objectiveUIPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            gobj.transform.SetParent(this.objectivesParent);

            // Setup position and scale of button.
            RectTransform rt = gobj.GetComponent <RectTransform>();
            rt.offsetMin        = new Vector2(0.0f, rt.offsetMin.y);
            rt.offsetMax        = new Vector2(0.0f, rt.offsetMax.y);
            rt.anchoredPosition = new Vector2(0.0f, i * -40.0f);
            rt.localScale       = Vector3.one;

            // Populate the objective with info.
            ObjectiveUI ui = gobj.GetComponent <ObjectiveUI>();
            if (ui != null)
            {
                A_Objective objective = mission.objectives[i];
                ui.objectiveName.text = objective.name;
                ui.objectiveDesc.text = objective.desc;
            }
            this.objectiveUIElements[i] = ui;
        }

        this.UpdateMissionObjectives();
    }
Example #2
0
    public DataObject(SO_Characters.CharacterScriptable[] characterScriptables, SO_Airships.AirshipScriptable[] airshipScriptables)
    {
        this.dateLastSaved = DateTime.Now;

        // Populate character inventory with 4 characters.
        this.characterInventory = new List <CharacterSerialized> ();
        this.characterInventory.Add(characterScriptables [(int)GameEnum.CharacterName.EMPTY].characterData.Clone());
        this.characterInventory.Add(characterScriptables [(int)GameEnum.CharacterName.MAIN_BOB].characterData.Clone());
        this.characterInventory.Add(characterScriptables [(int)GameEnum.CharacterName.MAIN_LILY].characterData.Clone());
        this.characterInventory.Add(characterScriptables [(int)GameEnum.CharacterName.MAIN_SAM].characterData.Clone());
        this.characterInventory.Add(characterScriptables [(int)GameEnum.CharacterName.MAIN_TIM].characterData.Clone());

        // Set current airship at 0.
        this.currentAirship = GameEnum.AirshipName.KOALA;

        // Save all airship data to binary.
        this.airships = new AirshipSerialized[airshipScriptables.Length];
        for (int i = 0; i < this.airships.Length; i++)
        {
            this.airships[i] = airshipScriptables[i].airshipData.Clone();
        }
        // Unlock the first airship.
        this.airships [(int)GameEnum.AirshipName.KOALA].isLocked = false;

        // Save characters from 0 and 1 (inventory index) into characterInventory.
        int airshipSlots = airshipScriptables[(int)this.currentAirship].slots.Length;

        this.charInAirshipSlotToInventory     = new int[airshipSlots];
        this.charInAirshipSlotToInventory [0] = 1;
        this.charInAirshipSlotToInventory [1] = 2;
        this.charInAirshipSlotToInventory [2] = 3;
        //this.charInAirshipSlotToInventory [3] = 4;

        // Save empty standby characters.
        int standbySlots = airshipScriptables[(int)this.currentAirship].standbySlots.Length;

        this.standbyInAirshipSlotToInventory     = new int[standbySlots];
        this.standbyInAirshipSlotToInventory [0] = 0;
        this.standbyInAirshipSlotToInventory [1] = 0;

        // Setup missions and objectives.
        A_Objective[]       objectives    = new A_Objective[1];
        Objective_KillEnemy kill_kamikaze = new Objective_KillEnemy("Kill the Kamikaze enemy.", "Kill the Kamikaze enemy.", GameEnum.EnemyName.ENEMY_KAMIKAZE);

        objectives[0] = kill_kamikaze;
        Mission m0 = new Mission("Tutorial", "This is the tutorial mission.", "Level_LayerTest", objectives);

        this.missions    = new Mission[1];
        this.missions[0] = m0;
    }