private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag != "Trigger" && other.gameObject.tag != "Player" && other.gameObject.tag != "ShooterBullet")
        {
            switch (other.gameObject.tag)
            {
            case "Shooter":
                Shooter hitShooter = other.GetComponentInParent <Shooter>();
                hitShooter.SubHealth();
                break;

            case "Brawler":
                Brawler hitBrawler = other.GetComponentInParent <Brawler>();
                hitBrawler.SubHealth();
                break;

            case "Ghost":
                Ghost hitGhost = other.GetComponentInParent <Ghost>();
                hitGhost.SubHealth();
                break;

            case "BrawlerGenerator":
                BrawlerGenerator hitBrawlerGenerator = other.GetComponentInParent <BrawlerGenerator>();
                hitBrawlerGenerator.SubHealth();
                break;

            case "GhostGenerator":
                GhostGenerator hitGhostGenerator = other.GetComponentInParent <GhostGenerator>();
                hitGhostGenerator.SubHealth();
                break;

            case "ShooterGenerator":
                ShooterGenerator hitShooterGenerator = other.GetComponentInParent <ShooterGenerator>();
                hitShooterGenerator.SubHealth();
                break;

            default:
                break;
            }

            Destroy(this.gameObject);
            Debug.Log(other.gameObject.name);
        }
    }
    private void PlaceEnemyGenerator()
    {
        int MaxCols = NumCellsX;
        int MaxRows = NumCellsZ;

        int GenColumn = Random.Range(0, NumCellsX);
        int GenRow    = Random.Range(0, NumCellsZ);

        List <Cell> generatorCells = new List <Cell>();
        Cell        checkCell      = GetCellAt(GenColumn, GenRow);

        for (int i = 0; i < numShooterGenerators; i++)
        {
            while ((GenColumn < MinGenDistFromPlayer && GenRow < MinGenDistFromPlayer) || generatorCells.Contains(checkCell))
            {
                GenColumn = Random.Range(0, NumCellsX);
                GenColumn = Random.Range(0, NumCellsZ);

                checkCell = GetCellAt(GenColumn, GenRow);
            }

            Cell GeneratorCell = GetCellAt(GenColumn, GenRow);
            generatorCells.Add(GeneratorCell);
            GameObject generatorObj = Instantiate(shooterGeneratorPrefab);
            generatorObj.transform.position = GeneratorCell.transform.position;
            ShooterGenerator generator = generatorObj.GetComponent <ShooterGenerator>();

            generator.Init(GeneratorCell);

            GenColumn = Random.Range(0, NumCellsX);
            GenColumn = Random.Range(0, NumCellsZ);
            checkCell = GetCellAt(GenColumn, GenRow);
        }

        for (int i = 0; i < numBrawlerGenerators; i++)
        {
            while ((GenColumn < MinGenDistFromPlayer && GenRow < MinGenDistFromPlayer) || generatorCells.Contains(checkCell))
            {
                GenColumn = Random.Range(0, NumCellsX);
                GenColumn = Random.Range(0, NumCellsZ);

                checkCell = GetCellAt(GenColumn, GenRow);
            }

            Cell GeneratorCell = GetCellAt(GenColumn, GenRow);
            generatorCells.Add(GeneratorCell);
            GameObject generatorObj = Instantiate(brawlerGeneratorPrefab);
            generatorObj.transform.position = GeneratorCell.transform.position;
            BrawlerGenerator generator = generatorObj.GetComponent <BrawlerGenerator>();

            generator.Init(GeneratorCell);

            GenColumn = Random.Range(0, NumCellsX);
            GenColumn = Random.Range(0, NumCellsZ);
            checkCell = GetCellAt(GenColumn, GenRow);
        }



        for (int i = 0; i < numGhostGenerators; i++)
        {
            while ((GenColumn < MinGenDistFromPlayer && GenRow < MinGenDistFromPlayer) || generatorCells.Contains(checkCell))
            {
                GenColumn = Random.Range(0, NumCellsX);
                GenColumn = Random.Range(0, NumCellsZ);

                checkCell = GetCellAt(GenColumn, GenRow);
            }

            Cell GeneratorCell = GetCellAt(GenColumn, GenRow);
            generatorCells.Add(GeneratorCell);
            GameObject generatorObj = Instantiate(ghostGeneratorPrefab);
            generatorObj.transform.position = GeneratorCell.transform.position;
            GhostGenerator generator = generatorObj.GetComponent <GhostGenerator>();

            generator.Init(GeneratorCell);
        }
    }
Пример #3
0
 public void SetGenerator(BrawlerGenerator Generator)
 {
     myGenerator = Generator;
 }