Example #1
0
 public override void Awake()
 {
     blackboard     = Owner.GetComponent <IBlackboard> ();
     boxCollider2D  = Owner.GetComponent <BoxCollider2D> ();
     statCollection = Owner.GetComponent <RPGStatCollection> ();
     controller     = Owner.GetComponent <Monster> ();
 }
Example #2
0
    void Start()
    {
        stats = new RPGDefaultStats();

        var statTypes = Enum.GetValues(typeof(RPGStatType));

        foreach (var statType in statTypes)
        {
            RPGStat stat = stats.GetStat((RPGStatType)statType);
            if (stat != null)
            {
                Debug.Log(string.Format("Stat {0}'s value is {1}",
                                        stat.StatName, stat.StatValue));
            }
        }

        var health = stats.GetStat <RPGStatModifiable>(RPGStatType.Health);

        health.AddModifier(new RPGStatModBasePercent(1.0f));      // 200
        health.AddModifier(new RPGStatModBaseAdd(50f));           // 250
        health.AddModifier(new RPGStatModTotalPercent(1.0f));     // 500
        health.UpdateModifiers();

        foreach (var statType in statTypes)
        {
            RPGStat stat = stats.GetStat((RPGStatType)statType);
            if (stat != null)
            {
                Debug.Log(string.Format("Stat {0}'s value is {1}",
                                        stat.StatName, stat.StatValue));
            }
        }
    }
 public override void Awake()
 {
     statCollection         = Owner.GetComponent <RPGStatCollection> ();
     faceDirectionComponent = Owner.GetComponent <FaceDirectionComponent> ();
     platformController     = Owner.GetComponent <Monster> ();
     blackboard             = Owner.GetComponent <Blackboard> ();
 }
Example #4
0
    // Use this for initialization
    void Start()
    {
        var dieDic = DieTypes.AttackDie;

        stats     = gameObject.AddComponent <RPGDefaultStats>();
        health    = stats.GetStat <RPGVital>(RPGStatType.Health);
        willpower = stats.GetStat <RPGVital>(RPGStatType.Willpower);
        stamina   = stats.GetStat <RPGVital>(RPGStatType.Stamina);
        dex       = stats.GetStat <RPGAttribute>(RPGStatType.Dexterity);
        attackDie = stats.GetStat <RPGAttribute>(RPGStatType.DieType);
        level     = stats.GetStat <RPGAttribute>(RPGStatType.Level);
        attack    = stats.GetStat <RPGAttribute>(RPGStatType.Attack);
        will      = stats.GetStat <RPGAttribute>(RPGStatType.Will);
        defense   = stats.GetStat <RPGAttribute>(RPGStatType.Defense);
        alive     = stats.GetStat <RPGAttribute>(RPGStatType.Alive);
        speed     = stats.GetStat <RPGAttribute>(RPGStatType.Speed);
        evasion   = stats.GetStat <RPGAttribute>(RPGStatType.Evasion);

        ///Modifiy base stats
        ///
        stamina.StatCurrentValue = 0;
        health.StatBaseValue     = health.StatBaseValue;
        health.SetCurrentValueToMax();
        attackDie.StatBaseValue = DieTypes.GetAttackDie(DieTypes.DieType.D4);
        dex.StatBaseValue       = dex.StatBaseValue + 2;
        dex.UpdateLinkers();
    }
Example #5
0
    void OnEnable()
    {
        entity     = GetComponent <Entity>();
        collection = GetComponent <RPGStatCollection>();

        // If the collection is not setup, trigger setup
        if (collection.IsCollectionSetup == false)
        {
            collection.SetupCollection();
        }

        // Get the stat with id of RPGStatType.Health of type RPGVital
        RPGVital health;

        if (collection.TryGetStat(RPGStatType.Health, out health))
        {
            // Connect to the Health stat's events
            health.AddValueListener(OnHealthValueChange);
            health.AddCurrentValueListener(OnHealthCurrentValueChange);

            // Add modifier to Health stat, then update stat's modifier value
            health.AddModifier(new RPGStatModBaseAdd(10.5f));
            health.UpdateModifiers();

            // Update the Health stat's current value to max
            health.SetCurrentValueToMax();
        }
    }
Example #6
0
    // Use this for initialization
    void Start()
    {
        stats  = gameObject.AddComponent <RPGDefaultStats>();
        health = stats.GetStat <RPGVital>(RPGStatType.Health);
        health.OnCurrentValueChange += OnStatValueChange;

        DisplayStatValues();
        Debug.Log(string.Format("_____________________"));
        HealthTest();
        DisplayStatValues();
    }
        private void DisplayCollectionLevelGUI(RPGStatCollection collection)
        {
            // Show controls for editing values of stats in the editor
            GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
            GUILayout.Label("Collection Level");
            GUILayout.EndHorizontal();

            GUILayout.Space(-4);

            GUILayout.BeginVertical("Box");

            GUILayout.BeginHorizontal();
            if (collection.ScaledLevel == 0)
            {
                GUILayout.Label("Level", EditorStyles.miniButtonLeft, GUILayout.Width(80));
            }
            else
            {
                GUILayout.Label("Level(Scaled)", EditorStyles.miniButtonLeft, GUILayout.Width(80));
            }

            GUILayout.Label(collection.Level.ToString(), EditorStyles.miniButtonMid);
            if (GUILayout.Button("+", EditorStyles.miniButtonMid, GUILayout.Width(40)))
            {
                if (Application.isPlaying)
                {
                    collection.ScaleToLevel(collection.Level + 1);
                }
                else
                {
                    collection.SetLevel(collection.NormalLevel + 1);
                }
            }
            if (GUILayout.Button("-", EditorStyles.miniButtonRight, GUILayout.Width(40)))
            {
                if (Application.isPlaying)
                {
                    collection.ScaleToLevel(collection.Level - 1);
                }
                else
                {
                    collection.SetLevel(collection.NormalLevel - 1);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Current Exp", EditorStyles.miniButtonLeft, GUILayout.Width(80));
            GUILayout.Label(collection.CurrentExp.ToString(), EditorStyles.miniButtonMid);
            GUILayout.Label("", EditorStyles.miniButtonRight, GUILayout.Width(80));
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Example #8
0
    /// <summary>
    /// A的攻击是否被B格挡?
    /// 结构如下:
    /// RPGStatCollection
    ///     ‖―― FLAG_DEFENSE 0/1
    ///     ‖―― DEFENSE_DIR 0/1/-1
    /// </summary>
    static public bool IsBlocked(Transform t_A, Transform t_B)
    {
        RPGStatCollection statCollection = t_B.GetComponentInChildren <RPGStatCollection>();

        if (statCollection == null ||
            !statCollection.ContainStat(GlobalSymbol.FLAG_DEFENSE) ||
            !statCollection.ContainStat(GlobalSymbol.DEFENSE_DIR))
        {
            return(false);
        }

        if (statCollection.GetStatValue(GlobalSymbol.FLAG_DEFENSE) == 0f)
        {
            return(false);
        }

        // 格挡方向
        int blockDirection = (int)statCollection.GetStatValue(GlobalSymbol.DEFENSE_DIR);

        // A相对于B的方向
        int A_relative_to_the_B_direction = (int)Mathf.Sign(t_A.position.x - t_B.position.x);

//        BoxCollider2D dBodyCollider = t_B.Find("DefenseBody")?.GetComponent<BoxCollider2D>();

//        if (dBodyCollider != null && dBodyCollider.enabled)
//            blockDirection = (int)Mathf.Sign(dBodyCollider.offset.x);

//        Debug.Log($"DamageDealer::IsBlocked() blockDirection = {blockDirection}" +
//                       $", A_relative_to_the_B_direction = {A_relative_to_the_B_direction}");

        // 标志为0时视为无死角防御
        if (blockDirection == 0)
        {
            return(true);
        }

        if ((A_relative_to_the_B_direction == 1 && blockDirection == 1) ||
            (A_relative_to_the_B_direction == -1 && blockDirection == -1))
        {
            return(true);
        }

        if ((A_relative_to_the_B_direction == 1 && blockDirection == -1) ||
            (A_relative_to_the_B_direction == -1 && blockDirection == 1))
        {
            return(false);
        }

        Debug.LogError($"DamageDealer::IsBlocked() 方法出现问题, blockDirection = {blockDirection}" +
                       $", A_relative_to_the_B_direction = {A_relative_to_the_B_direction}");
        return(false);
    }
    void Start()
    {
        stats = new RPGDefaultStats();

        var health = stats.GetStat <RPGVital>(RPGStatType.Health);

        health.OnCurrentValueChange += OnStatValueChange;

        DisplayStatValues();

        health.StatCurrentValue -= 75;

        DisplayStatValues();
    }
    // Use this for initialization
    void Start()
    {
        stats = this.gameObject.AddComponent <RPGDefaultStats> ();

        var health = stats.GetStat <RPGVital> (RPGStatType.Health);

        health.OnCurrentValueChange += OnStatValueChange;

        DisplayStatValues();

        health.StatCurrentValue -= 75;

        DisplayStatValues();
    }
Example #11
0
        protected virtual void Awake()
        {
            base.Awake();
            base.ignoreGlobalTime = false;
            base.timeLayer        = CupheadTime.Layer.Enemy;

            controller       = GetComponent <Prime31.CharacterController2D>();
            m_SpriteRenderer = transform.Find("ActionAnimator")?.GetComponent <SpriteRenderer>();
            StatCollection   = GetComponent <RPGStatCollection>();

            if (StatCollection == null)
            {
                Debug.LogError($"{gameObject.name} 物体上没有找到<RPGStatCollection>组件,无法继续初始化<Monster>组件");
            }
        }
Example #12
0
    public void OnEnable()
    {
        _statCollection = GetComponent <RPGStatCollection>();
        if (_statCollection != null)
        {
            if (_statCollection.IsCollectionSetup == false)
            {
                _statCollection.SetupCollection();
            }

            if (_statCollection.TryGetStat(_healthType, out _health) == false)
            {
                Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}",
                                       this.name, _healthType.ToString());
            }

            if (_statCollection.TryGetStat(_healthRegenType, out _healthRegen) == false)
            {
                Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}",
                                       this.name, _healthRegenType.ToString());
            }

            if (_statCollection.TryGetStat(_energyType, out _energy) == false)
            {
                Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}",
                                       this.name, _energyType.ToString());
            }

            if (_statCollection.TryGetStat(_energyRegenType, out _energyRegen) == false)
            {
                Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}",
                                       this.name, _energyRegenType.ToString());
            }

            if (_statCollection.TryGetStat(_manaType, out _mana) == false)
            {
                Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}",
                                       this.name, _manaType.ToString());
            }

            if (_statCollection.TryGetStat(_manaRegenType, out _manaRegen) == false)
            {
                Debug.LogWarningFormat("[{0}]: Collection does not contain stat of type {1}",
                                       this.name, _manaRegenType.ToString());
            }
        }
    }
Example #13
0
        public override void Awake()
        {
            base.Awake();
            transform = Owner.transform;
            m_Monster = Owner.GetComponent <Monster>();
            // m_Player = GameManager.Player?.GetComponent<Player.CharacterController2D>();
            // m_Health = Owner.GetComponent<EnemyHealth>();
            m_SpriteRenderer   = transform.Find("ActionAnimator")?.GetComponent <SpriteRenderer>();
            m_StatCollection   = Owner.GetComponent <RPGStatCollection> ();
            pmFSM              = Owner.GetComponent <PlayMakerFSM>();
            behaviourTreeOwner = Owner.GetComponent <NodeCanvas.BehaviourTrees.BehaviourTreeOwner>();

            if (m_StatCollection == null)
            {
                Debug.LogError($"MonsterFsmStateAction::Awake() {Owner.name} 物体上没有找到<RPGStatCollection>组件或字段没有赋值,无法初始化");
            }
        }
Example #14
0
    /// <summary>
    /// 查找目标身上的RPG属性组件
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    static public RPGStatCollection FindObjectStatCollection(GameObject obj)
    {
        if (obj == null)
        {
            return(null);
        }

        RPGStatCollection statCollection = null;

        statCollection = obj.GetComponentInParent <RPGStatCollection>();
        if (statCollection == null)
        {
            statCollection = obj.GetComponentInChildren <RPGStatCollection>();
        }

        return(statCollection);
    }
        public override bool OnCheck()
        {
            return(true);

            Transform target = blackboard.GetValue <Transform> ("Target");

            if (target == null)
            {
                return(false);
            }

            RPGStatCollection statCollection = DamageDealer.FindObjectStatCollection(target.gameObject);

            if (statCollection == null || !statCollection.ContainStat(GlobalSymbol.HP))
            {
                return(false);
            }

            return(statCollection.GetStat <RPGVital> (GlobalSymbol.HP).StatValueCurrent > 0f);
        }
Example #16
0
    // Use this for initialization
    void Start()
    {
        var dieDic = DieTypes.AttackDie;

        stats       = gameObject.AddComponent <RPGDefaultStats>();
        socialStats = gameObject.GetComponent <SocialStats>();
        health      = stats.GetStat <RPGVital>(RPGStatType.Health);
        willpower   = stats.GetStat <RPGVital>(RPGStatType.Willpower);
        stamina     = stats.GetStat <RPGVital>(RPGStatType.Stamina);
        dex         = stats.GetStat <RPGAttribute>(RPGStatType.Dexterity);
        attackDie   = stats.GetStat <RPGAttribute>(RPGStatType.DieType);
        level       = stats.GetStat <RPGAttribute>(RPGStatType.Level);
        attack      = stats.GetStat <RPGAttribute>(RPGStatType.Attack);
        will        = stats.GetStat <RPGAttribute>(RPGStatType.Will);
        defense     = stats.GetStat <RPGAttribute>(RPGStatType.Defense);
        alive       = stats.GetStat <RPGAttribute>(RPGStatType.Alive);
        speed       = stats.GetStat <RPGAttribute>(RPGStatType.Speed);
        evasion     = stats.GetStat <RPGAttribute>(RPGStatType.Evasion);

        if (gameObject.GetComponent <CurrentState>().inCombat)
        {
            SetPlayerStatusBars();
        }


        ///Modifiy base stats
        ///
        health.StatBaseValue += 10;
        health.SetCurrentValueToMax();
        attackDie.StatBaseValue = DieTypes.GetAttackDie(DieTypes.DieType.D4);
        dex.StatBaseValue       = dex.StatBaseValue + 1;
        dex.UpdateLinkers();
        Debug.Log("Player health is: " + health.StatBaseValue);
        Debug.Log("Extroversion: " + socialStats.GetStat(SocialStats.SocialStatType.Extroversion).StatBaseValue);

        ///Tests
        socialStats.SocialStatChange(socialStats.GetStat(SocialStats.SocialStatType.Extroversion));
        Debug.Log("Extroversion after increment: " + socialStats.GetStat(SocialStats.SocialStatType.Extroversion).StatValue);
    }
        private void DisplayCollectionAssetGUI(RPGStatCollection collection)
        {
            // Determine the string to display for the given stat collection
            var    asset = RPGStatCollectionDatabase.Instance.Get(collection.StatCollectionId);
            string displayText;

            // If the asset is found within the database use it's name.
            if (asset != null)
            {
                displayText = asset.Name;
            }
            // If the id is below zero no collection is assigned.
            else if (collection.StatCollectionId <= 0)
            {
                displayText = "Not Set";
            }
            // If no asset is assigned and the id i above zero
            // the previous collection is currently missing.
            else
            {
                displayText = "Missing";
            }

            GUILayout.Space(4);

            // Show the collection's name and id and allow user to change
            // the assigned stat collection via a dialog popup
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            if (GUILayout.Button(string.Format("[ID: {0}] {1}", Mathf.Max(0, collection.StatCollectionId).ToString("D4"), displayText), EditorStyles.toolbarPopup))
            {
                RPGStatCollectionDatabase.Instance.LoadDatabase();
                XmlDatabaseEditorUtility.ShowContext(RPGStatCollectionDatabase.Instance, (value) => {
                    collection.StatCollectionId = value.Id;
                }, typeof(RPGStatCollectionWindow));
            }
            EditorGUI.EndDisabledGroup();
        }
Example #18
0
		public override void Awake () {
			statCollection = gameObject.GetComponentInChildren<RPGStatCollection>();
			blackboard     = GameObject.Find ( "GameRule" ).GetComponentInChildren<BlackboardComponent>();
		}
        private void DisplayCollectionGUI(RPGStatCollection collection)
        {
            // Show controls for editing values of stats in the editor
            GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
            GUILayout.Label("Stats");
            GUILayout.Label("Increment By", GUILayout.Width(90));
            // Increase the amount stat values are adjusted by multiples of 10
            if (GUILayout.Button("+", EditorStyles.toolbarButton, GUILayout.Width(24)))
            {
                increaseAmount = Mathf.Min(increaseAmount * 10, 10000);
            }
            // Shows the current amount stat values are adjusted by in editor
            GUILayout.Label(increaseAmount.ToString("D5"), GUILayout.Width(40));
            // Decrease the amount stat values are adjusted by multiples of 10
            if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(24)))
            {
                increaseAmount = Mathf.Max(increaseAmount / 10, 1);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(-4);

            // Show all the stats within the editor only when the
            // editor is playing, else the stat list will not be
            // initialized.
            GUILayout.BeginVertical("Box");
            if (Application.isPlaying)
            {
                var groups = collection.StatDict.GroupBy(pair => {
                    var category = RPGStatCategoryDatabase.Instance.Get(pair.Value.StatCategoryId);
                    if (category != null)
                    {
                        return(category.Id);
                    }
                    return(0);
                });

                foreach (var group in groups)
                {
                    GUILayout.Label(RPGStatCategoryDatabase.Instance.Get(group.First().Value.StatCategoryId).Name, EditorStyles.centeredGreyMiniLabel);
                    foreach (var pair in group)
                    {
                        var currentValue = pair.Value as IStatValueCurrent;

                        bool isActive = activeStatIds.Contains(pair.Key);

                        GUILayout.BeginHorizontal();
                        GUILayout.Label(string.Format("Id: {0, 6}", pair.Key.ToString()), EditorStyles.miniButtonLeft, GUILayout.Width(80));
                        GUILayout.Label(RPGStatTypeDatabase.Instance.Get(pair.Key).Name, EditorStyles.miniButtonMid);

                        if (currentValue == null)
                        {
                            GUILayout.Label(string.Format("{0, 13}", pair.Value.StatValue), EditorStyles.miniButtonMid, GUILayout.Width(120));
                        }
                        else
                        {
                            GUILayout.Label(string.Format("{0, 6}", currentValue.StatValueCurrent), EditorStyles.miniButtonMid, GUILayout.Width(60));
                            GUILayout.Label(string.Format("{0, 6}", pair.Value.StatValue), EditorStyles.miniButtonMid, GUILayout.Width(60));
                        }

                        var clicked = GUILayout.Toggle(isActive, isActive ? '\u25BC'.ToString() : '\u25B6'.ToString(), EditorStyles.miniButtonRight, GUILayout.Width(60));
                        if (clicked == true && isActive == false)
                        {
                            activeStatIds.Add(pair.Key);
                        }
                        else if (clicked == false && isActive == true)
                        {
                            activeStatIds.Remove(pair.Key);
                        }
                        GUILayout.EndHorizontal();


                        // Show the name and id of the current stat
                        //var clicked = GUILayout.Toggle(isActive, string.Format("ID {0, 4}: {1, -20}",
                        //    pair.Key.ToString(), statName), EditorStyles.foldout);
                        //
                        //if (clicked) {
                        //    activeStatId = pair.Key;
                        //}

                        if (activeStatIds.Contains(pair.Key) == false)
                        {
                            continue;
                        }

                        GUILayout.Space(-3);

                        // Display the stat's value along with controls to
                        // modifiy the value by the current increase amount.
                        GUILayout.BeginVertical("Box");
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Value", GUILayout.Width(60));
                        GUILayout.Label(pair.Value.StatValue.ToString("D8"), EditorStyles.centeredGreyMiniLabel);

                        if (GUILayout.Button("+", EditorStyles.miniButtonLeft, GUILayout.Width(30)))
                        {
                            pair.Value.ModifyBaseValue(increaseAmount);
                        }

                        if (GUILayout.Button("-", EditorStyles.miniButtonRight, GUILayout.Width(30)))
                        {
                            pair.Value.ModifyBaseValue(-increaseAmount);
                        }
                        GUILayout.EndHorizontal();

                        // If the stat implements IStatCurrentValue display the
                        // current value of the given stat.
                        if (currentValue != null)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Current", GUILayout.Width(60));
                            GUILayout.Label(currentValue.StatValueCurrent.ToString("D8"), EditorStyles.centeredGreyMiniLabel);
                            if (GUILayout.Button("+", EditorStyles.miniButtonLeft, GUILayout.Width(30)))
                            {
                                currentValue.StatValueCurrent += increaseAmount;
                            }

                            if (GUILayout.Button("-", EditorStyles.miniButtonRight, GUILayout.Width(30)))
                            {
                                currentValue.StatValueCurrent -= increaseAmount;
                            }
                            GUILayout.EndHorizontal();
                        }

                        var iModifiable = pair.Value as IStatModifiable;
                        if (iModifiable != null)
                        {
                            EditorGUI.indentLevel++;
                            GUILayout.BeginHorizontal();
                            showStatModifiers = GUILayout.Toggle(showStatModifiers, "Active Modifiers", EditorStyles.miniButton);
                            GUILayout.EndHorizontal();

                            if (showStatModifiers)
                            {
                                GUILayout.BeginHorizontal("Box");
                                for (int i = 0; i < iModifiable.GetModifierCount(); i++)
                                {
                                    var mod = iModifiable.GetModifierAt(i);

                                    if (mod != null)
                                    {
                                        GUILayout.BeginHorizontal();
                                        GUILayout.Label(mod.GetType().Name);
                                        GUILayout.Label(mod.Value.ToString());
                                        if (GUILayout.Button("-", EditorStyles.miniButton))
                                        {
                                            iModifiable.RemoveModifier(mod);
                                        }
                                        GUILayout.EndHorizontal();
                                    }
                                }

                                if (iModifiable.GetModifierCount() <= 0)
                                {
                                    GUILayout.Label("No Active Modifier", EditorStyles.centeredGreyMiniLabel);
                                }
                                GUILayout.EndHorizontal();
                            }
                            EditorGUI.indentLevel--;
                        }

                        GUILayout.EndVertical();
                    }
                }

                if (collection.StatCollectionId <= 0)
                {
                    GUILayout.Label("No Stat Collection Selected", EditorStyles.centeredGreyMiniLabel);
                }
                else if (collection.StatDict.Count <= 0)
                {
                    GUILayout.Label("No Stats are contained within the collection", EditorStyles.centeredGreyMiniLabel);
                }
            }
            else
            {
                GUILayout.Label("Stats Appear in Playmode", EditorStyles.centeredGreyMiniLabel);
            }

            GUILayout.EndVertical();
        }
Example #20
0
 public override void Awake()
 {
     statCollection = DamageDealer.FindObjectStatCollection(gameObject);
 }
 public override void Awake()
 {
     statCollection = DamageDealer.FindObjectStatCollection(gameObject);
     blackboard     = DamageDealer.FindObjectT <Blackboard> (gameObject);
 }
Example #22
0
 public override void Awake()
 {
     statCollection = gameObject.GetComponentInChildren <RPGStatCollection>();
 }
Example #23
0
    public bool DealDamage(GameObject hit, Vector3 hitPoint)
    {
        DamageReceiver receiver = FindObjectDamageReceiver(hit);

        // 检查开关
        if (receiver == null || !receiver.enabled)
        {
            return(false);
        }

        // 检查忽略
        if (IgnoredReceivers.Contains(receiver))
        {
            return(false);
        }

        // 检查类型匹配
        if (!damageTypes.GetType(receiver.type))
        {
            //Debug.Log($"{hit.transform.GetPath()}目标类型与DamageDealer类型不匹配:{receiver.type} {damageTypes}");
            return(false);
        }

        // 检查伤害判定间隔
        if (useDamageInterval &&
            timers.ContainsKey(receiver.GetInstanceID()) &&
            timers[receiver.GetInstanceID()] < damageInterval)
        {
            return(false);
        }

        this.hitPoint = hitPoint;

        // 实际伤害值
        float realDamage = 0f;

        // 实际伤害结算次数
        int realDamageApplyCount = damageApplyCount;

        switch (damageSource)
        {
        case DamageSource.Player:
            break;

        case DamageSource.Enemy:

            if (statCollection == null)
            {
                statCollection = origin?.GetComponent <RPGStatCollection> ();
            }

            if (!dontDealDamage)
            {
                damageInfo = new DamageInfo(damage, origin.gameObject);
                damageInfo.damageSourceType = damageSource;
                damageInfo.attackType       = attackType;
                damageInfo.attackRangeType  = attackRangeType;
                damageInfo.movesName        = moveName;
            }

            break;

        case DamageSource.Trap:

            if (!dontDealDamage)
            {
                damageInfo = new DamageInfo(damage, origin.gameObject);
                damageInfo.damageSourceType = damageSource;
                damageInfo.attackType       = attackType;
                damageInfo.attackRangeType  = attackRangeType;
                damageInfo.movesName        = moveName;
                damageInfo.ignoreBlock      = ignoreBlock;
            }

            break;
        }

        // 伤害结算
        if (damageInfo != null)
        {
            //Debug.Log ( $"对{receiver.transform.GetPath ()}结算伤害" );
            for (var i = 0; i < realDamageApplyCount; ++i)
            {
                receiver.TakeDamage(damageInfo);
            }
        }

        // 伤害结算完毕后,是否要忽略后续对相同Receiver的判定
        if (ignoreReceiverOnDealDamage)
        {
            IgnoreReceiver(receiver);
        }

        if (useDamageInterval)
        {
            if (!timers.ContainsKey(receiver.GetInstanceID()))
            {
                timers.Add(receiver.GetInstanceID(), 0f);
            }
            timers[receiver.GetInstanceID()] = 0.0f;
        }


        OnDealDamage?.Invoke(damage * damageMultiplier, receiver, this);

        return(true);
    }