public NPCAttacker(SceneNPC awholeNPC) { _wholeNPC = awholeNPC; IsAttacking = false; _firstUpdate = true; _weapon = _wholeNPC.GetComponentInChildren <SceneWeapon>(); }
public void PerformAction(bool alternate = false) { _alternateModeInProgress = alternate; if (UsedItem != null && UsedItem.GetComponent <SceneWeapon>() != null) { SceneWeapon sw = UsedItem.GetComponent <SceneWeapon>(); if (alternate && sw.WeaponData.IsThrowWeapon && !sw.IsAttacking && !_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Throw")) { sw.IsAttacking = true; sw.CurrentAttackMode = FightSystem.AttackMode.ThrowAttack; _mainAnimator.SetTrigger("Throw"); sw.PrepareToThrowAsWeapon((float)sw.WeaponData["throwForce"]); UsedItem.GetComponent <ActiveObject>().ClearUsedObject(); ActiveObjectsManager.Instance.AddActiveObject(UsedItem.GetComponent <ActiveObject>()); FPPUIManager.Instance.InventoryObject.RemoveItemAfterThrow(); UsedItem = null; } else if (!alternate && sw.WeaponData.IsMeleeWeapon && !sw.IsAttacking && !_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Attack") && !_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Attack(2)")) { sw.IsAttacking = true; sw.CurrentAttackMode = FightSystem.AttackMode.MeleeAttack; string trigStr = Random.Range(0, 2) == 0 ? "Attack" : "Attack2"; _mainAnimator.SetTrigger(trigStr); } else if (!alternate && sw.WeaponData.IsShootingWeapon && !sw.IsAttacking) { sw.IsAttacking = true; sw.CurrentAttackMode = FightSystem.AttackMode.ShootScanAttack; //string trigStr = Random.Range(0, 2) == 0 ? "Attack" : "Attack2"; if (sw.WeaponData.CurrentFireMode == FightSystem.FireMode.Single) { _mainAnimator.SetTrigger("Shoot"); } else { _mainAnimator.SetTrigger("AutoShoot"); } _autofireShots = 1; PerformScanHit(); } /* ??? else if (sw == null && !UsedItem.IsAttacking && !_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Get")) * { * _mainAnimator.SetTrigger("Get"); * }*/ } }
public void PerformScanHit() { if (UsedItem != null) { SceneWeapon sw = UsedItem.GetComponent <SceneWeapon>(); if (sw != null && UsedItem.ItemData != null && sw.IsAttacking) { if (sw.WeaponData.IsMeleeWeapon && sw.WeaponData["scanHit"] != null && (bool)sw.WeaponData["scanHit"] == true) { SceneWeaponHitter[] hitters = UsedItem.GetComponentsInChildren <SceneWeaponHitter>(); Vector3 hitPoint; GameObject hited = FPPUIManager.Instance.CameraLooksOnScanHit((float)sw.WeaponData["meleeRange"], GetFiringAccuracy(), out hitPoint); if (hited != null && hited.GetComponent <SceneDestructible>() != null) { foreach (SceneWeaponHitter swh in hitters) { swh.GeneralHited(hited.GetComponent <SceneDestructible>(), hitPoint); } } sw.IsAttacking = false; } else if (sw.WeaponData.IsShootingWeapon && sw.CurrentAttackMode == FightSystem.AttackMode.ShootScanAttack && sw.WeaponData["scanHit"] != null && (bool)sw.WeaponData["scanHit"] == true) { SceneWeaponHitter[] hitters = UsedItem.GetComponentsInChildren <SceneWeaponHitter>(); Vector3 hitPoint; GameObject hited = FPPUIManager.Instance.CameraLooksOnScanHit((float)sw.WeaponData["shootRange"], GetFiringAccuracy(), out hitPoint); if (hited != null) { SceneDestructible hitesDestr = FindDestructibleObject(hited); if (hitesDestr != null) { foreach (SceneWeaponHitter swh in hitters) { swh.GeneralHited(hitesDestr, hitPoint); } } } sw.InvokeShootEffects(); } } } }
private void Update() { /* * if (_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Attack")) * Debug.Log("Attack"); * if (_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Attack(2)")) * Debug.Log("Attack(2)"); * if (_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Idle")) * Debug.Log("Idle"); * if (_mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("Idle_Other")) * Debug.Log("Idle_Other"); */ _alternateModeInProgress = FPPUIManager.Instance.IsActionInProgress(false); GameManager.Instance.ThePlayerController.SetCameraFOV(_alternateModeInProgress ? int.Parse(EJRConsts.Instance["preciseTargetFov"]) : int.Parse(EJRConsts.Instance["defaultTargetFov"])); //auto fire if (UsedItem != null) { SceneWeapon sw = UsedItem.GetComponent <SceneWeapon>(); if (sw != null && !sw.IsAttacking && _mainAnimator.GetCurrentAnimatorStateInfo(0).IsName("AutoShoot")) { if (FPPUIManager.Instance.IsActionInProgress(true) && (sw.WeaponData.CurrentFireMode != FightSystem.FireMode.Triple || _autofireShots < 3)) { sw.IsAttacking = true; sw.CurrentAttackMode = FightSystem.AttackMode.ShootScanAttack; _autofireShots++; PerformScanHit(); } else { sw.IsAttacking = false; _mainAnimator.SetTrigger("StopAttack"); } } } }
public void SwitchWeaponMode() { if (UsedItem != null) { SceneWeapon sw = UsedItem.GetComponent <SceneWeapon>(); if (sw != null && sw.WeaponData.IsShootingWeapon) { if (sw.WeaponData.CurrentFireMode == FightSystem.FireMode.Single) { if (sw.WeaponData.TripleFireModeEnabled) { sw.WeaponData.CurrentFireMode = FightSystem.FireMode.Triple; } else if (sw.WeaponData.AutoFireModeEnabled) { sw.WeaponData.CurrentFireMode = FightSystem.FireMode.Auto; } } else if (sw.WeaponData.CurrentFireMode == FightSystem.FireMode.Triple) { if (sw.WeaponData.AutoFireModeEnabled) { sw.WeaponData.CurrentFireMode = FightSystem.FireMode.Auto; } else { sw.WeaponData.CurrentFireMode = FightSystem.FireMode.Single; } } else if (sw.WeaponData.CurrentFireMode == FightSystem.FireMode.Auto) { sw.WeaponData.CurrentFireMode = FightSystem.FireMode.Single; } } } }