Exemplo n.º 1
0
    IEnumerator SpawnEnemy()
    {
        if (campingFeature == null)
        {
            campingFeature = GetComponent <CampingFeature>();
        }
        Transform spawnTile     = campingFeature.GetSpawnTile();
        Material  tileMat       = spawnTile.GetComponent <Renderer>().material;
        Color     initialColour = tileMat.color;

        float spawnTimer = 0;

        while (spawnTimer < spawnDelay)
        {
            tileMat.color = Color.Lerp(initialColour, flashColour, Mathf.PingPong(spawnTimer * tileFlashSpeed, 1));
            spawnTimer   += Time.deltaTime;
            yield return(null);
        }
        if (instantiator == null)
        {
            instantiator = FindObjectOfType <Instantiator>();
        }
        GameObject instance = instantiator.Instantiate(spawnable, spawnTile.position + Vector3.up);

        Spawned(instance);
    }
Exemplo n.º 2
0
 private void Start()
 {
     gm             = FindObjectOfType <Game>();
     instantiator   = FindObjectOfType <Instantiator>();
     campingFeature = GetComponent <CampingFeature>();
 }
Exemplo n.º 3
0
 private void Awake()
 {
     campingFeature            = FindObjectOfType <CampingFeature>();
     campingFeatureToggle.isOn = PlayerPrefs.GetInt("CampingEnabled", 0) == 0;
 }