Example #1
0
        public bool Reload()
        {
            bool          retVal = false;
            RuntimeWeapon c      = weaponManager.GetCurrent();

            if (c.curAmmo < c.w_actual.magazineAmmo)
            {
                if (c.w_actual.magazineAmmo <= c.curCarryingAmmo)
                {
                    c.curAmmo          = c.w_actual.magazineAmmo;
                    c.curCarryingAmmo -= c.curAmmo;
                }
                else
                {
                    c.curAmmo         = c.curCarryingAmmo;
                    c.curCarryingAmmo = 0;
                }

                retVal = true;
                anim.CrossFade("Rifle Reload", 0.2f);
                states.isAiming      = false;
                states.isInteracting = true;
            }

            return(retVal);
        }
Example #2
0
        public void RemoveRuntimeWeapon(RuntimeWeapon rw)
        {
            if (rw.m_instance)
            {
                Destroy(rw.m_instance);
            }

            if (runtimeWeapons.Contains(rw))
            {
                runtimeWeapons.Remove(rw);
            }
        }
Example #3
0
        public RuntimeWeapon WeaponToRuntimeWeapon(Weapon w)
        {
            RuntimeWeapon rw = new RuntimeWeapon();

            rw.w_actual        = w;
            rw.curAmmo         = w.magazineAmmo;
            rw.curCarryingAmmo = w.maxAmmo;

            runtimeWeapons.Add(rw);

            return(rw);
        }
Example #4
0
        public void EquipWeapon(RuntimeWeapon rw)
        {
            Weapon w = rw.w_actual;

            lh_target = rw.w_hook.leftHandIK;

            rh_target.localPosition    = w.m_h_ik.pos;
            rh_target.localEulerAngles = w.m_h_ik.rot;

            basePosition = w.m_h_ik.pos;
            baseRotation = w.m_h_ik.rot;

            onIdleDiableOh = rw.w_actual.onIdleDiableOh;
        }
Example #5
0
        public void EquipRuntimeWeapon(RuntimeWeapon rw)
        {
            if (weaponManager.GetCurrent() != null)
            {
                anim.CrossFade("Switch", 0.2f);
                states.isAiming      = false;
                switchingWeapon      = true;
                states.isInteracting = true;
                UnEquipWeapon(weaponManager.GetCurrent());
            }

            rw.m_instance.SetActive(true);
            a_hook.EquipWeapon(rw);

            anim.SetFloat(StaticStrings.animParamWeaponType, rw.w_actual.WeaponType);
            weaponManager.SetCurrent(rw);
        }
Example #6
0
        public bool ShootWeapon(float t)
        {
            bool retVal = false;

            RuntimeWeapon c = weaponManager.GetCurrent();

            if (c.curAmmo > 0)
            {
                if (t - c.lastFired > c.w_actual.fireRate)
                {
                    retVal = true;
                    c.ShootWeapon();
                    a_hook.RecoilAnim();
                }
            }

            return(retVal);
        }
Example #7
0
        public void CreateRuntimeWeapon(string id, ref RuntimeWeapon r_w_m)
        {
            Weapon        w  = resourcesManager.GetWeapon(id);
            RuntimeWeapon rw = resourcesManager.runtime.WeaponToRuntimeWeapon(w);

            GameObject go = Instantiate(w.modelPrefab);

            rw.m_instance = go;
            rw.w_actual   = w;
            rw.w_hook     = go.GetComponent <WeaponHook>();
            go.SetActive(false);

            Transform p = anim.GetBoneTransform(HumanBodyBones.RightHand);

            go.transform.SetParent(p);
            go.transform.localPosition    = Vector3.zero;
            go.transform.localEulerAngles = Vector3.zero;
            go.transform.localScale       = Vector3.one;

            r_w_m = rw;
        }
Example #8
0
 public void UnEquipWeapon(RuntimeWeapon rw)
 {
     rw.m_instance.SetActive(false);
 }
Example #9
0
 public void SetCurrent(RuntimeWeapon rw)
 {
     curWeapon = rw;
 }