2021-04-08 20:09:59 +08:00
|
|
|
|
using Cal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public class CharacterAwakeSystem : AwakeSystem<Character>
|
|
|
|
|
{
|
|
|
|
|
public override void Awake(Character self)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
self.getAttributeFunc = self.GetAttribute;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class CharacterLoadSystem : LoadSystem<Character>
|
|
|
|
|
{
|
|
|
|
|
public override void Load(Character self)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
self.getAttributeFunc = self.GetAttribute;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class CharacterDeserializeSystem : DeserializeSystem<Character>
|
|
|
|
|
{
|
|
|
|
|
public override void Deserialize(Character self)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
self.getAttributeFunc = self.GetAttribute;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class CharacterDestroySystem : DestroySystem<Character>
|
|
|
|
|
{
|
|
|
|
|
public override void Destroy(Character self)
|
|
|
|
|
{
|
|
|
|
|
self.attribute.Clear();
|
|
|
|
|
self.pointRecord.Clear();
|
|
|
|
|
self.getAttributeFunc = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static class CharacterSystem
|
|
|
|
|
{
|
|
|
|
|
public static float GetAttribute(this Character self, AttributeType type)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
self.attribute.TryGetValue((int)type, out float value);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
public static void Set(this Character self, AttributeType type, float value)
|
|
|
|
|
{
|
|
|
|
|
self.attribute[(int)type] = value;
|
|
|
|
|
}
|
|
|
|
|
public static void SetAdd(this Character self, AttributeType type, float value)
|
|
|
|
|
{
|
|
|
|
|
int intKey = (int)type;
|
|
|
|
|
if (!self.attribute.ContainsKey(intKey))
|
|
|
|
|
self.attribute[intKey] = 0;
|
|
|
|
|
self.attribute[intKey] += value;
|
|
|
|
|
}
|
|
|
|
|
public static void AddAllPoint(this Character self, int value)
|
|
|
|
|
{
|
|
|
|
|
self.SetAdd(AttributeType.力量, value);
|
|
|
|
|
self.SetAdd(AttributeType.敏捷, value);
|
|
|
|
|
self.SetAdd(AttributeType.精神, value);
|
|
|
|
|
self.SetAdd(AttributeType.智慧, value);
|
|
|
|
|
self.SetAdd(AttributeType.体质, value);
|
|
|
|
|
self.SetAdd(AttributeType.耐力, value);
|
|
|
|
|
}
|
|
|
|
|
public static void AddPoint(this Character self, AttributeType type, int value)
|
|
|
|
|
{
|
|
|
|
|
int intType = (int)type;
|
|
|
|
|
if (!self.pointRecord.TryGetValue(intType, out int oldValue))
|
|
|
|
|
{
|
|
|
|
|
self.pointRecord[intType] = value;
|
|
|
|
|
}
|
|
|
|
|
self.pointRecord[intType] = oldValue + value;
|
|
|
|
|
SetAdd(self, type, value);
|
|
|
|
|
}
|
|
|
|
|
public static int RemovePoint(this Character self)
|
|
|
|
|
{
|
|
|
|
|
int record = 0;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (KeyValuePair<int, int> kv in self.pointRecord)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
SetAdd(self, (AttributeType)kv.Key, -kv.Value);
|
|
|
|
|
record += kv.Value;
|
|
|
|
|
}
|
|
|
|
|
self.pointRecord.Clear();
|
|
|
|
|
return record;
|
|
|
|
|
}
|
|
|
|
|
public static void ReSet(this Character self)
|
|
|
|
|
{
|
|
|
|
|
self.attribute.Clear();
|
|
|
|
|
self.pointRecord.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|