Пример #1
0
        /// <summary>
        /// Raised first when the object comes into existance. Called
        /// even if script is not enabled.
        /// </summary>
        void Awake()
        {
            // Don't destroyed automatically when loading a new scene
            DontDestroyOnLoad(gameObject);

            // Initialize the manager
            CombatManager.Awake();
        }
Пример #2
0
        /// <summary>
        /// Called after the Awake() and before any Update() is called.
        /// </summary>
        public IEnumerator Start()
        {
            // Create the coroutine here so we don't re-create over and over
            WaitForEndOfFrame lWaitForEndOfFrame = new WaitForEndOfFrame();

            // Loop endlessly so we can process the combat
            while (true)
            {
                yield return(lWaitForEndOfFrame);

                CombatManager.EndOfFrameUpdate();
            }
        }
Пример #3
0
        /// <summary>
        /// Grab all the combat targets that could be affected by the style and weapon
        /// </summary>
        /// <param name="rStyle">AttackStyle that defines the field-of-attack</param>
        /// <param name="rWeapon">Weapon that is currently being used</param>
        /// <param name="rCombatTargets">List of CombatTargets we will fill with the results</param>
        /// <param name="rIgnore">Combatant to ignore. Typically this is the character asking for the query.</param>
        /// <returns></returns>
        public virtual int QueryCombatTargets(AttackStyle rAttackStyle, IWeaponCore rWeapon, List <CombatTarget> rCombatTargets, Transform rIgnore)
        {
            IWeaponCore lWeapon = (rWeapon != null ? rWeapon : mPrimaryWeapon);

            CombatFilter lFilter = new CombatFilter(rAttackStyle);

            lFilter.MinDistance = (rAttackStyle.MinRange > 0f ? rAttackStyle.MinRange : _MinMeleeReach + lWeapon.MinRange);
            lFilter.MaxDistance = (rAttackStyle.MaxRange > 0f ? rAttackStyle.MaxRange : _MaxMeleeReach + lWeapon.MaxRange);

            rCombatTargets.Clear();
            int lTargetCount = CombatManager.QueryCombatTargets(_Transform, CombatOrigin, lFilter, rCombatTargets, rIgnore);

            return(lTargetCount);
        }