Example #1
0
        public Runtimeweapon WeaponToRuntimeWeapon(Weapon w, bool isLeft = false)
        {
            GameObject    go   = new GameObject();
            Runtimeweapon inst = go.AddComponent <Runtimeweapon>();

            go.name       = w.itemName;
            inst.instance = new Weapon();
            StaticFunctions.DeepCopyWeapon(w, inst.instance);

            inst.WeaponStats = new WeaponStats();
            WeaponStats w_stats = ResourcesManager.singleton.GetWeaponStats(w.itemName);

            StaticFunctions.DeepCopyWeaponStats(w_stats, inst.WeaponStats);

            inst.weaponModel = Instantiate(inst.instance.modelPrefeb) as GameObject;
            Transform p = states.anim.GetBoneTransform((isLeft) ? HumanBodyBones.LeftHand : HumanBodyBones.RightHand);

            inst.weaponModel.transform.parent = p;

            inst.weaponModel.transform.localPosition    = (isLeft) ? inst.instance.l_model_pos : inst.instance.r_model_pos;
            inst.weaponModel.transform.localEulerAngles = (isLeft) ? inst.instance.l_model_eulers : inst.instance.r_model_eulers;
            inst.weaponModel.transform.localScale       = inst.instance.model_scale;

            inst.w_hook = inst.weaponModel.GetComponentInChildren <WeaponHook>();

            inst.w_hook.InitDamageColliders(states);


            inst.weaponModel.SetActive(false);
            return(inst);
        }
Example #2
0
        public void EquipWeapon(Runtimeweapon w, bool isLeft = false)
        {
            if (isLeft)
            {
                if (leftHandWeapon != null)
                {
                    leftHandWeapon.weaponModel.SetActive(false);
                }

                leftHandWeapon = w;
            }
            else
            {
                if (rightHandWeapon != null)
                {
                    rightHandWeapon.weaponModel.SetActive(false);
                }

                rightHandWeapon = w;
            }


            string targetIlde = w.instance.oh_idle;

            targetIlde += (isLeft) ? "_l" : "_r";
            states.anim.SetBool(StaticStrings.mirror, isLeft);
            states.anim.Play(StaticStrings.changeWeapon);
            states.anim.Play(targetIlde);

            UI.QuickSlot uiSlot = UI.QuickSlot.singleton;
            uiSlot.UpdateSlot((isLeft) ? UI.QSlotType.lh : UI.QSlotType.rh, w.instance.icon);

            w.weaponModel.SetActive(true);
        }
Example #3
0
        public void LoadInventory()
        {
            unarmedRuntime = WeaponToRuntimeWeapon(ResourcesManager.singleton.GetWeapon(unarmedId), false);

            for (int i = 0; i < rh_weapons.Count; i++)
            {
                Runtimeweapon rw =
                    WeaponToRuntimeWeapon(ResourcesManager.singleton.GetWeapon(rh_weapons[i]));

                r_r_weapons.Add(rw);
            }

            for (int i = 0; i < lh_weapons.Count; i++)
            {
                Runtimeweapon rw =
                    WeaponToRuntimeWeapon(ResourcesManager.singleton.GetWeapon(lh_weapons[i]), true);

                r_l_weapons.Add(rw);
            }

            if (r_r_weapons.Count > 0)
            {
                if (r_index > r_r_weapons.Count - 1)
                {
                    r_index = 0;
                }

                rightHandWeapon = r_r_weapons[r_index];
            }

            if (r_l_weapons.Count > 0)
            {
                if (l_index > r_l_weapons.Count - 1)
                {
                    l_index = 0;
                }

                leftHandWeapon = r_l_weapons[l_index];
            }

            if (rightHandWeapon != null)
            {
                EquipWeapon(rightHandWeapon, false);
            }

            if (leftHandWeapon != null)
            {
                EquipWeapon(leftHandWeapon, true);
                hasLeftHandWeapon = true;
            }

            for (int i = 0; i < spell_items.Count; i++)
            {
                SpellToRuntimeSpell(ResourcesManager.singleton.GetSpell(spell_items[i]));
            }
            //hasLeftHandWeapon = (leftHandWeapon != null);

            if (r_spells.Count > 0)
            {
                if (s_index > r_spells.Count)
                {
                    s_index = 0;
                }

                EquipSpell(r_spells[s_index]);
            }

            for (int i = 0; i < consumable_items.Count; i++)
            {
                RuntimeConsumable c = ConsumableToRuntime(ResourcesManager.singleton.GetConsumable(consumable_items[i]));
                r_consum.Add(c);
            }

            if (r_consum.Count > 0)
            {
                if (c_index > r_consum.Count - 1)
                {
                    c_index = 0;
                }

                EquipConsuamble(r_consum[c_index]);
            }

            InitALLDamageColliders(states);
            CloseAllDamageColliders();
        }