コード例 #1
0
    public List <GlobalStat> GetStats()
    {
        string sql = @"SELECT * from GlobalStats";      //no, not a good practice

        var stats = new List <GlobalStat>();

        try
        {
            string ConString = Constants.connString;
            conn = new SqlConnection(ConString);

            cmd = new SqlCommand(sql, conn);
            conn.Open();
            dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                GlobalStat stat = new GlobalStat();
                stat.Key   = dr[0].ToString();
                stat.Value = int.Parse(dr[1].ToString());

                stats.Add(stat);
            }
        }
        catch (SQLDataReaderException ex)
        {
            logger.Log(ex);
            throw;
        }
        return(stats);
    }
コード例 #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null)
            {
                return(null);
            }

            JObject globalStatsObject = JObject.Load(reader);

            List <GlobalStat> globalStats = new List <GlobalStat>();

            foreach (var globalStatProperty in globalStatsObject.Children <JProperty>())
            {
                GlobalStat globalStat = new GlobalStat();

                globalStat.Name = globalStatProperty.Name;

                foreach (var globalStatDetailsProperty in globalStatProperty.Value.Children <JProperty>())
                {
                    string value = globalStatDetailsProperty.Value.ToString();

                    if (globalStatDetailsProperty.Name == "total")
                    {
                        globalStat.Total = Int32.Parse(value);
                    }
                }

                globalStats.Add(globalStat);
            }

            return(globalStats);
        }
コード例 #3
0
 public void TerrifyingGaze()
 {
     mod.Add(new StatModifier(-.5f, StatModType.PercentMult, this, skill.name));
     if (Owner.isEnemy)
     {
         GlobalStat terrifyingGaze = new GlobalStat(mod[0], "Speed", Owner, skill.name, GlobalStatModType.Towers);
         GameManager.Instance.activeMap.AddGlobalStat(terrifyingGaze);
         Owner.ownedGlobalStats.Add(terrifyingGaze);
     }
     else
     {
         GlobalStat terrifyingGaze = new GlobalStat(mod[0], "Speed", Owner, skill.name, GlobalStatModType.Enemies);
         GameManager.Instance.activeMap.AddGlobalStat(terrifyingGaze);
         Owner.ownedGlobalStats.Add(terrifyingGaze);
     }
 }
コード例 #4
0
    public bool LoadFromDisk()
    {
        Debug.Log("Loading...");
        if (!Directory.Exists(Path.Combine(Application.persistentDataPath, "Data")) ||
            !File.Exists(Path.Combine(Application.persistentDataPath, "Data/000.dat")))
        {
            Debug.LogWarning("No Save Data Exist Or Corrupted");
            // MyGlobal.Coins = 100;
            SaveToDisk();
            LoadFromDisk();
            return(false);
        }


        var       formatter = new BinaryFormatter();
        SaveClass instance;

        try
        {
            using (var fs = new FileStream(Path.Combine(Application.persistentDataPath, "Data/000.dat"), FileMode.Open, FileAccess.Read))
            {
                fs.Read(_iv, 0, _iv.Length);
                using (var c = _aes.CreateDecryptor(Key, _iv))
                    using (var cs = new CryptoStream(fs, c, CryptoStreamMode.Read))
                    {
                        instance = (SaveClass)formatter.Deserialize(cs);
                    }
            }

            MyGlobal = instance.MyGlobal;
            //for (int i = 0; i < MyLevels.Count; i++)
            //{
            //    MyLevels[i] = instance.MyLevels[i];
            //}

            return(true);
        }
        catch (Exception e)
        {
            Debug.LogException(e);
            Debug.LogWarning("No Save Data Exist Or Corrupted");
            SaveToDisk();
            return(LoadFromDisk());
        }
    }
コード例 #5
0
ファイル: MapDetails.cs プロジェクト: m4gni2de/DefenderRPG
    public void RemoveGlobalStat(GlobalStat globalStat)
    {
        if (globalStat.type == GlobalStatModType.Enemies)
        {
            foreach (Enemy enemy in liveEnemies)
            {
                globalStat.RemoveStat(enemy.GetComponent <Monster>());
            }
        }
        else
        {
            foreach (Monster monster in liveTowers)
            {
                globalStat.RemoveStat(monster);
            }
        }

        activeGlobalStats.Remove(globalStat);
        StartCoroutine(GlobalStatsCheck());
    }
コード例 #6
0
ファイル: MapDetails.cs プロジェクト: m4gni2de/DefenderRPG
    public void AddGlobalStat(GlobalStat globalStat)
    {
        if (!activeGlobalStats.Contains(globalStat))
        {
            activeGlobalStats.Add(globalStat);
        }

        if (globalStat.type == GlobalStatModType.Enemies)
        {
            foreach (Enemy enemy in liveEnemies)
            {
                enemy.GetComponent <Monster>().GlobalStatMod(this);
            }
        }
        else
        {
            foreach (Monster monster in liveTowers)
            {
                monster.GlobalStatMod(this);
            }
        }
    }