示例#1
0
        public bool PrepareWeapon()
        {
            if (Weapon)
            {
                if (Weapon.gameObject.IsPrefab()) //if it is a prefab then instantiate it!!
                {
                    if (Transform.childCount > 0)
                    {
                        Object.Destroy(Transform.GetChild(0).gameObject);
                    }

                    Weapon      = GameObject.Instantiate(Weapon, Transform);
                    Weapon.name = Weapon.name.Replace("(Clone)", "");
                    Weapon.transform.SetLocalTransform(Weapon.HolsterOffset);
                }

                var mweapon = Weapon.GetComponent <MWeapon>();
                if (mweapon != null)
                {
                    mweapon.Holster = ID;
                }

                var IsCollectable = Weapon.GetComponent <ICollectable>();
                IsCollectable?.Pick();

                return(true);
            }
            return(false);
        }
示例#2
0
        /// <summary> Performs a Fast equiping of a MWeapon</summary>
        /// <param name="weapon">Weapon to equip</param>
        /// <param name="doParent">Parent the weapon to the Hand, it also resets the scale to 1.1.1</param>
        public virtual void Equip_FAST(MWeapon weapon, bool doParent = true)
        {
            Weapon = weapon;

            if (debug)
            {
                Debug.Log($"<b>{name}:<color=cyan> [FAST EQUIP -> {Weapon.Holster.name} -> {Weapon.name}]</color> </b>");         //Debug
            }
            ExitAim();


            SendMessage(Weapon.IsRightHanded ? FreeRightHand : FreeLeftHand, true);  //IK REINS

            WeaponType   = Weapon.WeaponType;
            WeaponAction = WA.Idle;                                             //Set the Action to Equip
            CombatMode   = true;
            Weapon.PrepareWeapon(this);
            Weapon.GetComponent <ICollectable>()?.Pick();

            Weapon.PlaySound(0); //Play Draw Sound

            if (doParent)
            {
                Weapon.gameObject.SetActive(true);                                                             //Set the Game Object Instance Active
                ParentWeapon();
                Weapon.transform.SetLocalTransform(Weapon.PositionOffset, Weapon.RotationOffset, Vector3.one); //Local position when is Parent to the weapon
            }

            OnEquipWeapon.Invoke(Weapon.gameObject);
        }
示例#3
0
 /// <summary>Send by the Weapons when they are Enabled (CALLED BY SEND MESSAGE MWEAPON)</summary>
 public virtual void WeaponEnabled(MWeapon weapon)
 {
     if (CombatMode && ActiveWeapon.WeaponID == weapon.WeaponID) //means that the weapon that we just use has been disabled
     {
         if (debug)
         {
             Debug.Log($"Active Weapon <B>{weapon.name}</B> Enabled");
         }
     }
 }
示例#4
0
 private void TryInstantiateWeapon(MWeapon Next_Weapon)
 {
     if (!AlreadyInstantiated)
     {
         var WeaponGO = Instantiate(Next_Weapon.gameObject, transform);      //Instanciate the Weapon GameObject
         WeaponGO.SetActive(false);                                          //Hide it to show it later
         Next_Weapon = WeaponGO.GetComponent <MWeapon>();                    //UPDATE THE REFERENCE
         if (debug)
         {
             Debug.Log("<B>" + WeaponGO.name + "</B> Instantiated");
         }
     }
     Weapon = Next_Weapon;
 }
示例#5
0
        private CWeapon BuildHelper(string arg)
        {
            var weapon = new CWeapon();
            var wStats = WeaponParamTable.Instance.Table[arg];
            var model  = new MWeapon();

            weapon.SetModel(model);
            weapon.Model.Data.Abilities      = WeaponAbilityFactory.Instance.CreateNewObject(wStats.Abilities);
            weapon.Model.Data.AccuracyMod    = wStats.AccuracyMod;
            weapon.Model.Data.APMod          = wStats.APMod;
            weapon.Model.Data.ArmorIgnore    = wStats.ArmorIgnore;
            weapon.Model.Data.ArmorPierce    = wStats.ArmorPierce;
            weapon.Model.Data.BlockIgnore    = wStats.BlockIgnore;
            weapon.Model.Data.CustomBullet   = wStats.CustomBullet;
            weapon.Model.Data.CustomFatality = wStats.CustomFatality;
            weapon.Model.Data.Damage         = wStats.Damage;
            weapon.Model.Data.Description    = wStats.Description;
            weapon.Model.Data.Durability     = wStats.MaxDurability;
            foreach (var effect in wStats.Effects)
            {
                var data  = effect.CloneData();
                var clone = EffectBuilder.Instance.BuildEffect(data, effect.Type);
                weapon.Model.Data.Effects.Add(clone);
            }
            weapon.Model.Data.Embed               = wStats.Embed;
            weapon.Model.Data.FatigueMod          = wStats.FatigueMod;
            weapon.Model.Data.InitiativeMod       = wStats.InitiativeMod;
            weapon.Model.Data.MaxDurability       = wStats.MaxDurability;
            weapon.Model.Data.MeleeBlockChance    = wStats.MeleeBlockChance;
            weapon.Model.Data.Name                = wStats.Name;
            weapon.Model.Data.ParryMod            = wStats.ParryMod;
            weapon.Model.Data.RangeMod            = wStats.RangeMod;
            weapon.Model.Data.ShieldDamagePercent = wStats.ShieldDamagePercent;
            weapon.Model.Data.Skill               = wStats.Skill;
            weapon.Model.Data.SpriteFXPath        = wStats.SpriteFXPath;
            weapon.Model.Data.StaminaMod          = wStats.StaminaMod;
            weapon.Model.Data.Tier                = wStats.Tier;
            weapon.Model.Data.WpnType             = wStats.Type;
            weapon.SetParams(wStats);
            weapon.SetView(new VWeapon());
            return(weapon);
        }
示例#6
0
        /// <summary>If the Rider had a weapon before mounting.. equip it.
        /// The weapon need an |IMWeapon| Interface, if not it wont be equiped</summary>
        public virtual void SetWeaponBeforeMounting(MWeapon weapon)
        {
            if (weapon == null)
            {
                return;
            }
            Weapon = weapon;
            if (Weapon)                                        //If the weapon doesn't have IMweapon Interface do nothing
            {
                CombatMode = true;

                Weapon.PrepareWeapon(this);
                Holster_SetActive(Weapon.HolsterID);                                                //Set the Active holster for the Active Weapon

                WeaponType   = Weapon.WeaponType;                                                   //Set the Weapon Type
                WeaponAction = WA.Idle;
                OnEquipWeapon.Invoke(Weapon.gameObject);
                Weapon.GetComponent <ICollectable>()?.Pick();

                ExitAim();

                Weapon.gameObject.SetActive(true);                                      //Set the Game Object Instance Active
                ParentWeapon();

                SendMessage(Weapon.IsRightHanded ? FreeRightHand : FreeLeftHand, true);  //IK REINS Message


                if (debug)
                {
                    Debug.Log($"<b>{name}:<color=cyan> [EQUIP BEFORE MOUNTING -> {Weapon.Holster.name} -> {Weapon.name}]</color> </b>"); //Debug
                }
                Weapon.gameObject.SetActive(true);                                                                                       //Set the Game Object Instance Active
                ParentWeapon();

                Weapon.GetComponent <ICollectable>()?.Pick();
            }
        }
示例#7
0
 public void SetModel(MWeapon m)
 {
     this._model = m;
 }
示例#8
0
 public void SetWeapon(GameObject weap) => Weapon = weap.GetComponent <MWeapon>();
示例#9
0
 public void SetWeapon(MWeapon weap) => Weapon    = weap;