Ejemplo n.º 1
0
 private void LogEvent(TileDamageEvent e)
 {
     if (e.LoggingLevel <= LoggingLevel)
     {
         Debug.Log(e.Description);
     }
 }
Ejemplo n.º 2
0
    IEnumerator Attacking()
    {
        attacking = true;
        animator.SetTrigger("Attacking");
        TileDamageEvent.Invoke(GetPieceDamage.ModifiedValue);
        yield return(new WaitForSeconds(1f));

        attacking = false;
    }
Ejemplo n.º 3
0
 protected void Awake()
 {
     PauseEvent.RegisterListener(LogEvent);
     MenuEvent.RegisterListener(LogEvent);
     TileSoldEvent.RegisterListener(LogEvent);
     TileDestroyedEvent.RegisterListener(LogEvent);
     TileDamageEvent.RegisterListener(LogEvent);
     TileUpdateEvent.RegisterListener(LogEvent);
     BaseDamageEvent.RegisterListener(LogEvent);
     BaseDamageUIEvent.RegisterListener(LogEvent);
     PurchaseMadeEvent.RegisterListener(LogEvent);
     PartsChangedUIEvent.RegisterListener(LogEvent);
     EnemyRecycledEvent.RegisterListener(LogEvent);
     GameStartEvent.RegisterListener(LogEvent);
     GameOverEvent.RegisterListener(LogEvent);
     GameWonEvent.RegisterListener(LogEvent);
     FastForwardEvent.RegisterListener(LogEvent);
 }
Ejemplo n.º 4
0
    private void TakeDamage(TileDamageEvent e)
    {
        Vector2Int cellLoc = (Vector2Int)grid.LocalToCell(transform.position);

        if (e.CellLoc == cellLoc)
        {
            CurrentHealth       -= e.DamageAmount;
            healthBar.percentage = (float)CurrentHealth / MaxHealth;
            gm.UpdateHealth((Vector3Int)cellLoc);

            if (CurrentHealth <= 0)
            {
                TileDestroyedEvent tileKilled = new TileDestroyedEvent
                {
                    Description = $"{name} tile was killed by {e.enemy.name}.",
                    CellLoc     = cellLoc
                };
                tileKilled.TriggerEvent();

                Destroy(gameObject);
            }
        }
    }
Ejemplo n.º 5
0
    protected void Awake()
    {
        grid = FindObjectOfType <Grid>();

        if (grid == null)
        {
            Debug.LogError($"{name}: unable to find grid!");
        }

        gm = FindObjectOfType <GameManager>();

        if (gm == null)
        {
            Debug.LogError($"{name}: unable to find game manager!");
        }

        if (HealthBarPrefab == null)
        {
            Debug.LogError($"{name}: no health bar prefab assigned!");
        }

        // Register listeners
        TileDamageEvent.RegisterListener(TakeDamage);
    }
Ejemplo n.º 6
0
 protected void OnDestroy()
 {
     TileDamageEvent.UnregisterListener(TakeDamage);
 }