Exemplo n.º 1
0
    public override void Initialize()
    {
        //get animations
        anim = GetComponent <Animator>();

        if (GetComponent <NavMeshAgent>())
        {
            agent = GetComponent <NavMeshAgent>();
        }

        for (int i = 0; i < anim.runtimeAnimatorController.animationClips.Length; i++)
        {
            if (anim.runtimeAnimatorController.animationClips[i].name.Contains("Attack"))
            {
                attacksName.Add(anim.runtimeAnimatorController.animationClips[i].name);
                attacksPos.Add(i);
            }
        }
        //add shootpoints
        foreach (Transform sp in transform.Find("ShootPoints"))
        {
            shootPoints.Add(sp);
        }

        stockpile = GameObject.Find("Bullets").GetComponent <BulletStockpile>();
        stockpile.AddBullet(bulletPrefab.name, bullets, 0.1f, bulletSpeed, transform.parent.parent.name);

        cam = Camera.main.gameObject;
    }
    private void OnEnable()
    {
        lives     = 3;
        bombCount = 1;
        damage    = 1;
        rof       = 1f;
        srt       = 60;

        bulletStockpile = GameObject.FindWithTag("GameController").GetComponent <BulletStockpile>();
        bulletStockpile.SetBps(0);
        rateOfFireText      = _rateOfFire.GetComponent <Text>();
        rateOfFireText.text = rof.ToString();
        damageText          = _damage.GetComponent <Text>();
        damageText.text     = damage.ToString();
        bombText            = _bombCounter.GetComponent <Text>();
        bombText.text       = bombCount.ToString();
        livesText           = _livesCounter.GetComponent <Text>();
        livesText.text      = lives.ToString();
        srtText             = _SRTCounter.GetComponent <Text>();
        srtText.text        = srt.ToString();

        shieldBehavior  = GetComponent <ShieldBehavior>();
        shipRender      = GetComponent <SpriteRenderer>();
        shipColl        = GetComponent <Collider2D>();
        soundController = GameObject.FindWithTag("GameController").GetComponent <SoundController>();
    }
Exemplo n.º 3
0
 //get stuff
 public override void Initialize()
 {
     cam       = Camera.main.gameObject;
     aim       = transform.GetChild(0).gameObject;
     stockpile = GameObject.Find("Bullets").GetComponent <BulletStockpile>();
     stockpile.AddBullet(bulletPrefab.name, bullets, firerate, bulletSpeed, transform.parent.parent.name);
     defaultTimer = firerate;
 }
Exemplo n.º 4
0
 protected void OnEnable()
 {
     _bulletStockpile = GameObject.FindWithTag("GameController").GetComponent <BulletStockpile>();
     button           = GetComponent <Button>();
     button.onClick.AddListener(BuyUpgrade);
     costText        = transform.Find("Cost").GetComponent <Text>();
     costText.text   = getCostText();
     soundController = GameObject.FindWithTag("GameController").GetComponent <SoundController>();
 }
Exemplo n.º 5
0
    public override void Initialize()
    {
        gm = GameObject.Find("GameManager").GetComponent <GameManager>();

        cam    = Camera.main.gameObject;
        player = GameObject.Find("Player");
        aim    = transform.GetChild(0).gameObject;
        if (GameObject.Find("Bullets").GetComponent <BulletStockpile>())
        {
            stockpile = GameObject.Find("Bullets").GetComponent <BulletStockpile>();
            stockpile.AddBullet(bulletPrefab.name, bullets, firerate, bulletSpeed, transform.parent.parent.name);
        }
        defaultTimer = firerate;
    }
Exemplo n.º 6
0
    ////////////////////////////////////////////////////////////////

    public void Initialize()
    {
        ////////////////////////////////////////////////////////////////

        shootPoints = transform.Find("ShootPoints");
        stockpile   = GameObject.Find("Bullets").GetComponent <BulletStockpile>();
        cam         = Camera.main.gameObject;
        anim        = GetComponent <Animator>();

        if (GetComponent <Collider>())
        {
            GetComponent <Collider>().enabled = false;
        }

        ////////////////////////////////////////////////////////////////
        // GET ATTACK ANIMATIONS
        ////////////////////////////////////////////////////////////////

        for (int i = 0; i < anim.runtimeAnimatorController.animationClips.Length; i++)
        {
            if (anim.runtimeAnimatorController.animationClips[i].name.Contains("Attack"))
            {
                attacksName.Add(anim.runtimeAnimatorController.animationClips[i].name);
                attacksPos.Add(i);
            }
        }

        ////////////////////////////////////////////////////////////////

        for (int i = 0; i < shootPoints.childCount; i++)
        {
            foreach (Transform sp in shootPoints.GetChild(i))
            {
                if (bullets.ContainsKey(bulletPrefabs[i].name))
                {
                    bullets[bulletPrefabs[i].name]++;
                }
                else
                {
                    bullets.Add(bulletPrefabs[i].name, 1);
                }
            }
            stockpile.AddBullet(bulletPrefabs[i].name, bullets[bulletPrefabs[i].name], firerate, bulletSpeed, transform.parent.parent.name);
        }

        ////////////////////////////////////////////////////////////////
    }
Exemplo n.º 7
0
    // Use this for initialization
    protected void Awake()
    {
        bulletStockpile = GameObject.FindWithTag("GameController").GetComponent <BulletStockpile>();
        soundController = GameObject.FindWithTag("GameController").GetComponent <SoundController>();
        enemyRenderer   = GetComponent <SpriteRenderer>();
        gameObject.name = "Enemy";

        //Entrance setup.
        yStop = Random.Range(2f, 4.5f);
        transform.position = new Vector3(Random.Range(-6.5f, 6.5f), 5.5f, 0);

        //rof setup.
        timeTillShoot = 1 / rof;

        playerShip = GameObject.FindWithTag("Player").GetComponent <PlayerShip>();
        playerColl = GameObject.FindWithTag("Player").GetComponent <Collider2D>();
    }
Exemplo n.º 8
0
    public override void Initialize()
    {
        if (GameObject.Find("GameManager"))
        {
            gm = GameObject.Find("GameManager").GetComponent <GameManager>();
        }


        if (transform.parent.parent.Find("RoadWayPoints"))
        {
            wayPointParent     = transform.parent.parent.Find("RoadWayPoints");
            wayPointMax        = wayPointParent.childCount - 1;
            transform.position = wayPointParent.GetChild(0).position;
            transform.position = new Vector3(transform.position.x, transform.localScale.y / 2, transform.position.z);
            ableToGoForward    = true;
        }
        else
        {
            Debug.Log("No waypoints!");
        }


        if (GameObject.Find("Player"))
        {
            player = GameObject.Find("Player");
        }

        if (transform.childCount != 0)
        {
            aim = transform.GetChild(0).gameObject;
        }

        if (GameObject.Find("Bullets").GetComponent <BulletStockpile>())
        {
            stockpile = GameObject.Find("Bullets").GetComponent <BulletStockpile>();
            stockpile.AddBullet(bulletPrefab.name, bullets, firerate, bulletSpeed, transform.parent.parent.name);
        }

        cam = Camera.main.gameObject;
        default_ShootTimer = firerate;
    }
Exemplo n.º 9
0
    ////////////////////////////////////////////////////////////////

    public override void Initialize()
    {
        ////////////////////////////////////////////////////////////////
        // GET STUFF
        ////////////////////////////////////////////////////////////////

        FindShootPoints(transform);

        //get animations
        anim = GetComponent <Animator>();
        for (int i = 0; i < anim.runtimeAnimatorController.animationClips.Length; i++)
        {
            if (anim.runtimeAnimatorController.animationClips[i].name.Contains("Attack"))
            {
                numberOfAttackAnims++;
            }
        }

        stockpile   = GameObject.Find("Bullets").GetComponent <BulletStockpile>();
        gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
        cam         = Camera.main.gameObject;

        ////////////////////////////////////////////////////////////////
        // ADD SHOOTPOINTS
        ////////////////////////////////////////////////////////////////

        foreach (Transform list in shootPoints)
        {
            foreach (Transform point in list)
            {
                points.Add(point);
            }
        }


        ////////////////////////////////////////////////////////////////
        // ADD BULLETS TO STOCKPILE
        ////////////////////////////////////////////////////////////////

        for (int i = 0; i < points.Count; i++)
        {
            foreach (Transform sp in points[i])
            {
                if (bullets.ContainsKey(bulletPrefabs[i].name))
                {
                    bullets[bulletPrefabs[i].name]++;
                }
                else
                {
                    bullets.Add(bulletPrefabs[i].name, 1);
                }
            }
        }

        ////////////////////////////////////////////////////////////////

        List <string> bulletsKeys = bullets.Keys.ToList();

        for (int i = 0; i < bulletPrefabs.Count; i++)
        {
            stockpile.AddBullet(bulletPrefabs[i].name, bullets[bulletPrefabs[i].name], 0.01f, bulletSpeeds[i], transform.parent.parent.name);
        }

        ////////////////////////////////////////////////////////////////
    }