You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
5.5 KiB
172 lines
5.5 KiB
using ET.EventType; |
|
|
|
namespace ET |
|
{ |
|
public class PeopleAwakeSystem: AwakeSystem<People,int> |
|
{ |
|
public override void Awake(People self,int configId) |
|
{ |
|
self.ConfigId = configId; |
|
} |
|
|
|
} |
|
|
|
[FriendClass(typeof(People))] |
|
public static class PeopleSystem |
|
{ |
|
public static void FromMessage(this People self, PeopleProto peopleProto) |
|
{ |
|
self.Id = peopleProto.Id; |
|
self.Name = peopleProto.Name; |
|
self.ConfigId = peopleProto.ConfigId; |
|
self.Labor = peopleProto.LaborLevel; |
|
self.LaborExp = peopleProto.LaborExp; |
|
self.Level = peopleProto.Level; |
|
self.Exp = peopleProto.Exp; |
|
self.Age = peopleProto.Age; |
|
self.BehaveType = peopleProto.BehaveType; |
|
self.TargetId = peopleProto.TargetId; |
|
self.PosX = peopleProto.X; |
|
self.PosY = peopleProto.Y; |
|
if (peopleProto.SkillList.Count > 0) |
|
{ |
|
var skillCom = self.GetOrAddComponent<SkillComponent>(); |
|
foreach (var v in peopleProto.SkillList) |
|
{ |
|
var skill = skillCom.AddChildWithId<Skill>(v.Id); |
|
skill.FromMessage(v); |
|
} |
|
} |
|
} |
|
|
|
public static PeopleProto ToMessage(this People self) |
|
{ |
|
PeopleProto peopleProto = new PeopleProto(); |
|
peopleProto.Id = self.Id; |
|
peopleProto.Name = self.Name; |
|
peopleProto.ConfigId = self.ConfigId; |
|
peopleProto.LaborLevel = self.Labor; |
|
peopleProto.LaborExp = self.LaborExp; |
|
peopleProto.Level = self.Level; |
|
peopleProto.Exp = self.Exp; |
|
peopleProto.Age = self.Age; |
|
peopleProto.BehaveType = self.BehaveType; |
|
peopleProto.TargetId = self.TargetId; |
|
peopleProto.X = self.PosX; |
|
peopleProto.Y = self.PosY; |
|
var skillCom = self.GetComponent<SkillComponent>(); |
|
if (skillCom != null) |
|
{ |
|
foreach (var v in skillCom.Children.Values) |
|
{ |
|
var skill = (Skill) v; |
|
peopleProto.SkillList.Add(skill.ToMessage()); |
|
} |
|
} |
|
return peopleProto; |
|
|
|
} |
|
|
|
public static int GetStrength(this People self) |
|
{ |
|
var numericComp = self.GetComponent<NumericComponent>(); |
|
return numericComp.GetAsInt(NumericType.Strength); |
|
} |
|
|
|
public static int GetGender(this People self) |
|
{ |
|
var numericComp = self.GetComponent<NumericComponent>(); |
|
return numericComp.GetAsInt(NumericType.Gender); |
|
} |
|
|
|
public static int GetBehaveType(this People self) |
|
{ |
|
return self.BehaveType; |
|
} |
|
|
|
public static void SetBehaveType(this People self,int val) |
|
{ |
|
self.BehaveType = val; |
|
#if !SERVER |
|
Game.EventSystem.Publish(new EventType.BehaveTypeChanged(){People = self}); |
|
#endif |
|
} |
|
public static long GetTargetId(this People self) |
|
{ |
|
return self.TargetId; |
|
} |
|
|
|
public static void SetTargetId(this People self, long val) |
|
{ |
|
self.TargetId = val; |
|
} |
|
|
|
public static int GetHp(this People self) |
|
{ |
|
var nc = self.GetComponent<NumericComponent>(); |
|
return nc.GetAsInt(NumericType.HP); |
|
} |
|
|
|
public static bool PeopleMove(this People self, float x, float y) |
|
{ |
|
self.PosX = x; |
|
self.PosY = y; |
|
return true; |
|
} |
|
|
|
public static int GetPeopleType(this People self) |
|
{ |
|
return self.Config.Type; |
|
} |
|
|
|
public static void InitNumericComponent(this People self) |
|
{ |
|
var nc = self.AddComponent<NumericComponent>(); |
|
nc.Set(NumericType.PeopleType,self.Config.Type); |
|
nc.Set(NumericType.Gender,self.Config.Gender); |
|
nc.Set(NumericType.Age,self.Age); |
|
nc.Set(NumericType.Labor,self.Config.Labor); |
|
nc.Set(NumericType.Wisdom,self.Config.Wisdom); |
|
nc.Set(NumericType.MoveSpeed,self.Config.MoveSpeed); |
|
|
|
if (self.AttriConfig != null) |
|
{ |
|
nc.Set(NumericType.Domination,self.AttriConfig.Domination); |
|
nc.Set(NumericType.Strength,self.AttriConfig.Strength); |
|
nc.Set(NumericType.Endurance,self.AttriConfig.Endurance); |
|
nc.Set(NumericType.Agile,self.AttriConfig.Agile); |
|
nc.Set(NumericType.SpiritualPower,self.AttriConfig.SpiritualPower); |
|
} |
|
|
|
} |
|
|
|
public static int GetLabor(this People self) |
|
{ |
|
var nc = self.GetComponent<NumericComponent>(); |
|
return nc.GetAsInt(NumericType.Labor); |
|
} |
|
|
|
//建造相关 |
|
public static int GetLaborWithCoefficient(this People self) |
|
{ |
|
int labor = self.GetLabor(); |
|
int laborCoefficientBuild = WorldParametersConfigCategory.Instance.Get(WorldParam.LaborCoefficientBuild).Value[0]; |
|
return labor * laborCoefficientBuild; |
|
} |
|
|
|
//农民类型才会成长,年龄增加 |
|
public static void GrowUp(this People self) |
|
{ |
|
if (self.PeopleType != (int)RoleTypeEnum.VILLAGERS) |
|
{ |
|
return; |
|
} |
|
|
|
self.Age += 1; |
|
|
|
} |
|
//public static void Add |
|
|
|
|
|
} |
|
}
|
|
|