public override void Execute(Sis owner)
        {
            GameObject model = owner.anim.gameObject;

            owner.aiming = model.AddComponent <IKAiming>();
            owner.aiming.Init(owner);
        }
        public override void Execute(Sis owner)
        {
            Weapon weapon = owner.inventory.currentWeapon;

            Weapon.RuntimeWeapon runtime = weapon.runtime;
            int bullets = runtime.currentBullets;

            isShooting.value = owner.isShooting;

            //Update Shooting Variables for FX and Ballistics
            Vector3 origin = (runtime.weaponTip == null ? runtime.modelInstance.transform.position : runtime.weaponTip.position);
            Vector3 dir    = owner.movementValues.aimPosition - origin;

            //Shooting
            if (owner.isShooting && !startedShooting)
            {
                startedShooting = true;

                if (bullets > 0)
                {
                    if (Time.realtimeSinceStartup - runtime.lastFired > weapon.fireRate)
                    {
                        runtime.lastFired = Time.realtimeSinceStartup;

                        //Ballistics
                        if (weapon.ballistics != null)
                        {
                            weapon.ballistics.Execute(owner, weapon, dir);
                        }

                        //Recoil and FX
                        runtime.weaponFX.Shoot(dir);
                        owner.aiming.StartRecoil();

                        //Decrement Bullets
                        if (weapon.decrementBulletsOnShoot)
                        {
                            runtime.currentBullets--;
                            if (runtime.currentBullets < 0)
                            {
                                runtime.currentBullets = 0;
                            }
                        }
                    }
                }
                else                 //Reload if out of bullets
                {
                    startedShooting   = false;
                    isShooting.value  = false;
                    owner.isShooting  = false;
                    owner.isReloading = true;
                }
            }

            //Delay
            if (startedShooting)
            {
                DelayStopShooting(owner);
            }
        }
        public override void Execute(Sis owner)
        {
            CapsuleCollider collider = owner.GetComponent <CapsuleCollider>();
            Vector3         center   = collider.center;

            center.y        = newY;
            collider.center = center;
        }
Exemple #4
0
 public override void Execute(Sis owner)
 {
     if (owner.inventory.SpawnCurrentWeapon(owner.anim.GetBoneTransform(HumanBodyBones.RightHand)))
     {
         //Update IK
         owner.aiming.UpdateWeaponAiming(owner.inventory.currentWeapon);
     }
 }
Exemple #5
0
 public override void Execute(Sis owner)
 {
     if (owner.anim == null)
     {
         Debug.Log("No Animator Found in action MovementAnimations");
         return;
     }
     owner.anim.SetFloat(floatName, owner.movementValues.moveAmount, 0.1f, owner.delta);
 }
Exemple #6
0
        public override void Execute(Sis owner)
        {
            Weapon weapon = owner.inventory.currentWeapon;

            Weapon.RuntimeWeapon runtime = weapon.runtime;

            isReloading.value = owner.isReloading;
            //Reloading
            if (owner.isReloading)
            {
                if (runtime.magazineSize < runtime.magazineCapacity)
                {
                    if (runtime.currentBullets == 0)
                    {
                        //Chik Chik
                    }
                    else                     //Start Reloading!
                    {
                        owner.isShooting = false;
                        //Start Animation
                        if (owner.reloadingDoOnce)
                        {
                            Debug.Log("Starting reload");
                            int bulletsNeeded = runtime.magazineCapacity - runtime.magazineSize;
                            if (runtime.currentBullets < bulletsNeeded)
                            {
                                bulletsNeeded = runtime.currentBullets;
                            }

                            owner.anim.SetBool("Reload", true);
                            owner.anim.SetInteger("AmmoToLoad", bulletsNeeded);
                            owner.reloadingDoOnce = false;
                            owner.doneReloading   = false;
                        }
                        else
                        {
                            //Reload at End of Animation
                            if (owner.doneReloading)
                            {
                                Debug.Log("Finishing reload");
                                owner.anim.SetBool("Reload", false);
                                owner.isReloading     = false;
                                owner.doneReloading   = false;
                                owner.reloadingDoOnce = true;
                                owner.inventory.ReloadCurrentWeapon();
                            }
                        }
                    }
                }
                else                 //Magazine is Full. Can't Reload
                {
                    owner.isReloading = false;
                }
            }
        }
 private void DelayStopShooting(Sis owner)
 {
     //yield return new WaitForSeconds(1f);
     shootingTimer += owner.delta;
     if (shootingTimer > shootingLength)
     {
         isShooting.value = false;
         owner.isShooting = false;
         startedShooting  = false;
         shootingTimer    = 0;
     }
 }
 public override bool CheckCondition(Sis owner)
 {
     if (owner)
     {
         if (reversed)
         {
             return(!owner.isAiming);
         }
         return(owner.isAiming);
     }
     return(false);
 }
Exemple #9
0
        public override void Execute(Sis owner)
        {
            //Debug.Log("SwitchChange: " + owner.switchWeaponChange);
            owner.inventory.ChangeWeaponIndex(owner.switchWeaponChange);
            GameObject oldWeaponModel = owner.inventory.currentWeapon.runtime.modelInstance;
            GameObject oldWeaponTip   = owner.inventory.currentWeapon.runtime.weaponTip.gameObject;

            if (owner.inventory.SpawnCurrentWeapon(owner.anim.GetBoneTransform(HumanBodyBones.RightHand)))
            {
                Destroy(oldWeaponModel);
                Destroy(oldWeaponTip);
                //Update IK
                owner.aiming.UpdateWeaponAiming(owner.inventory.currentWeapon);
            }
        }
        public override void Execute(Sis owner)
        {
            if (isShooting.value && !owner.isAiming)
            {
                gunReadyTimer = gunReadyLength;
            }

            if (gunReadyTimer > 0)
            {
                gunReadyTimer -= owner.delta;
            }

            isGunReady.value = gunReadyTimer > 0;
            owner.isGunReady = isGunReady.value;
        }
        public override void Execute(Sis owner)
        {
            Vector3 origin = owner.mTransform.position;

            origin.y += snapRange;
            Vector3    dir  = -Vector3.up;
            float      dist = snapRange * 2;        //Checks After origin has been pushed up
            RaycastHit hit;

            if (Physics.Raycast(origin, dir, out hit, dist, ~ignoreLayers))
            {
                Vector3 targetPosition = hit.point;
                targetPosition.x          = owner.mTransform.position.x;
                targetPosition.z          = owner.mTransform.position.z;
                owner.mTransform.position = targetPosition;                 //origin must be at bottom
            }
        }
        public override void Execute(Sis owner)
        {
            //Get direction of looking
            Vector3 targetDir = owner.movementValues.lookDirection;

            if (targetDir == Vector3.zero)
            {
                targetDir = owner.mTransform.forward;
            }

            Quaternion targetRotation = Quaternion.LookRotation(targetDir);

            //Rotate Transform towards looking
            float rotateAmount = speed * owner.delta;

            owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation, targetRotation, rotateAmount);
        }
Exemple #13
0
        public void Init(Sis sis)
        {
            owner = sis;
            anim  = owner.anim;

            if (shoulder == null)
            {
                shoulder = anim.GetBoneTransform(HumanBodyBones.RightShoulder);
            }

            CreateAimPivot();
            CreateRightHandTarget();
            //Setup Aim Position
            owner.movementValues.aimPosition    = owner.mTransform.position + owner.mTransform.forward * 15;
            owner.movementValues.aimPosition.y += 1.4f;

            recoilHandler = new RecoilHandler();
        }
        public override void Execute(Sis owner)
        {
            //Get Move Direction
            Vector3 targetDir = owner.movementValues.moveDirection;

            if (targetDir == Vector3.zero)
            {
                targetDir = owner.mTransform.forward;
            }

            //Get Speed of Rotation
            float moveAmount   = owner.movementValues.moveAmount;
            float rotateAmount = moveAmount * speed * owner.delta;

            //Rotate Transform Towards Move Direction
            Quaternion targetRotation = Quaternion.LookRotation(targetDir);

            owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation, targetRotation, rotateAmount);
        }
        public override void Execute(Sis owner)
        {
            Vector3 origin = owner.mTransform.position;
            //origin.y += snapRange;
            Vector3    dir  = -Vector3.up;
            float      dist = snapRange;        //Checks After origin has been pushed up
            RaycastHit hit;

            if (!Physics.Raycast(origin, dir, out hit, dist, ignoreLayers.value))
            {
                /*Vector3 targetPosition = hit.point;
                 * targetPosition.x = owner.mTransform.position.x;
                 * targetPosition.z = owner.mTransform.position.z;
                 * owner.mTransform.position = targetPosition; //origin must be at bottom
                 */
                origin.y -= owner.delta;
                owner.mTransform.position = origin;
            }
            Debug.DrawLine(origin, origin + dir * dist, Color.red);
        }
Exemple #16
0
        public override void Execute(Sis owner)
        {
            //Handles Move Amount
            float moveAmount  = owner.movementValues.moveAmount;
            float targetSpeed = (owner.isCrouching ? crouchSpeed : movementSpeed);

            if (moveAmount > 0.1f)
            {
                owner.rigid.drag = 0;
            }
            else
            {
                owner.rigid.drag = movementDrag;
            }


            //Set Velocity
            Vector3 velocity = owner.mTransform.forward * moveAmount * targetSpeed;

            owner.rigid.velocity = velocity;
        }
        public override void Execute(Sis owner)
        {
            ResourcesManager rm = GameManagers.ResourceManager;

            //Create Weapon
            Weapon targetWeapon = (Weapon)rm.InstiateItem(owner.inventory.weaponName);

            owner.inventory.currentWeapon = targetWeapon;
            targetWeapon.Init();

            //Set Weapon Transform
            Transform rightHand       = owner.anim.GetBoneTransform(HumanBodyBones.RightHand);
            Transform weaponTransform = targetWeapon.runtime.modelInstance.transform;

            weaponTransform.parent           = rightHand;
            weaponTransform.localPosition    = Vector3.zero;
            weaponTransform.localEulerAngles = Vector3.zero;
            weaponTransform.localScale       = new Vector3(1, 1, 1);

            //Update IK
            owner.aiming.UpdateWeaponAiming(targetWeapon);
        }
Exemple #18
0
        public override void Execute(Sis owner)
        {
            if (owner.anim == null)
            {
                Debug.Log("No Animator Found in action MovementAnimations");
                return;
            }
            owner.anim.SetFloat(floatName, owner.movementValues.moveAmount, 0.1f, owner.delta);

            if (owner.isAiming)
            {
                owner.anim.SetFloat("LocomotionSpeedMultiplier", 0.4f);
            }
            else if (owner.isGunReady)
            {
                owner.anim.SetFloat("LocomotionSpeedMultiplier", 0.7f);
            }
            else
            {
                owner.anim.SetFloat("LocomotionSpeedMultiplier", 1f);
            }
        }
        public override void Execute(Sis owner)
        {
            //Handle Move Amount and Direction
            float   moveAmount    = owner.movementValues.moveAmount;
            Vector3 moveDirection = owner.movementValues.moveDirection;
            float   targetSpeed   = (owner.isCrouching ? crouchSpeed : movementSpeed);

            if (moveAmount > 0.1f)
            {
                owner.rigid.drag = 0;
            }
            else
            {
                owner.rigid.drag = movementDrag;
            }


            //Set Velocity
            Vector3 velocity = moveDirection * (moveAmount * targetSpeed);

            owner.rigid.velocity = velocity;
        }
Exemple #20
0
        public override void Execute(Sis owner)
        {
            Weapon weapon = owner.inventory.currentWeapon;

            Weapon.RuntimeWeapon runtime = weapon.runtime;
            int bullets = runtime.currentBullets;

            //Reloading
            if (owner.isReloading)
            {
                int magazine = weapon.magazineBullets;
                if (bullets < magazine)
                {
                    //Start Animation
                    if (!owner.isInteracting)
                    {
                        owner.isInteracting = true;
                        owner.PlayAnimation("Reload");
                        owner.anim.SetBool("InteractingHands", true);
                    }
                    else
                    {
                        //Reload at End of Animation
                        if (!owner.anim.GetBool("InteractingHands"))
                        {
                            owner.isReloading   = false;
                            owner.isInteracting = false;
                            owner.inventory.ReloadCurrentWeapon();
                        }
                    }
                }
                else                 //Magazine is Full. Can't Reload
                {
                    owner.isReloading = false;
                }
            }
        }
Exemple #21
0
 public override bool CheckCondition(Sis owner)
 {
     return(owner.health <= 0);
 }
Exemple #22
0
 public override void Execute(Sis owner)
 {
     owner.aiming.HandleRecoil();
 }
Exemple #23
0
 public override void Execute(Sis owner)
 {
     switcher.Execute(owner);
 }
 public override void Execute(Sis owner)
 {
     action.Execute();
 }
Exemple #25
0
 public override void Execute(Sis owner)
 {
     owner.rigid.velocity = Vector3.zero;
 }