//saves the final result matrix as dataAttributes/dataItems -> SimpleDataModel
    private void EncodeResultToSimpleDataModel()
    {
        for (var i = 1; i <= K; i++)
        {
            for (var j = 1; j <= _input.Count; j++)
            {
                if (_clusterMatrix[i, j] != Vector3.zero)
                {
                    var dataItem = new DataItem();

                    var x        = new DataAttribute();
                    var y        = new DataAttribute();
                    var z        = new DataAttribute();
                    var centroid = new DataAttribute();

                    var valueX        = _clusterMatrix[i, j].x;
                    var valueY        = _clusterMatrix[i, j].y;
                    var valueZ        = _clusterMatrix[i, j].z;
                    var valueCentroid = (float)i;

                    x.Init(j, "x", valueX + "", DataAttribute.Valuetype.ValFloat);
                    y.Init(j, "y", valueY + "", DataAttribute.Valuetype.ValFloat);
                    z.Init(j, "z", valueZ + "", DataAttribute.Valuetype.ValFloat);
                    centroid.Init(0, "centroid", valueCentroid + "", DataAttribute.Valuetype.ValFloat);

                    dataItem.Add(x);
                    dataItem.Add(y);
                    dataItem.Add(z);
                    dataItem.Add(centroid);

                    _simpleDataModel.Add(dataItem);
                }
            }
        }
    }
Esempio n. 2
0
    public ItemSet Read(string file)
    {
        StreamReader csvfile = new StreamReader(file);
        ItemSet      General = new ItemSet();
        ItemSet      items   = new ItemSet();
        DataItem     set     = new DataItem();
        string       Line    = "";
        string       temp    = "";
        int          start   = 0;
        int          id      = 0;
        int          tcn     = 0;

        Line = csvfile.ReadLine();

        while (!csvfile.EndOfStream)
        {
            Line = csvfile.ReadLine();
            tcn++;
            items = new ItemSet();

            while (Line.IndexOf(",") != -1)
            {
                set  = new DataItem();
                temp = Line.Substring(0, Line.IndexOf(","));

                Line = Line.Substring(Line.IndexOf(",") + 1);
                set.Add(temp, id);
                items.Add(set);
                id++;
                start = Line.IndexOf(",");
            }
            temp = Line;
            set.Add(temp, id);
            items.Add(set);
            id    = 0;
            temp  = "";
            start = 0;
            General.Add(items);
        }
        //General.Add(items);
        Console.WriteLine("Total count" + General.Count);
        return(General);
    }
        public virtual SPListItemCollectionFacade <TParentFacade> Add(Action <SPListItem> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            SPListItem li = DataItem.Add();

            action(li);
            li.Update();
            return(GetCurrentFacade());
        }
 public void addFloatMatrixColwise(float[][] data)
 {
     for (int i = 0; i < data.Length; i++)
     {
         var dataItem = new DataItem();
         for (int j = 0; j < data[0].Length; j++)
         {
             var dataAttribute = new DataAttribute();
             dataAttribute.Init(j, "var" + j, data[i][j] + "", DataAttribute.Valuetype.ValFloat);
             dataItem.Add(dataAttribute);
         }
         Add(dataItem);
     }
 }
 private void AddNote()
 {
     dataItem.Add(note);
 }
        private GenericDatamodel ReadCsv()
        {
            GenericDatamodel dataModel = new SimpleDatamodel();

            var pathToData = _path + _filename;

            if (File.Exists(pathToData))
            {
                var fileContent = System.IO.File.ReadAllLines(pathToData);

                if (fileContent.Length == 0)
                {
                    throw new FileLoadException("Empty file!");
                }

                var start           = 0;
                var attributeTitles = TrimStringArray(fileContent[0].Split(_delimiter.ToCharArray()));
                if (!_hasHeader)
                {
                    for (var i = 0; i < attributeTitles.Length; i++)
                    {
                        attributeTitles[i] = "Column_" + (i + 1);
                    }
                }
                else
                {
                    start++;
                }

                var datatypes = new DataAttribute.Valuetype[attributeTitles.Length];
                var firstRow  = TrimStringArray(fileContent[start].Split(_delimiter.ToCharArray()));
                for (var i = 0; i < firstRow.Length; i++)
                {
                    datatypes[i] = DataAttribute.GetDataType(firstRow[i]);
                }

                for (var i = start; i < fileContent.Length; i++)
                {
                    var dataItem   = new DataItem();
                    var attributes = TrimStringArray(fileContent[i].Split(_delimiter.ToCharArray()));
                    if (attributes.Length != attributeTitles.Length)
                    {
                        throw new FileLoadException("Can not load " + pathToData + ". Row " + i + " does not contain the same amount of columns than the first row(" + attributeTitles.Length + ").");
                    }
                    ;

                    for (var j = 0; j < attributes.Length; j++)
                    {
                        var dataAttribute = new DataAttribute();
                        dataAttribute.Init(j, attributeTitles[j], attributes[j], datatypes[j]);
                        dataItem.Add(dataAttribute);
                    }
                    dataModel.Add(dataItem);
                }

                if ((_hasHeader && fileContent.Length - 1 != dataModel.GetDataItems().Count) || (!_hasHeader && fileContent.Length != dataModel.GetDataItems().Count))
                {
                    throw new FileLoadException("Incomplete Parsing! Not all rows were transformed imported as data items!");
                }
                ;

                return(dataModel);
            }
            else
            {
                throw new FileLoadException("Did not find file '" + pathToData + "'.");
            }
        }
Esempio n. 7
0
    IEnumerator init_network()
    {
        Debug.Log("init_network start");
        yield return(StartCoroutine(config.SpreadSheet(Defines.SS_MASTER, "config", () => { })));

        masterChara.SetSaveFilename(Defines.FILENAME_MASTERCHARA);

        masterChara.Load(m_textAssetHolder.Get("master_chara"));
        masterWeapon.Load(m_textAssetHolder.Get("master_weapon"));
        masterArmor.Load(m_textAssetHolder.Get("master_armor"));
        masterSkill.Load(m_textAssetHolder.Get("master_skill"));
        masterPotion.Load(m_textAssetHolder.Get("master_potion"));
        masterTreasure.Load(m_textAssetHolder.Get("master_treasure"));
        masterEnemy.Load(m_textAssetHolder.Get("master_enemy"));
        masterItem.Load(m_textAssetHolder.Get("master_item"));
        masterStage.Load(m_textAssetHolder.Get("master_stage"));
        masterFloor.Load(m_textAssetHolder.Get("master_floor"));
        masterHelp.Load(m_textAssetHolder.Get("master_help"));

#if UNITY_EDITOR
        if (m_bLoadNetworkData)
        {
            #region 通信初期化
            yield return(StartCoroutine(masterChara.SpreadSheet(Defines.SS_MASTER, "chara", () => { })));

            yield return(StartCoroutine(masterWeapon.SpreadSheet(Defines.SS_MASTER, "weapon", () => { })));

            yield return(StartCoroutine(masterArmor.SpreadSheet(Defines.SS_MASTER, "armor", () => { })));

            yield return(StartCoroutine(masterSkill.SpreadSheet(Defines.SS_MASTER, "skill", () => { })));

            yield return(StartCoroutine(masterPotion.SpreadSheet(Defines.SS_MASTER, "potion", () => { })));

            yield return(StartCoroutine(masterTreasure.SpreadSheet(Defines.SS_MASTER, "treasure", () =>
            {
                /*
                 * foreach( MasterTreasureParam master in masterTreasure.list)
                 * {
                 *      Debug.Log(string.Format("id:{0} name:{1} sprite:{2}", master.treasure_id , master.name , master.sprite_name));
                 * }
                 */
            })));

            yield return(StartCoroutine(masterEnemy.SpreadSheet(Defines.SS_MASTER, "enemy", () => { })));

            yield return(StartCoroutine(masterItem.SpreadSheet(Defines.SS_MASTER, "item", () => { })));

            yield return(StartCoroutine(masterStage.SpreadSheet(Defines.SS_MASTER, "stage", () => { })));

            yield return(StartCoroutine(masterFloor.SpreadSheet(Defines.SS_MASTER, "floor", () => { })));

            yield return(StartCoroutine(masterHelp.SpreadSheet(Defines.SS_MASTER, "help", () => { })));

            #endregion
        }
#endif
        // 未初期化扱い
        if (!user_data.HasKey(Defines.KEY_AUTOPOTION_RATE))
        {
            user_data.WriteInt(Defines.KEY_USE_AUTOMOVE, 1);
            user_data.WriteInt(Defines.KEY_USE_AUTOPOTION, 1);

            user_data.WriteFloat(Defines.KEY_AUTOPOTION_RATE, Defines.DEFAULT_AUTOPOTION_RATE);
            user_data.WriteFloat(Defines.KEY_SOUNDVOLUME_BGM, Defines.SOUND_VOLME_DEFAULT);
            user_data.WriteFloat(Defines.KEY_SOUNDVOLUME_SE, Defines.SOUND_VOLME_DEFAULT);
        }


        game_data.SetSaveFilename(Defines.FILENAME_GAMEDATA);
        if (game_data.LoadMulti() == false)
        {
            // なんかする
            // なにもしなくてok
        }
        dataChara.SetSaveFilename(Defines.FILENAME_DATACHARA);
        if (dataChara.LoadMulti() == false)
        {
            // 初期データ的ななにか保存はしない
            DataCharaParam slime = new DataCharaParam();
            slime.chara_id = 1;
            slime.status   = DataChara.STATUS.USING.ToString();
            dataChara.list.Add(slime);
        }
        dataWeapon.SetSaveFilename(Defines.FILENAME_DATAWEAPON);
        if (dataWeapon.LoadMulti() == false)
        {
            DataWeaponParam add_weapon = new DataWeaponParam();
            add_weapon.weapon_id = 1;
            add_weapon.level     = 1;
            add_weapon.equip     = 1;           // 武器はtfで良いのでは?
            dataWeapon.Add(add_weapon);
        }
        dataWeaponAlbum.SetSaveFilename(Defines.FILENAME_DATAWEAPONALBUM);
        if (dataWeaponAlbum.LoadMulti() == false)
        {
            dataWeaponAlbum.AddAlbum(1);
        }


        dataArmor.SetSaveFilename(Defines.FILENAME_DATAARMOR);
        if (dataArmor.LoadMulti() == false)
        {
            for (int i = 0; i < MasterArmor.ArmorPositionArr.Length; i++)
            {
                DataArmorParam add = new DataArmorParam();
                add.position = MasterArmor.ArmorPositionArr[i];
                add.level    = 1;
                MasterArmorParam mas = masterArmor.list.Find(p => p.position == add.position && p.level == add.level);
                add.armor_id = mas.armor_id;
                dataArmor.list.Add(add);
            }
        }
        dataSkill.SetSaveFilename(Defines.FILENAME_DATASKILL);
        if (dataSkill.LoadMulti() == false)
        {
            dataSkill.list.Add(new DataSkillParam(1, 1));
        }
        dataPotion.SetSaveFilename(Defines.FILENAME_DATAPOTION);
        if (dataPotion.LoadMulti() == false)
        {
            DataPotionParam add = new DataPotionParam();
            add.potion_id = 1;
            add.num       = 9;
            add.is_use    = true;
            dataPotion.list.Add(add);
        }

        dataTreasure.SetSaveFilename(Defines.FILENAME_DATATREASURE);
        if (dataTreasure.LoadMulti() == false)
        {
            /*
             * int add_serial = dataTreasure.Add(1001);
             * DataTreasureParam add_treasure = dataTreasure.list.Find(p => p.serial == add_serial);
             * add_treasure.equip = 1;
             */
        }
        dataTreasureAlbum.SetSaveFilename(Defines.FILENAME_DATATREASUREALBUM);
        if (dataTreasureAlbum.LoadMulti() == false)
        {
            /*
             * dataTreasureAlbum.Add(1002);
             * dataTreasureAlbum.Add(1003);
             * dataTreasureAlbum.Add(1006);
             * dataTreasureAlbum.Add(1010);
             * dataTreasureAlbum.Add(1026);
             */
        }

        /*
         * dataScroll.SetSaveFilename(Defines.FILENAME_DATASCROLL);
         * if( dataScroll.LoadMulti()== false)
         * {
         *      dataScroll.list.Add(new DataScrollParam(1, 120));
         *      dataScroll.list.Add(new DataScrollParam(2, 120));
         *      dataScroll.list.Add(new DataScrollParam(3, 120));
         *      dataScroll.list.Add(new DataScrollParam(4, 120));
         *      dataScroll.list.Add(new DataScrollParam(5, 120));
         * }
         */
        dataUnit.SetSaveFilename(Defines.FILENAME_DATAUNIT);
        if (dataUnit.LoadMulti() == false)
        {
        }
        dataItem.SetSaveFilename(Defines.FILENAME_DATAITEM);
        if (dataItem.LoadMulti() == false)
        {
            for (int i = 0; i < 5; i++)
            {
                dataItem.Add(Defines.ITEM_ID_SCROLL_BLUE + i, 0);
            }
        }
        dataGetItem.SetSaveFilename(Defines.FILENAME_DATAITEM_GET);
        if (dataGetItem.LoadMulti() == false)
        {
        }
        dataStage.SetSaveFilename(Defines.FILENAME_DATASTAGE);
        if (dataStage.LoadMulti() == false)
        {
            DataStageParam data = new DataStageParam();
            data.stage_id = 1;
            data.status   = 1;
            dataStage.list.Add(data);
        }
        dataFloor.SetSaveFilename(Defines.FILENAME_DATAFLOOR);
        if (dataFloor.LoadMulti() == false)
        {
            DataFloorParam data = new DataFloorParam();
            data.floor_id = 1;
            data.status   = 1;
            dataFloor.list.Add(data);
        }


        if (m_txtKey != null)
        {
            user_data.AddListenerInt(Defines.KeyKey, (iValue) =>
            {
                m_txtKey.text = iValue.ToString();
            });
            user_data.AddListenerInt(Defines.KeyGoldKey, (iValue) =>
            {
                m_txtGoldKey.text = iValue.ToString();
            });
            user_data.AddListenerInt(Defines.KeyCoin, (iValue) =>
            {
                m_txtCoin.text = iValue.ToString();
            });
            user_data.AddListenerInt(Defines.KeyGem, (iValue) =>
            {
                m_txtGem.text = iValue.ToString();
            });

#if UNITY_EDITOR
            /*
             * AddGem(debug_gem);
             * AddCoin(debug_coin);
             * AddKey(debug_key);
             * AddGoldKey(debug_gold_key);
             */
#endif
            //m_txtKey.text = user_data.ReadInt(Defines.KeyKey).ToString(); ;
            //m_txtGoldKey.text = user_data.Read(Defines.KeyGoldKey);
            //m_txtCoin.text = user_data.Read(Defines.KeyCoin);
            //m_txtGem.text = user_data.Read(Defines.KeyGem);
        }



        Initialized = true;
        Debug.Log("init_network end");
        yield return(null);
    }