コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        DamageSystem system = other.GetComponent <DamageSystem>();

        if (system != null && system != self)
        {
            if (currentlyDamaged.Contains(system))
            {
                return;
            }


            currentlyDamaged.Add(system);


            if (EnableDamage)
            {
                //print("Bit " + other.transform.name);
                bool deaded = system.IsDead;
                system.ApplyDamage(this.Amount);
                if (this.isParentDamager && system.IsDead != deaded)
                {
                    GameStats.Kills++;
                }
            }
        }
    }
コード例 #2
0
        public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
        {
            var linesCollider = PrefabHelper.Intantiate(_linesColliderPrefab, Game.Instance.gameObject);

            linesCollider.transform.position   = castContext.Caster.Position;
            linesCollider.transform.localScale = Vector3.one;
            linesCollider.OnTrigger           += (unit) =>
            {
                if (unit.PlayerId != castContext.Caster.PlayerId)
                {
                    DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), unit);
                }
            };
            var renderers = linesCollider.GetComponentsInChildren <Renderer>();

            return(new SyncScenario(
                       new List <ISyncScenarioItem> {
                new ActionScenarioItem(() =>
                {
                    FMODUnity.RuntimeManager.PlayOneShot("event:/Explosion");
                }),
                new AlphaTween(renderers, 0),
                new AlphaTween(renderers, 1, 0.1f, EaseType.QuadIn),
                new AlphaTween(renderers, 0, 0.3f, EaseType.QuadOut)
            },
                       (s, interrupted) => Object.Destroy(linesCollider.gameObject)
                       ).PlayRegisterAndReturnSelf());
        }
コード例 #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (damageSafety)
        {
            return;
        }
        DamageSystem system = other.GetComponent <DamageSystem>();

        if (system == null || system == this.system)
        {
            return;
        }

        bool Deaded = system.IsDead;

        system.ApplyDamage(damage);

        if (system.IsDead != Deaded && FromParent)
        {
            GameStats.Kills++;
        }


        damageSafety = true;
        Destroy(this.gameObject);
    }
コード例 #4
0
ファイル: Explosion.cs プロジェクト: Mouserr/CrazyBalls
        public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
        {
            var effect = PrefabHelper.Intantiate(_explosionEffectPrefab, Game.Instance.gameObject);

            effect.transform.position   = castContext.Caster.Position;
            effect.transform.localScale = Vector3.zero;

            var radius  = _radius.GetValue(abilityLevel);
            var targets = MapController.Instance.GetEnemiesInArea(castContext.Caster.Position,
                                                                  radius, castContext.Caster.PlayerId);

            for (int i = 0; i < targets.Count; i++)
            {
                DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), targets[i]);
            }

            return(new SyncScenario(
                       new List <ISyncScenarioItem> {
                new ActionScenarioItem(() =>
                {
                    FMODUnity.RuntimeManager.PlayOneShot("event:/Explosion");
                }),
                new AlphaTween(effect, 1),
                new ScaleTween(effect, 10 * radius * Vector3.one, 0.5f, EaseType.QuadIn),
                new AlphaTween(effect, 0, 0.3f, EaseType.QuadOut)
            },
                       (s, interrupted) => Object.Destroy(effect.gameObject)
                       ).PlayRegisterAndReturnSelf());
        }
コード例 #5
0
 public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
 {
     return(new ActionScenarioItem(() =>
     {
         DamageSystem.ApplyDamage(null, DamagePerTurn.GetValue(abilityLevel), castContext.Target);
     }
                                   ).PlayRegisterAndReturnSelf());
 }
コード例 #6
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        IDamager damager = (IDamager)other.GetComponent(typeof(IDamager));

        if (damager != null)
        {
            DamageSystem.ApplyDamage(damager, controller.GetPlayer(), transform.position - other.transform.position);
        }
    }
コード例 #7
0
    private void ApplyExplode()
    {
        Collider2D[] objects = Physics2D.OverlapCircleAll(transform.position, fieldOfImpact, LayerToHit);

        foreach (Collider2D obj in objects)
        {
            Vector2    dir       = obj.transform.position - transform.position;
            IDamagable damagable = (IDamagable)obj.GetComponent(typeof(IDamagable));
            if (damagable != null)
            {
                DamageSystem.ApplyDamage(this.GetComponent <Enemy>(), damagable, dir);
            }
        }


        Destroy(gameObject);
    }
コード例 #8
0
        private void OnHit(Projectile projectile, Collision collision)
        {
            if (collision.gameObject.TryGetComponent <UnitLink>(out var unitLink))
            {
                _damageSystem.ApplyDamage(projectile.Info, unitLink.Unit);
            }

            projectile.Hit -= OnHit;
            var launcherConfig = projectile.Info.Launcher.Config;

            _projectilePools[launcherConfig].ReleaseObject(projectile);

            var explosion = _explosionPools[launcherConfig].GetObject();

            explosion.transform.position = collision.GetContact(0).point;
            explosion.gameObject.SetActive(true);
        }
コード例 #9
0
ファイル: RaidBossAttack.cs プロジェクト: Mouserr/CrazyBalls
        public override ISyncScenarioItem Apply(CastContext castContext, int abilityLevel)
        {
            var directions = _directions[_index].GetDirections();

            _index = _index + 1 >= _directions.Length ? 0 : _index + 1;
            var items = new List <ISyncScenarioItem>();

            foreach (var direction in directions)
            {
                var effect = PrefabHelper.Intantiate(_explosionEffectPrefab, Game.Instance.gameObject);
                effect.transform.position   = castContext.Caster.Position + direction * _distance;
                effect.transform.localScale = Vector3.zero;
                var radius = _radius.GetValue(abilityLevel);

                items.Add(new SyncScenario(
                              new List <ISyncScenarioItem>
                {
                    new AlphaTween(effect, 1),
                    new ScaleTween(effect, 10 * radius * Vector3.one, 0.5f, EaseType.QuadIn),

                    new ActionScenarioItem(() =>
                    {
                        FMODUnity.RuntimeManager.PlayOneShot("event:/Gas");
                    }),
                    new ActionScenarioItem(() =>
                    {
                        var targets = MapController.Instance.GetEnemiesInArea(effect.transform.position,
                                                                              radius, castContext.Caster.PlayerId);

                        for (int i = 0; i < targets.Count; i++)
                        {
                            if (!DamageSystem.ApplyDamage(castContext.Caster, _damage.GetValue(abilityLevel), targets[i]))
                            {
                                targets[i].AddEffect(new CharacterEffect(EffectOnTouch, abilityLevel));
                            }
                        }
                    }),
                    new AlphaTween(effect, 0, 0.3f, EaseType.QuadOut)
                },
                              (s, interrupted) => Object.Destroy(effect.gameObject)
                              ));
            }

            return(new CompositeItem(items).PlayRegisterAndReturnSelf());
        }
コード例 #10
0
ファイル: Enemy.cs プロジェクト: zzf18676456441/caRPG
    /// Collision damage
    private void OnCollisionEnter2D(Collision2D collision)
    {
        IDamager   damager    = (IDamager)collision.collider.GetComponent(typeof(IDamager));
        IDamagable damagable  = (IDamagable)collision.collider.GetComponent(typeof(IDamagable));
        Enemy      enemyCheck = (Enemy)collision.collider.GetComponent(typeof(Enemy));

        if (enemyCheck != null)
        {
            return;
        }
        if (damager != null)
        {
            DamageSystem.ApplyDamage(damager, this, collision.relativeVelocity);
        }
        if (damagable != null)
        {
            DamageSystem.ApplyDamage(this, damagable, collision.relativeVelocity);
        }
    }
コード例 #11
0
    public void NotifyCollision(Collision2D collision, IDamager hitter)
    {
        Debug.Log(collision.collider.gameObject.name);
        // Can the thing I hit deal damage?
        IDamager damager = (IDamager)collision.collider.GetComponent(typeof(IDamager));

        // Can the thing I hit take damage?
        IDamagable damagable = (IDamagable)collision.collider.GetComponent(typeof(IDamagable));

        // If it can deal damage, apply that damage to the player.
        if (damager != null)
        {
            DamageSystem.ApplyDamage(damager, controller.GetPlayer(), collision.relativeVelocity);
        }

        // If it can take damage, apply this object's damage to it.
        if (damagable != null)
        {
            DamageSystem.ApplyDamage(hitter, damagable, collision.relativeVelocity);
        }
    }
コード例 #12
0
    public virtual void GetHit()
    {
        if (calculateDamage)
        {
            //寻找是否有最终伤害buff
            FinalDamageBuff finalDamageBuff = (FinalDamageBuff)character.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));

            foreach (var o in other)
            {
                //<伤害序列,伤害结果>
                List <int> damageList = new List <int>();

                if (ExtraHitSystem(extraHit))
                {
                    DebugLogPanel.GetInstance().Log("速击!" + "(" + character.GetComponent <CharacterStatus>().roleCName + " -> " + o.GetComponent <CharacterStatus>().roleCName + ")");
                    hit++;
                }

                //每Hit
                for (int i = 0; i < hit; i++)
                {
                    int d;
                    var doNextHit = DamageSystem.ApplyDamage(character, o, this, comboSkill == null && hoverRange == 0 || comboSkill != null && comboSkill.hoverRange == 0, finalDamageBuff == null ? 0 : finalDamageBuff.Factor, out d);
                    damageList.Add(d);
                    if (!doNextHit)
                    {
                        break;
                    }
                }

                //如果有最终伤害Buff,且Duration小于0,手动撤销影响。(此处应为倍化术)
                if (finalDamageBuff != null && finalDamageBuff.Duration < 0)
                {
                    finalDamageBuff.Undo(character);
                }

                for (int i = 0; i < damageList.Count; i++)
                {
                    bool donePost = false;
                    //异步时,要把迭代器传进去。
                    GameController.GetInstance().Invoke(j => {
                        if (o)
                        {
                            //飘字
                            if (damage > 0)
                            {
                                if (damageList[j] > 0)
                                {
                                    //受击动作
                                    HitEffect(o);

                                    UIManager.GetInstance().FlyNum(o.GetComponent <CharacterStatus>().arrowPosition / 2 + o.position, damageList[j].ToString(), Color.white, true);
                                }
                                else if (damageList[j] == 0)
                                {
                                    UIManager.GetInstance().FlyNum(o.GetComponent <CharacterStatus>().arrowPosition / 2 + o.position, damageList[j].ToString(), Color.white, false);
                                }
                                else if (damageList[j] < 0)
                                {
                                    //受击动作
                                    HitEffect(o);
                                }
                            }
                            else
                            {
                                UIManager.GetInstance().FlyNum(o.GetComponent <CharacterStatus>().arrowPosition / 2 + o.position, Mathf.Abs(damageList[j]).ToString(), UIManager.hpColor, false);
                            }
                            if (!donePost)
                            {
                                PostEffect(o);
                                donePost = true;
                            }
                        }
                    }, hitInterval * i, i);
                }
            }
        }
    }
コード例 #13
0
ファイル: AttackSkill.cs プロジェクト: a616150508/SLGanim
    public override void Effect()
    {
        if (effectState == EffectState.origin)
        {
            originSkill.Effect();
        }
        else
        {
            //结算消耗以及动作归位。
            base.Effect();

            if (calculateDamage)
            {
                //寻找是否有最终伤害buff
                FinalDamageBuff finalDamageBuff = (FinalDamageBuff)character.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));

                foreach (var o in other)
                {
                    //<伤害序列,伤害结果>
                    Dictionary <int, int> damageDic = new Dictionary <int, int>();

                    //每Hit
                    for (int i = 0; i < hit; i++)
                    {
                        int d;
                        var doNextHit = DamageSystem.ApplyDamage(character, o, skipDodge, damageFactor, skillRate, extraCrit, extraPounce, comboSkill == null && hoverRange == 0 || comboSkill != null && comboSkill.hoverRange == 0, finalDamageBuff == null ? 0 : finalDamageBuff.Factor, out d);
                        damageDic.Add(i, d);
                        if (!doNextHit)
                        {
                            break;
                        }
                    }

                    //如果有最终伤害Buff,且Duration小于0,手动撤销影响。(此处应为倍化术)
                    if (finalDamageBuff != null && finalDamageBuff.Duration < 0)
                    {
                        finalDamageBuff.Undo(character);
                    }
                    //comboSkill是指组合技的第二个技能。这里说明是第一个技能,结合前面的条件,则这里是无连续技的技能逻辑。
                    if (comboSkill == null)
                    {
                        //寻求合击的逻辑
                        var comboUnits = DamageSystem.ComboDetect(character, o);
                        if (comboUnits.Count > 0)
                        {
                            for (int i = 0; i < comboUnits.Count; i++)
                            {
                                int             d;
                                FinalDamageBuff u_finalDamageBuff = (FinalDamageBuff)comboUnits[i].GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));
                                var             ninjaCombo        = new NinjaCombo();
                                ninjaCombo.SetLevel(comboUnits[i].GetComponent <CharacterStatus>().skills["NinjaCombo"]);
                                DamageSystem.ApplyDamage(comboUnits[i], o, false, ninjaCombo.damageFactor, ninjaCombo.skillRate, ninjaCombo.extraCrit, ninjaCombo.extraPounce, ninjaCombo.hoverRange == 0, u_finalDamageBuff == null ? 0 : u_finalDamageBuff.Factor, out d);
                                damageDic.Add(damageDic.Count + i, d);
                                comboUnits[i].GetComponent <Animator>().SetInteger("Skill", 0);
                            }
                        }
                    }

                    FlyNum(damageDic, o);
                }
            }
        }
    }
コード例 #14
0
ファイル: AttackSkill.cs プロジェクト: k87280592100/SLGanim
    public override void Effect()
    {
        if (effectState == EffectState.origin)
        {
            originSkill.Effect();
        }
        else
        {
            base.Effect();

            FinalDamageBuff finalDamageBuff = (FinalDamageBuff)character.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));

            foreach (var o in other)
            {
                //<伤害序列,伤害结果>
                Dictionary <int, int> damageDic = new Dictionary <int, int>();

                //每Hit
                for (int i = 0; i < hit; i++)
                {
                    int d;
                    var doNextHit = DamageSystem.ApplyDamage(character, o, damageFactor, skillRate, extraCrit, extraPounce, comboSkill == null && hoverRange == 0 || comboSkill != null && comboSkill.hoverRange == 0, finalDamageBuff == null ? 0 : finalDamageBuff.Factor, out d);
                    damageDic.Add(i, d);
                    if (!doNextHit)
                    {
                        break;
                    }
                }
                foreach (var data in damageDic)
                {
                    RoundManager.GetInstance().Invoke(i => {
                        if (o)
                        {
                            if (data.Value >= 0)
                            {
                                UIManager.GetInstance().FlyNum(o.GetComponent <CharacterStatus>().arrowPosition / 2 + o.position + Vector3.down * 0.2f * i + Vector3.left * 0.2f * (Mathf.Pow(-1, i) > 0 ? 0 : 1), damageDic[i].ToString());
                            }
                        }
                    }, 0.2f * data.Key, data.Key);
                }
                if (finalDamageBuff != null && finalDamageBuff.Duration < 0)
                {
                    finalDamageBuff.Undo(character);
                }
                //comboSkill是指组合技的第二个技能。
                if (comboSkill == null)
                {
                    var comboUnits = DamageSystem.ComboDetect(character, o);
                    if (comboUnits.Count > 0)
                    {
                        foreach (var u in comboUnits)
                        {
                            int             d;
                            FinalDamageBuff u_finalDamageBuff = (FinalDamageBuff)u.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));
                            var             ninjaCombo        = new NinjaCombo();
                            ninjaCombo.SetLevel(u.GetComponent <CharacterStatus>().skills["NinjaCombo"]);
                            DamageSystem.ApplyDamage(u, o, ninjaCombo.damageFactor, ninjaCombo.skillRate, ninjaCombo.extraCrit, ninjaCombo.extraPounce, ninjaCombo.hoverRange == 0, u_finalDamageBuff == null ? 0 : u_finalDamageBuff.Factor, out d);
                            UIManager.GetInstance().FlyNum(o.GetComponent <CharacterStatus>().arrowPosition / 2 + o.position, d.ToString());
                            u.GetComponent <Animator>().SetInteger("Skill", 0);
                        }
                    }
                }
            }
        }
    }