Example #1
0
 private void NotifyIcon_OnMouseUp(object sender, MouseButtonEventArgs e)
 {
     e.Handled = true;
     TrayIcon?.IconMouseUp(e.ChangedButton, MouseHelper.GetCursorPositionParam(), System.Windows.Forms.SystemInformation.DoubleClickTime);
 }
Example #2
0
        private void AwakeningLoopThread(List <AwakeItem> preferredAwakeItemList)
        {
            try
            {
                LogHelper.AppendLog(_ui, "Bot has started");

                Win32.SetForegroundWindow(_botConfig.Process.MainWindowHandle);

                AwakeningResolver awakeResolver = new AwakeningResolver(_serverConfig);

                while (_isRunning)
                {
                    var stopWatch = Stopwatch.StartNew();

                    MouseHelper.SetCursorPosition(new Point(_botConfig.ItemPosition.X + 3, _botConfig.ItemPosition.Y));

                    Thread.Sleep(50);

                    MouseHelper.SetCursorPosition(new Point(_botConfig.ItemPosition.X - 3, _botConfig.ItemPosition.Y));

                    Thread.Sleep(50);

                    // Hover over the item to check the awake
                    MouseHelper.SetCursorPosition(_botConfig.ItemPosition);

                    // Add specified delay to compensate for laggy server
                    int delayBeforeSnapshot = 0;

                    _ui.Invoke(new Action(() =>
                    {
                        delayBeforeSnapshot = _ui.TrackBarBeforeSnapshotMsDelay.Value;
                    }));

                    Thread.Sleep(delayBeforeSnapshot);

                    Bitmap bmp = awakeResolver.SnapshotRectangle(_botConfig.AwakeReadRectangle);

                    UpdateStepUi(_ui.PictureBoxDebug1, _ui.LabelStep1, bmp);

                    bmp = awakeResolver.DifferentiateAwakeText(bmp);

                    UpdateStepUi(_ui.PictureBoxDebug2, _ui.LabelStep2, bmp);

                    bmp = awakeResolver.CropBitmapSmart(bmp);

                    UpdateStepUi(_ui.PictureBoxDebug3, _ui.LabelStep3, bmp);

                    string awakeText = awakeResolver.GetAwakening(bmp);

                    LogHelper.AppendLog(_ui, "Raw awake In-game text: \"" + awakeText + "\"");

                    List <Awake> itemAwakes = new AwakeningParser(_serverConfig, awakeText).GetCompletedAwakes();

                    string awakeAchieved = "";

                    for (int i = 0; i < itemAwakes.Count; ++i)
                    {
                        awakeAchieved += itemAwakes[i].ToString() + (i == (itemAwakes.Count - 1) ? "" : " | ");
                    }

                    if (awakeAchieved.Length <= 0)
                    {
                        awakeAchieved = "No awake found\n";
                        LogHelper.AppendLog(_ui, awakeAchieved);
                    }

                    LogHelper.AppendLog(_ui, awakeAchieved);

                    bool shouldBreak = false;

                    if (_ui.CheckboxStopIfAwakeUnrecognized.Checked)
                    {
                        foreach (var awake in itemAwakes)
                        {
                            if (awake.TypeIndex == -1)
                            {
                                StopBot();

                                LogHelper.AppendLog(_ui, "An awake was not recognized, stopping the bot.");

                                shouldBreak = true;

                                break;
                            }
                        }
                    }

                    if (shouldBreak)
                    {
                        break;
                    }

                    var preferredAwakesList = ConvertAwakeItemListToAwakeList(preferredAwakeItemList);

                    // Go through each awake group and see if any of them meets the requirements
                    foreach (var preferredAwake in preferredAwakesList)
                    {
                        // Check if awake meets the requirements
                        if (AwakeMeetsRequirements(itemAwakes, preferredAwake))
                        {
                            LogHelper.AppendLog(_ui, "Preferred awake was successfully achieved");

                            stopWatch.Stop();

                            UpdateIterationTimeLabels(stopWatch.ElapsedMilliseconds);

                            shouldBreak = true;

                            break;
                        }
                    }

                    if (shouldBreak)
                    {
                        break;
                    }

                    LogHelper.AppendLog(_ui, "Preferred awake was not achieved");

                    // Doubleclick reversion scroll
                    MouseHelper.LeftClick(_botConfig.ReversionPosition);
                    MouseHelper.LeftClick(_botConfig.ReversionPosition);

                    const int ms = 200;

                    Thread.Sleep(ms);

                    // Click item with reversion
                    MouseHelper.LeftClick(_botConfig.ItemPosition);

                    // Wait until the reversion is done on the item
                    Thread.Sleep(_serverConfig.ScrollFinishDelay);

                    if (_ui.ComboBoxSupportAugmentation.Checked)
                    {
                        MouseHelper.LeftClick(_botConfig.AwakeScrollPosition);
                    }
                    else
                    {
                        // Doubleclick awake scroll
                        MouseHelper.LeftClick(_botConfig.AwakeScrollPosition);
                        MouseHelper.LeftClick(_botConfig.AwakeScrollPosition);
                    }

                    Thread.Sleep(ms);

                    // Click item with awake scroll
                    MouseHelper.LeftClick(_botConfig.ItemPosition);

                    Thread.Sleep(ms);

                    MouseHelper.SetCursorPosition(new Point(_botConfig.ItemPosition.X + 200, _botConfig.ItemPosition.Y + 200));

                    Thread.Sleep(ms);

                    MouseHelper.SetCursorPosition(_botConfig.ItemPosition);

                    // Wait until the awake is done on the item
                    Thread.Sleep(_serverConfig.ScrollFinishDelay);

                    bmp.Dispose();

                    stopWatch.Stop();

                    UpdateIterationTimeLabels(stopWatch.ElapsedMilliseconds);
                }

                StopBot();

                LogHelper.AppendLog(_ui, "Bot has finished");
            }
            catch (Exception ex)
            {
                StopBot();
                LogHelper.AppendLog(_ui, ex.ToString());
            }
        }
Example #3
0
 public void WaitIdle()
 {
     MouseHelper.WaitIdle();
 }
Example #4
0
 public static bool InputCancelPressed()
 {
     return(KeyboardHelper.InputPressed(KeyboardHelper.InputCancelStatus) || MouseHelper.InputRightButtonPressed());
 }
        /// <summary>
        /// Move the cursor on the map.
        /// </summary>
        /// <returns>Returns true if the cursor was moved</returns>
        public bool CursorControl()
        {
            bool CursorMoved = false;

            if (MouseHelper.MouseMoved())
            {
                float NewX = MouseHelper.MouseStateCurrent.X / TileSize.X;
                float NewY = MouseHelper.MouseStateCurrent.Y / TileSize.Y;

                NewX += CameraPosition.X;
                NewY += CameraPosition.Y;

                if (NewX < 0)
                {
                    NewX = 0;
                }
                else if (NewX >= MapSize.X)
                {
                    NewX = MapSize.X - 1;
                }
                if (NewY < 0)
                {
                    NewY = 0;
                }
                else if (NewY >= MapSize.Y)
                {
                    NewY = MapSize.Y - 1;
                }

                if (NewX != CursorPosition.X || NewY != CursorPosition.Y)
                {
                    //Update the camera if needed.
                    if (CursorPosition.X - CameraPosition.X - 3 < 0 && CameraPosition.X > -3)
                    {
                        --CameraPosition.X;
                    }
                    else if (CursorPosition.X - CameraPosition.X + 3 >= ScreenSize.X && CameraPosition.X + ScreenSize.X < MapSize.X + 3)
                    {
                        ++CameraPosition.X;
                    }

                    if (CursorPosition.Y - CameraPosition.Y - 3 < 0 && CameraPosition.Y > -3)
                    {
                        --CameraPosition.Y;
                    }
                    else if (CursorPosition.Y - CameraPosition.Y + 3 >= ScreenSize.Y && CameraPosition.Y + ScreenSize.Y < MapSize.Y + 3)
                    {
                        ++CameraPosition.Y;
                    }

                    CursorPosition.X = NewX;
                    CursorPosition.Y = NewY;
                    CursorMoved      = true;
                }
            }
            bool CanKeyboardMove = false;

            if (InputHelper.InputLeftHold() || InputHelper.InputRightHold() || InputHelper.InputUpHold() || InputHelper.InputDownHold())
            {
                CursorHoldTime += 1.5f;

                if (CursorHoldTime <= 1.5f)
                {
                    CanKeyboardMove = true;
                }
                else if (CursorHoldTime >= 8)
                {
                    CanKeyboardMove = true;
                    CursorHoldTime -= 8;
                }
            }
            else
            {
                CursorHoldTime = -1;
            }
            //X
            if (InputHelper.InputLeftHold() && CanKeyboardMove)
            {
                //Update the camera if needed.
                if (CursorPosition.X - CameraPosition.X - 3 < 0 && CameraPosition.X > -3)
                {
                    --CameraPosition.X;
                }

                CursorPosition.X -= (CursorPosition.X > 0) ? 1 : 0;
                CursorMoved       = true;
            }
            else if (InputHelper.InputRightHold() && CanKeyboardMove)
            {
                //Update the camera if needed.
                if (CursorPosition.X - CameraPosition.X + 3 >= ScreenSize.X && CameraPosition.X + ScreenSize.X < MapSize.X + 3)
                {
                    ++CameraPosition.X;
                }

                CursorPosition.X += (CursorPosition.X < MapSize.X - 1) ? 1 : 0;
                CursorMoved       = true;
            }
            //Y
            if (InputHelper.InputUpHold() && CanKeyboardMove)
            {
                //Update the camera if needed.
                if (CursorPosition.Y - CameraPosition.Y - 3 < 0 && CameraPosition.Y > -3)
                {
                    --CameraPosition.Y;
                }

                CursorPosition.Y -= (CursorPosition.Y > 0) ? 1 : 0;
                CursorMoved       = true;
            }
            else if (InputHelper.InputDownHold() && CanKeyboardMove)
            {
                //Update the camera if needed.
                if (CursorPosition.Y - CameraPosition.Y + 3 >= ScreenSize.Y && CameraPosition.Y + ScreenSize.Y < MapSize.Y + 3)
                {
                    ++CameraPosition.Y;
                }

                CursorPosition.Y += (CursorPosition.Y < MapSize.Y - 1) ? 1 : 0;
                CursorMoved       = true;
            }

            return(CursorMoved);
        }
        private void UpdateOwner(GameTime gameTime)
        {
            bool IsIdle = true;

            if (Controller.IsButtonDown(MoveRightButtons))
            {
                IsIdle = false;
                Owner.Move(MovementInputs.Right);
            }
            else if (Controller.IsButtonDown(MoveLeftButtons))
            {
                IsIdle = false;
                Owner.Move(MovementInputs.Left);
            }

            if (Controller.IsButtonDown(JumpButtons))
            {
                IsIdle = false;
                Owner.Jump();
            }
            else if (Controller.IsButtonDown(CrouchButtons))
            {
                IsIdle = false;
                Owner.Crouch();
                //Disabled until I can specify which platforms to not fall through.
                //Owner.FallThroughFloor();
            }
            else if (KeyboardHelper.KeyHold(Keys.X))
            {
                IsIdle = false;
                Owner.GoProne();
            }

            if (IsIdle)
            {
                Owner.SetIdle();
            }

            if (Controller.IsButtonReleased(JumpButtons))
            {
                Owner.StopJump();
            }

            if (KeyboardHelper.KeyHold(Keys.Space))
            {
                Owner.UseJetpack(gameTime);
            }
            else
            {
                Owner.Freefall(gameTime);
            }

            if (Controller.IsButtonPressed(ShootButtons))
            {
                Owner.UnholsterWeaponsIfNeeded();
                Owner.UseCombo(gameTime, AttackInputs.LightPress);
            }
            else if (Controller.IsButtonDown(ShootButtons))
            {
                Owner.UnholsterWeaponsIfNeeded();
                Owner.UseCombo(gameTime, AttackInputs.LightHold);
            }

            if (MouseHelper.InputRightButtonPressed())
            {
                Owner.HolsterAndReplaceWeapon(Owner.Weapons.ActiveSecondaryWeapons[0]);
            }
            else if (MouseHelper.InputRightButtonReleased())
            {
                Owner.UseCombo(gameTime, AttackInputs.HeavyPress, Owner.Weapons.ActiveSecondaryWeapons[0], true);
                Owner.UnholsterWeaponsIfNeeded();
            }
            else if (MouseHelper.InputRightButtonHold())
            {
                Owner.UseCombo(gameTime, AttackInputs.HeavyHold, Owner.Weapons.ActiveSecondaryWeapons[0], false);
            }
        }
Example #7
0
 public static bool InputCancelHold()
 {
     return(KeyboardHelper.InputCancelStatus > 0 || MouseHelper.InputRightButtonHold());
 }
 protected override void OnMouseMove(MouseEventArgs e) =>
 MouseHelper.OnLeftButtonMove(this, e, (s, offset, p1, p2) => viewModel?.MoveAllItems(p1, p2));
Example #9
0
        public void Update(double deltaTime)
        {
            var chunks = _worldManager.GetLoadedChunks(_world);

            foreach (var chunk in chunks)
            {
                var chunkPos = chunk.Item1;
                var chunkPositionInWorldCoordinates = new Vector2(chunkPos.X * 16 + 8, chunkPos.Z * 16 + 8);
                if ((_player.Position.Xz - chunkPositionInWorldCoordinates).LengthFast > _renderDistance * 16 + 16)
                {
                    _worldManager.SetChunkToUnload(_world, chunkPos.X, chunkPos.Z);
                }
            }

            _worldManager.UnloadChunks(_world);
            CleanMeshes();
            _player.Update(deltaTime);

            if (KeyboardHelper.IsKeyPressed(Key.P))
            {
                StaticReferences.ParallelMode = !StaticReferences.ParallelMode;
            }
            if (KeyboardHelper.IsKeyPressed(Key.Plus))
            {
                _renderDistance += 1;
            }
            if (KeyboardHelper.IsKeyPressed(Key.Minus))
            {
                _renderDistance = _renderDistance > 1 ? _renderDistance - 1 : _renderDistance;
            }
            if (KeyboardHelper.IsKeyPressed(Key.Escape))
            {
                OnUnload();
                _gameStateManager.SetGameState(null);
            }
            if (MouseHelper.IsKeyPressed(MouseButton.Left))
            {
                HitInfo hitInfo;
                if (_worldManager.CastRay(_world, _player.Position + new Vector3(0, 1.7f, 0f), _player.EyeForward, 20f, out hitInfo))
                {
                    _worldManager.SetBlockIdAt(_world, hitInfo.X, hitInfo.Y, hitInfo.Z, 0);
                }
            }
            if (MouseHelper.IsKeyPressed(MouseButton.Right))
            {
                HitInfo hitInfo;
                if (_worldManager.CastRay(_world, _player.Position + new Vector3(0, 1.7f, 0f), _player.EyeForward, 20f, out hitInfo))
                {
                    var x = hitInfo.X;
                    var y = hitInfo.Y;
                    var z = hitInfo.Z;
                    if (hitInfo.Face == HitInfo.FaceEnum.Left)
                    {
                        x--;
                    }
                    else if (hitInfo.Face == HitInfo.FaceEnum.Right)
                    {
                        x++;
                    }
                    else if (hitInfo.Face == HitInfo.FaceEnum.Top)
                    {
                        y++;
                    }
                    else if (hitInfo.Face == HitInfo.FaceEnum.Bottom)
                    {
                        y--;
                    }
                    else if (hitInfo.Face == HitInfo.FaceEnum.Front)
                    {
                        z++;
                    }
                    else if (hitInfo.Face == HitInfo.FaceEnum.Back)
                    {
                        z--;
                    }
                    _worldManager.SetBlockIdAndMetadataAt(_world, x, y, z, (byte)_selectedBlockId, (byte)_selectedBlockMetadata);
                }
            }
            if (KeyboardHelper.IsKeyPressed(Key.Q))
            {
                _selectedBlockId       = _blockSelector.GetPreviousBlock(_selectedBlockId);
                _selectedBlockMetadata = 0;
            }
            if (KeyboardHelper.IsKeyPressed(Key.E))
            {
                _selectedBlockId       = _blockSelector.GetNextBlock(_selectedBlockId);
                _selectedBlockMetadata = 0;
            }
            if (KeyboardHelper.IsKeyPressed(Key.R))
            {
                _selectedBlockMetadata = _selectedBlockMetadata >= 255 ? 0 : _selectedBlockMetadata + 1;
            }
            if (KeyboardHelper.IsKeyPressed(Key.F))
            {
                _selectedBlockMetadata = _selectedBlockMetadata <= 0 ? 255 : _selectedBlockMetadata - 1;
            }
            if (KeyboardHelper.IsKeyPressed(Key.BracketRight))
            {
                _destroySphereRadius = _destroySphereRadius < 30 ? _destroySphereRadius + 1 : _destroySphereRadius;
            }
            if (KeyboardHelper.IsKeyPressed(Key.BracketLeft))
            {
                _destroySphereRadius = _destroySphereRadius > 1 ? _destroySphereRadius - 1 : _destroySphereRadius;
            }
            if (KeyboardHelper.IsKeyPressed(Key.X))
            {
                HitInfo hitInfo;
                if (_worldManager.CastRay(_world, _player.Position + new Vector3(0, 1.7f, 0f), _player.EyeForward, 800f, out hitInfo))
                {
                    var impactPoint = new Vector3(hitInfo.X, hitInfo.Y, hitInfo.Z);
                    for (int x = hitInfo.X - _destroySphereRadius + 1; x <= hitInfo.X + _destroySphereRadius - 1; x++)
                    {
                        for (int y = hitInfo.Y - _destroySphereRadius + 1; y <= hitInfo.Y + _destroySphereRadius - 1; y++)
                        {
                            for (int z = hitInfo.Z - _destroySphereRadius + 1; z <= hitInfo.Z + _destroySphereRadius - 1; z++)
                            {
                                if ((new Vector3(x, y, z) - impactPoint).LengthFast <= _destroySphereRadius)
                                {
                                    _worldManager.SetBlockIdAt(_world, x, y, z, 0);
                                }
                            }
                        }
                    }
                }
            }
            if (KeyboardHelper.IsKeyPressed(Key.C))
            {
                HitInfo hitInfo;
                if (_worldManager.CastRay(_world, _player.Position + new Vector3(0, 1.7f, 0f), _player.EyeForward, 800f, out hitInfo))
                {
                    var impactPoint = new Vector3(hitInfo.X, hitInfo.Y, hitInfo.Z);
                    for (int x = hitInfo.X - _destroySphereRadius + 1; x <= hitInfo.X + _destroySphereRadius - 1; x++)
                    {
                        for (int y = hitInfo.Y - _destroySphereRadius + 1; y <= hitInfo.Y + _destroySphereRadius - 1; y++)
                        {
                            for (int z = hitInfo.Z - _destroySphereRadius + 1; z <= hitInfo.Z + _destroySphereRadius - 1; z++)
                            {
                                if ((new Vector3(x, y, z) - impactPoint).LengthFast <= _destroySphereRadius)
                                {
                                    _worldManager.SetBlockIdAndMetadataAt(_world, x, y, z, (byte)_selectedBlockId, (byte)_selectedBlockMetadata);
                                }
                            }
                        }
                    }
                }
            }
            if (KeyboardHelper.IsKeyPressed(Key.V))
            {
                HitInfo hitInfo;
                if (_worldManager.CastRay(_world, _player.Position + new Vector3(0, 1.7f, 0f), _player.EyeForward, 800f, out hitInfo))
                {
                    int[,] cupil = new[, ]
                    {
                        { -1, -1, -1, -1, -1, 07, 07, 07, 07, -1, -1, -1, -1 },
                        { -1, -1, -1, 07, 07, 08, 08, 08, 08, 07, -1, -1, -1 },
                        { -1, -1, 07, 00, 00, 00, 00, 00, 08, 08, 07, -1, -1 },
                        { -1, 07, 08, 00, 00, 08, 08, 08, 08, 08, 08, 07, -1 },
                        { 07, 07, 08, 00, 08, 08, 08, 08, 08, 08, 08, 07, -1 },
                        { 07, 08, 00, 08, 08, 08, 08, 15, 08, 08, 15, 07, -1 },
                        { -1, 07, 08, 08, 08, 07, 06, 08, 08, 08, 08, 06, 07 },
                        { 07, 08, 08, 08, 08, 08, 07, 07, 07, 07, 07, 07, -1 },
                        { 07, 00, 08, 07, 08, 08, 08, 08, 08, 08, 07, -1, -1 },
                        { 07, 00, 07, 08, 07, 07, 08, 07, 07, 07, 08, 07, -1 },
                        { -1, 07, 08, 08, 07, -1, 07, -1, -1, -1, 07, -1, -1 },
                        { -1, -1, 07, 07, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
                    };
                    var impactPoint = new Vector3(hitInfo.X, hitInfo.Y, hitInfo.Z);
                    for (int x = 0; x < 13; x++)
                    {
                        for (int y = 11; y >= 0; y--)
                        {
                            if (cupil[y, x] != -1)
                            {
                                _worldManager.SetBlockIdAndMetadataAt(_world, hitInfo.X - 7 + x, hitInfo.Y + 12 - y, hitInfo.Z, (byte)35, (byte)cupil[y, x]);
                            }
                        }
                    }
                }
            }

            var txt = $"Framerate: {_framerate:0.0}\nDirection : {_player.EyeForward.X:0.00} ; {_player.EyeForward.Y:0.00} ; {_player.EyeForward.Z:0.00}\nPosition: {_player.Position.X:0.00} ; {_player.Position.Y:0.00} ; {_player.Position.Z:0.00}\nParallel Mode: {StaticReferences.ParallelMode}\nRender distance: {_renderDistance} chunks\nDestroy sphere radius: {_destroySphereRadius}\nHand: {_blocksProvider.GetBlockForId((byte)_selectedBlockId).Name}:{_selectedBlockMetadata}";

            txt           += $"\nVisible chunks: {_visibleChunks}";
            txt           += $"\nVisible blocks: {_gpuBlocks}";
            _text.Str      = txt;
            _text.Position = new Vector2(5, _height - 5);
        }
Example #10
0
 void SetDemoModulePresenterContent(object content)
 {
     MouseHelper.WaitIdle();
     _demoModulePresenter.Content = content;
 }
        private void UpdateOwner(GameTime gameTime)
        {
            if (GrenadeCooldown > 0)
            {
                GrenadeCooldown -= gameTime.ElapsedGameTime.TotalSeconds;
            }

            bool IsIdle = true;

            if (InputHelper.InputRightHold() || KeyboardHelper.KeyHold(Keys.D))
            {
                IsIdle = false;
                Owner.Move(MovementInputs.Right);
            }
            else if (InputHelper.InputLeftHold() || KeyboardHelper.KeyHold(Keys.A))
            {
                IsIdle = false;
                Owner.Move(MovementInputs.Left);
            }

            if (InputHelper.InputUpHold() || KeyboardHelper.KeyHold(Keys.W))
            {
                IsIdle = false;
                Owner.Jump();
            }
            else if (InputHelper.InputDownPressed() || KeyboardHelper.KeyPressed(Keys.S))
            {
                IsIdle = false;
                Owner.StartCrouch();
                //Disabled until I can specify which platforms to not fall through.
                //Owner.FallThroughFloor();
            }
            else if (InputHelper.InputDownHold() || KeyboardHelper.KeyHold(Keys.S))
            {
                IsIdle = false;
                Owner.Crouch();
                //Disabled until I can specify which platforms to not fall through.
                //Owner.FallThroughFloor();
            }
            else if (KeyboardHelper.KeyHold(Keys.X))
            {
                IsIdle = false;
                Owner.GoProne();
            }

            if (IsIdle)
            {
                Owner.SetIdle();
            }

            if (InputHelper.InputUpReleased() || KeyboardHelper.KeyReleased(Keys.W))
            {
                Owner.StopJump();
            }

            if (KeyboardHelper.KeyHold(Keys.Space))
            {
                Owner.UseJetpack(gameTime);
            }
            else
            {
                Owner.Freefall(gameTime);
            }

            if (KeyboardHelper.KeyPressed(Keys.R))
            {
                for (int W = 0; W < Owner.Weapons.ActivePrimaryWeapons.Count; W++)
                {
                    Weapon ActiveWeapon = Owner.Weapons.ActivePrimaryWeapons[W];
                    if (ActiveWeapon.ReloadCombo != null && ActiveWeapon.ActiveCombo == null)
                    {
                        ActiveWeapon.ActiveCombo = ActiveWeapon.NoneCombo;
                    }
                }
                Owner.Reload();
            }
            else if (MouseHelper.InputLeftButtonPressed())
            {
                Owner.UnholsterWeaponsIfNeeded();
                Owner.UseCombo(gameTime, AttackInputs.LightPress);
            }
            else if (MouseHelper.InputLeftButtonHold())
            {
                Owner.UnholsterWeaponsIfNeeded();
                Owner.UseCombo(gameTime, AttackInputs.LightHold);
            }

            if (GrenadeCooldown <= 0)
            {
                if (MouseHelper.InputRightButtonPressed())
                {
                    if (Owner.Weapons.ActiveSecondaryWeapons.Count > 0)
                    {
                        Owner.HolsterAndReplaceWeapon(Owner.Weapons.ActiveSecondaryWeapons[0]);
                    }
                    else
                    {
                        Owner.UseCombo(gameTime, AttackInputs.HeavyPress);
                    }
                }
                else if (MouseHelper.InputRightButtonReleased())
                {
                    if (Owner.Weapons.ActiveSecondaryWeapons.Count > 0)
                    {
                        Owner.UseCombo(gameTime, AttackInputs.HeavyPress, Owner.Weapons.ActiveSecondaryWeapons[0], true);
                        Owner.UnholsterWeaponsIfNeeded();
                        GrenadeCooldown = 1;
                    }
                }
                else if (MouseHelper.InputRightButtonHold())
                {
                    if (Owner.Weapons.ActiveSecondaryWeapons.Count > 0)
                    {
                        Owner.UseCombo(gameTime, AttackInputs.HeavyHold, Owner.Weapons.ActiveSecondaryWeapons[0], false);
                    }
                    else
                    {
                        Owner.UseCombo(gameTime, AttackInputs.HeavyHold);
                    }
                }
            }

            if (KeyboardHelper.KeyPressed(Keys.D1))
            {
                Owner.ChangeWeapon(-1);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D2))
            {
                Owner.ChangeWeapon(0);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D3))
            {
                Owner.ChangeWeapon(1);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D4))
            {
                Owner.ChangeWeapon(2);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D5))
            {
                Owner.ChangeWeapon(3);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D6))
            {
                Owner.ChangeWeapon(4);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D7))
            {
                Owner.ChangeWeapon(5);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D8))
            {
                Owner.ChangeWeapon(6);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D9))
            {
                Owner.ChangeWeapon(7);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D0))
            {
                Owner.ChangeWeapon(8);
            }
        }
Example #12
0
 public static void ResetState()
 {
     KeyboardHelper.ResetState();
     MouseHelper.ResetState();
 }
Example #13
0
        public override void DoUpdate(GameTime gameTime)
        {
            Map.ListLayer[Map.ActiveLayerIndex].LayerGrid.AddDrawablePoints(AttackChoice, Color.FromNonPremultiplied(255, 0, 0, 190));

            if (InputHelper.InputConfirmPressed() || MouseHelper.InputLeftButtonReleased())
            {
                ActiveSquad.CurrentLeader.CurrentAttack.UpdateAttack(ActiveSquad.CurrentLeader, ActiveSquad.Position, Map.CursorPosition,
                                                                     Map.GetTerrainType(Map.CursorPosition.X, Map.CursorPosition.Y, Map.ActiveLayerIndex), ActiveSquad.CanMove);

                if (!ActiveSquad.CurrentLeader.CurrentAttack.CanAttack)
                {
                    Map.sndDeny.Play();
                    return;
                }

                int TargetSelect = 0;
                //Verify if the cursor is over one of the possible MV position.
                while ((Map.CursorPosition.X != AttackChoice[TargetSelect].X || Map.CursorPosition.Y != AttackChoice[TargetSelect].Y) &&
                       ++TargetSelect < AttackChoice.Count)
                {
                    ;
                }
                //If nothing was found.
                if (TargetSelect >= AttackChoice.Count)
                {
                    return;
                }

                Map.TargetSquadIndex = -1;

                for (int P = 0; P < Map.ListPlayer.Count; P++)
                {
                    //Find if a Unit is under the cursor.
                    TargetSelect = Map.CheckForSquadAtPosition(P, Map.CursorPosition, Vector3.Zero);
                    //If one was found.
                    if (TargetSelect >= 0)
                    {
                        if (Map.ListPlayer[ActivePlayerIndex].Team != Map.ListPlayer[P].Team)//If it's an ennemy.
                        {
                            Map.PrepareSquadsForBattle(ActiveSquad, Map.ListPlayer[P].ListSquad[TargetSelect]);

                            SupportSquadHolder ActiveSquadSupport = new SupportSquadHolder();
                            ActiveSquadSupport.PrepareAttackSupport(Map, ActivePlayerIndex, ActiveSquad, Map.ListPlayer[P].ListSquad[TargetSelect]);

                            SupportSquadHolder TargetSquadSupport = new SupportSquadHolder();
                            TargetSquadSupport.PrepareDefenceSupport(Map, P, Map.ListPlayer[P].ListSquad[TargetSelect]);

                            Map.ComputeTargetPlayerDefence(ActiveSquad, ActiveSquadSupport, ActivePlayerIndex, Map.ListPlayer[P].ListSquad[TargetSelect], TargetSquadSupport, P);

                            break;
                        }
                    }
                }
                Map.sndConfirm.Play();
            }
            else
            {
                bool CursorMoved = Map.UpdateMapNavigation();
                if (CursorMoved)
                {
                    BattlePreview = new BattlePreviewer(Map, ActiveSquad, ActiveSquad.CurrentLeader.CurrentAttack);
                }
                BattlePreview.UpdateUnitDisplay();
            }
        }
Example #14
0
        private static void TestRivenStuff()
        {
            var c  = new GameCapture();
            var rp = new RivenParser();
            var ss = new ScreenStateHandler();

            var image = "test.png";
            var b     = c.GetFullImage();

            b.Save("test.png");
            b.Dispose();

            var p       = new ChatParser();
            var results = p.ParseChatImage(new Bitmap(image), true, true, 27).Where(r => r is ChatMessageLineResult).Cast <ChatMessageLineResult>();

            var clean  = new ImageCleaner();
            var coords = new CoordinateList();

            results.SelectMany(r => r.ClickPoints).ToList().ForEach(i => coords.Add(i.X, i.Y));
            clean.SaveClickMarkers("test.png", "test_marked.png", coords);

            var mouse = new MouseHelper();

            var index = 0;
            var sw    = new Stopwatch();

            foreach (var clr in results.Where(r => r is ChatMessageLineResult).Cast <ChatMessageLineResult>())
            {
                foreach (var click in clr.ClickPoints)
                {
                    b = c.GetFullImage();
                    if (ss.IsChatOpen(b))
                    {
                        //Hover over riven
                        System.Threading.Thread.Sleep(17);
                        mouse.MoveTo(click.X, click.Y);

                        //Click riven
                        System.Threading.Thread.Sleep(17);
                        mouse.Click(click.X, click.Y);
                        System.Threading.Thread.Sleep(17);
                    }

                    //Move mouse out of the way
                    mouse.MoveTo(0, 0);
                    sw.Restart();
                    var tries = 0;
                    while (true)
                    {
                        try
                        {
                            var bitmap2 = c.GetFullImage();
                            if (ss.GetScreenState(bitmap2) == ScreenState.RivenWindow)
                            {
                                var crop = rp.CropToRiven(bitmap2);
                                crop.Save(index.ToString() + ".png");
                                crop.Dispose();
                                bitmap2.Dispose();
                                break;
                            }
                            bitmap2.Dispose();
                        }
                        catch { }
                        tries++;
                        if (tries > 15)
                        {
                            Console.WriteLine("Riven not detected! Abort!");
                            break;
                        }
                    }
                    Console.WriteLine("Got \"riven\" in " + sw.Elapsed.TotalSeconds + " seconds");

                    //Hover over exit
                    System.Threading.Thread.Sleep(33);
                    mouse.MoveTo(3816, 2013);

                    //Click exit
                    var bitmap = c.GetFullImage();
                    if (ss.GetScreenState(bitmap) == ScreenState.RivenWindow)
                    {
                        System.Threading.Thread.Sleep(17);
                        mouse.Click(3816, 2013);
                        System.Threading.Thread.Sleep(17);
                    }
                    bitmap.Dispose();

                    //Move mouse out of the way
                    System.Threading.Thread.Sleep(17);
                    mouse.MoveTo(0, 0);

                    System.Threading.Thread.Sleep(17);
                    index++;
                }
            }
            //c.Dispose();
        }
Example #15
0
        public Window1()
        {
            InitializeComponent();

            Library.Init();

            _screen = new Screen();

            _browser = new EyetrackerBrowser();
            _browser.EyetrackerFound += _browser_EyetrackerFound;
            _browser.EyetrackerRemoved += _browser_EyetrackerRemoved;
            _browser.EyetrackerUpdated += _browser_EyetrackerUpdated;

            MouseHelper mh = new MouseHelper(camera);
            mh.EventSource = viewPort;

            _eyePair = new EyePair(visualModel);

            const double radius = 0.05;
            DiffuseMaterial cylinderMaterial = new DiffuseMaterial();
            cylinderMaterial.Brush = Brushes.OrangeRed;

            _leftGazeVector = new Cylinder();
            _leftGazeVector.Radius1 = radius;
            _leftGazeVector.Radius2 = radius;
            _leftGazeVector.Material = cylinderMaterial;

            _rightGazeVector = new Cylinder();
            _rightGazeVector.Radius1 = radius;
            _rightGazeVector.Radius2 = radius;
            _rightGazeVector.Material = cylinderMaterial;

            DiffuseMaterial axisMaterial = new DiffuseMaterial(Brushes.Lime);

            Cylinder xAxis = new Cylinder();
            xAxis.Radius1 = radius;
            xAxis.Radius2 = radius;
            xAxis.Point1 = new Point3D(0.0, 0.0, 0.0);
            xAxis.Point2 = new Point3D(1.0, 0.0, 0.0);
            xAxis.Material = axisMaterial;

            Cylinder yAxis = new Cylinder();
            yAxis.Radius1 = radius;
            yAxis.Radius2 = radius;
            yAxis.Point1 = new Point3D(0.0, 0.0, 0.0);
            yAxis.Point2 = new Point3D(0.0, 1.0, 0.0);
            yAxis.Material = axisMaterial;

            Cylinder zAxis = new Cylinder();
            zAxis.Radius1 = radius;
            zAxis.Radius2 = radius;
            zAxis.Point1 = new Point3D(0.0, 0.0, 0.0);
            zAxis.Point2 = new Point3D(0.0, 0.0, 1.0);
            zAxis.Material = axisMaterial;

            visualModel.Children.Add(_leftGazeVector);
            visualModel.Children.Add(_rightGazeVector);
            visualModel.Children.Add(_screen);
            visualModel.Children.Add(xAxis);
            visualModel.Children.Add(yAxis);
            visualModel.Children.Add(zAxis);

            for (int i = 0; i < 12; i++)
            {
                Cylinder edge = new Cylinder();
                edge.Radius1 = 0.1;
                edge.Radius2 = 0.1;
                edge.Point1 = new Point3D(0.0, 0.0, 0.0);
                edge.Point2 = new Point3D(0.0, 0.0, 1.0);
                edge.Material = cylinderMaterial;

                _headBox.Add(edge);
                visualModel.Children.Add(edge);
            }
        }
Example #16
0
        private void OnTileEvent(object sender, ServerEventArgs e)
        {
            lock (_tileEventSync)
            {
                if (e.ServerEvent is TileUpdatedEvent)
                {
                    var ev = (TileUpdatedEvent)e.ServerEvent;

                    // TODO: review this. We are changing ServerEntity without notifying others.
                    //
                    // This code makes the ImageBoxView and its TileViews all out-of-sync.
                    // The Tiles referenced by the ServerEntity of the ImageBoxView still references the old Tile entities.
                    // If another object observes PropertyChange event on the ImageBoxView.ServerEntity to detect
                    // changes, it may stop working after this.
                    //
                    ServerEntity = ev.Tile;

                    var performance = PerformanceMonitor.CurrentInstance;
                    if (performance.CurrentTile == this)
                    {
                        if (ev.Tile != null && ev.Tile.Image != null)
                        {
                            performance.LogImageDraw(ev.Tile.Image.Length);
                        }
                    }

                    Draw(ev.Identifier, ev.Tile.Image);

                    performance.RenderingLag--;
                }
                else if (e.ServerEvent is ContextMenuEvent)
                {
                    OnContextMenuEvent((e.ServerEvent as ContextMenuEvent));
                }
                else if (e.ServerEvent is PropertyChangedEvent)
                {
                    var ev = (PropertyChangedEvent)e.ServerEvent;
                    if (ev.PropertyName == "Selected")
                    {
                        ServerEntity.Selected = (bool)ev.Value;
                        if (ServerEntity.Selected)
                        {
                            MouseHelper.SetActiveElement(this);
                        }

                        UpdateBorder();
                        return;
                    }
                    if (ev.PropertyName == "HasCapture")
                    {
                        ServerEntity.HasCapture = (bool)ev.Value;
                        return;
                    }
                    if (ev.PropertyName == "Image")
                    {
                        //ServerEntity.Image = (byte[])ev.Value;
                        Draw(ev.Identifier, (byte[])ev.Value);
                        return;
                    }
                    if (ev.PropertyName == "Cursor")
                    {
                        OnCursorChanged(ev.Value as AppServiceReference.Cursor);
                        return;
                    }
                    if (ev.PropertyName == "MousePosition")
                    {
                        OnMousePositionChanged((Position)ev.Value);
                    }
                    if (ev.PropertyName == "HasCapture")
                    {
                        ServerEntity.HasCapture = (bool)ev.Value;
                        return;
                    }
                    if (ev.PropertyName == "InformationBox")
                    {
                        OnInformationBoxChanges(ev.Value as InformationBox);
                        return;
                    }
                }
            }
        }
Example #17
0
        private void Image_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var trayIcon = (sender as Decorator).DataContext as NotifyIcon;

            trayIcon?.IconMouseUp(e.ChangedButton, MouseHelper.GetCursorPositionParam(), System.Windows.Forms.SystemInformation.DoubleClickTime);
        }
Example #18
0
        public override void Update()
        {
            if (mDrawRectangle.Contains(MouseHelper.PositionPoint))
            {
                if (MouseHelper.Instance.IsClickedLeft)
                {
                    foreach (Data d in mEntity)
                    {
                        if (d.Texture.CollisionBox.Contains(MouseHelper.PositionPoint) && MouseHelper.Instance.IsClickedLeft)
                        {
                            SelectRectangleObject.Position   = d.Texture.Position;
                            SelectRectangleObject.IsSelected = true;
                            GameLogic.GhostData = d;
                            if (d.Name == "IconMoveArea")
                            {
                                GameLogic.EState = EditorState.PlaceWayPoint;
                            }
                            else if (d.Name == "IconEventArea")
                            {
                                GameLogic.EState = EditorState.PlaceEventArea;
                            }
                            else if (d.Name.Contains("wolf") | d.Name.Contains("witch") | d.Name.Contains("spider"))
                            {
                                GameLogic.EState = EditorState.PlaceEnemy;
                            }
                            else if (d.Name.Contains("Collectable"))
                            {
                                GameLogic.EState = EditorState.PlaceCollectable;
                            }
                            else if (d.Name.Contains("Item") || d.Name.Contains("laterne"))
                            {
                                GameLogic.EState = EditorState.PlaceItem;
                            }
                            else if (d.Name.Contains("Light"))
                            {
                                GameLogic.EState = EditorState.PlaceLight;
                            }
                            else if (InteractiveObjectDataManager.Instance.HasElement(d.Name))
                            {
                                GameLogic.EState = EditorState.PlaceInteractiveObject;
                            }
                            else if (d.Name.Contains("Ground"))
                            {
                                GameLogic.EState = EditorState.PlaceGround;
                            }

                            else
                            {
                                GameLogic.EState = EditorState.PlaceSprites;
                            }
                            break;
                        }
                        else
                        {
                            SelectRectangleObject.IsSelected = false;
                            GameLogic.SelectedEntity         = null;
                            GameLogic.EState = EditorState.Standard;
                        }
                    }
                    MouseHelper.ResetClick();
                }
                else if (!MouseHelper.Instance.IsClickedLeft)
                {
                    foreach (Data d in mEntity)
                    {
                        if (d.Texture.CollisionBox.Contains(MouseHelper.PositionPoint))
                        {
                            MouseOverObject   = true;
                            ObjectDescription = d.Name;
                            return;
                        }
                        else
                        {
                            MouseOverObject = false;
                        }
                    }
                }
            }
            MouseOverObject = false;
        }
Example #19
0
 public static bool InputConfirmHold()
 {
     return(KeyboardHelper.InputConfirmStatus > 0 || MouseHelper.InputLeftButtonHold());
 }
Example #20
0
 void Start()
 {
     mouseHelper = GetComponent <MouseHelper>();
 }
Example #21
0
 public static bool InputConfirmPressed()
 {
     return(KeyboardHelper.InputPressed(KeyboardHelper.InputConfirmStatus) || MouseHelper.InputLeftButtonPressed());
 }
Example #22
0
 public static Point GetMousePosition(UIElement zoomControl, UIElement area)
 {
     // Convert position from zoomcontrol space to graph space
     return(zoomControl.TranslatePoint(MouseHelper.GetMousePosition(zoomControl), area));
 }
Example #23
0
 private void Control_OnMouseMove(object sender, MouseEventArgs e) =>
 MouseHelper.OnLeftButtonMove((UIElement)sender, e, Move);
Example #24
0
        public bool OnBeforeContextMenu(IWebBrowser browserControl, IContextMenuParams parameters)
        {
            var chromiumWebBrowser = browserControl as ChromiumWebBrowser;

            if (chromiumWebBrowser != null)
            {
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    try
                    {
                        var customContextMenu = chromiumWebBrowser.ContextMenu;
                        customContextMenu.MenuItems.Clear();
                        if (parameters.IsEditable)
                        {
                            customContextMenu.MenuItems.Add(new MenuItem("撤销", (s, e) => { chromiumWebBrowser.Undo(); }));
                            customContextMenu.MenuItems.Add(new MenuItem("重做", (s, e) => { chromiumWebBrowser.Redo(); }));
                            customContextMenu.MenuItems.Add(new MenuItem("-"));
                        }

                        /*if (parameters.HasImageContents)
                         * {
                         *  customContextMenu.MenuItems.Add(new MenuItem("图片另存为", (s, e) => { chromiumWebBrowser.Copy(); }));
                         *  customContextMenu.MenuItems.Add(new MenuItem("-"));
                         * }*/
                        customContextMenu.MenuItems.Add(new MenuItem("剪切", (s, e) => { chromiumWebBrowser.Cut(); }));
                        customContextMenu.MenuItems.Add(new MenuItem("复制", (s, e) => { chromiumWebBrowser.Copy(); }));
                        customContextMenu.MenuItems.Add(new MenuItem("粘贴", (s, e) => { chromiumWebBrowser.Paste(); }));
                        customContextMenu.MenuItems.Add(new MenuItem("-"));
                        customContextMenu.MenuItems.Add(new MenuItem("后退", (s, e) => { chromiumWebBrowser.Back(); })
                        {
                            Enabled = chromiumWebBrowser.CanGoBack
                        });
                        customContextMenu.MenuItems.Add(new MenuItem("前进", (s, e) => { chromiumWebBrowser.Forward(); })
                        {
                            Enabled = chromiumWebBrowser.CanGoForward
                        });
                        customContextMenu.MenuItems.Add(new MenuItem("刷新", (s, e) => { chromiumWebBrowser.Reload(); })
                        {
                            Enabled = chromiumWebBrowser.CanReload
                        });

                        /*customContextMenu.MenuItems.Add(new MenuItem("-"));
                         * customContextMenu.MenuItems.Add(new MenuItem("缩小",
                         *  (s, e) =>
                         *  {
                         *      chromiumWebBrowser.ZoomLevel /= 1.2;
                         *  }));
                         * customContextMenu.MenuItems.Add(new MenuItem("放大",
                         *  (s, e) => { chromiumWebBrowser.ZoomLevel *= 1.2; }));
                         * customContextMenu.MenuItems.Add(new MenuItem("默认显示大小",
                         *  (s, e) =>
                         *  {
                         *      chromiumWebBrowser.ZoomLevel = 1;
                         *  }));*/
                        customContextMenu.MenuItems.Add(new MenuItem("-"));
                        customContextMenu.MenuItems.Add(new MenuItem("打印", (s, e) => { chromiumWebBrowser.Print(); }));

                        Point point;
                        if (MouseHelper.GetCursorPos(out point))
                        {
                            int top = 0, left = 0;
                            if (WindowState.Normal.Equals(Application.Current.MainWindow.WindowState))
                            {
                                top  = (int)Application.Current.MainWindow.Top + 20;
                                left = (int)Application.Current.MainWindow.Left + 8;
                            }
                            customContextMenu.Show(chromiumWebBrowser, new Point(point.X - left, point.Y - top - 62));
                        }
                    }
                    catch (Exception exception)
                    {
                        _loggor.Error(exception);
                    }
                }));
            }
            return(false);
        }
Example #25
0
        public void Update()
        {
            var direction = (MouseHelper.GetWorldPosition() - transform.position).normalized;

            Rigidbody.MovePosition(transform.position + direction * Speed * Time.deltaTime);
        }
Example #26
0
 void Awake()
 {
     Instance = this;
 }
Example #27
0
    void Start()
    {
        mouseHelper = GetComponent<MouseHelper>();

        gameCamera = GameObject.Find("GameCamera").camera;
        gameCameraOffset = gameCamera.transform.position;

        editorCrane = GameObject.Find("EditorCrane");

        // TODO: Change this
        var backgroundObj = GameObject.Find("GUIEditorBlockBackground");
        guiBlockBackground = backgroundObj.GetComponent<GUITexture>();
        backgroundObj.transform.position = new Vector3(-1, -1, 0);
    }
Example #28
0
        /*private void OnTargetSelected(TargetSelected e) {
         *  if (e.Target != null) {
         *      BeginMoving();
         *  }
         * }*/

        private void BeginMoving()
        {
            StopMoving();

            //var speed = Actor.Compute(Speed);
            var raycast  = MouseHelper.Raycast();
            var position = raycast.point;

            Target = raycast.transform.gameObject;

            //var distance = Vector3.Distance(new Vector3(raycast.point.x, 0, raycast.point.z), new Vector3(Actor.transform.position.x, 0, Actor.transform.position.z));

            //MovementEffect = Actor.AddEffect(RunEffect);

            /*if (Distance > 3) {
             *  MovementEffect = Actor.AddEffect(RunEffect);
             * }
             * else {
             *  MovementEffect = Actor.AddEffect(WalkEffect);
             *  speed /= 2;
             * }*/

            /*if (targettable != null) {
             *  Movement = Actor.Create<MoveToObject>(cursor => {
             *      cursor.Speed = speed;
             *      cursor.Target = targettable.gameObject;
             *  });
             *
             *  Movement.AsPromise().Then(() => {
             *      TryInteract(targettable.gameObject);
             *  });
             * }
             * else {
             *  Movement = Actor.Create<FollowCursor>(cursor => { cursor.Speed = speed; });
             * }*/

            if (!Target.HasComponent <Targettable>())
            {
                Target = gameObject;
                //target = Instantiate(MovementIndicator);
                //target.transform.position = new Vector3(position.x, transform.position.y, position.z);

                this.GetOrAdd <FollowCursor>();
            }

            /*Movement = Actor.Add<MoveToObject>(move => {
             *  move.Speed = speed;
             *  move.Target = target;
             * });*/

            Actor.With <MovementController>(controller => {
                controller.SetDestination(Target);
            });

            /*Movement.AsPromise().Then(() => {
             *  if(IsTemporary) {
             *      //target.Delete();
             *  }
             *  else {
             *      //TryInteract(targettable.gameObject);
             *  }
             *
             *  StopMoving();
             * });*/
        }
        public override void Update(GameTime gameTime)
        {
            float DrawY = PanelY + 32;
            int CurrentAllMutatorsIndex = (int)(MouseHelper.MouseStateCurrent.Y - DrawY) / 20 + AvailableMutatorsValue;
            if (CurrentAllMutatorsIndex >= 0 && CurrentAllMutatorsIndex < ListAvailableMutators.Count && MouseHelper.InputLeftButtonPressed()
                && MouseHelper.MouseStateCurrent.X >= LeftPanelX && MouseHelper.MouseStateCurrent.X < LeftPanelX + PanelWidth - 20)
            {
                SelectedAvailableMutatorsIndex = CurrentAllMutatorsIndex;
                ActiveMutator = ListAvailableMutators[CurrentAllMutatorsIndex];
            }

            int CurrentActiveMutatorsIndex = (int)(MouseHelper.MouseStateCurrent.Y - DrawY) / 20 + ActiveMutatorsValue;
            if (CurrentActiveMutatorsIndex >= 0 && CurrentActiveMutatorsIndex < ListActiveMutators.Count && MouseHelper.InputLeftButtonPressed()
                && MouseHelper.MouseStateCurrent.X >= RightPanelX && MouseHelper.MouseStateCurrent.X < RightPanelX + PanelWidth - 20)
            {
                SelectedActiveMutatorsIndex = CurrentActiveMutatorsIndex;
                ActiveMutator = ListActiveMutators[CurrentActiveMutatorsIndex];
            }

            foreach (IUIElement ActiveButton in ArrayMenuButton)
            {
                ActiveButton.Update(gameTime);
            }
        }
Example #30
0
    // Use this for initialization
    void Start()
    {
        gameplay = this;

        _MainCamera = (Camera)gameObject.GetComponent("Camera");

        _SelectionListWindow = new SelectionListWindow(Screen.width / 2, Screen.height / 2 + 100);

        _AbilityManagerList = new SelectionListGenericWindow(Screen.width / 2, Screen.height / 2 + 100);

        _SelectionCardNameWindow = new SelectionCardNameWindow(Screen.width / 2 - 50, Screen.height / 2);
        _SelectionCardNameWindow.CreateCardList();
        _SelectionCardNameWindow.SetGame(this);

        _DecisionWindow = new DecisionWindow(Screen.width / 2, Screen.height / 2 + 100);
        _DecisionWindow.SetGame(this);

        _NotificationWindow = new NotificacionWindow(Screen.width / 2, Screen.height / 2 + 100);
        _NotificationWindow.SetGame(this);

        FromHandToBindList = new List<Card>();

        AttackedList = new List<Card>();

        UnitsCalled = new List<Card>();

        EnemySoulBlastQueue = new List<Card>();

        _PopupNumber = new PopupNumber();

        _MouseHelper = new MouseHelper(this);
        GameChat = new Chat();

        opponent = PlayerVariables.opponent;

        playerHand = new PlayerHand();
        enemyHand = new EnemyHand();

        field = new Field(this);
        enemyField = new EnemyField(this);
        guardZone = new GuardZone();
        guardZone.SetField(field);
        guardZone.SetEnemyField(enemyField);
        guardZone.SetGame(this);

        fieldInfo = new FieldInformation();
        EnemyFieldInfo = new EnemyFieldInformation();

        Data = new CardDataBase();
        List<CardInformation> tmpList = Data.GetAllCards();
        for(int i = 0; i < tmpList.Count; i++)
        {
            _SelectionCardNameWindow.AddNewNameToTheList(tmpList[i]);
        }

        //camera = (CameraPosition)GameObject.FindGameObjectWithTag("MainCamera").GetComponent("CameraPosition");
        //camera.SetLocation(CameraLocation.Hand);

        LoadPlayerDeck();
        LoadEnemyDeck();

        gamePhase = GamePhase.CHOOSE_VANGUARD;

        bDrawing = true;
        bIsCardSelectedFromHand = false;
        bPlayerTurn = false;

        bDriveAnimation = false;
        bChooseTriggerEffects = false;
        DriveCard = null;

        //Texture showed above a card when this is selected for an action (An attack, for instance)
        CardSelector = GameObject.FindGameObjectWithTag("CardSelector");
        _CardMenuHelper = (CardHelpMenu)GameObject.FindGameObjectWithTag("CardMenuHelper").GetComponent("CardHelpMenu");
        _GameHelper = (GameHelper)GameObject.FindGameObjectWithTag("GameHelper").GetComponent("GameHelper");

        bPlayerTurn = PlayerVariables.bFirstTurn;

        //ActivePopUpQuestion(playerDeck.DrawCard());
        _CardMenu = new CardMenu(this);

        _AbilityManager = new AbilityManager(this);
        _AbilityManagerExt = new AbilityManagerExt();

        _GameHelper.SetChat(GameChat);
        _GameHelper.SetGame(this);

        EnemyTurnStackedCards = new List<Card>();

        dummyUnitObject = new UnitObject();
        dummyUnitObject.SetGame(this);

        stateDynamicText = new DynamicText();
    }
Example #31
0
 private void NotifyIcon_OnMouseMove(object sender, MouseEventArgs e)
 {
     e.Handled = true;
     TrayIcon?.IconMouseMove(MouseHelper.GetCursorPositionParam());
 }
Example #32
0
        /// <summary>
        /// Does the mailing.
        /// </summary>
        public static void DoMail()
        {
            MailList.Load();
            Thread.Sleep(1000);
            MouseHelper.Hook();
            if (!MakeMailReady())
            {
                MouseHelper.ReleaseMouse();
                return;
            }
            AddedItemsStatus answer = ClickItems(true, 12);
            bool             done   = false;

            while (true)
            {
                switch (answer)
                {
                case AddedItemsStatus.ClickedAll:
                    Logging.Write("Mail full sending");
                    MailFrame.ClickSend();
                    Thread.Sleep(3500);
                    if (LazySettings.MacroForMail)
                    {
                        SetMailNameUsingMacro();
                    }
                    else
                    {
                        MailFrame.SetReceiverHooked(LazySettings.MailTo);
                    }
                    Thread.Sleep(500);
                    break;

                case AddedItemsStatus.ClickedSomething:
                    Logging.Write("Mail partly full sending and stopping loop");
                    MailFrame.ClickSend();
                    Thread.Sleep(500);
                    done = true;
                    break;

                case AddedItemsStatus.Error:
                    //Continue the loop as it could just be a single read error.
                    break;

                default:
                    done = true;
                    break;
                }
                if (done)
                {
                    break;
                }
                Thread.Sleep(1000);
                Application.DoEvents();
                answer = ClickItems(false, 12);
            }
            KeyHelper.SendKey("ESC");
            MailFrame.Close();
            MouseHelper.ReleaseMouse();
            CloseAllBags();
            Logging.Write("Brok loop with: " + answer);
        }
Example #33
0
    void InitializeScene()
    {
        // Remove any created items from last game and reset variables
        if (players != null)
        {
            foreach (var p in players)
            {
                Destroy(p.baseObject);
            }

            players = null;
        }

        playerTurnIndex = 0;
        turnState = TurnState.Starting;

        // Initialize references
        guiController = GetComponent<GUIController>();
        editorController = GetComponent<EditorController>();
        fileController = GetComponent<FileController>();

        // Add back editorController if it is not there (it was destoryed for performance )
        if (editorController == null)
        {
            editorController = gameObject.AddComponent<EditorController>();
        }

        blockPrefabs = new List<GameObject>();
        blockPrefabs.Add(GameObject.Find("PB_Square"));
        blockPrefabs.Add(GameObject.Find("PB_Hexagon"));
        blockPrefabs.Add(GameObject.Find("PB_Trapezoid"));
        blockPrefabs.Add(GameObject.Find("PB_Rhombus"));
        blockPrefabs.Add(GameObject.Find("PB_Triangle"));
        blockPrefabs.Add(GameObject.Find("PB_ThinRhombus"));

        blockImages = new List<Texture2D>();
        blockImages.Add((Texture2D)Resources.Load("Texture/FlatSquare"));
        blockImages.Add((Texture2D)Resources.Load("Texture/FlatHexagon"));
        blockImages.Add((Texture2D)Resources.Load("Texture/FlatTrapezoid"));
        blockImages.Add((Texture2D)Resources.Load("Texture/FlatRhombus"));
        blockImages.Add((Texture2D)Resources.Load("Texture/FlatTriangle"));
        blockImages.Add((Texture2D)Resources.Load("Texture/FlatThinRhombus"));

        mouseHelper = GetComponent<MouseHelper>();

        baseHolder = GameObject.Find("BaseHolder");
        factory = GameObject.Find("Factory");
        prefabBase = GameObject.Find("PB_Base");

        activeBaseMarker = GameObject.Find("ActiveBaseMarker");

        cameraObj = GameObject.Find("GameCamera");
        gameCamera = cameraObj.camera;
        radarCameraObj = GameObject.Find("RadarCamera");
        radarCamera = radarCameraObj.camera;
        SetRadarCameraVisible(false);

        shooter = GameObject.Find("Shooter");

        // Hide Factory
        if (hideFactory)
        {
            factory.transform.position = new Vector3(0, 100, 0);
        }
    }
Example #34
0
        private void Image_MouseMove(object sender, MouseEventArgs e)
        {
            var trayIcon = (sender as Decorator).DataContext as NotifyIcon;

            trayIcon?.IconMouseMove(MouseHelper.GetCursorPositionParam());
        }