Example #1
0
 public void SetTrapInfo()
 {
     foreach (var t in trapList.param)
     {
         if (trapId == t.ID)
         {
             trapInfo = t;
         }
     }
 }
Example #2
0
    public void CatchTrap(TrapList.Param trap, GameObject obj)
    {
        if (trap == null)
        {
            return;
        }

        switch (trap.ID)
        {
        case "Sw":
            catchTrap = true;
            Observable.Timer(System.TimeSpan.FromSeconds(trap.Time))
            .Take(1)
            .Subscribe(_ => {
                catchTrap = false;
                Destroy(obj);
            })
            .AddTo(this);
            break;

        case "J":
            CmdHitBullet((int)trap.Power);
            Observable.Timer(System.TimeSpan.FromSeconds(0.5))
            .Take(1)
            .Subscribe(_ => {
                Destroy(obj);
                catchTrap = false;
            })
            .AddTo(this);

            break;

        case "N":
            catchTrap = true;
            Observable.Timer(System.TimeSpan.FromSeconds(trap.Time))
            .Take(1)
            .Subscribe(_ => {
                if (type == PlayerMode.Chase)
                {
                    ChasePlayer cahser = gameObject.GetComponent <ChasePlayer>();
                    cahser.Change_Mode("0");
                }
                Destroy(obj);
                catchTrap = false;
            })
            .AddTo(this);
            break;
        }
    }
Example #3
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                IWorkbook book = null;
                if (Path.GetExtension(filePath) == ".xls")
                {
                    book = new HSSFWorkbook(stream);
                }
                else
                {
                    book = new XSSFWorkbook(stream);
                }

                foreach (string sheetName in sheetNames)
                {
                    var exportPath = "Assets/Resources/TrapList/" + sheetName + ".asset";

                    // check scriptable object
                    var data = (TrapList)AssetDatabase.LoadAssetAtPath(exportPath, typeof(TrapList));
                    if (data == null)
                    {
                        data = ScriptableObject.CreateInstance <TrapList>();
                        AssetDatabase.CreateAsset((ScriptableObject)data, exportPath);
                        data.hideFlags = HideFlags.NotEditable;
                    }
                    data.param.Clear();

                    // check sheet
                    var sheet = book.GetSheet(sheetName);
                    if (sheet == null)
                    {
                        Debug.LogError("[QuestData] sheet not found:" + sheetName);
                        continue;
                    }

                    // add infomation
                    for (int i = 1; i <= sheet.LastRowNum; i++)
                    {
                        IRow  row  = sheet.GetRow(i);
                        ICell cell = null;

                        var p = new TrapList.Param();

                        cell = row.GetCell(0); p.ID = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(1); p.Name = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(2); p.Power = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(3); p.Range = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(4); p.Bullet = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(5); p.Time = (cell == null ? 0.0 : cell.NumericCellValue);
                        cell = row.GetCell(6); p.Speed = (cell == null ? 0.0 : cell.NumericCellValue);

                        data.param.Add(p);
                    }

                    // save scriptable object
                    ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject;
                    EditorUtility.SetDirty(obj);
                }
            }
        }
    }