///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <summary> /// Sets the weapon that are in the Inventory /// </summary> /// <param name="Next_Weapon">Game object that it should have an IMWeapon Interface</param> public virtual void SetWeaponByInventory(GameObject Next_Weapon) { StopAllCoroutines(); if (!rider.IsRiding) { return; //Work Only when is riding else Skip } if (Next_Weapon == null) //That means Store the weapon { if (ActiveWeapon) { Store_Weapon(); //Debug.Log("Active Weapon NOT NULL Store the Active Weapon"); } return; } IMWeapon Next_IMWeapon = Next_Weapon.GetComponent <IMWeapon>(); if (Next_IMWeapon == null) { if (ActiveWeapon) { Store_Weapon(); //Debug.Log("Active Weapon NOT NULL and Store because Next Weapon is not Compatible"); } return; //If the Next Weapon doesnot have the IMWeapon Interface dismiss... the next weapon is not compatible } if (Active_IMWeapon == null) { if (!AlreadyInstantiated) { Next_Weapon = Instantiate(Next_Weapon, rider.transform); //Instanciate the Weapon GameObject Next_Weapon.SetActive(false); } SetActiveWeapon(Next_Weapon); Draw_Weapon(); //Debug.Log("Active weapon is NULL so DRAW"); return; } if (Active_IMWeapon.Equals(Next_IMWeapon)) //Option 2 If the Weapon has the Same ID { if (!IsInCombatMode) { Draw_Weapon(); //Debug.Log("Active weapon is the same as the NEXT Weapon and we are NOT in COmbat so DRAW"); } else { Store_Weapon(); //Debug.Log("Active weapon is the same as the NEXT Weapon and we ARE in COmbat so STORE"); } } else //If the weapons are different Swap it { StartCoroutine(SwapWeaponsInventory(Next_Weapon)); //Debug.Log("Active weapon is DIFFERENT to the NEXT weapon so Switch" + Next_Weapon); } }
///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <summary> /// Draw (Set the Correct Parameters to play Draw Weapon Animation) /// </summary> public virtual void Draw_Weapon() { EnableMountAttack(false); //Disable Attack Animations of the Animal ResetRiderCombat(); if (UseInventory) //If is using inventory { if (Active_IMWeapon != null) { SetActiveHolder(Active_IMWeapon.Holder); //Set the Current Holder to the weapon asigned holder } } else //if Use Holders { if (ActiveHolderTransform.childCount == 0) { return; } IMWeapon isCombatible = ActiveHolderTransform.GetChild(0).GetComponent <IMWeapon>(); //Check if the Child on the holder Has a IMWeapon on it if (isCombatible == null) { return; } SetActiveWeapon(ActiveHolderTransform.GetChild(0).gameObject); //Set Active Weapon to the Active Holder Child } _weaponType = GetWeaponType(); //Set the Weapon Type (For the correct Animations) SetAction(Active_IMWeapon.RightHand ? WeaponActions.DrawFromRight : WeaponActions.DrawFromLeft); //Set the Weapon Action to -1 to Draw Weapons From Right or from left -2 SetWeaponIdleAnimState(Active_IMWeapon.RightHand); ActiveAbility = CombatAbilities.Find(ability => ability.TypeOfAbility(Active_IMWeapon)); //Find the Ability for the IMWeapon LinkAnimator(); if (debug) { Debug.Log("Draw: " + ActiveWeapon.name); //Debug } }
/// <summary> Draw (Set the Correct Parameters to play Draw Weapon Animation) </summary> public virtual void Draw_Weapon() { ResetRiderCombat(); if (UseInventory) //If is using inventory { if (ActiveWeapon != null) { SetActiveHolder(ActiveWeapon.Holder); //Set the Current Holder to the weapon asigned holder } } else //if Use Holders { if (ActiveHolderTransform.childCount == 0) { return; } IMWeapon isCombatible = ActiveHolderTransform.GetChild(0).GetComponent <IMWeapon>(); //Check if the Child on the holder Has a IMWeapon on it if (isCombatible == null) { return; } ActiveWeaponGameObject = (ActiveHolderTransform.GetChild(0).gameObject); //Set Active Weapon to the Active Holder Child } WeaponType = GetWeaponType(); //Set the Weapon Type (For the correct Animations) WeaponAction = ActiveWeapon.RightHand ? WA.DrawFromRight : WA.DrawFromLeft; //Set the Weapon Action to -1 to Draw Weapons From Right or from left -2 SetWeaponIdleAnimState(ActiveWeapon.RightHand); SetActiveAbility(); if (debug) { Debug.Log($"Play Draw Animation with: <b>{ActiveWeaponGameObject?.name}</b>"); //Debug } }
/// <summary>Sets the weapon that are in the Inventory</summary> /// <param name="Next_Weapon">Game object that it should have an IMWeapon Interface</param> public virtual void SetWeaponByInventory(GameObject Next_Weapon) { if (!Rider.IsRiding) { return; //Work Only when is riding else Skip } if (UseHolders) { return; //Work Only when is riding else Skip } if (WeaponAction != WA.Idle && WeaponAction != WA.None && WeaponAction != WA.AimLeft && WeaponAction != WA.AimRight && WeaponAction != WA.Hold) { return; //If is not on any of these states then Dont Equip.. } StopAllCoroutines(); if (Next_Weapon == null) //That means Store the weapon { if (ActiveWeaponGameObject) { Store_Weapon(); } if (debug) { Debug.Log("Active Weapon NOT NULL Store the Active Weapon"); } return; } IMWeapon Next_IMWeapon = Next_Weapon.GetComponent <IMWeapon>(); if (Next_IMWeapon == null) { if (ActiveWeaponGameObject) { Store_Weapon(); } if (debug) { Debug.Log("Active Weapon NOT NULL and Store because Next Weapon is not Compatible"); } return; //If the Next Weapon doesnot have the IMWeapon Interface dismiss... the next weapon is not compatible } if (ActiveWeapon == null) //Means there's no weapon active so draw it { if (!AlreadyInstantiated) { Next_Weapon = Instantiate(Next_Weapon, Rider.transform); //Instanciate the Weapon GameObject Next_Weapon.SetActive(false); //Hide it to show it later if (debug) { Debug.Log("<B>" + Next_Weapon.name + "</B> Instantiated"); } } ActiveWeaponGameObject = Next_Weapon; Draw_Weapon(); //Debug.Log("Active weapon is NULL so DRAW"); } else if (ActiveWeapon.Equals(Next_IMWeapon)) //You are trying to draw the same weapon { if (!CombatMode) { Draw_Weapon(); Debug.Log("Active weapon is the same as the NEXT Weapon and we are NOT in Combat so DRAW"); } else { Store_Weapon(); if (debug) { Debug.Log("Active weapon is the same as the NEXT Weapon and we ARE in Combat so STORE"); } } } else //If the weapons are different Swap it { StartCoroutine(SwapWeaponsInventory(Next_Weapon)); if (debug) { Debug.Log("Active weapon is DIFFERENT to the NEXT weapon so Switch" + Next_Weapon); } } }
public override bool TypeOfAbility(IMWeapon weapon) { return(weapon is IGun); }
public abstract bool TypeOfAbility(IMWeapon weapon);