/// <summary> /// Shoot bullets in all angle in current frame. /// </summary> public void ShootAllAngleByFrame() { Vector3 newRotation = this.transform.localEulerAngles; Vector3 recordRotation = newRotation; for (int count = 0; count < 360 / mDegreePerShoot; ++count) { switch (mShootAxis) { case JCS_Axis.AXIS_X: newRotation.x = mDegreePerShoot * count; break; case JCS_Axis.AXIS_Y: newRotation.y = mDegreePerShoot * count; break; case JCS_Axis.AXIS_Z: newRotation.z = mDegreePerShoot * count; break; } transform.localEulerAngles = newRotation; mShootAction.Shoot(); } transform.localEulerAngles = recordRotation; mShooted = true; }
/// <summary> /// Process/Handle the inputs from the user. /// </summary> private void ProcessInput() { if (JCS_Input.GetMouseByAction(mShootAction.KeyAct, mShootAction.MouseButton) || JCS_Input.GetKeyByAction(mShootAction.KeyAct, mShootAction.ShootKeyCode)) { if (mShootAction.GetCheckAbleToShootFunction().Invoke()) { // do call back mShootAction.GetShootCallback().Invoke(); // shoot a bullet. for (int count = 0; count < mShootAction.ShootCount; ++count) { mShootAction.Shoot(); } } } }
/// <summary> /// /// </summary> /// <param name="processIndex"> thread id. </param> private void Sequence(int processIndex) { // get the timer from the thread float newTimer = mTimers.at(processIndex); // add time to timer newTimer += Time.deltaTime; // check if we can shoot or not if (mTimePerShoot < newTimer) { int totalShootCount = mShootCount.at(processIndex); int currentShootCount = mShootCounter.at(processIndex); if (currentShootCount == totalShootCount) { // Remove Thread. EndProcessSequence(processIndex); return; } Vector3 spawnPos = this.transform.position; // if stay in the same position if (mSequenceStay) { spawnPos = mShootPos.at(processIndex); } if (mShootGapEffect) { spawnPos.y += currentShootCount * mShootGap; } // direction. bool direction = mShootDirection.at(processIndex); // shoot a bullet if (mInSequenceEffect) { bool theSub = true; // meaning the head of the bullet in sequence. if (currentShootCount == 0) { theSub = false; if (mDamageApplying != null) { mShootAction.Shoot(spawnPos, direction, mDamageApplying, currentShootCount, theSub, mTargetsPerSequence.at(processIndex)); } else { mShootAction.Shoot(spawnPos, direction, mHit, currentShootCount, theSub, mTargetsPerSequence.at(processIndex)); } // after set the damage set it back to null mDamageApplying = null; } // process the sub bullet in sequence else { mShootAction.Shoot(spawnPos, direction, mHit, currentShootCount, theSub, mTargetsPerSequence.at(processIndex)); } } else { mShootAction.Shoot(spawnPos, direction, 1, currentShootCount, false); } ++currentShootCount; // update new count, in order // to spawn next bullet mShootCounter.set(processIndex, currentShootCount); newTimer = 0; } // update timer mTimers.set(processIndex, newTimer); }