コード例 #1
0
        // Update is called once per frame
        void Update()
        {
            Vector3 DistanceToCenter;

            DistanceToCenter   = Target.transform.position - this.transform.position;
            DistanceToCenter.y = 0; //get rid of the vertical component

            if (FireTurret == true)
            {
                ShootWeapon(DistanceToCenter.normalized);
                FireTurret = false;
            }



            for (int i = 0; i < Bolts.Count; ++i)
            {
                if (Bolts[i].IsEnabled == false)             //if the timer is off and hence beyond its age limit
                {
                    RaydraProjectile CurrentBolt = Bolts[i]; //get the instance
                    Bolts.RemoveAt(i);
                    Destroy(CurrentBolt.gameObject);
                }
                else
                {
                    Bolts[i].transform.position += Bolts[i].TravelPath; //move the projecti
                }
            }


            //Debug.Log("Center is" + DistanceToCenter.magnitude.ToString());
            //   Vector3 DistanceToTarget= Target - Th;
        }
コード例 #2
0
        /*!shoot path is the direction of the that the projectile will travel in
         * \param ShootPath the directon that projectile will move in when fired*/
        public void ShootWeapon(Vector3 ShootPath)
        {
            if (Bolts != null && Bolts.Count < 100)
            {
                RaydraProjectile Projectile = null;
                if (WeaponFired == false)
                {     //if we have not fired the weapon
                    if (WeaponCharger.IsFullyCharged == false)
                    { // if the weapon is not charged fire the smaller bolt
                        Projectile = (RaydraProjectile)Instantiate(Bolt, BoltSpawnPoint.transform.position, BoltSpawnPoint.transform.rotation);
                        // Projectile = (RaydraProjectile)Instantiate(TheBall, TheBall.transform.position, TheBall.transform.rotation);
                    }
                    else
                    {
                        if (!ThePlayer.ReadyToScore())
                        { //the player is not able to score
                            Projectile = (RaydraProjectile)Instantiate(LargeBolt, BoltSpawnPoint.transform.position, BoltSpawnPoint.transform.rotation);

                            WeaponCharger.ChargerReset(); //reset the charger
                        }
                        else
                        {
                            TheBall.BallWasFired();
                            ThePlayer.PlayerBallPossessionState = BallPossessionState.DoseNotHaveBall;
                            Projectile = null;
                        }
                        X8Animator.SetBool("WeaponCharged", false);
                    }
                }
                if (Projectile != null)
                {
                    //shoot the larger bolt faster
                    if (Projectile.tag == "LargeBolt")
                    {
                        Projectile.Path = ShootPath;
                    }
                    else
                    {
                        Projectile.Path = ShootPath * .45f;
                    }

                    //the bolt will live for 4.5 seconds
                    Projectile.LifeLimit = 4.5f;
                    //add the bolt to the list of projectiles
                    Bolts.Add(Projectile);
                }

                WeaponFired = true;
            }
        }
コード例 #3
0
        // Update is called once per frame
        void Update()
        {
            AnimatorStateInfo Layer1State = X8Animator.GetCurrentAnimatorStateInfo(1);


            for (int i = 0; i < Bolts.Count; ++i)
            {
                if (Bolts[i].IsTicking == false)             //if the timer is off and hence beyond its age limit
                {
                    RaydraProjectile CurrentBolt = Bolts[i]; //get the instance
                    Bolts.RemoveAt(i);
                    Destroy(CurrentBolt.gameObject);
                }
                else
                {
                    Bolts[i].transform.position += Bolts[i].TravelPath; //move the projecti
                }
            }


            if (Input.GetButton("Shoot"))
            {
                if (X8Animator.GetBool("Shoot") == false)
                {
                    X8Animator.SetBool("Shoot", true);
                }

                ChargeTimer.TurnTimerOn(); //turn on the charge timer
                ChargeTimer.Update();
            }
            else
            {
                X8Animator.SetBool("Shoot", false);
            }

            if (Input.GetButtonUp("Shoot"))
            {
                //fire the weapon upon the release of the the button
                this.ShootWeapon(CameraFocus.transform.position - Camera.main.transform.position);
                if (WeaponCharged == true) //reset the the charged state of the weapon
                {
                    WeaponCharged = false;
                }

                ChargeTimer.Reset(); //reset the charge time
            }

            if (Layer1State.IsName("Shoot"))
            {
                X8Animator.SetLayerWeight(1, 1);//increase the weigt of the layer with the shoot animation
            }
            else
            {
                /// ThePlayer.PlayerAttackState = AttackMode.NotFiringAbility;
                X8Animator.SetLayerWeight(1, 0);
                if (this.WeaponFired == true)
                {
                    this.WeaponFired = false;
                }
            }
        }
コード例 #4
0
        // Update is called once per frame
        void FixedUpdate()
        {
            AnimatorStateInfo Layer1State = X8Animator.GetCurrentAnimatorStateInfo(1);


            for (int i = 0; i < Bolts.Count; ++i)
            {
                if (Bolts[i].IsEnabled == false || Bolts[i].HitSomething == true) //if the timer is off and hence beyond its age limit
                {
                    RaydraProjectile CurrentBolt = Bolts[i];                      //get the instance
                    Bolts.RemoveAt(i);
                    Destroy(CurrentBolt.gameObject);
                }
                else
                {
                    Bolts[i].transform.position += Bolts[i].TravelPath; //move the projecti
                }
            }

            if (!X8Animator.GetBool("Phase") && !X8Animator.GetBool("Tackle")) //As long as the character if not phasing or tackling
            {                                                                  //start of phase if check
                if (Input.GetButton("Shoot"))
                {
                    ThePlayer.ShootTimer.Reset();       //reset the shoot timer
                    ThePlayer.ShootTimer.TurnTimerOn(); //turn on the shoot timer



                    if (X8Animator.GetBool("Shoot") == false)
                    {
                        X8Animator.SetBool("Shoot", true);
                    }

                    WeaponCharger.EnableCharger(); //turn on the charge timer
                    WeaponCharger.Charging();      //charge the weapon

                    if (WeaponCharger.IsFullyCharged == true)
                    {
                        //when the weapon is charged
                        X8Animator.SetBool("WeaponCharged", true);
                    }
                    else
                    {
                        X8Animator.SetBool("WeaponCharged", false);
                    }
                }
                else
                {
                    X8Animator.SetBool("Shoot", false);
                }


                if (Input.GetButtonUp("Shoot")) //when the button is released
                {
                    this.ShootWeapon((CameraFocus.transform.position - ThePlayer.MyCamera.transform.position).normalized);
                    if (WeaponCharger.IsFullyCharged == true) //reset the the charged state of the weapon
                    {
                        ThePlayer.ShootTimer.Reset();         //reset the shoot timer
                    }
                    WeaponCharger.ChargerReset();             //reset the weapon charger
                }
            } //end of phase of check


            if (Layer1State.IsName("Shoot"))
            {
                X8Animator.SetLayerWeight(1, 1);//increase the weigt of the layer with the shoot animation
            }
            else
            {
                /// ThePlayer.PlayerAttackState = AttackMode.NotFiringAbility;
                X8Animator.SetLayerWeight(1, 0);
                if (this.WeaponFired == true)
                {
                    this.WeaponFired = false;
                }
            }
        }