private bool CheckCanDoWork(int workId, GameEntity entity) { WorksConfig workConfig = WorksConfigProvider.Instance.GetWorksConfig(workId); if (null != workConfig && workConfig.CostAction <= entity.attr.Value.Action) { return(true); } return(false); }
protected override void Execute(List <GameEntity> entities) { foreach (GameEntity entity in entities) { foreach (int workId in entity.work.Value) { WorksConfig workConfig = WorksConfigProvider.Instance.GetWorksConfig(workId); if (null != workConfig) { if (entity.attr.Value.Action >= workConfig.CostAction) { entity.attr.Value.SetAction(Operate_Type.OT_Relative, -workConfig.CostAction); entity.attr.Value.SetAttributeByType((AttrbuteEnum)workConfig.AddAttrType, Operate_Type.OT_Relative, workConfig.AddAttrValue); } } } entity.work.Value.Clear(); } Services.Instance.CharacterPanelService.JumpToPlayer(); }
public void NextRound() { int workCount = WorksConfigProvider.Instance.GetWorksConfigCount(); var entities = Contexts.sharedInstance.game.GetGroup(GameMatcher.Character).GetEntities(); foreach (GameEntity entity in entities) { int actionCost = 0; List <int> works = new List <int>(); while (entity.attr.Value.Action > actionCost) { int workId = Util.RandomUtil.Next(1, workCount); WorksConfig workConfig = WorksConfigProvider.Instance.GetWorksConfig(workId); if (null != workConfig) { actionCost += workConfig.CostAction; works.Add(workConfig.Id); } } entity.ReplaceWork(works); } }