Beispiel #1
0
        // -----------------------------------------------------------------------------------
        // OnSetWeapon
        // -----------------------------------------------------------------------------------
        public void OnSetWeapon(Item weapon)
        {
            this.weapon = weapon;
            animator.SetBool("IsAttack", false);
            if (weaponModel != null)
            {
                Destroy(weaponModel);
            }
            if (weapon == null)
            {
                animator.SetInteger("WeaponType", -1);
            }
            else
            {
                ItemWeaponTemplate tmpl = (ItemWeaponTemplate)weapon.template;
                weaponModel = (GameObject)Instantiate(tmpl.model);
                weaponModel.transform.parent        = weaponHand.transform;
                weaponModel.transform.localPosition = Vector3.zero;

                //fhiz: if i remove this and weapon models are not perfectly aligned,
                //      they end up upside down etc.
                // weaponModel.transform.localRotation = Quaternion.identity;

                weaponModel.transform.localScale = Vector3.one;
                animator.SetInteger("WeaponType", GetAnimationId(tmpl));
            }
        }
Beispiel #2
0
 // -----------------------------------------------------------------------------------
 // GetAnimationId
 // -----------------------------------------------------------------------------------
 public static int GetAnimationId(ItemWeaponTemplate item)
 {
     if (item is ItemWeaponRangedTemplate)
     {
         return(0);
     }
     if (item is ItemWeaponMeleeTemplate)
     {
         ItemWeaponMeleeTemplate weapon = (ItemWeaponMeleeTemplate)item;
         return(weapon.animationId);
     }
     return(0);
 }