Beispiel #1
0
        void FPSHit(Unit hitUnit, Vector3 hitPoint)
        {
            if (attInstance.srcWeapon.GetAOERange() > 0)
            {
                LayerMask mask1 = 1 << LayerManager.LayerCreep();
                LayerMask mask2 = 1 << LayerManager.LayerCreepF();
                LayerMask mask  = mask1 | mask2;

                Collider[] cols = Physics.OverlapSphere(hitPoint, attInstance.srcWeapon.GetAOERange(), mask);
                if (cols.Length > 0)
                {
                    List <Unit> tgtList = new List <Unit>();
                    for (int i = 0; i < cols.Length; i++)
                    {
                        Unit unit = cols[i].gameObject.GetComponent <Unit>();
                        if (!unit.dead)
                        {
                            tgtList.Add(unit);
                        }
                    }
                    if (tgtList.Count > 0)
                    {
                        for (int i = 0; i < tgtList.Count; i++)
                        {
                            AttackInstance attInst = new AttackInstance();
                            attInst.srcWeapon = attInstance.srcWeapon;
                            attInst.tgtUnit   = tgtList[i];
                            tgtList[i].ApplyEffect(attInst);
                        }
                    }
                }
            }
            else
            {
                if (hitUnit != null && hitUnit.IsCreep())
                {
                    attInstance.tgtUnit = hitUnit;
                    hitUnit.ApplyEffect(attInstance);
                }
            }
        }
Beispiel #2
0
        IEnumerator AOETowerRoutine()
        {
            if (CurrentStat.customMask > -1)
            {
                TargetMask = CurrentStat.customMask;
            }
            else if (targetMode == _TargetMode.Hybrid)
            {
                LayerMask mask1 = 1 << LayerManager.LayerCreep();
                LayerMask mask2 = 1 << LayerManager.LayerCreepF();
                TargetMask = mask1 | mask2;
            }
            else if (targetMode == _TargetMode.Air)
            {
                TargetMask = 1 << LayerManager.LayerCreepF();
            }
            else if (targetMode == _TargetMode.Ground)
            {
                TargetMask = 1 << LayerManager.LayerCreep();
            }

            while (true)
            {
                yield return(new WaitForSeconds(GetCooldown()));

                while (stunned || IsInConstruction())
                {
                    yield return(null);
                }



                Collider[] cols = Physics.OverlapSphere(thisT.position, GetAttackRange(), TargetMask);
                if (cols.Length > 0)
                {
                    Transform soPrefab = GetShootObjectT();
                    if (soPrefab != null)
                    {
                        ObjectPoolManager.Spawn(soPrefab, thisT.position, thisT.rotation);
                    }

                    //SendMessage("OnAttackTargetStarted", SendMessageOptions.DontRequireReceiver);
                    //print("AOE attack");

                    for (int i = 0; i < cols.Length; i++)
                    {
                        Unit unit = cols[i].transform.GetComponent <Unit>(); //damage all units in its range
                        if (unit == null && !unit.dead)
                        {
                            continue;
                        }

                        AttackInstance attInstance = new AttackInstance();
                        attInstance.srcUnit = this;
                        attInstance.tgtUnit = unit;
                        attInstance.Process();

                        unit.ApplyEffect(attInstance);
                    }
                }
                else
                {
                    //SendMessage("OnAttackTargetStopped", SendMessageOptions.DontRequireReceiver);
                    //print("AOE stopped");
                }
            }
        }