コード例 #1
0
	// Use this for initialization
	void Start () {
		nextSplit = Time.time + splitTime;
		pathinfo = gameObject.GetComponent<AIPathFinder> ();
		health = 200;
		this.speed = 15;
		this.gameObject.GetComponent<AIPathFinder> ().speed = (float)this.speed;
	}
コード例 #2
0
    void DoBulletHit()
    {
        if (radius == 0)
        {
            targetE.takeDamage(damage);
        }
        else
        {
            Collider[] cols = Physics.OverlapSphere(transform.position, radius);

            foreach (Collider c in cols)
            {
                AIPathFinder e = c.GetComponent <AIPathFinder>();
                if (e != null)
                {
                    e.GetComponent <AIPathFinder>().takeDamage(damage);
                }
            }
        }
        GameObject ParticalEffect = (GameObject)Instantiate(ParticalSystem, targetE.transform.position, targetE.transform.rotation);

        Destroy(ParticalEffect, 2f);

        Destroy(gameObject);
    }
コード例 #3
0
    void ShootAt(AIPathFinder e)
    {
        GameObject bulletGO = (GameObject)Instantiate(bulletPrefab, turretTransfom.GetChild(0).GetChild(0).transform.position, turretTransfom.rotation);

        Bullet b = bulletGO.GetComponent <Bullet>();

        b.target  = e.transform;
        b.targetE = e;
        b.damage  = Damage;
        b.radius  = DamageRadius;
        b.speed   = BulletSpeed;
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        spawnCDremaining -= Time.deltaTime;



        CountdownTimeText.text = "Next Wave: " + System.Math.Round(spawnTimer, 2).ToString();
        if (spawnTimer > 0)
        {
            spawnTimer -= Time.deltaTime;
            if (spawnTimer < 0)
            {
                spawnTimer = 0;
            }
        }

        ScoreManager sm = GameObject.FindObjectOfType <ScoreManager>();

        if (spawnCDremaining <= 0)
        {
            spawnCDremaining = spawnCooldown;
            bool DidSpawn = false;

            foreach (WaveComponent wc in waveComps)
            {
                if (wc.spawned < wc.num)
                {
                    GameObject bulletGO = (GameObject)Instantiate(wc.enemyPrefab, this.transform.position, this.transform.rotation);

                    AIPathFinder b = bulletGO.GetComponent <AIPathFinder>();
                    b.target = Goal.transform;

                    wc.spawned++;
                    DidSpawn = true;
                    break;
                }
            }
            if (DidSpawn == false)
            {
                if (transform.parent.childCount > 1)
                {
                    transform.parent.GetChild(1).gameObject.SetActive(true);
                }
                ;
//				} else {
//					Instantiate(GO.)
//				}

                Destroy(gameObject);
            }
        }
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        CDTimer -= Time.deltaTime;

        if (CDTimer <= 0)
        {
            CDTimer = CDTime;

            GameObject bulletGO = (GameObject)Instantiate(spawnPreFab, this.transform.position, this.transform.rotation);

            AIPathFinder b = bulletGO.GetComponent <AIPathFinder>();
            b.target = Goal.transform;
        }
    }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        AIPathFinder[] enemies = GameObject.FindObjectsOfType <AIPathFinder>();

        AIPathFinder nearestEnemy = null;
        float        dist         = Mathf.Infinity;

        foreach (AIPathFinder e in enemies)
        {
            float d = Vector3.Distance(this.transform.position, e.transform.position);
            if (nearestEnemy == null || d < dist)
            {
                nearestEnemy = e;
                dist         = d;
            }
        }

        if (nearestEnemy == null)
        {
            Debug.Log("No Enemies");
            return;
        }

        Vector3 a   = nearestEnemy.transform.position;
        Vector3 b   = this.transform.position;
        Vector3 dir = a - b;

        Quaternion lookRot = Quaternion.LookRotation(dir);

        turretTransfom.rotation = Quaternion.Euler(0, lookRot.eulerAngles.y, 0);

        fireCooldownLeft -= Time.deltaTime;
        if (fireCooldownLeft <= 0 && dir.magnitude <= range)
        {
            fireCooldownLeft = fireCooldown;
            ShootAt(nearestEnemy);
        }
    }
コード例 #7
0
ファイル: TileGenerator.cs プロジェクト: brandonLaing/GP2
 private void SetStartingNode(AIPathFinder ai)
 {
     ai.currentNode = GetRandomStartLocation(ai.gameObject);
 }