예제 #1
0
    void Update()
    {
        if (UnactiveHazards.Count > 0 && WaveControl.GetInstance().IsWaveActive())
        {
            if (currentTimer >= currentHazardsSpawnTime)
            {
                currentTimer = 0f;
                float randomNumber = Random.Range(0f, 100f);
                if (randomNumber <= currentChanceOfSpawn)
                {
                    currentChanceOfSpawn    = startingChanceOfSpawn;
                    currentHazardsSpawnTime = startingHazardsSpawnTime;

                    int          randomIndex = Random.Range(0, UnactiveHazards.Count);
                    HazardSquare hazard      = UnactiveHazards[randomIndex];
                    hazard.SetActive(true);
                    ActiveHazards.Add(hazard);
                    UnactiveHazards.Remove(hazard);
                }
                else
                {
                    currentChanceOfSpawn    += plusChancePerCheck;
                    currentHazardsSpawnTime -= minusTimePerCheck;
                }
            }
            else
            {
                currentTimer += Time.deltaTime;
            }
        }
    }
예제 #2
0
 private void CheckCanSpawn()
 {
     if (GameManager.Get().tutorialDone&& !canSpawnItems && WaveControl.GetInstance().IsWaveActive())
     {
         canSpawnItems = true;
     }
 }
예제 #3
0
        private void btnBrowseSound2_Click(object sender, EventArgs e)
        {
            ofdSound = new OpenFileDialog();
            ofdSound.InitialDirectory = String.IsNullOrEmpty(LastPath)? "c:\\": LastPath;
            ofdSound.Filter           = "txt files (*.wav)|*.wav|All files (*.*)|*.*";
            ofdSound.FilterIndex      = 2;
            ofdSound.RestoreDirectory = true;

            if (ofdSound.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // Process wave control
                    wc2      = new WaveControl();
                    wc2.Name = ofdSound.FileName;
                    LastPath = Path.GetDirectoryName(ofdSound.FileName);
                    wc2.Read(wc2, ofdSound.FileName, pbSound2);
                    wc2.Refresh();

                    // Add wave result
                    pSound2.Controls.Clear();
                    pSound2.Controls.Add(wc2);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while reading the sound file: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     coreObj       = GameObject.Find("Core");
     coreObjHealth = coreObj.GetComponent <CoreHealth>();
     waveScript    = coreObj.GetComponent <WaveControl>();
     coreHealthTxt = GameObject.Find("/CanvasObjectives/CoreHealthTxt").GetComponent <Text>();
     nextWaveTxt   = GameObject.Find("/CanvasObjectives/NextWaveTxt").GetComponent <Text>();
 }
예제 #5
0
 void Start()
 {
     currentWave    = 0;
     enemiesKilled  = 0;
     gui            = GameObject.FindGameObjectWithTag("GUI").GetComponent <GameGUI>();
     waveController = Camera.main.GetComponent <WaveControl>();
     LevelUp();  // Init to level 1
 }
예제 #6
0
 void Start()
 {
     currentWave = 0;
     enemiesKilled = 0;
     gui = GameObject.FindGameObjectWithTag("GUI").GetComponent<GameGUI>();
     waveController = Camera.main.GetComponent<WaveControl>();
     LevelUp();  // Init to level 1
 }
예제 #7
0
 private void Start()
 {
     anim = GetComponent <Animator>();
     wave = WaveControl.GetInstance();
     WaveControl.HordeIncoming += HordeIncomingTrigger;
     currentWave   = wave.currentWave;
     waveText.text = "NEW GAME";
     DisableWarnings();
 }
    public void Start()
    {
        // Get wavecontrol reference
        wc = Camera.main.GetComponent <WaveControl>();

        // Get player controller reference
        playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

        // Get player reference
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
    }
예제 #9
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
예제 #10
0
    private Monster GetMonster()
    {
        Monster[] monsters      = WaveControl.GetMonsters();
        Monster   monsterReturn = null;

        if (monsters.Length > 0)
        {
            monsterReturn = monsters[0];

            foreach (Monster monster in monsters)
            {
                float distance = GetDistanceToMonster(monster);
                if (distance <= attack.GetDistanceAttack() && distance < GetDistanceToMonster(monsterReturn))
                {
                    monsterReturn = monster;
                }
            }
        }

        return(monsterReturn);
    }
    // Use this for initialization
    void Start()
    {
        animator   = GetComponent <Animator>();
        controller = GetComponent <CharacterController>();
        camera     = Camera.main;
        gui        = GameObject.FindGameObjectWithTag("GUI").gameObject.GetComponent <GameGUI>();
        wc         = camera.GetComponent <WaveControl>();

        // Set guns to default values
        GetGunByID(1).SetDamage(1.0f);
        GetGunByID(1).SetAmmoPerMag(32);
        GetGunByID(1).SetCurrentMagAmmo(32);
        GetGunByID(2).SetDamage(3.0f);
        GetGunByID(2).SetAmmoPerMag(2);
        GetGunByID(2).SetCurrentMagAmmo(2);
        GetGunByID(3).SetDamage(2.0f);
        GetGunByID(3).SetAmmoPerMag(10);
        GetGunByID(3).SetCurrentMagAmmo(10);

        // Equip default gun (AR)
        EquipGun(0);
        currentGun.SetCurrentMagAmmo(32);
    }
예제 #12
0
    void HandleClick()
    {
        // Clicking anywhere will remove instructions
        if (instructionPref != null)
        {
            Destroy(instructionPref);
        }

        // Start Game
        if (!start && waveControl == null)
        {
            GameObject waveObj = GameObject.Instantiate(waveObjPref);
            waveControl = waveObj.GetComponent <WaveControl>();
            waveControl.Init();
            start = true;
        }

        // Check board selection
        int x = (int)Input.mousePosition.x / (Screen.width / 32);  // 32 cells
        int y = (int)Input.mousePosition.y / (Screen.height / 18); // 14 cells +2+2 on for top and bottom UI

        y -= 2;                                                    // Board starts 2 cells up.



        GameObject obj = Game.grid.CheckGrid(y, x);

        if (obj != null && selectedTower == null)
        {
            selectedTower = obj.GetComponent <Tower>();
            #region Tower
            if (!selected)
            {
                float width  = Screen.width / 32;
                float height = Screen.height / 18;
                selected = true;
                towerSelect.rectTransform.position = new Vector3((x + 0.5f) * width, (y + 2.5f) * height, 0);
                // Drawing the Selection UI varies if near the edge. Take care of specific cases
                // NW corner
                if (x < 2 && y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                // NE corner
                else if (x > 29 && y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(-45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                // SE corner
                else if (x > 29 && y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(0, 45, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(-45, 0, 0);
                }
                // Top
                else if (y > 11)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                else if (x > 29)
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(-45, 0, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(0, -45, 0);
                }
                else
                {
                    towerCharge.rectTransform.position = towerSelect.rectTransform.position + new Vector3(0, 45, 0);
                    towerSell.rectTransform.position   = towerSelect.rectTransform.position + new Vector3(45, 0, 0);
                }
            }
            #endregion
        }
        else // Try looking at UI objects
        {
            RaycastHit2D hit = Physics2D.Raycast(new Vector2(Input.mousePosition.x / Screen.width * 19.2f, Input.mousePosition.y / Screen.height * 10.8f - 1.2f), Vector2.right, 0.1f);

            if (hit.collider != null)
            {
                //Game.TargetEnemy = hit.collider.gameObject.GetComponent<Enemy>();
            }

            #region UI

            // Create a raycast using the mouse position and test against the UI
            PointerEventData pointer = new PointerEventData(EventSystem.current);
            pointer.position = Input.mousePosition;
            List <RaycastResult> raycast = new List <RaycastResult>();
            EventSystem.current.RaycastAll(pointer, raycast);

            if (raycast.Count == 0)
            {
                selected = false;
                towerSelect.rectTransform.position = new Vector3(-100, 0);
                selectedTower = null;
                return; // found nothing
            }

            // You can click either a UI element, or Tower on the board.
            // First check if selecting UI element - Towers, Abilities, Pause, Speed, Menu

            for (int i = 0; i < raycast.Count; i++)
            {
                Debug.Log(raycast[0]);


                TowerButton towerBtn = raycast[i].gameObject.GetComponent <TowerButton>();
                if (towerBtn != null) // Tower UI Element found
                {
                    if (Game.charges < towerBtn.cost)
                    {
                        return;                               // make sure u have enough money
                    }
                    dragObject = GameObject.Instantiate(dragPref);
                    DragControl dc = dragObject.GetComponent <DragControl>();
                    //dc.obj = towerBtn.Tower;
                    dc.buttonRef = towerBtn;
                    dc.sprite    = towerBtn.Tower.GetComponent <SpriteRenderer>().sprite;
                    isTower      = true;
                    dc.cost      = towerBtn.cost;
                    break;
                }
                AbilityBtn abilityBtn = raycast[i].gameObject.GetComponent <AbilityBtn>();
                if (abilityBtn != null)
                {
                    if (Game.charges > 0)
                    {
                        if (abilityBtn.abilityType == AbilityType.Red && Game.redCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartRed();
                            Game.redCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Blue && Game.blueCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartBlue();
                            Game.blueCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Yellow && Game.yellowCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartYellow();
                            Game.yellowCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Purple && Game.purpleCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartPurple();
                            Game.purpleCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Orange && Game.orangeCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartOrange();
                            Game.orangeCount--;
                        }
                        else if (abilityBtn.abilityType == AbilityType.Green && Game.greenCount > 0)
                        {
                            lightObj.GetComponent <LightObject>().StartGreen();
                            Game.greenCount--;
                        }
                        break;
                    }
                }
                SpeedBtn speedBtn = raycast[i].gameObject.GetComponent <SpeedBtn>();
                if (speedBtn != null)
                {
                    speedBtn.Click();
                }

                if (raycast[i].gameObject.tag == "Pause")
                {
                    if (Game.isPaused)
                    {
                        Game.isPaused  = false;
                        Game.GameSpeed = Game.Speed;
                        Time.timeScale = Game.Speed;
                    }
                    else
                    {
                        Game.isPaused  = true;
                        Time.timeScale = 0;
                        Game.GameSpeed = 0;
                    }
                }

                if (raycast[i].gameObject.tag == "Charge")
                {
                    if (selectedTower != null)
                    {
                        if (selectedTower.ChargeTower())
                        {
                            Game.charges--;
                        }
                    }
                }
                else if (raycast[i].gameObject.tag == "Sell")
                {
                    if (selectedTower != null)
                    {
                        // Destory tower, get half half a charge
                        selectedTower.SellTower();
                        Game.chargeCounter += chargeMax / 2;
                    }
                }
            }
            #endregion

            // Remove tower selection
            selected = false;
            towerSelect.rectTransform.position = new Vector3(-100, 0);
            selectedTower = null;
        }
    }
예제 #13
0
 void Start()
 {
     anim   = gameObject.GetComponent <Animator>();
     waves  = GameObject.Find("GameControl").GetComponent <WaveControl>();
     h.text = "Health:" + Health;
 }
예제 #14
0
 public void FreezeEnemies()
 {
     WaveControl.GetInstance().RalenticeEnemies();
     Destroy(gameObject);
 }
예제 #15
0
 private void Die()
 {
     WaveControl.MonsterDie(GetComponent <Monster>());
     hp.OnHpDieEvent.RemoveListener(Die);
 }
예제 #16
0
 public void OnUltimateLight()
 {
     SetUltimateAvailable(false);
     WaveControl.GetInstance().KillAllEnemiesOnScreen();
 }
예제 #17
0
 // Use this for initialization
 void Awake()
 {
     Instan = this;
 }
예제 #18
0
 void Start()
 {
     potentialTargets = new List <GameObject>();
     currentWave      = GameObject.Find("Core").GetComponent <WaveControl>();
 }
    // Use this for initialization
    void Start()
    {
        animator = GetComponent<Animator>();
        controller = GetComponent<CharacterController>();
        camera = Camera.main;
        gui = GameObject.FindGameObjectWithTag("GUI").gameObject.GetComponent<GameGUI>();
        wc = camera.GetComponent<WaveControl>();

        // Set guns to default values
        GetGunByID(1).SetDamage(1.0f);
        GetGunByID(1).SetAmmoPerMag(32);
        GetGunByID(1).SetCurrentMagAmmo(32);
        GetGunByID(2).SetDamage(3.0f);
        GetGunByID(2).SetAmmoPerMag(2);
        GetGunByID(2).SetCurrentMagAmmo(2);
        GetGunByID(3).SetDamage(2.0f);
        GetGunByID(3).SetAmmoPerMag(10);
        GetGunByID(3).SetCurrentMagAmmo(10);

        // Equip default gun (AR)
        EquipGun(0);
        currentGun.SetCurrentMagAmmo(32);
    }
예제 #20
0
    public void Start()
    {
        // Get wavecontrol reference
        wc = Camera.main.GetComponent<WaveControl>();

        // Get player controller reference
        playerController = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();

        // Get player reference
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
    }
예제 #21
0
 public void HordeIncomingTrigger(WaveControl wc)
 {
     anim.SetTrigger("horde");
 }
예제 #22
0
 void Start()
 {
     waveControl = GameObject.Find("Controladores").GetComponent <WaveControl>();
     ENEMY_TYPES = Enemy.Length;
 }
예제 #23
0
 private void Start()
 {
     Instance      = this;
     activeEnemies = new List <Enemy>();
 }