コード例 #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);
        }
コード例 #2
0
        public static void DeepCopyWeaponStats(WeaponStats from, WeaponStats to)
        {
            if (from == null)
            {
                Debug.Log(to.weaponId + "weapon stats weren't found, assinging everything as zero");
                return;
            }

            to.weaponId = from.weaponId;
            to.physical = from.physical;
            to.slash    = from.slash;
            to.strike   = from.strike;
            to.thrust   = from.thrust;
            to.magic    = from.magic;
            to.lighting = from.lighting;
            to.fire     = from.fire;
            to.dark     = from.dark;
        }
コード例 #3
0
        public static int CalculateBaseDamage(WeaponStats w, CharacterStats st, float mutiplier = 1)
        {
            float physical = (w.physical * mutiplier) - st.physical;
            float strike   = (w.strike * mutiplier) - st.vs_strike;
            float slash    = (w.slash * mutiplier) - st.vs_slash;
            float thrust   = (w.thrust * mutiplier) - st.vs_thrust;

            float sum = physical + strike + slash + thrust;

            float magic    = (w.magic * mutiplier) - st.magic;
            float fire     = (w.fire * mutiplier) - st.fire;
            float lighting = (w.lighting * mutiplier) - st.lighting;
            float dark     = (w.dark * mutiplier) - st.dark;

            sum += magic + fire + lighting + dark;

            if (sum <= 0)
            {
                sum = 1;
            }

            return(Mathf.RoundToInt(sum));
        }