Skip to content

Commit

Permalink
ハイスコアを読み込めるようにした
Browse files Browse the repository at this point in the history
jsonを使ってできるようにした。書き込みはまた今度。
  • Loading branch information
RyoRyo-2010 committed Nov 15, 2023
1 parent f8d7c4e commit 78b245f
Show file tree
Hide file tree
Showing 27 changed files with 86,268 additions and 0 deletions.
136 changes: 136 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Github\wanwan2\ codebase based on best match to current usage at 2023/11/15
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]


#Core editorconfig formatting - indentation

#use soft tabs (spaces) for indentation
indent_style = space

#Formatting - indentation options

#indent switch case contents.
csharp_indent_case_contents = true
#indent switch labels
csharp_indent_switch_labels = true

#Formatting - new line options

#place catch statements on a new line
csharp_new_line_before_catch = true
#place else statements on a new line
csharp_new_line_before_else = true
#require finally statements to be on a new line after the closing brace
csharp_new_line_before_finally = true
#require members of object intializers to be on separate lines
csharp_new_line_before_members_in_object_initializers = true
#require braces to be on a new line for methods, control_blocks, types, lambdas, properties, accessors, and object_collection_array_initializers (also known as "Allman" style)
csharp_new_line_before_open_brace = methods, control_blocks, types, lambdas, properties, accessors, object_collection_array_initializers

#Formatting - organize using options

#sort System.* using directives alphabetically, and place them before other usings
dotnet_sort_system_directives_first = true

#Formatting - spacing options

#require NO space between a cast and the value
csharp_space_after_cast = false
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_after_colon_in_inheritance_clause = true
#require a space after a keyword in a control flow statement such as a for loop
csharp_space_after_keywords_in_control_flow_statements = true
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_before_colon_in_inheritance_clause = true
#remove space within empty argument list parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false
#remove space between method call name and opening parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
csharp_space_between_method_call_parameter_list_parentheses = false
#remove space within empty parameter list parentheses for a method declaration
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
csharp_space_between_method_declaration_parameter_list_parentheses = false

#Formatting - wrapping options

#leave code block on separate lines
csharp_preserve_single_line_blocks = false
#leave statements and member declarations on the same line
csharp_preserve_single_line_statements = true

#Style - Code block preferences

#prefer no curly braces if allowed
csharp_prefer_braces = false:suggestion

#Style - expression bodied member options

#prefer block bodies for accessors
csharp_style_expression_bodied_accessors = false:suggestion
#prefer block bodies for constructors
csharp_style_expression_bodied_constructors = false:suggestion
#prefer block bodies for methods
csharp_style_expression_bodied_methods = false:suggestion
#prefer block bodies for properties
csharp_style_expression_bodied_properties = false:suggestion

#Style - expression level options

#prefer out variables to be declared before the method call
csharp_style_inlined_variable_declaration = false:suggestion
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion

#Style - Expression-level preferences

#prefer default(T) over default
csharp_prefer_simple_default_expression = false:suggestion
#prefer objects to be initialized using object initializers when possible
dotnet_style_object_initializer = true:suggestion

#Style - implicit and explicit types

#prefer var over explicit type in all cases, unless overridden by another code style rule
csharp_style_var_elsewhere = true:suggestion
#prefer explicit type over var to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = false:suggestion
#prefer var when the type is already mentioned on the right-hand side of a declaration expression
csharp_style_var_when_type_is_apparent = true:suggestion

#Style - language keyword and framework type options

#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

#Style - Miscellaneous preferences

#prefer anonymous functions over local functions
csharp_style_pattern_local_over_anonymous_function = false:suggestion

#Style - modifier options

#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

#Style - Modifier preferences

#when this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,internal,private,protected,static,readonly,override,unsafe:suggestion

#Style - Pattern matching

#prefer is expression with type casts instead of pattern matching
csharp_style_pattern_matching_over_as_with_null_check = false:suggestion

#Style - qualification options

#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer methods not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_method = false:suggestion
#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = false:suggestion
29 changes: 29 additions & 0 deletions Assets/Scripts/CheckScores/Score.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"scores": [
{
"rank": 1,
"date": "データなし",
"score": 0
},
{
"rank": 2,
"date": "データなし",
"score": 0
},
{
"rank": 3,
"date": "データなし",
"score": 0
},
{
"rank": 4,
"date": "データなし",
"score": 0
},
{
"rank": 5,
"date": "データなし",
"score": 0
}
]
}
7 changes: 7 additions & 0 deletions Assets/Scripts/CheckScores/Score.json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions Assets/Scripts/CheckScores/ScoreManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using Newtonsoft.Json;
using System.Text;
using System;

public class ScoreManager : MonoBehaviour
{
public TextAsset FirstJson;
private string filePath;
[SerializeField]
public Text ScoreText;

private ScoresJson Scores;
// Start is called before the first frame update
void Start()
{
//セーブデータあるか確認
filePath = Path.Combine(Application.persistentDataPath, "Scores.json");
if(!File.Exists(filePath))
{
StreamWriter sw = new StreamWriter(filePath,false, Encoding.UTF8);
sw.Write(FirstJson.text);
sw.Flush();
sw.Close();
}

//データ読み込み
StreamReader sr = new StreamReader(filePath, Encoding.UTF8);

string jsonStr = sr.ReadToEnd();

sr.Close();
Scores = JsonConvert.DeserializeObject<ScoresJson>(jsonStr);
string scoreText = "";
//画面に表示させる
foreach(Score s in Scores.scores)
{
scoreText += $"{s.rank}.{s.date} {s.score}{Environment.NewLine}";
}
ScoreText.text = scoreText;
}

// Update is called once per frame
void Update()
{

}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:命名スタイル", Justification = "<保留中>")]
public class ScoresJson
{

public IList<Score> scores { get; set; }
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:命名スタイル", Justification = "<保留中>")]
public class Score
{
public int rank { get; set; }
public string date { get; set; }
public int score { get; set; }
}
11 changes: 11 additions & 0 deletions Assets/Scripts/CheckScores/ScoreManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Packages/Newtonsoft.Json.13.0.3/.signature.p7s
Binary file not shown.
20 changes: 20 additions & 0 deletions Packages/Newtonsoft.Json.13.0.3/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2007 James Newton-King

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file not shown.
71 changes: 71 additions & 0 deletions Packages/Newtonsoft.Json.13.0.3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ![Logo](https://raw.githubusercontent.com/JamesNK/Newtonsoft.Json/master/Doc/icons/logo.jpg) Json.NET

[![NuGet version (Newtonsoft.Json)](https://img.shields.io/nuget/v/Newtonsoft.Json.svg?style=flat-square)](https://www.nuget.org/packages/Newtonsoft.Json/)
[![Build status](https://dev.azure.com/jamesnk/Public/_apis/build/status/JamesNK.Newtonsoft.Json?branchName=master)](https://dev.azure.com/jamesnk/Public/_build/latest?definitionId=8)

Json.NET is a popular high-performance JSON framework for .NET

## Serialize JSON

```csharp
Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Sizes = new string[] { "Small" };

string json = JsonConvert.SerializeObject(product);
// {
// "Name": "Apple",
// "Expiry": "2008-12-28T00:00:00",
// "Sizes": [
// "Small"
// ]
// }
```

## Deserialize JSON

```csharp
string json = @"{
'Name': 'Bad Boys',
'ReleaseDate': '1995-4-7T00:00:00',
'Genres': [
'Action',
'Comedy'
]
}";

Movie m = JsonConvert.DeserializeObject<Movie>(json);

string name = m.Name;
// Bad Boys
```

## LINQ to JSON

```csharp
JArray array = new JArray();
array.Add("Manual text");
array.Add(new DateTime(2000, 5, 23));

JObject o = new JObject();
o["MyArray"] = array;

string json = o.ToString();
// {
// "MyArray": [
// "Manual text",
// "2000-05-23T00:00:00"
// ]
// }
```

## Links

- [Homepage](https://www.newtonsoft.com/json)
- [Documentation](https://www.newtonsoft.com/json/help)
- [NuGet Package](https://www.nuget.org/packages/Newtonsoft.Json)
- [Release Notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Contributing Guidelines](https://github.com/JamesNK/Newtonsoft.Json/blob/master/CONTRIBUTING.md)
- [License](https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/json.net)
Binary file not shown.
Loading

0 comments on commit 78b245f

Please sign in to comment.