void ExecuteAttacks(MouseDirections direction) { // Perform dual-wield attacks if (LeftHandWeapon && RightHandWeapon) { // Hand-specific attacks if (direction == MouseDirections.Right || direction == MouseDirections.DownRight) { RightHandWeapon.ShowWeapon = false; LeftHandWeapon.OnAttackDirection(direction); lastAttackHand = Hand.Left; return; } else if (direction == MouseDirections.Left || direction == MouseDirections.DownLeft) { LeftHandWeapon.ShowWeapon = false; RightHandWeapon.OnAttackDirection(direction); lastAttackHand = Hand.Right; return; } else { // Alternate attack hand alternateAttack = !alternateAttack; } // Fire alternating attack if (alternateAttack) { LeftHandWeapon.OnAttackDirection(direction); lastAttackHand = Hand.Left; } else { RightHandWeapon.OnAttackDirection(direction); lastAttackHand = Hand.Right; } } else if (LeftHandWeapon && !RightHandWeapon) { // Just fire left hand LeftHandWeapon.OnAttackDirection(direction); lastAttackHand = Hand.Left; } else if (!LeftHandWeapon && RightHandWeapon) { // Just fire right hand RightHandWeapon.OnAttackDirection(direction); lastAttackHand = Hand.Right; } else { // No weapons set, no attacks possible lastAttackHand = Hand.None; } }
/// <summary> /// Mouse the cursor in the specified direction by the /// specified amount /// </summary> /// <param name="mouseDir">which way to move</param> /// <param name="pixels">by how much</param> public static void SimulateMoveMouse(MouseDirections mouseDir, int pixels = 1) { int mouseX = Cursor.Position.X; int mouseY = Cursor.Position.Y; int mouseChangeX = 0; int mouseChangeY = 0; switch (mouseDir) { case MouseDirections.East: mouseChangeX += pixels; mouseChangeY = 0; break; case MouseDirections.North: mouseChangeX = 0; mouseChangeY -= pixels; break; case MouseDirections.Northeast: mouseChangeX += pixels; mouseChangeY -= pixels; break; case MouseDirections.Northwest: mouseChangeX -= pixels; mouseChangeY -= pixels; break; case MouseDirections.South: mouseChangeX = 0; mouseChangeY += pixels; break; case MouseDirections.Southeast: mouseChangeX += pixels; mouseChangeY += pixels; break; case MouseDirections.Southwest: mouseChangeX -= pixels; mouseChangeY += pixels; break; case MouseDirections.West: mouseChangeX -= pixels; mouseChangeY = 0; break; } mouseX += mouseChangeX; mouseY += mouseChangeY; Cursor.Position = new Point(mouseX, mouseY); }
private void TrackAction(MouseDirections action) { if (action == lastAction) { actionCount++; return; } else { lastAction = action; actionCount = 0; } }
void ExecuteAttacks(MouseDirections direction) { if (ScreenWeapon) { // Fire screen weapon animation ScreenWeapon.OnAttackDirection(direction); lastAttackHand = Hand.Right; } else { // No weapon set, no attacks possible lastAttackHand = Hand.None; } }
/// <summary> /// Mouse the cursor in the specified direction by the /// specified amount /// </summary> /// <param name="mouseDir">which way to move</param> /// <param name="pixels">by how much</param> public static void SimulateMoveMouse(MouseDirections mouseDir, int pixels = 1) { int mouseX = Cursor.Position.X; int mouseY = Cursor.Position.Y; int mouseChangeX = 0; int mouseChangeY = 0; switch (mouseDir) { case MouseDirections.East: mouseChangeX += pixels; mouseChangeY = 0; break; case MouseDirections.North: mouseChangeX = 0; mouseChangeY -= pixels; break; case MouseDirections.Northeast: mouseChangeX += pixels; mouseChangeY -= pixels; break; case MouseDirections.Northwest: mouseChangeX -= pixels; mouseChangeY -= pixels; break; case MouseDirections.South: mouseChangeX = 0; mouseChangeY += pixels; break; case MouseDirections.Southeast: mouseChangeX += pixels; mouseChangeY += pixels; break; case MouseDirections.Southwest: mouseChangeX -= pixels; mouseChangeY += pixels; break; case MouseDirections.West: mouseChangeX -= pixels; mouseChangeY = 0; break; } mouseX += mouseChangeX; mouseY += mouseChangeY; Cursor.Position = new Point(mouseX, mouseY); }
void Update() { // Automatically update weapons from inventory when PlayerEntity available if (playerEntity != null) UpdateHands(); else playerEntity = GameManager.Instance.PlayerEntity; // Toggle weapon sheath if (InputManager.Instance.ActionStarted(InputManager.Actions.ReadyWeapon)) ToggleSheath(); // Toggle weapon hand if (InputManager.Instance.ActionComplete(InputManager.Actions.SwitchHand)) ToggleHand(); // Do nothing if weapons sheathed if (Sheathed) { ShowWeapons(false); return; } // Reset tracking if user not holding down 'SwingWeapon' button and no attack in progress //if (!Input.GetButton("Fire2") && !isAttacking) if (!InputManager.Instance.HasAction(InputManager.Actions.SwingWeapon) && !isAttacking) { lastAction = MouseDirections.None; actionCount = 0; isAttacking = false; ShowWeapons(true); return; } // Handle attack in progress if (IsLeftHandAttacking() || IsRightHandAttacking()) { isAttacking = true; return; } // If an attack was in progress it is now complete. // Attempt to transfer damage based on last attack hand. if (isAttacking) { // Complete attack isAttacking = false; // Transfer melee damage if (lastAttackHand == 0) MeleeDamage(LeftHandWeapon); else if (lastAttackHand == 1) MeleeDamage(RightHandWeapon); } // Restore weapon visibility ShowWeapons(true); // Track mouse attack and exit if no action registered TrackMouseAttack(); if (lastAction == MouseDirections.None || actionCount < TriggerCount) return; // Time for attacks ExecuteAttacks(); }
void Update() { // Toggle weapon sheath //if (Input.GetKeyDown(KeyCode.Z)) if (InputManager.Instance.ActionStarted(InputManager.Actions.ReadyWeapon)) { ToggleSheath(); } // Do nothing if weapons sheathed if (Sheathed) { ShowWeapons(false); return; } // Reset tracking if user not holding down 'SwingWeapon' button and no attack in progress //if (!Input.GetButton("Fire2") && !isAttacking) if (!InputManager.Instance.HasAction(InputManager.Actions.SwingWeapon) && !isAttacking) { lastAction = MouseDirections.None; actionCount = 0; isAttacking = false; ShowWeapons(true); return; } // Handle attack in progress if (IsLeftHandAttacking() || IsRightHandAttacking()) { isAttacking = true; return; } // If an attack was in progress it is now complete. // Attempt to transfer damage based on last attack hand. if (isAttacking) { // Complete attack isAttacking = false; // Transfer melee damage if (lastAttackHand == 0) { MeleeDamage(LeftHandWeapon); } else if (lastAttackHand == 1) { MeleeDamage(RightHandWeapon); } } // Restore weapon visibility ShowWeapons(true); // Track mouse attack and exit if no action registered TrackMouseAttack(); if (lastAction == MouseDirections.None || actionCount < TriggerCount) { return; } // Time for attacks ExecuteAttacks(); }
void Update() { // Toggle weapon sheath //if (Input.GetKeyDown(KeyCode.Z)) if (InputManager.Instance.ActionStarted(InputManager.Actions.ReadyWeapon)) ToggleSheath(); // Do nothing if weapons sheathed if (Sheathed) { ShowWeapons(false); return; } // Reset tracking if user not holding down 'SwingWeapon' button and no attack in progress //if (!Input.GetButton("Fire2") && !isAttacking) if (!InputManager.Instance.HasAction(InputManager.Actions.SwingWeapon) && !isAttacking) { lastAction = MouseDirections.None; actionCount = 0; isAttacking = false; ShowWeapons(true); return; } // Handle attack in progress if (IsLeftHandAttacking() || IsRightHandAttacking()) { isAttacking = true; return; } // If an attack was in progress it is now complete. // Attempt to transfer damage based on last attack hand. if (isAttacking) { // Complete attack isAttacking = false; // Transfer melee damage if (lastAttackHand == 0) MeleeDamage(LeftHandWeapon); else if (lastAttackHand == 1) MeleeDamage(RightHandWeapon); } // Restore weapon visibility ShowWeapons(true); // Track mouse attack and exit if no action registered TrackMouseAttack(); if (lastAction == MouseDirections.None || actionCount < TriggerCount) return; // Time for attacks ExecuteAttacks(); }
private void TrackAction(MouseDirections action) { if (action == lastAction) { actionCount++; return; } else { lastAction = action; actionCount = 0; } }
/// <summary> /// Class constructor /// </summary> /// <param name="objPoint"></param> /// <param name="enumMouseDirection"></param> public MouseIncrementor(Point objPoint, MouseDirections enumMouseDirection) { _objPoint = objPoint; _initialPoint = _objPoint; _enumMouseDirection = enumMouseDirection; }
public MouseIncrementor(Point objPoint, MouseDirections enumMouseDirection) { _objPoint = objPoint; _enumMouseDirection = enumMouseDirection; }