示例#1
0
    public override void onTargetReached()
    {
        Vector3 explodePosition = m_target.transform.position;

        if (m_target != null)
        {
            DestroyObject(m_target);
        }
        GameObject [] aAllEnemies = TDWorld.getWorld().getAllEnemiesUnsafe();
        foreach (GameObject thisObject in aAllEnemies)
        {
            if (thisObject == null)
            {
                continue;
            }
            if ((thisObject.transform.position - explodePosition).magnitude > TDWorld.getWorld().m_configuration.towerCanonBallDamageRadius)
            {
                continue;
            }
            TDEnemy enemy = TDWorld.getWorld().getTDEnemy(thisObject);
            if (enemy == null)
            {
                continue;
            }
            if (enemy.canFly())
            {
                continue;
            }
            enemy.receiveDamage(m_damage.clone(enemy), null);
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        float currentTime = Time.time;
        float respawn     = getRestoration();

        if (currentTime < (m_restTime + respawn))
        {
            return;
        }
        GameObject [] aAllEnemies = TDWorld.getWorld().getAllEnemiesUnsafe();
        double        recDist     = -1;
        GameObject    recObject   = null;
        TDDamage      damage      = getTowerDamage();

        foreach (GameObject thisObject in aAllEnemies)
        {
            if (thisObject == null)
            {
                continue;
            }
            float dist            = (transform.position - thisObject.transform.position).magnitude;
            float efficientRadius = getEfficientRadius();
            if (dist < efficientRadius)
            {
                TDEnemy enemy = TDWorld.getWorld().getTDEnemy(thisObject);
                if (enemy.canFly())
                {
                    if (!shootsFlying())
                    {
                        continue;
                    }
                }
                if (!TDWorld.getWorld().m_strategy.shouldShootAt(enemy, damage))
                {
                    continue;
                }
                if ((recDist < 0) || (recDist > dist))
                {
                    recDist   = dist;
                    recObject = thisObject;
                }
            }
        }
        if (recObject == null)
        {
            return;
        }
        TDEnemy recEnemy = TDWorld.getWorld().getTDEnemy(recObject);

        TDWorld.getWorld().m_strategy.shootingAt(recEnemy, damage);
        shootTo(recEnemy);
        m_restTime = Time.time;
    }
示例#3
0
    private void patrol()
    {
        m_path = null;
        TDWorld world = TDWorld.getWorld();

        GameObject [] aEnemies = world.getAllEnemiesUnsafe();
        foreach (GameObject enemy in aEnemies)
        {
            if ((enemy.transform.position - transform.position).magnitude < world.m_configuration.heroPatrolRadius)
            {
                TDEnemy tdEnemy = world.getTDEnemy(enemy);
                if (tdEnemy.canFly())
                {
                    continue;
                }
                if (hasPathTo(enemy))
                {
                    m_state = State.eWalk;
                    break;
                }
            }
        }
    }