예제 #1
0
    public void UseFrame(int index)
    {
        if (!starting && EndAction != null && EndAction[currentIndex] != default(Action))
        {
            try
            {
                EndAction[currentIndex]();
            }
            catch
            {
                EndAction[currentIndex] = default(Action);
            }
        }
        starting     = false;
        currentIndex = index;
        currentTime  = 0;

        if (xFlips != null && canChangeFlipX)
        {
            owner.FlipX = owner.FlipX ^ xFlips[currentIndex];
        }
        if (yFlips != null && canChangeFlipY)
        {
            owner.FlipY = owner.FlipY ^ yFlips[currentIndex];
        }

        if (frames != null)
        {
            if (currentIndex >= frames.Length || currentIndex < 0)
            {
                Debug.Log(name + ": " + currentIndex);
            }
            foreach (frame f in frames[currentIndex].frames)
            {
                if (f != null)
                {
                    f.Use();
                }
            }
        }


        if (StartAction != null && StartAction[currentIndex] != default(Action))
        {
            try
            {
                StartAction[currentIndex]();
            }
            catch
            {
                StartAction[currentIndex] = default(Action);
            }
        }
    }
예제 #2
0
    protected void HadleInputs()
    {
        Vertical   = Input.GetAxis("Vertical");
        Horizontal = Input.GetAxis("Horizontal");

        HorizonalMouse = Input.GetAxis("Mouse X");
        VerticalMouse  = Input.GetAxis("Mouse Y");

        if (Input.GetKey(KeyCode.LeftShift))
        {
            PressShift?.Invoke();
        }

        if (Input.GetKey(KeyCode.E))
        {
            StartAction?.Invoke(true);
        }

        if (Input.GetMouseButton(0))
        {
            FireMachineGun?.Invoke();
        }

        if (Input.GetMouseButton(1))
        {
            FireRocket?.Invoke();
        }
    }
        private List <StartAction> search()
        {
            List <StartAction> list = new List <StartAction>();

            connection = new MySqlConnection(connString);
            try
            {
                connection.Open();
                command    = new MySqlCommand(sql, connection);
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    StartAction sact = new StartAction();
                    sact.ID             = dataReader.GetInt32(0);
                    sact.BusinessPlanId = dataReader.GetInt32(1);
                    sact.Name           = dataReader.GetString(2);
                    sact.ActionCost     = dataReader.GetInt32(3);
                    list.Add(sact);
                }
                dataReader.Close();
                command.Dispose();
                connection.Close();
            }
            catch (Exception ex)
            {
                return(null);
            }
            return(list);
        }
예제 #4
0
        /// <summary>
        /// Runs the operation
        /// </summary>
        /// <returns>The disposable wrapper</returns>
        public DisposableAction Run()
        {
            // Run start action
            StartAction?.Invoke();

            // Create the disposable action
            return(new DisposableAction(DisposeAction, LockOperation));
        }
 // POST api/startaction
 public StartAction Post(StartAction strAct)
 {
     if (strActService.Insert(strAct))
     {
         strAct.ID = Program.GetLastId();
         return(strAct);
     }
     return(null);
 }
예제 #6
0
        public static void HandleInitialButtons(Packet packet)
        {
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767) && ClientVersion.RemovedInVersion(ClientVersionBuild.V4_3_4_15595))
            {
                // State = 0: Looks to be sent when initial action buttons get sent, however on Trinity we use 1 since 0 had some difficulties
                // State = 1: Used in any SMSG_ACTION_BUTTONS packet with button data on Trinity. Only used after spec swaps on retail.
                // State = 2: Clears the action bars client sided. This is sent during spec swap before unlearning and before sending the new buttons
                if (packet.ReadByte("Packet Type") == 2)
                {
                    return;
                }
            }

            var buttonCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) ? 144 : 132;

            var startAction = new StartAction {
                Actions = new List <Action>(buttonCount)
            };

            for (var i = 0; i < buttonCount; i++)
            {
                var action = new Action {
                    Button = (uint)i
                };

                var packed = packet.ReadInt32();

                if (packed == 0)
                {
                    continue;
                }

                action.Id = (uint)(packed & 0x00FFFFFF);
                packet.AddValue("Action", action.Id, i);

                action.Type = (ActionButtonType)((packed & 0xFF000000) >> 24);
                packet.AddValue("Type", action.Type, i);

                startAction.Actions.Add(action);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595))
            {
                packet.ReadByte("Packet Type");
            }

            WoWObject character;

            if (Storage.Objects.TryGetValue(SessionHandler.LoginGuid, out character))
            {
                var player = character as Player;
                if (player != null && player.FirstLogin)
                {
                    Storage.StartActions.Add(new Tuple <Race, Class>(player.Race, player.Class), startAction, packet.TimeSpan);
                }
            }
        }
예제 #7
0
        public void Datahandle(byte[] bytes)
        {
            BaseNetObject bno = NetBaseTool.BytesToObject(bytes) as BaseNetObject;

            if (bno is SystemNetObject)
            {
                SystemNetObject systemNetObject = bno as SystemNetObject;
                if (systemNetObject.GetType() == typeof(Msg))
                {
                    Console.WriteLine(systemNetObject);
                }
                else if (systemNetObject.GetType() == typeof(GetMyUserData))
                {
                    MyUserData = (systemNetObject as GetMyUserData).userData;
                }
                else if (systemNetObject.GetType() == typeof(CreateRoomS2C))
                {
                    transmit = (systemNetObject as CreateRoomS2C).PlayerId;
                    wait.Set();
                }
                else if (systemNetObject.GetType() == typeof(JoinRoomS2C))
                {
                    transmit = (systemNetObject as JoinRoomS2C);
                    wait.Set();
                }
                else if (systemNetObject.GetType() == typeof(GetRoomListS2C))
                {
                    transmit = (systemNetObject as GetRoomListS2C).rooms;
                    wait.Set();
                }
                else if (systemNetObject.GetType() == typeof(PlayerJoinS2C))
                {
                    PlayerJoin?.Invoke((systemNetObject as PlayerJoinS2C).playerId);
                }
                else if (systemNetObject.GetType() == typeof(PlayerLeaveS2C))
                {
                    PlayerLeave?.Invoke((systemNetObject as PlayerLeaveS2C).playerId);
                }
                else if (systemNetObject.GetType() == typeof(GameStart))
                {
                    StartAction?.Invoke();
                }
            }
            else
            {
                GameNetObject gno = bno as GameNetObject;
                if (gno == null)
                {
                    throw new ArgumentException(bno.GetType() + " Can't Used");
                }
                ReceiveAction?.Invoke(gno);
            }
            //防止死锁
            // wait.Set();
        }
 // PUT api/startaction/5
 public StartAction Put(int id, StartAction newStartAction)
 {
     newStartAction.ID = id;
     if (strActService.SearchId(id).Count > 0)
     {
         if (strActService.Edit(newStartAction))
         {
             return(newStartAction);
         }
     }
     return(null);
 }
        /// <summary> Start the shader. Bind the program and call Start on each sumcomponent.  Then invoke StartAction</summary>
        public virtual void Start(GLMatrixCalc c)
        {
            GL.UseProgram(0);           // ensure no active program - otherwise the stupid thing picks it
            GL.BindProgramPipeline(pipelineid);

            foreach (var x in shaders)                             // let any programs do any special set up
            {
                x.Value.Start(c);
            }

            StartAction?.Invoke(this, c);                           // any shader hooks get a chance.
        }
        // DELETE api/startaction/5
        public StartAction Delete(int id)
        {
            StartAction oldStartAction = new StartAction();
            var         data           = strActService.SearchId(id);

            if (data.Count > 0)
            {
                oldStartAction.SetStartAction(data.ElementAt(0));
                if (strActService.DeleteId(id))
                {
                    return(oldStartAction);
                }
            }
            return(null);
        }
예제 #11
0
        public void Update()
        {
            if (m_IsPause) 
                return;

            
            //计算delay 时间
            if (UnityEngine.Time.realtimeSinceStartup >=m_CurRunTime + m_DelayTime+m_LastPauseTime)
            {
                if (!IsRunning)
                {
                    m_CurRunTime = UnityEngine.Time.realtimeSinceStartup;
                    m_DelayTime = 0;
                    StartAction?.Invoke();
                }

                IsRunning = true;
            }



            if (!IsRunning)
                return;

            //计算interval
            if (UnityEngine.Time.realtimeSinceStartup >= m_CurRunTime + m_Pausetime)
            {
                m_CurRunTime = UnityEngine.Time.realtimeSinceStartup + m_Interval;
                m_Pausetime = 0;


                RunAction?.Invoke(m_Loop - m_CurLoop);
                //Loop即使为0也执行一次
                if (m_Loop != -1)
                {
                    if (m_CurLoop >= m_Loop)
                    {
                        CompleteAction?.Invoke();
                        Stop();
                    }

                    m_CurLoop++;
                }

            }

        }
        public override Task StartAsync(CancellationToken cancellationToken = default)
        {
            startupService = Services.GetRequiredService <TStartup>();

            if (startupService == null)
            {
                throw new NullReferenceException(nameof(startupService));
            }

            if (StartAction != null)
            {
                StartAction.Invoke(startupService);
                return(Task.CompletedTask);
            }

            return(StartActionAsync?.Invoke(startupService, cancellationToken));
        }
예제 #13
0
    /// <summary>
    /// Runs the operation
    /// </summary>
    /// <returns>The disposable wrapper</returns>
    public async Task <IDisposable> RunAsync()
    {
        // Await the lock and get the disposable
        IDisposable d = await DisposableLock.LockAsync();

        try
        {
            // Run start action
            StartAction.Invoke();
        }
        catch
        {
            d.Dispose();
            throw;
        }

        // Create the disposable action
        return(new DisposableAction(DisposeAction, d));
    }
예제 #14
0
        public static void HandleActionButtons(Packet packet)
        {
            const int buttonCount = 132;

            var startAction = new StartAction {
                Actions = new List <Action>(buttonCount)
            };

            for (var i = 0; i < buttonCount; ++i)
            {
                var action = new Action();
                //packet.ReadUInt64("Action");

                action.Button = (uint)i;

                action.Id = packet.ReadUInt32();
                var type = packet.ReadUInt32();

                packet.AddValue("Action " + i, action.Id);
                packet.AddValue("Type " + i, type);

                if (type == 0)
                {
                    startAction.Actions.Add(action);
                }
            }

            packet.ReadByte("Packet Type");

            if (CoreParsers.SessionHandler.LoginGuid != null)
            {
                WoWObject character;
                if (Storage.Objects.TryGetValue(CoreParsers.SessionHandler.LoginGuid, out character))
                {
                    var player = character as Player;
                    if (player != null && player.FirstLogin)
                    {
                        Storage.StartActions.Add(new Tuple <Race, Class>(player.Race, player.Class), startAction, packet.TimeSpan);
                    }
                }
            }
        }
예제 #15
0
        private void StartServer()
        {
            var url = _cfg.ServerURL;

            SetStatus($"Starting server at [{url}] ...");
            try
            {
                StartAction?.Invoke(url);
                SetStatus("Server successfully started.");
            }
            catch (TargetInvocationException ex)
            {
                var msg = GetPortConflictMessage(url);
                MessageBox.Show(msg, "Failed to start server", MessageBoxButton.OK, MessageBoxImage.Error);
                ex.ShowAlert();
            }
            catch (Exception ex)
            {
                SetStatus(ex.Info(true, true));
            }
        }
예제 #16
0
        /// <summary> Perform animation on control at this time in ms. Called internally by Control.Animate
        /// Animation is performed on a system tick by calling GLControlDisplay.Animate(timestamp);
        /// </summary>
        public void Animate(GLBaseControl cs, ulong timems)
        {
            if (DeltaTime)                  // if we were set up with delta times, then set the starttime/end time as moved on from timems
            {
                StartTime += timems;
                EndTime   += timems;
                DeltaTime  = false;
            }

            if (State == StateType.Waiting && timems >= StartTime)
            {
                State = StateType.Running;
                Start(cs);
                StartAction?.Invoke(this, cs, timems);
            }

            if (State == StateType.Running)
            {
                ulong  elapsed    = timems - StartTime;
                ulong  timetomove = EndTime - StartTime;
                double deltain    = (double)elapsed / (double)timetomove;   // % in, 0-1

                if (deltain >= 1.0)
                {
                    End(cs);

                    if (RemoveAfterEnd)
                    {
                        cs.Animators.Remove(this);
                    }

                    State = StateType.Done;
                    FinishAction?.Invoke(this, cs, timems);
                }
                else
                {
                    Middle(cs, deltain);
                }
            }
        }
예제 #17
0
        public void SetStartAction(StartAction action)
        {
            switch (action)
            {
            case StartAction.Project:
                Get <RadioButton>("startProject").Checked = true;
                break;

            case StartAction.Program:
                Get <RadioButton>("startExternalProgram").Checked = true;
                break;

            case StartAction.StartURL:
                Get <RadioButton>("startBrowserInURL").Checked = true;
                break;

            default:
                throw new NotSupportedException("Unknown action!");
            }

            UpdateEnabledStates(null, EventArgs.Empty);
        }
 protected override void OnStart(string[] args)
 {
     StartAction?.Invoke();
 }
예제 #19
0
 public void RegisterDelayStartCallback(Action <object> callback, object state)
 {
     StartCount++;
     StartAction?.Invoke(callback, state);
 }
예제 #20
0
 public Task StartAsync(CancellationToken cancellationToken)
 {
     StartCount++;
     StartAction?.Invoke(cancellationToken);
     return(Task.CompletedTask);
 }
예제 #21
0
 public override void OnStart(Activity span)
 => StartAction?.Invoke(span);
예제 #22
0
 public override void Entry()
 {
     currentTime = 0;
     hittingTargets.Clear();
     StartAction?.Invoke();
 }
예제 #23
0
 /// <summary> Start the shader. Bind the program and then invoke StartAction</summary>
 public virtual void Start(GLMatrixCalc c)
 {
     GL.UseProgram(Id);
     StartAction?.Invoke(this, c);
 }
예제 #24
0
 public void SetAction(StartAction action)
 {
     _action = action;
 }
 public bool Edit(StartAction sact)
 {
     sql = "UPDATE start_actions SET business_plans_bpID='" + sact.BusinessPlanId + "', name='" + sact.Name + "',actionCost='" + sact.ActionCost + "' WHERE actionID='" + sact.ID + "'";
     return(EditTable());
 }
예제 #26
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(System.Windows.Markup.XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            Thread.CurrentThread.Name = "MainThread";

            base.OnStartup(e);

            // Init logger
            log4net.Config.XmlConfigurator.Configure();

            // Register handler for unhandled exceptions
            this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(this.App_DispatcherUnhandledException);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);

            // Build
            var mainViewModel = new MainViewModel();

            this.startViewModel = new StartViewModel();
            var scanViewModel               = new ScanViewModel();
            var previewViewModel            = new PreviewViewModel();
            var previewNoFilesViewModel     = new PreviewNoFilesViewModel();
            var synchronizeViewModel        = new SynchronizeViewModel();
            var synchronizeNoFilesViewModel = new SynchronizeNoFilesViewModel();
            var resultViewModel             = new ResultViewModel();

            var synchronizer = new Synchronizer(new FileLogger());

            var startAction              = new StartAction();
            var scanAction               = new ScanAction(synchronizer);
            var previewAction            = new PreviewAction();
            var previewNoFilesAction     = new PreviewNoFilesAction();
            var synchronizeNoFilesAction = new SynchronizeNoFilesAction();
            var synchronizeAction        = new SynchronizeAction(synchronizer);
            var resultAction             = new ResultAction();

            var mainWindow = new MainWindow();

            // Bind
            startAction.Synchronize += scanAction.Process;

            scanAction.Preview        += previewAction.Process;
            scanAction.PreviewNoFiles += previewNoFilesAction.Process;
            scanAction.Canceled       += startAction.Process;

            previewAction.Synchronize        += synchronizeAction.Process;
            previewAction.SynchronizeNoFiles += synchronizeNoFilesAction.Process;
            previewAction.Canceled           += startAction.Process;

            previewNoFilesAction.Ok += startAction.Process;

            synchronizeAction.Result += resultAction.Process;

            synchronizeNoFilesAction.Ok += startAction.Process;

            resultAction.Ok += startAction.Process;

            // Inject
            startAction.Inject(mainViewModel);
            startAction.Inject(this.startViewModel);
            scanAction.Inject(mainViewModel);
            scanAction.Inject(scanViewModel);
            previewAction.Inject(mainViewModel);
            previewAction.Inject(previewViewModel);
            previewNoFilesAction.Inject(mainViewModel);
            previewNoFilesAction.Inject(previewNoFilesViewModel);
            synchronizeNoFilesAction.Inject(mainViewModel);
            synchronizeNoFilesAction.Inject(synchronizeNoFilesViewModel);
            synchronizeAction.Inject(mainViewModel);
            synchronizeAction.Inject(synchronizeViewModel);
            resultAction.Inject(mainViewModel);
            resultAction.Inject(this.startViewModel);
            resultAction.Inject(resultViewModel);

            mainWindow.Inject(mainViewModel);

            // Run
            this.startViewModel.LoadDefaultJobList();

            this.MainWindow = mainWindow;
            startAction.Process();
            this.MainWindow.Show();
        }
예제 #27
0
 private static string StartActionQToString(StartAction? action)
 {
     return action.HasValue ? action.Value.ToString() : null;
 }
 public bool Insert(StartAction sact)
 {
     sql = "INSERT INTO start_actions (business_plans_bpID, name,actionCost) VALUES ('" + sact.BusinessPlanId + "' , '" + sact.Name + "' , '" + sact.ActionCost + "'    )";
     return(EditTable());
 }
        public DataBus GetDataBus()
        {
            bool isTimeOut = IsTimeOut;

            if (isTimeOut)
            {
                if (dataBus != null)
                {
                    try
                    {
                        //Send stop mession first
                        StopAction          stopAction = new StopAction(dataBus);
                        HttpResponseMessage response   = stopAction.DoAction();
                        string str = response.GetContent();
                    }
                    catch
                    {
                        //Nothing to do.
                    }
                }
            }
            if (dataBus == null || isTimeOut)
            {
                sessionStart = System.DateTime.Now;

                dataBus = LoadBalanceUtil.GetDataBus(connectionInfo);

                //Start action.
                StartAction         startAction = new StartAction(dataBus);
                HttpResponseMessage response    = startAction.DoAction();

                string str = response.GetContent();

                try
                {
                    Start startEntity = startAction.ResponseData as Start;
                    dataBus.ThreadId = startEntity.Threads[0].ThreadId;
                }
                catch (Exception ex)
                {
                    throw new Exception("Start:" + str);
                }


                ActionUtil.GetFormAndData(dataBus, string.Empty);

                //Login
                LoginAction loginAction = new LoginAction(dataBus);
                loginAction.UserName = dataBus.UserName;
                loginAction.Password = dataBus.EncryptedPassword;
                response             = loginAction.DoAction();
                string loginMessage = response.GetContent();

                GetMessageAction fetchMessageAction = new GetMessageAction(dataBus);

                fetchMessageAction.DoAction();
                Execute execute = fetchMessageAction.ResponseData as Execute;

                while (execute != null && execute.ClientRequestEntity != null)
                {
                    ActionUtil.StoreMessages(execute.ClientRequestEntity);
                    fetchMessageAction = new GetMessageAction(dataBus);
                    fetchMessageAction.DoAction();
                    execute = fetchMessageAction.ResponseData as Execute;
                }

                //fetchMessageAction = new GetMessageAction(dataBus);
                //fetchMessageAction. DoAction();

                ActionUtil.GetFormAndData(dataBus, string.Empty);

                SetPreferencesAction setPreferencesAction = new SetPreferencesAction(dataBus);

                response = setPreferencesAction.DoAction();
                string         setPreferencesMessage = response.GetContent();
                SetPreferences setPreferences        = setPreferencesAction.ResponseData as SetPreferences;
            }
            else
            {
                dataBus.Refresh();
                dataBus.ThreadId++;
            }

            return(dataBus);
        }
예제 #30
0
		public void SetStartAction(StartAction action)
		{
			switch(action) {
				case StartAction.Project:
					Get<RadioButton>("startProject").Checked = true;
					break;
				case StartAction.Program:
					Get<RadioButton>("startExternalProgram").Checked = true;
					break;
				case StartAction.StartURL:
					Get<RadioButton>("startBrowserInURL").Checked = true;
					break;
				default:
					throw new NotSupportedException("Unknown action!");
			}
			
			UpdateEnabledStates(null, EventArgs.Empty);
		}
예제 #31
0
        public static void HandleActionButtons(Packet packet)
        {
            const int buttonCount = 132;

            var startAction = new StartAction {
                Actions = new List <Action>(buttonCount)
            };

            var buttons = new byte[buttonCount][];

            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i]    = new byte[8];
                buttons[i][4] = packet.ReadBit();
            }

            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i][0] = packet.ReadBit();
            }
            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i][7] = packet.ReadBit();
            }
            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i][2] = packet.ReadBit();
            }
            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i][6] = packet.ReadBit();
            }
            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i][3] = packet.ReadBit();
            }
            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i][1] = packet.ReadBit();
            }
            for (var i = 0; i < buttonCount; i++)
            {
                buttons[i][5] = packet.ReadBit();
            }

            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 0);
            }
            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 3);
            }
            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 5);
            }
            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 7);
            }
            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 6);
            }
            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 1);
            }
            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 4);
            }
            for (var i = 0; i < buttonCount; i++)
            {
                packet.ReadXORByte(buttons[i], 2);
            }

            packet.ReadByte("Packet Type");

            for (int i = 0; i < buttonCount; i++)
            {
                var actionId = BitConverter.ToInt32(buttons[i], 0);

                if (actionId == 0)
                {
                    continue;
                }

                var action = new Action
                {
                    Button = (uint)i,
                    Id     = (uint)actionId,
                    Type   = 0 // removed in MoP
                };

                packet.AddValue("Action", action.Id, i);
                startAction.Actions.Add(action);
            }

            WoWObject character;

            if (Storage.Objects.TryGetValue(SessionHandler.LoginGuid, out character))
            {
                var player = character as Player;
                if (player != null && player.FirstLogin)
                {
                    Storage.StartActions.Add(new Tuple <Race, Class>(player.Race, player.Class), startAction, packet.TimeSpan);
                }
            }
        }
예제 #32
0
파일: Form1.cs 프로젝트: o92/betterpad
 private void Form1_Shown(object sender, EventArgs e)
 {
     //Run any actions queued by window manager
     StartAction?.Invoke(this);
 }