Browse Source

增加FarmlandDic的初始化

master
wserver/wangdisen 3 years ago
parent
commit
7255ef1755
  1. 13
      Proto/OuterMessage.proto
  2. 15
      Server/Hotfix/Demo/Unit/UnitFactory.cs
  3. 31
      Server/Model/Generate/Message/OuterMessage.cs
  4. 2
      Server/Model/Generate/Message/OuterOpcode.cs
  5. 2
      Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs
  6. 31
      Unity/Codes/Hotfix/Demo/Helper/CheatHelper.cs
  7. 18
      Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs
  8. 31
      Unity/Codes/Model/Generate/Message/OuterMessage.cs
  9. 2
      Unity/Codes/Model/Generate/Message/OuterOpcode.cs

13
Proto/OuterMessage.proto

@ -1271,4 +1271,17 @@ message M2C_ChangeBehave // IActorLocationResponse
}
//ResponseType M2C_CheatItemList
message C2M_CheatItemList // IActorLocationRequest
{
int32 RpcId = 90;
repeated int32 ConfigIds = 1;
repeated int32 Nums = 2;
}
message M2C_CheatItemList // IActorLocationResponse
{
int32 RpcId = 90;
int32 Error = 91;
string Message = 92;
}

15
Server/Hotfix/Demo/Unit/UnitFactory.cs

@ -57,6 +57,7 @@ namespace ET
unit.SeasonConfig = SeasonConfigCategory.Instance.Get(unit.Season);
unitComponent.AddChild(unit);
InitNoDb(unit);
}
else
{
@ -193,5 +194,19 @@ namespace ET
menuComponent.Add(v, 0);
}*/
}
public static void InitNoDb(Unit unit)
{
foreach (var v in unit.GetComponent<BuildingComponent>().Children.Values)
{
foreach (var c in v.Children.Values)
{
if (c.GetType() == typeof (Farmland))
{
unit.FarmlandDic[c.Id] = (Farmland) c;
}
}
}
}
}
}

31
Server/Model/Generate/Message/OuterMessage.cs

@ -2650,4 +2650,35 @@ namespace ET
}
[ResponseType(nameof(M2C_CheatItemList))]
[Message(OuterOpcode.C2M_CheatItemList)]
[ProtoContract]
public partial class C2M_CheatItemList: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public List<int> ConfigIds = new List<int>();
[ProtoMember(2)]
public List<int> Nums = new List<int>();
}
[Message(OuterOpcode.M2C_CheatItemList)]
[ProtoContract]
public partial class M2C_CheatItemList: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
}

2
Server/Model/Generate/Message/OuterOpcode.cs

@ -156,5 +156,7 @@ namespace ET
public const ushort M2C_FarmlandSeed = 10153;
public const ushort C2M_ChangeBehave = 10154;
public const ushort M2C_ChangeBehave = 10155;
public const ushort C2M_CheatItemList = 10156;
public const ushort M2C_CheatItemList = 10157;
}
}

2
Unity/Codes/Hotfix/Demo/Farmland/FarmlandSystem.cs

@ -12,7 +12,7 @@
{
public override void Awake(Farmland self)
{
self.Parent.Parent.GetParent<Unit>().AddFarmland(self);
}
}

31
Unity/Codes/Hotfix/Demo/Helper/CheatHelper.cs

@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
namespace ET
{
[FriendClass(typeof(Unit))]
[FriendClass(typeof (Unit))]
public static class CheatHelper
{
public static async ETTask<int> AddItem(Unit unit, int id, int type, uint num)
@ -22,18 +23,18 @@ namespace ET
}
else
{
storeComponent.Remove(id, (int)Math.Abs(num));
storeComponent.Remove(id, (int) Math.Abs(num));
}
}
else if (type == 2)
{
if (id == NumericType.Water)
{
unit.Water += num;
unit.Water += num;
}
else if (id == NumericType.Food)
{
unit.Food += num;
unit.Food += num;
}
else if (id == NumericType.SilverTael)
{
@ -109,5 +110,27 @@ namespace ET
throw;
}
}
public static async ETTask<int> AddItemList(Unit unit, List<int> configIds, List<int> nums)
{
try
{
C2M_CheatItemList msg = new C2M_CheatItemList() { ConfigIds = configIds, Nums = nums };
M2C_CheatItemList resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_CheatItemList;
if (resp.Error == ErrorCode.ERR_Success)
{
for (int i = 0; i < configIds.Count; i++)
{
unit.GetComponent<StoreComponent>().Add(configIds[i], nums[i]);
}
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
}
}

18
Unity/Codes/Hotfix/Demo/People/PeopleSystem.cs

@ -165,7 +165,23 @@ namespace ET
self.Age += 1;
}
//public static void Add
//增加体质经验
public static void AddPhysiqueExp(this People self, int exp)
{
}
//增加寿命经验
public static void AddLifeExp(this People self, int exp)
{
}
//增加劳力经验
public static void AddLaborExp(this People self, int exp)
{
}
}

31
Unity/Codes/Model/Generate/Message/OuterMessage.cs

@ -2650,4 +2650,35 @@ namespace ET
}
[ResponseType(nameof(M2C_CheatItemList))]
[Message(OuterOpcode.C2M_CheatItemList)]
[ProtoContract]
public partial class C2M_CheatItemList: Object, IActorLocationRequest
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(1)]
public List<int> ConfigIds = new List<int>();
[ProtoMember(2)]
public List<int> Nums = new List<int>();
}
[Message(OuterOpcode.M2C_CheatItemList)]
[ProtoContract]
public partial class M2C_CheatItemList: Object, IActorLocationResponse
{
[ProtoMember(90)]
public int RpcId { get; set; }
[ProtoMember(91)]
public int Error { get; set; }
[ProtoMember(92)]
public string Message { get; set; }
}
}

2
Unity/Codes/Model/Generate/Message/OuterOpcode.cs

@ -156,5 +156,7 @@ namespace ET
public const ushort M2C_FarmlandSeed = 10153;
public const ushort C2M_ChangeBehave = 10154;
public const ushort M2C_ChangeBehave = 10155;
public const ushort C2M_CheatItemList = 10156;
public const ushort M2C_CheatItemList = 10157;
}
}

Loading…
Cancel
Save