Exemple #1
0
        public void Create(IcSkSEntity entity, int index)
        {
            var buffs = _buffManager.GetBuffsCondition <TMechanics>(entity, _getHealth);

            var damage = _buffManager.GetBuffData <TDamageBuff>(entity, index);

#if ENABLE_MANAGED_JOBS
            for (var i = 0; i < buffs.Length; i++)
#else
            for (var i = 0; i < buffs.Count; i++)
#endif
            {
                var buffInfo = buffs[i];

                var buff = buffInfo.Buff;

                buff.Value = buff.Value - damage.Value;

                _buffManager.SetBuffData(entity, buff, buffInfo.Index);

                //todo 一个单位只有第一条血条会受伤
                break;
            }

            _buffManager.RemoveBuff(entity, damage);
        }
Exemple #2
0
        /// <summary>
        /// unity物体绑定,绑定成功将会给go添加一个 <see cref="EntityBindComponent"/>组件
        /// </summary>
        /// <param name="go"></param>
        /// <param name="entity"></param>
        /// <returns>实体不存在返回false,存在将被覆盖</returns>
        public bool BindEntity(GameObject go, IcSkSEntity entity)
        {
            if (!_checkEntity(entity))
            {
                return(false);
            }

            if (!_entityBindMap.ContainsKey(entity))
            {
                _entityBindMap.Add(entity, go);
            }
            else
            {
                _entityBindMap[entity] = go;
            }

            var entityBind = go.GetComponent <EntityBindComponent>();

            if (!entityBind)
            {
                entityBind = go.AddComponent <EntityBindComponent>();
            }

            entityBind.Entity = entity;

            return(true);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>不存在返回null</returns>
        public GameObject FindBindGo(IcSkSEntity entity)
        {
            if (!_checkEntity(entity))
            {
                return(null);
            }

            _entityBindMap.TryGetValue(entity, out var go);

            return(go);
        }
        public void Destroy(IcSkSEntity entity, int index)
        {
            var damage = _buffManager.GetBuffData <TDamageBuff>(entity, index);

            var fixedLifesteals = _buffManager.GetBuffs <TPercentageLifesteal>(damage.Entity);

            if (fixedLifesteals.Count == 0)
            {
                return;
            }

            float lifestealValue = 0;

            foreach (var fixedLifesteal in fixedLifesteals)
            {
                if (fixedLifesteal.Type == damage.Type)
                {
                    lifestealValue += damage.Value * fixedLifesteal.Value;
                }
            }

            var lifesteal = fixedLifesteals[fixedLifesteals.Count - 1];

            var mechanicBuffs = _buffManager.GetBuffs <TMechanics>(damage.Entity);

            if (mechanicBuffs.Count == 0)
            {
                return;
            }

            for (var i = 0; i < mechanicBuffs.Count; i++)
            {
                var mechanicBuff = mechanicBuffs[i];

                if (mechanicBuff.MechanicsType == MechanicsType.Health)
                {
                    mechanicBuff.Value += lifesteal.Value;

                    //第二条血把他当最大血量
                    if (mechanicBuffs.Count >= 2)
                    {
                        if (mechanicBuff.Value > mechanicBuffs[1].Value)
                        {
                            mechanicBuff.Value = mechanicBuffs[1].Value;
                        }
                    }

                    _buffManager.SetBuffData(damage.Entity, mechanicBuff, i);

                    break;
                }
            }
        }
Exemple #5
0
        private void _addBuff(IcSkSEntity entity)
        {
            var count = _entityManager.BuffManager.GetBuffCount <TestBuff1>(entity);
            var value = count % 2;

            if (value == 0)
            {
                _entityManager.AddBuff(entity, new TestBuff1(count + 1, count + 1));
            }
            else
            {
                count = _entityManager.BuffManager.GetBuffCount <TestBuff2>(entity);
                _entityManager.AddBuff(entity, new TestBuff2(count + 1, MechanicsType.Health));
            }
        }
        public void Create(IcSkSEntity entity, int index)
        {
            var fixedBuffs = _buffManager.GetBuffs <TDamageReduceFixedBuff>(entity);

            if (fixedBuffs.Count == 0)
            {
                return;
            }

            //todo 只使用最后一个减伤buff
            TDamageReduceFixedBuff damageReduceFixedBuff = fixedBuffs[fixedBuffs.Count - 1];

            TDamageBuff damageBuff = _buffManager.GetBuffData <TDamageBuff>(entity, index);

            if (damageBuff.Type == damageReduceFixedBuff.Type)
            {
                damageBuff.Value -= damageReduceFixedBuff.Value;

                if (damageBuff.Value <= 0)
                {
                    damageBuff.Value = 0;
                }
            }
        }
 public void Link(IcSkSEntity icSkSEntity)
 {
     this.IcSkSEntity = icSkSEntity;
 }
 public void Init(IIcSkSEntityManager <IcSkSEntity> entityManager, IcSkSEntity icSkSEntity)
 {
     EntityManager = entityManager;
     Link(icSkSEntity);
 }
        public override void Create(IcSkSEntity entity, int index)
        {
            var buff = BuffManager.GetBuffData <T>(entity, index);

            buff.LastTriggerTime = buff.Duration;
        }