Exemplo n.º 1
0
 public override void OnTick(Entity entity, float deltaTime)
 {
     valueDecimal = deltaTime * Value;
     if (valueDecimal > 1)
     {
         modifier.Delta = Mathf.RoundToInt(valueDecimal);
         modifier.TakeEffect(entity);
         valueDecimal -= modifier.Delta;
     }
 }
Exemplo n.º 2
0
    public override void HitRecycleNow()
    {
        transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
        if (IsNotRecycled)
        {
            if (HitEffect != null || HitEffect != "")
            {
                GameObject shootHitEffect = ObjectPool.GetObject(HitEffect, "Effects");
                shootHitEffect.transform.position = transform.position + Vector3.forward * 10f;
            }
            Nowtime = 0;

            List <GameObject> targets = GetAttackTargets();
            if (targets != null && targets.Count != 0)
            {
                foreach (var t in targets)
                {
                    gravitationModifier = new GravitationModifier(transform.position, GravitationInternal, GravitationPower);
                    gravitationModifier.TakeEffect(t.GetComponent <Entity>());
                    AnimatorParameterFragment animator = new AnimatorParameterFragment();
                    for (int i = 0; i < 3; i++)
                    {
                        HealthModifier hm = new HealthModifier(-30);
                        hm.TakeEffect(t.GetComponent <Entity>());
                        animator.Animator = t.transform.GetChild(0).GetComponent <Animator>();
                        animator.Name     = "Hit";
                        animator.TakeEffect();
                    }
                    if (t.gameObject.GetComponent <Entity>().GetCapability <Health>().Value < 0)
                    {
                        animator.Name = "Die";
                        animator.TakeEffect();
                        if (t.gameObject.CompareTag("Player"))
                        {
                            StopPlayerMovementFragment stopPlayerMovementFragment = new StopPlayerMovementFragment(0f);
                            stopPlayerMovementFragment.TakeEffect(t.GetComponent <Entity>());

                            StopPlayerStateFragment stopPlayerStateFragment = new StopPlayerStateFragment(0f);
                            stopPlayerStateFragment.TakeEffect(t.GetComponent <Entity>());
                        }
                        ;
                        gameObject.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
                    }
                }
            }
            flyingDistance = 0;
            targetDistance = 0;
            ObjectPool.RecycleObject(gameObject);
            IsNotRecycled = false;
        }
    }
Exemplo n.º 3
0
        private async void Delay(float ms, Entity actor)
        {
            int step = (int)(0.2 * 1000 / ms);      // 延迟释放攻击,与动画配合
            List <Collider2D> HurtTargets = new List <Collider2D>();

            do
            {
                step++;
                await Task.Delay((int)ms);

                if (step == SkillInternal * 500 / ms)
                {
                    HurtTargets.Clear();
                }
                Collider2D[] cols = Physics2D.OverlapCircleAll(actor.transform.position, actor.GetComponent <Entity>().GetCapability <Attack>().Range);
                if (cols.Length > 0)
                {
                    List <GameObject> Targets = new List <GameObject>();
                    foreach (var c in cols)
                    {
                        if (c.transform.CompareTag(actor.transform.GetComponent <WeaponController>().AttackTag) && !HurtTargets.Contains(c))
                        {
                            Targets.Add(c.gameObject);
                            HurtTargets.Add(c);
                        }
                    }
                    if (Targets.Count != 0)
                    {
                        HealthModifier     healthModifier     = new HealthModifier(-Damage);
                        MoveTowardFragment moveTowardFragment = new MoveTowardFragment();
                        foreach (var t in Targets)
                        {
                            moveTowardFragment.Direction    = (t.transform.position - actor.transform.position);
                            moveTowardFragment.InternalTime = 0.2f;
                            moveTowardFragment.Speed        = HitPower;
                            moveTowardFragment.TakeEffect(t.GetComponent <Entity>());
                            healthModifier.TakeEffect(t.GetComponent <Entity>());
                        }
                    }
                }
            } while (step < SkillInternal * 1000 / ms);
        }