コード例 #1
0
    void Shoot()
    {
        GameObject bulletGO = (GameObject)Instantiate(ProjectailPrefab, firePoint.position, firePoint.rotation);
        projectile bullet   = bulletGO.GetComponent <projectile>();

        if (bullet != null)
        {
            Stats.Shoot(bullet, target, bularc);
        }
    }
コード例 #2
0
    void UpdateTarget()
    {
        float ClosestTarget = 0f;

        GameObject[] enemies = GameObject.FindGameObjectsWithTag(EnemyTag);
        foreach (GameObject Enemy in enemies)
        {
            EnemyPath E_Path          = Enemy.GetComponent <EnemyPath>();
            float     distanceToEnemy = Vector2.Distance(transform.position, Enemy.transform.position);
            if (distanceToEnemy <= range)
            {
                ClosestEnemy = E_Path.distanceTravelled;
                if (ClosestEnemy > ClosestTarget)
                {
                    ClosestTarget = ClosestEnemy;
                    TargetEnemy   = Enemy;
                    target        = TargetEnemy.transform;
                }
            }
        }
        if (TargetEnemy != null)
        {
            if (Vector2.Distance(transform.position, TargetEnemy.transform.position) > range)
            {
                TargetEnemy   = null;
                target        = null;
                ClosestTarget = 0;
            }
            else
            {
                if (useChimical)
                {
                    Chimical();
                    GameObject spawn = Instantiate(ChemTrail, TargetEnemy.transform.position, TargetEnemy.transform.rotation);
                    Stats.Shoot(spawn.GetComponent <ChimicalTrail>());
                }
            }
        }
    }
コード例 #3
0
 //dmg claclution
 void Damage(Transform Enemy)
 {
     Enemy.GetComponent <EnemyStats>().CalcDamage(Physic, Fire, Water, Air, Earth);
     Stats.Shoot(Enemy, 0.5f);
 }