public LogicAction ToLogicAction(GameData gameData, AssetProvider assetProvider) { var newLogicAction = new LogicAction(); newLogicAction.type = Type; newLogicAction.boolValue = BoolValue; newLogicAction.intValue = IntValue; newLogicAction.floatValue = FloatValue; newLogicAction.stringValue = StringValue; newLogicAction.affectionType = AffectionType; newLogicAction.resourceType = ResourceType; newLogicAction.puzzleState = PuzzleState; newLogicAction.locationDefinition = gameData.Locations.Get(LocationDefinitionID); newLogicAction.girlPairDefinition = gameData.GirlPairs.Get(GirlPairDefinitionID); newLogicAction.itemDefinition = gameData.Items.Get(ItemDefinitionID); newLogicAction.girlDefinition = gameData.Girls.Get(GirlDefinitionID); newLogicAction.cutsceneDefinition = gameData.Cutscenes.Get(CutsceneDefinitionID); if (BackgroundMusic != null) { newLogicAction.backgroundMusic = BackgroundMusic.ToAudioKlip(assetProvider); } return(newLogicAction); }
public LogicActionInfo(LogicAction logicAction, AssetProvider assetProvider) { if (logicAction == null) { throw new ArgumentNullException(nameof(logicAction)); } if (assetProvider == null) { throw new ArgumentNullException(nameof(assetProvider)); } Type = logicAction.type; BoolValue = logicAction.boolValue; IntValue = logicAction.intValue; FloatValue = logicAction.floatValue; StringValue = logicAction.stringValue; AffectionType = logicAction.affectionType; ResourceType = logicAction.resourceType; PuzzleState = logicAction.puzzleState; LocationDefinitionID = logicAction.locationDefinition?.id ?? -1; GirlPairDefinitionID = logicAction.girlPairDefinition?.id ?? -1; ItemDefinitionID = logicAction.itemDefinition?.id ?? -1; GirlDefinitionID = logicAction.girlDefinition?.id ?? -1; CutsceneDefinitionID = logicAction.cutsceneDefinition?.id ?? -1; if (logicAction.backgroundMusic != null) { BackgroundMusic = new AudioKlipInfo(logicAction.backgroundMusic, assetProvider); } }
private void DequueLogicAction() { try { LogicAction action = null; do { action = null; lock (m_queueLogicAction) { if (0 < m_queueLogicAction.Count) { action = m_queueLogicAction.Dequeue();//移除并返回栈顶数据 } } if (null != action) { action.ProcessAction(); } } while (action != null); } catch (Exception ex) { DebugMod.LogException(ex); } }
public static void Subscribe(LogicAction action) { if (_logic == null) { _logic = new Logic(); } subscribers.Add(action); }
public static Logic Execute(LogicAction action, bool silently = false) { if (_logic == null) { _logic = new Logic(); } action(_logic); if (!silently) { subscribers.ForEach(subscriber => { subscriber(_logic); }); } return(_logic); }
/// <summary> /// Executes a search on the database, based on criteria set on <seealso cref="SortAndFilterData"/> entity returning a list of elements that matches that criteria /// </summary> /// <param name="sortAndFilter">the entity containing sort and search criteria</param> /// <param name="getCount">determines whether we should return the amount of elements returned</param> /// <returns>a <seealso cref="SearchResults{T}"/> object containing the view models that matched the criteria and a count property if <paramref name="getCount"/> is true</returns> protected SearchResults <TViewModel> GetList(SortAndFilterData sortAndFilter) { currentAction = LogicAction.Get; SearchResults <TViewModel> result = null; ExecuteCrudMethod(() => { using (var unitOfWork = factory.CreateUoW()) { unitOfWork.Execute(() => { result = ExecuteGetList(sortAndFilter, unitOfWork); }); } }, result); return(result); }
/// <summary> /// Executes logic to delete an entity into a db /// </summary> /// <param name="viewModel">the view model that will be deleted</param> protected void Delete(TViewModel viewModel) { currentAction = LogicAction.Delete; ValidateModel(viewModel); PerformSpecificValidations(viewModel); var model = ToModel(viewModel); ExecuteCrudMethod(() => { using (var unitOfWork = factory.CreateUoW()) { unitOfWork.Execute(() => { ExecuteDeleteMethod(model, (TIUnitOfWork)unitOfWork); }, true); } }, viewModel); }
/// <summary> /// Returns an entity based on its Id /// </summary> /// <param name="id">the Id that matches the entity</param> /// <returns>the view model that represents the actual entity</returns> protected TViewModel GetEntityById(TIdentity id) { currentAction = LogicAction.Get; ValidateId(id); TViewModel viewModel = null; ExecuteCrudMethod(() => { using (var unitOfWork = factory.CreateUoW()) { unitOfWork.Execute(() => { viewModel = ExecuteGetById(id, (TIUnitOfWork)unitOfWork); }); } }, viewModel); return(viewModel); }
/// <summary> /// Executes logic to Update an entity into a db /// </summary> /// <param name="viewModel">the view model taht will be updated</param> /// <returns></returns> protected TViewModel Update(TViewModel viewModel) { currentAction = LogicAction.Update; ValidateModel(viewModel); ValidateId(viewModel.Id); PerformSpecificValidations(viewModel); var model = ToModel(viewModel); ExecuteCrudMethod(() => { using (var unitOfWork = factory.CreateUoW()) { unitOfWork.Execute(() => { viewModel = ExecuteUpdateMethod(model, (TIUnitOfWork)unitOfWork); }, true); } }, viewModel); return(viewModel); }
public bool CallLogicAction(Def.LogicActionDefine actionType, ActionParam param) { try { LogicAction action = (LogicAction)LogicActionFactory.Instance.CreateAction(actionType); if (null == action) { return(false); } action.ActionId = (int)actionType; action.ActParam = param; lock (m_queueLogicAction) { m_queueLogicAction.Enqueue(action); } return(true); } catch (Exception ex) { DebugMod.LogException(ex); return(false); } }
/// <summary> /// Define an application general error message, maybe based on logic action, and return it here /// </summary> protected virtual string GetGeneralError(LogicAction action) { return($"An error has occurred while {action.ToName()}.\r\nPlease try again."); }
public void PlaybackZhaNiao(PlaybackFrameData data) { LogicAction.PlaybackZhaNiao(data); }
public void PlaybackChi(PlaybackFrameData data) { LogicAction.PlaybackChi(data); }
public void PlaybackGangMing(PlaybackFrameData data) { LogicAction.PlaybackMingGang(data); }
public void PlaybackHuanBao(PlaybackFrameData data) { LogicAction.PlaybackBao(data); }
public void PlaybackGameOver(PlaybackFrameData data) { LogicAction.PlaybackGameOver(data); }
public void PlaybackLiuJu(PlaybackFrameData data) { LogicAction.PlaybackLiuju(data); }
public void PlaybackGangZhua(PlaybackFrameData data) { LogicAction.PlaybackZhuaGang(data); }
public static void Unsubscribe(LogicAction action) { subscribers.Remove(action); }
public void PlaybackAnGang(PlaybackFrameData data) { LogicAction.PlaybackAnGang(data); }
static void Main(string[] args) { LogicAction.Logic(); }
public void PlaybackThrowoutCard(PlaybackFrameData data) { LogicAction.PlaybackThrowoutCard(data); }
public void PlaybackSendCard(PlaybackFrameData data) { LogicAction.PlaybackSendCard(data); }