示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
 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);
     }
 }
示例#4
0
 public static void Subscribe(LogicAction action)
 {
     if (_logic == null)
     {
         _logic = new Logic();
     }
     subscribers.Add(action);
 }
示例#5
0
        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);
        }
示例#10
0
    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);
        }
    }
示例#11
0
 /// <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.");
 }
示例#12
0
 public void PlaybackZhaNiao(PlaybackFrameData data)
 {
     LogicAction.PlaybackZhaNiao(data);
 }
示例#13
0
 public void PlaybackChi(PlaybackFrameData data)
 {
     LogicAction.PlaybackChi(data);
 }
示例#14
0
 public void PlaybackGangMing(PlaybackFrameData data)
 {
     LogicAction.PlaybackMingGang(data);
 }
示例#15
0
 public void PlaybackHuanBao(PlaybackFrameData data)
 {
     LogicAction.PlaybackBao(data);
 }
示例#16
0
 public void PlaybackGameOver(PlaybackFrameData data)
 {
     LogicAction.PlaybackGameOver(data);
 }
示例#17
0
 public void PlaybackLiuJu(PlaybackFrameData data)
 {
     LogicAction.PlaybackLiuju(data);
 }
示例#18
0
 public void PlaybackGangZhua(PlaybackFrameData data)
 {
     LogicAction.PlaybackZhuaGang(data);
 }
示例#19
0
 public static void Unsubscribe(LogicAction action)
 {
     subscribers.Remove(action);
 }
示例#20
0
 public void PlaybackAnGang(PlaybackFrameData data)
 {
     LogicAction.PlaybackAnGang(data);
 }
示例#21
0
 static void Main(string[] args)
 {
     LogicAction.Logic();
 }
示例#22
0
 public void PlaybackThrowoutCard(PlaybackFrameData data)
 {
     LogicAction.PlaybackThrowoutCard(data);
 }
示例#23
0
 public void PlaybackSendCard(PlaybackFrameData data)
 {
     LogicAction.PlaybackSendCard(data);
 }