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.
61 lines
1.9 KiB
61 lines
1.9 KiB
using System; |
|
|
|
namespace ET |
|
{ |
|
public class MonsterGroupAwakeSystem: AwakeSystem<MonsterGroup,int> |
|
{ |
|
public override void Awake(MonsterGroup self,int configId) |
|
{ |
|
self.ConfigId = configId; |
|
} |
|
|
|
|
|
} |
|
|
|
[FriendClass(typeof(MonsterGroup))] |
|
[FriendClass(typeof(Fighter))] |
|
public static class MonsterGroupSystem |
|
{ |
|
public static void FromMessage(this MonsterGroup self, MonsterGroupProto proto) |
|
{ |
|
self.Id = proto.Id; |
|
self.ConfigId = proto.ConfigId; |
|
self.Seed = proto.Seed; |
|
self.X = proto.X; |
|
self.Y = proto.Y; |
|
self.ResId = proto.ResId; |
|
} |
|
|
|
public static MonsterGroupProto ToMessage(this MonsterGroup self) |
|
{ |
|
var proto = new MonsterGroupProto(); |
|
proto.Id = self.Id; |
|
proto.ConfigId = self.ConfigId; |
|
proto.Seed = self.Seed; |
|
proto.X = self.X; |
|
proto.Y = self.Y; |
|
proto.ResId = self.ResId; |
|
return proto; |
|
} |
|
|
|
public static (int,int)MonsterDrop(this MonsterGroup self, Fighter fighter) |
|
{ |
|
int seed = self.Seed % ((int) Math.Pow(10, fighter.Pos + 1)); |
|
seed = seed / (int) Math.Pow(10, fighter.Pos); |
|
|
|
var dropConfig = DropGroupConfigCategory.Instance.Get(fighter.MonsterConfig.DropGroup); |
|
int index = 0; |
|
ValleyRandom rand = new ValleyRandom(); |
|
rand.SetSeed(self.Seed-seed*1234); |
|
if (dropConfig.ItemId.Length > 1) |
|
{ |
|
index = RandomHelper.RandomByWeight(dropConfig.Weight); |
|
} |
|
|
|
//掉落数量 |
|
int dropAmount = RandomHelper.RandomNumber(dropConfig.DropAmount[index * 2], dropConfig.DropAmount[index * 2 + 1]); |
|
return (dropConfig.ItemId[index], dropAmount); |
|
} |
|
|
|
} |
|
} |