浏览代码

Save Data Logic + icon

/main
Thomas ICHÉ 6 年前
当前提交
f2dc1367
共有 4 个文件被更改,包括 281 次插入0 次删除
  1. 53
      Icons/Actions/ic-action-save.png
  2. 110
      Icons/Actions/ic-action-save.png.meta
  3. 107
      Runtime/Logic/SaveDataLogic.cs
  4. 11
      Runtime/Logic/SaveDataLogic.cs.meta

53
Icons/Actions/ic-action-save.png

之前 之后
宽度: 192  |  高度: 192  |  大小: 13 KiB

110
Icons/Actions/ic-action-save.png.meta


fileFormatVersion: 2
guid: 02a5b6174ed64e24ea35c86a99568fcf
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

107
Runtime/Logic/SaveDataLogic.cs


using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients.Logic
{
public class SaveDataLogic : LogicBase
{
public enum Evaluation
{
Equal,
NotEqual,
Greater,
GreaterOrEqual,
Less,
LessOrEqual
}
public Evaluation Test = Evaluation.Equal;
public GameSaveManager.Location SaveLocation = GameSaveManager.Location.System;
public GameSaveManager.ValueType ValueType = GameSaveManager.ValueType.String;
public string Key = "SomeKey";
public bool BoolTargetValue;
public int IntTargetValue;
public float FloatTargetValue;
public string StringTargetValue;
[ReorderableList]
public Callable[] OnTestSuccess;
[ReorderableList]
public Callable[] OnTesFail;
public override void Execute()
{
var gsm = Manager.Get<GameSaveManager>();
bool result = false;
switch(ValueType)
{
case GameSaveManager.ValueType.Bool:
if (!gsm.HasBool(Key, SaveLocation))
{
WarnNotExist(Key, ValueType, SaveLocation);
}
else
{
result = TestValue(gsm.GetBool(Key, SaveLocation), BoolTargetValue);
}
break;
case GameSaveManager.ValueType.Int:
if (!gsm.HasInt(Key, SaveLocation))
{
WarnNotExist(Key, ValueType, SaveLocation);
}
else
{
result = TestValue(gsm.GetInt(Key, SaveLocation), IntTargetValue);
}
break;
case GameSaveManager.ValueType.Float:
if (!gsm.HasFloat(Key, SaveLocation))
{
WarnNotExist(Key, ValueType, SaveLocation);
}
else
{
result = TestValue(gsm.GetFloat(Key, SaveLocation), FloatTargetValue);
}
break;
case GameSaveManager.ValueType.String:
if (!gsm.HasSting(Key, SaveLocation))
{
WarnNotExist(Key, ValueType, SaveLocation);
}
else
{
result = TestValue(gsm.GetString(Key, SaveLocation), StringTargetValue);
}
break;
}
}
bool TestValue<T>(T value, T other) where T : System.IComparable<T>
{
switch(Test)
{
case Evaluation.Equal: return value.CompareTo(other) == 0;
case Evaluation.NotEqual: return value.CompareTo(other) != 0;
case Evaluation.Greater: return value.CompareTo(other) > 0;
case Evaluation.GreaterOrEqual: return value.CompareTo(other) >= 0;
case Evaluation.Less: return value.CompareTo(other) < 0;
case Evaluation.LessOrEqual: return value.CompareTo(other) <= 0;
}
return false;
}
void WarnNotExist(string name, GameSaveManager.ValueType type, GameSaveManager.Location location)
{
Debug.LogWarning(string.Format("Save Data Logic: Trying to get {0} value to non existent {1} data in {2} save.", type, name, location));
}
}
}

11
Runtime/Logic/SaveDataLogic.cs.meta


fileFormatVersion: 2
guid: 45422369810891b4fa9c4c7ea5628111
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存