Ejemplo n.º 1
0
  public void SpawnPlayer()
  {
    var point = Game.self.location.GetChild("PlayerSpawnPoint");
    Error.Verify(point != null);

    cam_go = Assets.TryReuse("Cameras/PlayerCamera");

    var player_go = Assets.TryReuse(prefab: "Characters/Player", activate: false);
    player_go.transform.position = new Vector3(point.transform.position.x, point.transform.position.y, point.transform.position.z);
    player_go.transform.rotation = new Quaternion(point.transform.rotation.x, point.transform.rotation.y, point.transform.rotation.z, point.transform.rotation.w);

    var unit = player_go.GetComponent<CombatUnit>();
    unit.Reset();
    unit.OnDamaged.AddListener(OnPlayerDamaged);

    player = unit;
    player_go.SetActive(true);

    hud = UI.Open<UIHud>();
    hud.Init();
  }
Ejemplo n.º 2
0
  public void Release()
  {
    current_wave = 0;
    player?.Release();

    foreach(var enemy in enemies)
    {
      if(enemy.is_alive)
      {
        var ai = enemy.gameObject.GetComponent<EnemyAI>();
        ai?.Release();
      }

      enemy.Release();
    }
    
    enemies.Clear();

    hud.CloseSelf();
    hud = null;

    Assets.Release(cam_go);
  }