示例#1
0
    /// <summary>
    /// Stage 변경 체크
    /// </summary>
    public void StartStageTimeLine()
    {
        isStageLoad = false;
        if (!isInit && isAwake)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            isAwake = false;
        }
        switch ((STAGE)status.stageNumber)
        {
        case STAGE.ONE:
            Common.RELOAD_GAME();
            LoadMap(0);
            break;

        case STAGE.TWO:
            Common.RELOAD_GAME();
            LoadMap(1);
            break;
        }
        Debugging.LogSystem("스테이지 단계 : " + status.stageNumber + "\r\n세부 스테이지 단계 : " + status.stageDetailNumber);
        isInit      = false;
        isAwake     = true;
        isStageLoad = true;
        NormalStart();
    }
示例#2
0
    public static void SaveCloudPlayer(string cloudData)
    {
        LoadPlayer();
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerData data = JsonConvert.DeserializeObject <PlayerData>(cloudData);

        try
        {
            if (data.level != 0)
            {
                formatter.Serialize(stream, data);
            }
        }
        catch (SerializationException e)
        {
            Debugging.LogError("유저 클라우드 데이터 저장에 실패 > " + e.Message);
            throw;
        }
        finally
        {
            stream.Close();
            Debugging.LogSystem(data.name + " 의 클라우드 데이터 성공");;
        }
    }
示例#3
0
    public static void InitPlayer(string localId, string name)
    {
        string path = Application.persistentDataPath + "/player.fun";

        if (!File.Exists(path) && string.IsNullOrEmpty(User.id))
        {
            User.id                      = localId;
            User.level                   = 1;
            User.exp                     = 0;
            User.coin                    = 1000;
            User.blackCrystal            = 100;
            User.portalEnergy            = 5;
            User.name                    = name;
            User.abilityCount            = 1;
            User.lobbyHeros              = new int[5];
            User.stageHeros              = new int[5];
            User.flatEnergyChargingLevel = 0;
            User.flatEnergyMaxLevel      = 0;
            User.addMoneyLevel           = 0;
            User.addExpLevel             = 0;
            User.addAttackLevel          = 0;
            User.addDefenceLevel         = 0;
            User.gachaSeed               = UnityEngine.Random.Range(0, 100);
            User.playerSkill             = new int[2];
            User.inventoryCount          = 100;
            SavePlayer();
            Debugging.LogSystem("Init Player");
        }
    }
示例#4
0
    public static void SavePlayer()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData();

        try
        {
            if (data.level != 0)
            {
                formatter.Serialize(stream, data);
            }
        }
        catch (SerializationException e)
        {
            Debugging.LogError("유저 데이터 저장에 실패 > " + e.Message);
            throw;
        }
        finally
        {
            stream.Close();
        }
        Debugging.LogSystem("File is saved in Successfully.");
    }
示例#5
0
    public static void LoadItem()
    {
        ItemDatabase id = ItemDatabase.Load();

        foreach (Item item in id.items)
        {
            items.Add(item);
        }
        Debugging.LogSystem("ItemDatabase is loaded Succesfully.");
    }
示例#6
0
    public static void SavePlayer()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData();

        formatter.Serialize(stream, data);
        stream.Close();

        Debugging.LogSystem("File is saved in Successfully.");
    }
示例#7
0
 public static void InitPlayer()
 {
     status.hpFull          = 5;
     status.hp              = 5;
     status.air             = 100;
     status.bullet          = 7;
     status.currentWeaponId = 1000;
     status.weaponType      = Common.WeaponType.no;
     status.minAttack       = 5;
     status.maxAttack       = 10;
     status.checkPoint      = new Vector3(-18.5f, 0.58f);
     status.weapons         = new List <Item>();
     status.weapons.Add(ItemSystem.GetItem(1000));
     Debugging.LogSystem("Init Player");
 }
示例#8
0
    public static void LoadMission()
    {
        missions.Clear();
        userMissions.Clear();
        string          path   = Application.persistentDataPath + "/Xml/Mission.Xml";
        MissionDatabase md     = null;
        MissionDatabase userMd = null;

        if (System.IO.File.Exists(path))
        {
            md     = MissionDatabase.Load();
            userMd = MissionDatabase.LoadUser();
        }
        else
        {
            md     = MissionDatabase.InitSetting();
            userMd = MissionDatabase.LoadUser();
        }

        if (md != null)
        {
            foreach (Mission mission in md.missions)
            {
                missions.Add(mission);
            }
        }
        if (userMd != null)
        {
            foreach (Mission mission in userMd.missions)
            {
                userMissions.Add(mission);
            }
        }
        if (missions != null && userMissions != null)
        {
            Debugging.LogSystem("MissionDatabase is loaded Succesfully.");
        }
        GetDayMissions();
        GetWeekMissions();
        GetArchivement();

        SetArchivementClearPoint();
        CheckClearMissions(true);
    }
示例#9
0
    public static ItemDatabase Load()
    {
        string    path = "Item";
        TextAsset _xml = Resources.Load <TextAsset>(path);

        if (_xml != null)
        {
            Debugging.LogSystem("ItemDatabase is loading... " + path + ".xml");
            XmlSerializer serializer = new XmlSerializer(typeof(ItemDatabase));
            var           reader     = new StringReader(_xml.text);
            ItemDatabase  itemDB     = serializer.Deserialize(reader) as ItemDatabase;
            reader.Close();
            return(itemDB);
        }
        else
        {
            Debugging.LogSystemWarning("ItemDatabase wasn't loaded. >> " + path + " is null. >>");
            return(null);
        }
    }
示例#10
0
    public static void LoadSkill()
    {
        skills.Clear();
        userSkills.Clear();
        string        path   = Application.persistentDataPath + "/Xml/Skill.Xml";
        SkillDatabase sd     = null;
        SkillDatabase userSd = null;

        if (System.IO.File.Exists(path))
        {
            sd     = SkillDatabase.Load();
            userSd = SkillDatabase.LoadUser();
        }
        else
        {
            sd     = SkillDatabase.InitSetting();
            userSd = SkillDatabase.LoadUser();
        }

        if (sd != null)
        {
            foreach (Skill skill in sd.skills)
            {
                skills.Add(skill);
            }
        }
        if (userSd != null)
        {
            foreach (Skill skill in userSd.skills)
            {
                userSkills.Add(skill);
            }
        }
        if (sd != null && userSd != null)
        {
            Debugging.LogSystem("SkillDatabase is loaded Succesfully.");
        }

        SetObtainPlayerSkill();
    }
示例#11
0
    public static void LoadAbility()
    {
        abilities.Clear();
        userAbilities.Clear();
        string          path   = Application.persistentDataPath + "/Xml/Ability.Xml";
        AbilityDatabase ad     = null;
        AbilityDatabase userAd = null;

        if (System.IO.File.Exists(path))
        {
            ad     = AbilityDatabase.Load();
            userAd = AbilityDatabase.LoadUser();
        }
        else
        {
            ad     = AbilityDatabase.InitSetting();
            userAd = AbilityDatabase.LoadUser();
        }

        if (ad != null)
        {
            foreach (Ability ability in ad.abilities)
            {
                abilities.Add(ability);
            }
        }
        if (userAd != null)
        {
            foreach (Ability ability in userAd.abilities)
            {
                userAbilities.Add(ability);
            }
            SetAbilityStats();
        }
        if (ad != null && userAd != null)
        {
            Debugging.LogSystem("AbilityDatabase is loaded Succesfully.");
        }
    }
示例#12
0
    public static void LoadHero()
    {
        heros.Clear();
        userHeros.Clear();
        string       path   = Application.persistentDataPath + "/Xml/Heros.Xml";
        HeroDatabase hd     = null;
        HeroDatabase userHd = null;

        // 유저 데이터가 있을경우 로드
        if (System.IO.File.Exists(path))
        {
            hd     = HeroDatabase.Load();
            userHd = HeroDatabase.LoadUser();
        }
        // 최초생성
        else
        {
            hd     = HeroDatabase.InitSetting();
            userHd = HeroDatabase.LoadUser();
        }
        if (hd != null)
        {
            foreach (HeroData hero in hd.heros)
            {
                heros.Add(hero);
            }
        }
        if (userHd != null)
        {
            foreach (HeroData hero in userHd.heros)
            {
                userHeros.Add(hero);
            }
        }
        if (heros != null & userHeros != null)
        {
            Debugging.LogSystem("HeroDatabase is loaded Succesfully.");
        }
    }
示例#13
0
    public static void LoadMap()
    {
        maps.Clear();
        userMaps.Clear();
        string      path   = Application.persistentDataPath + "/Xml/Map.Xml";
        MapDatabase md     = null;
        MapDatabase userMd = null;

        if (System.IO.File.Exists(path))
        {
            md     = MapDatabase.Load();
            userMd = MapDatabase.LoadUser();
        }
        else
        {
            md     = MapDatabase.InitSetting();
            userMd = MapDatabase.LoadUser();
        }
        if (md != null)
        {
            foreach (Map map in md.maps)
            {
                maps.Add(map);
            }
        }
        if (userMd != null)
        {
            foreach (Map map in userMd.maps)
            {
                userMaps.Add(map);
            }
        }
        if (maps != null && userMaps != null)
        {
            Debugging.LogSystem("MapDatabase is loaded Succesfully.");
        }
    }
示例#14
0
    public static void LoadItem()
    {
        items.Clear();
        userItems.Clear();
        string       path   = Application.persistentDataPath + "/Xml/Item.Xml";
        ItemDatabase id     = null;
        ItemDatabase userId = null;

        if (System.IO.File.Exists(path))
        {
            id     = ItemDatabase.Load();
            userId = ItemDatabase.LoadUser();
        }
        else
        {
            id     = ItemDatabase.InitSetting();
            userId = ItemDatabase.LoadUser();
        }
        if (id != null)
        {
            foreach (Item item in id.items)
            {
                items.Add(item);
            }
        }
        if (userId != null)
        {
            foreach (Item item in userId.items)
            {
                userItems.Add(item);
            }
        }
        if (items != null && userItems != null)
        {
            Debugging.LogSystem("ItemDatabase is loaded Succesfully.");
        }
    }
示例#15
0
 private void Start()
 {
     Debugging.LogSystem("map list is loaded Succesfully.");
     isInit = true;
     StartStageTimeLine();
 }
示例#16
0
    public static void LoadPlayer()
    {
        Common.isDataLoadSuccess = false;
        int        loadTryCount = 0;
        string     path         = Application.persistentDataPath + "/player.fun";
        PlayerData data         = null;

        while (loadTryCount < 3)
        {
            if (File.Exists(path))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                FileStream      stream    = new FileStream(path, FileMode.Open);

                data = formatter.Deserialize(stream) as PlayerData;
                stream.Close();
                break;
            }
            else
            {
                loadTryCount++;
            }
        }
        if (data != null)
        {
            status.isDead       = false;
            status.isPlaying    = false;
            status.isCtrl       = false;
            status.isInBuilding = false;

            status.hp                = data.hp;
            status.hpFull            = data.hpFull;
            status.coin              = data.coin;
            status.air               = data.air;
            status.bullet            = data.bullet;
            status.currentWeaponId   = data.currentWeaponId;
            status.minAttack         = data.minAttack;
            status.maxAttack         = data.maxAttack;
            status.stageNumber       = data.stageNumber;
            status.stageDetailNumber = data.stageDetailNumber;
            status.checkPoint        = new Vector3(data.checkPoint[0], data.checkPoint[1]);
            string[] str = data.weapons.Split(',');
            str = Common.GetDistinctValues <string>(str);
            foreach (var weapon in str)
            {
                if (!string.IsNullOrEmpty(weapon))
                {
                    int  weaponNumber = Convert.ToInt32(weapon);
                    Item item         = ItemSystem.GetItem(weaponNumber);
                    if (item != null)
                    {
                        status.weapons.Add(item);
                    }
                }
            }
            Debugging.LogSystem("File is loaded Successfully >> Try : " + loadTryCount + "\r\n" + JsonUtility.ToJson(data));
        }
        else
        {
            Debugging.LogSystemWarning("Save file not fount in " + path);
            InitPlayer();
        }
        Common.isDataLoadSuccess = true;
    }