Ejemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.name == "Goal")
        {
            foreach (SimpleRotation s in other.gameObject.GetComponentsInChildren <SimpleRotation>())
            {
                s.enabled = false;
                // TODO fix
                s.gameObject.transform.localEulerAngles = new Vector3(12.439f, -28.887f, 58.768f);
                s.gameObject.transform.localPosition    = new Vector3(-0.0101f, 0.0243f, 0.0017f);
            }
            UserInterface.instance.CollectGoal();
            other.gameObject.transform.SetParent(leftHand);
            other.gameObject.transform.localPosition    = Vector3.zero;
            other.gameObject.transform.localEulerAngles = Vector3.zero;
            other.gameObject.GetComponentInChildren <SpriteRenderer>().enabled = false;
        }

        if (other.gameObject.tag == "DifficultyTrigger")
        {
            EnemyGlobalSettings.NextLevel();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Health")
        {
            currentLife = maxLife;
            UserInterface.instance.RefreshPlayerStats();
            other.gameObject.GetComponent <Collectable>().Collect();
            AudioManager.instance.PlaySound("Heart_Collect");
        }
    }
Ejemplo n.º 2
0
 void Start()
 {
     colliders         = GetComponentsInChildren <BoxCollider>();
     currentDifficulty = EnemyGlobalSettings.GetDifficulty();
     SpawnAll();
     StartCoroutine(Respawn());
 }
Ejemplo n.º 3
0
 public void StartGame()
 {
     player.GetComponent <PlayerMovement>().enabled        = true;
     player.GetComponent <PlayerShooting>().enabled        = true;
     player.GetComponent <PlayerNavigation>().enabled      = true;
     cameraCenter.GetComponent <CameraBehaviour>().enabled = true;
     EnemyGlobalSettings.SetGameplayActive(true);
     mainMenuSong.SetActive(false);
     inGameSong.SetActive(true);
 }
Ejemplo n.º 4
0
 public void SpawnAll()
 {
     CleanList();
     foreach (Collider c in colliders)
     {
         for (int i = enemies.Count; i < EnemyGlobalSettings.GetDensity(); i++)
         {
             Vector3 pos = GenerateRandomPointAtCollider(c);
             pos = new Vector3(pos.x, height, pos.z);
             enemies.Add(Instantiate(EnemyGlobalSettings.GetEnemy(), pos, Quaternion.identity));
         }
     }
 }
Ejemplo n.º 5
0
    IEnumerator Respawn()
    {
        yield return(new WaitForSeconds(Random.Range(3.0f, 6.0f)));

        if (EnemyGlobalSettings.GetDifficulty() != currentDifficulty)
        {
            currentDifficulty = EnemyGlobalSettings.GetDifficulty();
            RemoveAll();
            SpawnAll();
        }
        else if (Vector3.Distance(transform.position, PlayerMovement.instance.transform.position) > 3.0f)
        {
            SpawnAll();
        }
        StartCoroutine(Respawn());
    }