Example #1
0
    public void RegisterSpawnPoint( SpawnPointController point )
    {
        ArrayList arr = new ArrayList(spawnPoints);
        arr.Add(point);

        spawnPoints = (SpawnPointController[])arr.ToArray(typeof(SpawnPointController));
    }
Example #2
0
    // Start is called before the first frame update
    void Awake()
    {
        // self
        rigidBody = GetComponent <Rigidbody2D>();

        // player
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

        // get parent point
        Transform            parentTransform = GetComponentInParent <Transform>();
        SpawnPointController spController    = GetComponentInParent <SpawnPointController>();

        // get bound transforms
        bounds    = new Transform[2];
        bounds[0] = spController.borders[0];
        bounds[1] = spController.borders[1];

        // spatial
        moveTargetIndex = 0;
        moveTarget      = bounds[moveTargetIndex].position;
        faceTarget      = moveTarget;
        direction       = 1;
        speeds          = new float[] { 15, 18, 20, 25 };

        // game stats
        healthMax     = 100;
        health        = healthMax;
        operationMode = 0;
        //speed = speeds[0];
        speed       = 20;
        heroInRange = false;
        calmState   = true;

        Debug.Log("Initiated");
    }
	protected void OnDestroy()
	{
		if(spawnPointController != null)
		{
			spawnPointController = null;
		}
	}
Example #4
0
 protected void OnDestroy()
 {
     if (spawnPointController != null)
     {
         spawnPointController = null;
     }
 }
Example #5
0
 private void SpawnZombie(SpawnPointController spawnPoint)
 {
     zombiesInGame++;
     if (zombiesRemaining == zombiesInGame)
     {
         spawningEnabled = false;
     }
     spawnPoint.SpawnZombie(round);
 }
 void SpawnEnemy(SpawnPointController spawn)
 {
     for (int i = 0; i < spawn.MaxNumberOfCreature; i++)
     {
         int             indexEnemy = Random.Range(0, enemyPool.Length);
         EnemyController enemyCtrl  = enemyPrefab.GetComponent <EnemyController>();
         enemyCtrl.Enemy = enemyPool[indexEnemy];
         GameObject enemy = Instantiate(enemyPrefab, spawn.transform);
         enemy.GetComponent <EnemyController>().SpawnPoint = spawn;
         spawn.CurrentNumberOfCreature++;
     }
 }
    public override void Execute()
    {
        executing = true;

        spawnPoint      = GameObject.Find(spawnPointName).transform; //TODO: Improve this
        spawnController = spawnPoint.GetComponent <SpawnPointController>();

        spiderIndex = 0;
        SpawnSpider();

        rsc.coroutineHlp.StartCoroutine(SpawnSpiders());
    }
    void Awake()
    {
        if (spawnPointController == null)
        {
            spawnPointController = this;
        }
        else
        {
            Debug.LogError("More than one card controller in application.");
        }

        spawnPoints = GetComponentsInChildren <WaveSpawner>();
    }
Example #9
0
    public override void Execute()
    {
        executing = true;

        spawnPoint      = GameObject.Find(spawnPointName).transform; //TODO: Improve this
        spawnController = spawnPoint.GetComponent <SpawnPointController>();

        SpawnSpider();

        if (totalSpawnsNumber > 1)
        {
            rsc.coroutineHlp.StartCoroutine(SpawnSpiders());
        }
        else
        {
            executing = false;
        }
    }
Example #10
0
    // Start is called before the first frame update
    void Awake()
    {
        // get AI
        enemyAI = GetComponent <EnemyAI>(); // Why does this NULL out one me?

        // set time left
        timeLeft = 60f;

        // get conductor
        spawnMaster = GameObject.FindObjectOfType <SpawnMaster>();

        // self
        rigidBody = GetComponent <Rigidbody2D>();

        // get borders
        spawnPoint = spawnMaster.spawnPoints[spawnPointIndex].GetComponent <SpawnPointController>();

        // Init AI
    }
Example #11
0
    private int CreateInstance(int chosenSpawnPointIndex)
    {
        for (int count = 0; count < enemyTypesNumber; count++)
        {
            for (int inner = 0; inner < enemyTypesNumber - typePopulations[count]; inner++)
            {
                pValues.Add(count);
            }
        }

        // select random type from the list
        System.Random rnd          = new System.Random();
        int           rndTypeIndex = rnd.Next(pValues.Count - 1);
        int           typeSpawn    = pValues[rndTypeIndex];

        Transform chosenSpawnPoint = spawnPoints[chosenSpawnPointIndex];
        // get coordinates of spawn point
        Vector3 spawnCoordinates = chosenSpawnPoint.transform.position;

        GameObject newEnemy = Instantiate(enemies[typeSpawn], spawnCoordinates, Quaternion.identity, chosenSpawnPoint);
        // send information to the enemy about the parent spawning point
        EnemyController      newEnemyController   = newEnemy.GetComponent <EnemyController>();
        EnemyAI              newEnemyAI           = newEnemy.GetComponent <EnemyAI>();
        SpawnPointController spawnPointController = chosenSpawnPoint.GetComponent <SpawnPointController>();

        newEnemyController.spawnPointIndex = chosenSpawnPointIndex;
        newEnemyController.selfType        = typeSpawn;
        newEnemy.layer = 11;
        //newEnemyController.enemyAI.boundOne = spawnPointController.borders[0].position;
        //newEnemyController.enemyAI.boundTwo = spawnPointController.borders[1].position;

        // log the new enemy in the population list
        population.Add(newEnemy);
        // mark the population type increase
        typePopulations[typeSpawn] += 1;

        return(typeSpawn);
    }
Example #12
0
 //--------------------------------------------------------------------------
 // public static methods
 //--------------------------------------------------------------------------
 //--------------------------------------------------------------------------
 // protected mono methods
 //--------------------------------------------------------------------------
 protected void Awake()
 {
     spawnPointController = this;
 }
	//--------------------------------------------------------------------------
	// public static methods
	//--------------------------------------------------------------------------
	//--------------------------------------------------------------------------
	// protected mono methods
	//--------------------------------------------------------------------------
	protected void Awake()
	{
		spawnPointController = this;
	}