/// <summary> /// Retrieves the specified ability. /// </summary> public override void OnStart() { var target = GetDefaultGameObject(m_TargetGameObject.Value); if (target != m_PrevTarget) { m_CharacterLocomotion = target.GetCachedComponent <UltimateCharacterLocomotion>(); // Find the specified ability. var abilities = m_CharacterLocomotion.GetAbilities(TaskUtility.GetTypeWithinAssembly(m_AbilityType.Value)); if (abilities.Length > 1) { // If there are multiple abilities found then the priority index should be used, otherwise set the ability to the first value. if (m_PriorityIndex.Value != -1) { for (int i = 0; i < abilities.Length; ++i) { if (abilities[i].Index == m_PriorityIndex.Value) { m_Ability = abilities[i]; break; } } } else { m_Ability = abilities[0]; } } else if (abilities.Length == 1) { m_Ability = abilities[0]; } m_PrevTarget = target; } }
/// <summary> /// The character has entered from the zone. /// </summary> /// <param name="characterLocomotion">The character that entered the zone.</param> protected override void CharacterEnter(UltimateCharacterLocomotion characterLocomotion) { // The other collider is the main character. m_Character = characterLocomotion.gameObject; m_CameraController = UnityEngineUtility.FindCamera(m_Character).GetComponent<CameraController>(); // The character must have the primary item in order for it to be equipped. var inventory = m_Character.GetCachedComponent<InventoryBase>(); for (int i = 0; i < m_ItemTypes.Length; ++i) { if (m_ItemTypes[i] == null) { continue; } inventory.PickupItemType(m_ItemTypes[i], 1, 0, false, false); } // Ensure the primary weapon is equipped. var equipUnequipAbilities = characterLocomotion.GetAbilities<EquipUnequip>(); for (int i = 0; i < equipUnequipAbilities.Length; ++i) { if (equipUnequipAbilities[i].ItemSetCategoryIndex == m_CategoryIndex) { equipUnequipAbilities[i].StartEquipUnequip(m_ItemSetIndex, true); break; } } // Setup the character for the zone. StateManager.SetState(m_Character, "FirstPersonSpringZone", true); EventHandler.ExecuteEvent(m_Character, "OnShowUI", false); // First person perspective is required... m_CameraController.SetPerspective(true); // With the combat movement type. m_MovementTypeSwitcher.UpdateMovementType(true, (int)MovementTypesZone.MovementType.FirstPersonCombat); }
public override void OnStart() { var target = GetDefaultGameObject(m_TargetGameObject.Value); if (target != m_PrevTarget) { m_CharacterLocomotion = target.GetCachedComponent <UltimateCharacterLocomotion>(); // Find the specified ability. var abilities = m_CharacterLocomotion.GetAbilities <ItemSetAbilityBase>(); // The category ID must match. for (int i = 0; i < abilities.Length; ++i) { if (abilities[i].ItemSetCategoryID == m_CategoryID.Value) { m_ItemSetAbility = abilities[i]; break; } } if (m_ItemSetAbility == null) { Debug.LogWarning("Error: Unable to find an ItemSet ability with category ID " + m_CategoryID.Value + "."); return; } m_PrevTarget = target; } }
/// <summary> /// Retrieves the use ability. /// </summary> public override void OnStart() { var target = GetDefaultGameObject(m_TargetGameObject.Value); if (target != m_PrevTarget) { m_CharacterLocomotion = target.GetCachedComponent <UltimateCharacterLocomotion>(); // Find the specified ability. var abilities = m_CharacterLocomotion.GetAbilities <Opsive.UltimateCharacterController.Character.Abilities.Items.Reload>(); // The slot ID and action ID must match. for (int i = 0; i < abilities.Length; ++i) { if (abilities[i].SlotID == m_SlotID.Value && abilities[i].ActionID == m_ActionID.Value) { m_ReloadAbility = abilities[i]; break; } } if (m_ReloadAbility == null) { Debug.LogWarning("Error: Unable to find a Reload ability with slot " + m_SlotID.Value + " and action " + m_ActionID.Value); return; } m_PrevTarget = target; } }
/// <summary> /// Initializes the default values. /// </summary> private void Start() { var character = GameObject.FindObjectOfType <DemoManager>().Character; m_CharacterLocomotion = character.GetComponent <UltimateCharacterLocomotion>(); m_Inventory = character.GetComponent <InventoryBase>(); m_EquipUnequipAbilities = m_CharacterLocomotion.GetAbilities <EquipUnequip>(); m_ActiveItemSets = new int[m_EquipUnequipAbilities.Length]; m_Index = -1; for (int i = 0; i < m_Objects.Length; ++i) { m_Objects[i].SetActive(false); } m_ParticleStreamAttributeMonitor.SetActive(false); }
/// <summary> /// An ItemAbility has been activated or deactivated. /// </summary> /// <param name="itemAbility">The ItemAbility activated or deactivated.</param> /// <param name="active">Was the ItemAbility activated?</param> private void OnItemAbilityActive(ItemAbility itemAbility, bool active) { if (!active || IsActive) { return; } // If another use ability is started or a use is active then the character shouldn't be able to counter attack. if (!(itemAbility is Block) || m_CharacterLocomotion.IsAbilityTypeActive <Use>()) { m_ImpactTime = -1; return; } // The block ability has been activated. The source of the block must be a melee weapon - counter attack doesn't work against non-melee weapons. var blockAbility = itemAbility as Block; m_OpponentMeleeWeapon = null; for (int i = 0; i < blockAbility.ImpactSources.Length; ++i) { if (blockAbility.ImpactSources[i] == null || !(blockAbility.ImpactSources[i] is MeleeWeapon)) { continue; } m_OpponentMeleeWeapon = blockAbility.ImpactSources[i] as MeleeWeapon; break; } if (m_OpponentMeleeWeapon == null) { return; } // The opponent must actively be attacking. m_OpponentLocomotion = m_OpponentMeleeWeapon.CharacterLocomotion; m_OpponentUseAbility = null; var useAbilities = m_OpponentLocomotion.GetAbilities <Use>(); if (useAbilities == null || useAbilities.Length == 0) { m_ImpactTime = -1; return; } for (int i = 0; i < useAbilities.Length; ++i) { if (!useAbilities[i].IsActive) { continue; } // The ability is active. Ensure it is using a melee weapon. for (int j = 0; j < useAbilities[i].UsableItems.Length; ++j) { var meleeWeapon = useAbilities[i].UsableItems[j] as MeleeWeapon; if (meleeWeapon != m_OpponentMeleeWeapon) { continue; } m_OpponentUseAbility = useAbilities[i]; break; } if (m_OpponentUseAbility != null) { break; } } if (m_OpponentUseAbility == null) { m_ImpactTime = -1; return; } m_ImpactTime = Time.time; }