Exemplo n.º 1
0
        //clone an instance
        public AttackInstance2D Clone()
        {
            AttackInstance2D attInstance = new AttackInstance2D();

            attInstance.processed = processed;
            attInstance.srcUnit   = srcUnit;
            attInstance.tgtUnit   = tgtUnit;

            attInstance.missed   = missed;
            attInstance.critical = critical;
            attInstance.destroy  = destroy;

            attInstance.stunned = stunned;
            attInstance.slowed  = slowed;
            attInstance.dotted  = dotted;

            attInstance.instantKill  = instantKill;
            attInstance.breakShield  = breakShield;
            attInstance.pierceShield = pierceShield;

            attInstance.damage       = damage;
            attInstance.damageHP     = damageHP;
            attInstance.damageShield = damageShield;

            attInstance.stun = stun;
            attInstance.slow = slow;
            attInstance.dot  = dot;

            return(attInstance);
        }
Exemplo n.º 2
0
        public void Shoot(AttackInstance2D attInst = null, Transform sp = null)
        {
            if (attInst.tgtUnit == null || attInst.tgtUnit.GetTargetTransform() == null)
            {
                ObjectPoolManager.Unspawn(gameObject);
                return;
            }

            attInstance  = attInst;
            target       = attInstance.tgtUnit;
            targetPos    = target.GetTargetTransform().position;
            hitThreshold = Mathf.Max(.1f, target.hitThreshold);
            shootPoint   = sp;

            if (type != _ShootObjectType.Beam)
            {
                if (shootPoint.position.x > targetPos.x)
                {
                    renderer.flipX = true;
                }
                else
                {
                    renderer.flipX = false;
                }
            }

            //if (shootPoint != null) transform.rotation = shootPoint.rotation;
            if (shootEffect != null && target.isAlive)
            {
                ObjectPoolManager.Spawn(shootEffect, transform.position, transform.rotation);
            }
            hit = false;

            print("Shoot");
            if (type == _ShootObjectType.Projectile)
            {
                StartCoroutine(ProjectileRoutine());
            }
            else if (type == _ShootObjectType.Beam)
            {
                StartCoroutine(BeamRoutine());
            }
            else if (type == _ShootObjectType.Bullet)
            {
                StartCoroutine(BulletRoutine());
            }
            else if (type == _ShootObjectType.Missile)
            {
                StartCoroutine(MissileRoutine());
            }
            else if (type == _ShootObjectType.Effect && effectDelay > 0)
            {
                StartCoroutine(EffectRoutine());
            }
            else
            {
                Hit();
            }
        }
Exemplo n.º 3
0
        private IEnumerator FireCoroutine()
        {
            //yield return new WaitForSeconds(.1f);
            ShootObject2D arrow = ObjectPoolManager.Spawn(shootObject).GetComponent <ShootObject2D>();

            arrow.transform.position = shootPosition.position;
            print("arrow.Shoot");
            AttackInstance2D attInstance = new AttackInstance2D();

            attInstance.srcUnit = this;
            attInstance.tgtUnit = target;
            attInstance.Process();
            arrow.Shoot(attInstance, shootPosition);
            yield return(null);
            //arrow.transform.DOLocalMove(target.targetPosition.position, .5f).OnComplete(() => { base.Fire(); Destroy(arrow.gameObject); });
        }