Ejemplo n.º 1
0
    private void Awake()
    {
        GameObject gameController = GameObject.FindGameObjectWithTag("GameController");

        waveManager = gameController.GetComponentInChildren <WaveManagerScript>();
        uIManager   = gameController.GetComponentInChildren <UIManagerScript>();
    }
Ejemplo n.º 2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 3
0
    private WaveManagerScript WMS;              //mengatur wave (kecepatan, health, dan spawnRate enemy)

    void Awake()
    {
        Player       = GameObject.Find("player").GetComponent <PlayerControler> ();
        SK           = GameObject.Find("Panel").GetComponent <ScoreKeeper> ();
        WMS          = GameObject.Find("WaveManager").GetComponent <WaveManagerScript> ();
        enemySpeed   = WMS.n_enemySpeed;
        initialSpeed = enemySpeed;                              //initial speed dijadikan acuan ketika nanti balik dari keadaan powerUp lupa
        WaveUI       = GameObject.Find("WaveClear").GetComponent <WaveClearUI>();
    }
Ejemplo n.º 4
0
    protected virtual void Awake()
    {
        myCollider2D     = GetComponent <Collider2D>();
        myRigidBody2D    = GetComponent <Rigidbody2D>();
        mySpriteRenderer = GetComponent <SpriteRenderer>();
        myAnimator       = GetComponent <Animator>();

        LevelManager = GameObject.FindGameObjectWithTag("GameController").GetComponentInChildren <LevelManagerScript>();
        waveManager  = GameObject.FindGameObjectWithTag("GameController").GetComponentInChildren <WaveManagerScript>();
    }
Ejemplo n.º 5
0
    private void Awake()
    {
        GameObject gameController = GameObject.FindGameObjectWithTag("GameController");

        levelManager = gameController.GetComponentInChildren <LevelManagerScript>();
        uIManager    = gameController.GetComponentInChildren <UIManagerScript>();
        poolManager  = gameController.GetComponentInChildren <PoolManagerScript>();
        waveManager  = gameController.GetComponentInChildren <WaveManagerScript>();

        mySpriteRenderer = ballistaHead.GetComponent <SpriteRenderer>();
        myAnimator       = ballistaHead.GetComponent <Animator>();

        isAlive = true;

        currentLife = life;
        currentAmmo = ammo;
        boltPoolID  = poolManager.PreCache(boltPrefab, 2);

        canShoot = true;

        UpdateUI();
    }
Ejemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        spawnerBody.SetActive(false);

        waveManager = WaveManagerScript.instance;
    }
Ejemplo n.º 7
0
 private void Awake()
 {
     Instance = this;
 }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        HealthDrop();

        /*Image[] grayed = new Image[](4);
         * for ()
         *      Image[] grayed = weaponShop.Find("Expensive").GetComponents<Image>();
         * for (int i = 0; i != grayed.Length; ++i)
         * {
         *      grayed[i].enabled = AttachWeaponScript.weaponPrices[i+1] >= money;
         * }*/

        /*for (int i = 0; i < weaponShop.transform.childCount; ++i)
         * {
         *      weaponShop.transform.GetChild(i).Find("Expensive").GetComponent<Image>().enabled
         *              = AttachWeaponScript.weaponPrices[i+1] > money;
         * }*/

        WaveManagerScript wms = waves.GetComponent <WaveManagerScript>();

        infoTop.GetComponent <Text>().text    = string.Format("Mental Health: {0}    Wave {1} of {2}", health, WaveManagerScript.currentWave + 1, wms.WaveCount());
        infoBottom.GetComponent <Text>().text = string.Format("Money: ${0}K", money);

        //GameObject.Find("EventSystem").GetComponent<UnityEventQueueSystem>
        if ((Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) && !EventSystem.current.IsPointerOverGameObject())
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit rch;             // = new RaycastHit();
            if (Physics.Raycast(ray, out rch))
            {
                AttachWeaponScript aws = rch.collider.gameObject.GetComponent <AttachWeaponScript>();
                if (aws != null)
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        //Debug.Log("Mouse Down hit: "+ rch.collider.name);

                        AttachWeaponScript.WeaponTypes weapon = weaponShop.GetComponent <WeaponShopScript>().SelectedWeapon();
                        if ((weapon != AttachWeaponScript.WeaponTypes.None) && (weapon != aws.GetWeaponType()))
                        {
                            int cost = AttachWeaponScript.weaponPrices[(int)weapon];

                            GameObject message = (GameObject)Instantiate(Resources.Load("prefabs/message"));
                            Vector3    pos     = rch.collider.bounds.center;
                            pos.y = 0;
                            message.GetComponentInChildren <PopupMessageScript>().pos = pos;
                            //transform.position/* + new Vector3(0,0,10.0f)*/;
                            message.GetComponent <RectTransform>().SetParent(canvas.transform);
                            message.transform.SetSiblingIndex(0);
                            message.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
                            message.GetComponentInChildren <Text>().text            = "-$" + (cost).ToString() + "K";

                            money -= cost;
                            aws.SetWeaponType(weapon);
                        }
                    }
                    else
                    {
                        if (aws.GetWeaponType() == AttachWeaponScript.WeaponTypes.LieGenerator)
                        {
                            aws.ActivateLies();
                        }
                    }
                }
            }
        }
    }