Пример #1
0
    public int damageToGive;       // how much damage the bullet inflicts

    private void Start()
    {
        gun = FindObjectOfType <EnemyGunController>();
        if (gun.scale < 0)                                                                                               // if the gun/player is facing left
        {
            speed = -gun.speed;                                                                                          // bullet now moves from right to left
            transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); // flip the bullet sprite as well
        }
        else
        {
            speed = gun.speed;
        }
    }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        player       = GameObject.FindGameObjectWithTag("Player").transform;
        enemyGun     = GetComponent <EnemyGunController>();
        viewAngle    = spotLight.spotAngle;
        OGLightColor = spotLight.color;
        waypoints    = new Vector3[pathHolder.childCount];

        for (int i = 0; i < waypoints.Length; i++)
        {
            waypoints[i] = pathHolder.GetChild(i).position;
            waypoints[i] = new Vector3(waypoints[i].x, transform.position.y, waypoints[i].z);
        }

        StartCoroutine(FollowPath(waypoints));
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (!canFire)
        {
            if (shotCounter <= 0)
            {
                canFire = true;
            }
            else
            {
                shotCounter -= Time.deltaTime;
            }
        }

        if (canFire)
        {
            shotCounter = timeBetweenShots;
            int index;
            enemies      = GameObject.FindGameObjectsWithTag("Enemy");
            index        = Random.Range(0, enemies.Length);
            currentEnemy = enemies[index];

            foreach (Transform child in currentEnemy.transform)
            {
                if (child.CompareTag("EnemyGun"))
                {
                    EnemyGunController egc = child.GetComponent <EnemyGunController>();

                    egc.Fire();

                    canFire = false;
                }
            }
        }



        if (!canFire2)
        {
            if (shotCounter2 <= 0)
            {
                canFire2 = true;
            }
            else
            {
                shotCounter2 -= Time.deltaTime;
            }
        }

        if (canFire2)
        {
            shotCounter2 = timeBetweenShots;
            int index;
            enemies2      = GameObject.FindGameObjectsWithTag("Enemy2");
            index         = Random.Range(0, enemies2.Length);
            currentEnemy2 = enemies2[index];

            foreach (Transform child in currentEnemy2.transform)
            {
                if (child.CompareTag("EnemyGun"))
                {
                    EnemyGunController egc = child.GetComponent <EnemyGunController>();

                    egc.Fire();

                    canFire2 = false;
                }
            }
        }
    }
    public int damageToGive;         // how much damage the bullet inflicts

    private void Start()
    {
        spawn = FindObjectOfType <EnemyGunController>();
        speed = spawn.speed;
    }