示例#1
0
        //---------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Add the action into one of the instances of "Threaded_Actions.cs"
        /// </summary>
        /// <param name="ActionDelegate"> method we want to add to stack</param>
        /// <param name="StartOnNewThread"> if true then create a new instance for a new thread, false dont</param>
        public void AddAction(dynamic ActionDelegate, bool StartOnNewThread, object [] Parameters = null)
        {
            try
            {
                Threaded_Action ActiveInstance;

                if (StartOnNewThread)
                {
                    //create new instance
                    ActiveInstance = new Threaded_Action(ProgramCounter);

                    //add method to the stack
                    ActiveInstance.AddAction(ProgramCounter, ActionDelegate, Parameters);

                    //add this isntance to the thread instance list
                    //so we can add mmore methods to it later
                    ListofActionThreads.Add(ActiveInstance);
                }
                else
                {
                    #region Create new instance if there arent any in the list
                    // make sure there is an existing instance
                    if (ListofActionThreads.Count == 0)
                    {
                        //create new instance
                        ActiveInstance = new Threaded_Action(ProgramCounter);

                        //add this isntance to the thread instance list
                        //so we can add mmore methods to it later
                        ListofActionThreads.Add(ActiveInstance);
                    }
                    #endregion

                    //get the most recent instance
                    ActiveInstance = ListofActionThreads[ListofActionThreads.Count - 1];

                    //add method to the stack
                    ActiveInstance.AddAction(ProgramCounter, ActionDelegate, Parameters);
                }

                //increment program counter
                ProgramCounter++;
            }
            //fail gracefully if unsuccesfull
            catch
            {
                System.Windows.Forms.MessageBox.Show(string.Format("Unable to add action to stack at Program counter pos: {0}", ProgramCounter));
            }
        }
示例#2
0
 private void FalconPunch_OnActivate(Player player)
 {
     ActiveInstance?.SetState(MRStates.FalconPunch.ToString());
 }
示例#3
0
 private void Zxcursed_OnActivate(Player player)
 {
     ActiveInstance?.SetState(MRStates.Cursed.ToString());
 }
示例#4
0
 private void Desrucxz_OnActivate(Player player)
 {
     ActiveInstance?.SetState(MRStates.Desruc.ToString());
 }
示例#5
0
 public override void HandleImmediateInputs(Player player, ImmediateInput input)
 {
     ActiveInstance?.HandleImmediateInputs(input);
 }