예제 #1
0
    void Start()
    {
        CopyUrl         = Application.streamingAssetsPath + "/SaveDice.csv";
        SaveUrl         = Application.persistentDataPath + "/SaveDice.csv";
        DiceOriginal    = DiceCopy;
        CSVReaderWriter = GameObject.Find("CSVReaderWriter");
        CSVScript       = CSVReaderWriter.GetComponent <CSVReaderWriter>();

        CSVScript.SaveCSVExists(CopyUrl, true);
        returnList = CSVScript.ReadCSV(CSVScript.ListMakeCSV(SettingUrl, Dices));
        CloneDice(returnList);
        MainCamera = GameObject.Find("MainCamera");
        //シーンのメインカメラをアクティブにする
        MainCamera.SetActive(true);
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        Dices = GameObject.FindGameObjectsWithTag("TagDice");
        // ASWDが押下されたとき、最後にクリックされた、もしくは作られたオブジェクトが移動する
        if (Input.GetKey(KeyCode.A))
        {
            DiceCopy.transform.Translate(-0.1f, 0.0f, 0.0f);
        }
        else if (Input.GetKey(KeyCode.S))
        {
            DiceCopy.transform.Translate(0.0f, 0.0f, -0.1f);
        }
        else if (Input.GetKey(KeyCode.W))
        {
            DiceCopy.transform.Translate(0.0f, 0.0f, 0.1f);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            DiceCopy.transform.Translate(0.1f, 0.0f, 0.0f);
        }

        // クリックされたとき、クリックされたサイコロを回転・停止させる
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        // 左クリックされたとき
        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                // クリックされたダイスを入れる
                DiceCopy        = hit.collider.gameObject;
                script          = DiceCopy.GetComponent <DicePrefab>();
                script.SpinFlag = true;
            }
            else
            {
                // クリックした位置にオブジェクトがなかった場合 サイコロを複製する
                // クリックした位置を格納
                ClickPosition = Input.mousePosition;
                // Z座標を調整
                ClickPosition.z = 10.0f;
                // 作ったダイスを入れる
                DiceCopy                  = Instantiate(DiceCopy, Camera.main.ScreenToWorldPoint(ClickPosition), Quaternion.identity);
                DiceCopy.tag              = "TagDice";
                DiceCopy.name             = "DiceCopy";
                DiceCopy.transform.parent = World.transform;
                // ダイスを作った場所をデバッグで表示
                Debug.Log("座標"   +  Camera.main.ScreenToWorldPoint(ClickPosition));
            }
            // 右クリックされたとき
        }
        else if (Input.GetMouseButtonDown(1))
        {
            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                DiceCopy        = hit.collider.gameObject;
                script          = DiceCopy.GetComponent <DicePrefab>();
                script.SpinFlag = false;
                // ダイスを止めた角度を表示
                Debug.Log("角度"   + hit.collider.gameObject.transform.localEulerAngles);
            }
        }
        // 押されたキーによって処理を変える
        if (Input.GetKeyDown(KeyCode.Space))
        {
            AllSpins();
        }

        // Qキー押下でサイコロを初期配置に戻す
        if (Input.GetKeyDown(KeyCode.Q))
        {
            // 初期設定CSVを読み込む
            returnList = CSVScript.ReadCSV(CSVScript.ListMakeCSV(SettingUrl, Dices));
            CloneDice(returnList);
            // 現在のサイコロの状態を保存する
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            CSVScript.WriteCSV(Dices, SaveUrl, CopyUrl);
            // 書き出したCSVファイルを読み込み
        }
        else if (Input.GetKeyDown(KeyCode.R))
        {
            // ファイルが存在するかどうか確認する
            if (CSVScript.SaveCSVExists(SaveUrl))
            {
                returnList = CSVScript.ReadCSV(CSVScript.ListMakeCSV(CopyUrl, Dices));
                CloneDice(returnList);
            }
            else
            {
                // 無かった場合初期設定CSVを読み込む
                Debug.Log("保存データ null");
                returnList = CSVScript.ReadCSV(CSVScript.ListMakeCSV(SettingUrl, Dices));
                CloneDice(returnList);
            }
        }
        else if (Input.GetKeyDown(KeyCode.F12))
        {
            Application.Quit();
        }
        else if (Input.GetKeyDown(KeyCode.Tab))
        {
            ChangeScean();
        }

        SelectionDise();
    }
예제 #3
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            if (args == null || args.Length < 3 || !File.Exists(args[2]))
            {
                Console.Write($"No proper arguments were specified or input file not found.{helpMsg}{version}{gameVer}");
                return;
            }
            var action  = args[0].ToLower();
            var type    = args[1].ToLower();
            var inFile  = args[2];
            var outFile = args.Length > 3 ? args[3] : action == "-d" ? $"{args[2]}{defaultDesExt}" : $"{args[2]}{defaultSerExt}";

            reply = "Done";
            try
            {
                switch (type)
                {
                case "-csv":
                    if (action == "-d")
                    {
                        var binary  = LoadBinary <CSVData>(inFile);
                        var ext     = outFile.LastIndexOf('.') > -1 && (outFile.Length - outFile.LastIndexOf('.')) == 4 ? outFile.Substring(outFile.LastIndexOf('.') + 1) : string.Empty;
                        var decoded = String.Equals(ext, "csv", StringComparison.OrdinalIgnoreCase)
                                ? CSVReaderWriter.WriteCSV(binary)
                                : JsonConvert.SerializeObject(binary, Formatting.Indented, new StringCollectionConverter());
                        File.WriteAllText(outFile, decoded);
                    }
                    else if (action == "-s")
                    {
                        var ext     = inFile.LastIndexOf('.') > -1 && (inFile.Length - inFile.LastIndexOf('.')) == 4 ? inFile.Substring(inFile.LastIndexOf('.') + 1) : string.Empty;
                        var cvsdata = String.Equals(ext, "csv", StringComparison.OrdinalIgnoreCase)
                                ? CSVReaderWriter.ReadCSV(inFile)
                                : JsonConvert.DeserializeObject <CSVData>(File.ReadAllText(inFile));
                        SaveBinary <CSVData>(outFile, cvsdata);
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case "-anm":
                    ProcessObject <Animations>(action, inFile, outFile, Formatting.Indented, Anim2DConverters);
                    break;

                case "-atl":
                    ProcessObject <TextureInfoList>(action, inFile, outFile, Formatting.Indented, TextureConverters);
                    break;

                case "-usr":
                    ProcessObject <UserInfo>(action, inFile, outFile, Formatting.Indented);
                    break;

                case "-sav":
                    ProcessObject <WorldSaveState>(action, inFile, outFile, Formatting.Indented, SaveDataConverters);
                    break;

                case "-fmt":
                    ProcessObject <FormattedText>(action, inFile, outFile, Formatting.Indented, FormtTextCoverters);
                    break;

                case "-con":
                    ProcessObject <ConversationSystem>(action, inFile, outFile, Formatting.Indented);
                    break;

                case "-rmm":
                    ProcessObject <RoomManager>(action, inFile, outFile, Formatting.Indented);
                    break;

                case "-mus":
                    ProcessObject <MusicManager>(action, inFile, outFile, Formatting.Indented);
                    break;

                case "-ovw":
                    ProcessObject <OverWorldManager>(action, inFile, outFile, Formatting.Indented, OverworldConverters);
                    break;

                case "-par":
                    ProcessObject <ParticleEngine>(action, inFile, outFile, Formatting.Indented, ParticleConverters);
                    break;

                default:
                    reply = $"No proper arguments were specified.{helpMsg}";
                    break;
                }
            }
            catch (Exception ex)
            {
                reply = $"ERROR: {ex.Message}\nEXCEPTION STACK: {ex}";
            }
            Console.Write(reply);
        }