protected override void OnSimulateUpdate()
        {
            if (BB.KeyList.Find(match => match.Key == "shoot").IsDown&& Interval > 0)
            {
                if (timer > Interval)
                {
                    timer = 0;
                    if (cBullet)
                    {
                        StartCoroutine(shoot());
                    }
                    else
                    {
                        CB.Shoot();
                    }
                }
                else
                {
                    timer += Time.deltaTime;
                }
            }
            else if (BB.KeyList.Find(match => match.Key == "shoot").IsReleased)
            {
                timer = Interval;
            }

            if (cBullet)
            {
                Tools.PrivateTools.SetPrivateField(CB, "isShooting", true);
            }
        }
Example #2
0
        private IEnumerator Shoot()
        {
            ShootEnabled = false;

            GameObject bulletClone = null;

            if (BulletNumber > 0 || StatMaster.GodTools.InfiniteAmmoMode)
            {
                if (bullet.Custom)
                {
                    ////克隆子弹物体
                    //bulletClone = (GameObject)Instantiate(bullet.bulletObject, CB.boltSpawnPos.position, CB.boltSpawnPos.rotation);
                    //bulletClone.SetActive(true);
                    ////子弹施加推力并且继承炮身速度
                    ////try { bulletClone.GetComponent<Rigidbody>().velocity = CB.Rigidbody.velocity; } catch { }
                    //bulletClone.GetComponent<Rigidbody>().AddForce(-transform.up * CB.boltSpeed * Strength);
                    //炮身施加后坐力
                    //gameObject.GetComponent<Rigidbody>().AddForce(knockBackSpeed * Strength * Mathf.Min(bullet.bulletObject.transform.localScale.x, bullet.bulletObject.transform.localScale.z) * transform.up);

                    bulletClone = (GameObject)Instantiate(bullet.bulletObject, CB.boltSpawnPos.position, CB.boltSpawnPos.rotation);
                    //bulletClone.SetActive(true);
                    //bulletClone.GetComponent<Rigidbody>().AddForce(-transform.up * CB.boltSpeed * Strength);
                }
                else if (CB.boltObject.gameObject.activeSelf == false)
                {
                    bulletClone = (GameObject)Instantiate(CB.boltObject.gameObject, CB.boltSpawnPos.position, CB.boltSpawnPos.rotation);
                }
            }

            float randomDelay = UnityEngine.Random.Range(0f, RandomDelay);

            yield return(new WaitForSeconds(randomDelay));

            if (bulletClone != null)
            {
                bulletClone.SetActive(true);
                bulletClone.GetComponent <Rigidbody>().AddForce(-transform.up * CB.boltSpeed * Strength);
            }

            if (!firstShotFired)
            {
                CB.Shoot();
            }

            BulletNumber--;
            firstShotFired = false;

            yield return(new WaitForSeconds(Interval));

            if (EnhancementEnabled)
            {
                ShootEnabled = true;
            }
        }
Example #3
0
        protected virtual IEnumerator Shoot()
        {
            ShootEnabled = false;

            if (StatMaster.GodTools.InfiniteAmmoMode && !firstShotFired)
            {
                CB.Shoot();
            }
            else
            {
                firstShotFired = false;
            }

            yield return(new WaitForSeconds(IntervalSlider.Value));

            ShootEnabled = true;
            yield break;
        }
Example #4
0
        public override void SimulateUpdateAlways()
        {
            if (StatMaster.isClient)
            {
                return;
            }
            if (Key25.IsPressed && 自动索敌.IsActive)
            {
                currentLocking = MyTargetSelector();
                LockingTimer   = currentLocking ? 0 : -1;
            }

            //烧坏
            if (HasBurnedOut && !StatMaster.GodTools.UnbreakableMode)
            {
                currentLocking = null; LockingTimer = -1;
                currentTarget  = null;
            }

            if (自动索敌.IsActive)
            {
                return;
            }

            //鼠标瞄准模式
            if (模式.Value == 1 && !聪明模式.IsActive)
            {
                AcquireTarget(Camera.main.ScreenPointToRay(Input.mousePosition));
            }
            //按键瞄准模式
            if (Key1.IsPressed && !HasBurnedOut && 模式.Value == 0)
            {
                AcquireTarget(Camera.main.ScreenPointToRay(Input.mousePosition));
            }

            //按键瞄准模式-取消
            if (Key2.IsPressed && 模式.Value == 0)
            {
                currentLocking = null; LockingTimer = -1;
                currentTarget  = null;
            }

            //后坐力
            if (VisualController == null)
            {
                return;
            }
            if (VisualController.Block == null)
            {
                return;
            }
            if (VisualController.Block.jointsToMe == null)
            {
                return;
            }
            foreach (Joint Jo in VisualController.Block.jointsToMe)
            {
                if (VisualController == null)
                {
                    return;
                }
                if (VisualController.Block == null)
                {
                    return;
                }
                if (VisualController.Block.jointsToMe == null)
                {
                    return;
                }
                if (Jo.GetComponentInParent <CanonBlock>())
                {
                    CanonBlock cb = Jo.GetComponentInParent <CanonBlock>();
                    cb.knockbackSpeed = 8000 * ((100 - KnockBackStablizierAdjuster.Value) / 100);
                    cb.randomDelay    = 0.000001f;
                    shoott            = StatMaster.isMP ? shoott : Input.GetMouseButtonDown(0);
                    if (FireOnMouseClick.IsActive && 模式.Value == 1 && shoott)
                    {
                        cb.Shoot();
                    }
                }
            }
            shoott = false;
        }
Example #5
0
 /// <summary>
 /// Shoots the cannon.
 /// </summary>
 public void Shoot()
 {
     cb.Shoot();
 }