コード例 #1
0
    public void LoadDataFromJSON(string jsonName)
    {
        string asset = jsonName.Replace(".json", "");

        gunStatJsonString = Resources.Load <TextAsset>(StringPathsInfo.GUNS_TEXTFILES_PATH + asset).text;
        if (gunStatJsonString.Length == 0)
        {
            return;
        }
        #region PARSE_DATA
        GunStats gunStat = JsonUtility.FromJson <GunStats>(gunStatJsonString);
        if (gunStat.Equals(GunStats.Empty))
        {
            return;
        }
        this.id                    = gunStat.Id;
        this.GunName               = gunStat.GunName;
        this.AmmoStats.AmmoSize    = gunStat.AmmoStats.AmmoSize;
        this.AmmoStats.CurrentAmmo = gunStat.AmmoStats.CurrentAmmo;
        this.AmmoStats.DeltaAmmo   = gunStat.AmmoStats.DeltaAmmo;
        this.AttackRate            = gunStat.AttackRate;
        this.MinAngle              = gunStat.MinAngle;
        this.MaxAngle              = gunStat.MaxAngle;
        this.Powerfull             = gunStat.Powerfull;
        this.GunType               = gunStat.GunType;
        this.maxAmmoSize           = gunStat.MaxAmmoSize;
        this.maxPowerFull          = gunStat.MaxPowerFull;
        this.maxAttackRate         = gunStat.MaxAttackRate;
        this.levelToOpen           = gunStat.LevelToOpen;

        #endregion
    }