예제 #1
0
파일: SaveMenu.cs 프로젝트: jacoba4/RaidTA
    public SaveUnit[] EntriesToSaveUnits(List<SetupManager.UnitEntry> entries)
    {
        SaveUnit[] newUnits = new SaveUnit[entries.Count];
        for (int i = 0; i < entries.Count; i++)
        {
            SetupManager.UnitEntry entry = entries[i];
            List<float> stats = new List<float>{ entry.unitID, entry.unitScript.hp, entry.unitScript.damage,
                entry.unitScript.attack_speed, entry.unitScript.range, entry.unitScript.move_speed};
            newUnits[i] = new SaveUnit(stats, entry.unitPos);
        }

        return newUnits;
    }
예제 #2
0
파일: SaveMenu.cs 프로젝트: jacoba4/RaidTA
    public List<SetupManager.UnitEntry> SaveUnitsToEntries(SaveUnit[] saveUnits)
    {
        List<SetupManager.UnitEntry> loadEntries = new List<SetupManager.UnitEntry>();
        for (int i = 0; i < saveUnits.Length; i++)
        {
            UnitSO unitDBSel = unitDB.units[(int) saveUnits[i].stats[0]];
            GameObject unitObj = (GameObject) Instantiate(unitDBSel.unit_prefab, transform.position, Quaternion.identity);
            unitObj.transform.position = saveUnits[i].pos;

            Unit newScript = unitObj.GetComponent<Unit>();
            newScript.hp = (int) saveUnits[i].stats[1];
            newScript.max_hp = (int) saveUnits[i].stats[1];
            newScript.damage = (int) saveUnits[i].stats[2];
            newScript.attack_speed = saveUnits[i].stats[3];
            newScript.range = saveUnits[i].stats[4];
            newScript.move_speed = saveUnits[i].stats[5];
            newScript.number.text = (i+1).ToString();

            SetupManager.UnitEntry newEntry = new SetupManager.UnitEntry() { unitID = (int) saveUnits[i].stats[0], unitScript = newScript, unitPos = saveUnits[i].pos };
            loadEntries.Add(newEntry);
        }

        return loadEntries;
    }