public void SomeMethod()
 {
     var someBool   = new EventArgTemplate <bool>(false);
     var someString = new EventArgTemplate <string>("");
     var someInt    = new EventArgTemplate <int>(0);
     var someFloat  = new EventArgTemplate <float>(0.0f);
 }
Exemplo n.º 2
0
    private void OnNewLevelSelected(object sender, EventArgTemplate <LevelController> levelController)
    {
        currentLevel = levelController.Attachment;

        AssignAllListeners();
        UpdateAll();
    }
Exemplo n.º 3
0
 protected virtual void HandleCompletion(bool success)
 {
     if (WaveCompleted != null)
     {
         var completion = new EventArgTemplate <bool>(success);
         WaveCompleted.Invoke(this, completion);
     }
 }
 public static void SafelyBroadcastEvent <T>(ref EventHandler <EventArgTemplate <T> > eventToBroadcast, T dataToAttach, object sender)
 {
     if (eventToBroadcast != null)
     {
         var attachment = new EventArgTemplate <T>(dataToAttach);
         eventToBroadcast.Invoke(sender, attachment);
     }
 }
Exemplo n.º 5
0
    private void OnTowerPurchased(object sender, EventArgTemplate <TowerConfiguration> purchasedTower)
    {
        if (placedTower != null)
        {
            Destroy(placedTower);
        }
        var prefab = purchasedTower.Attachment.TowerPrefab;

        placedTower = Instantiate(prefab);
        placedTower.transform.parent        = transform;
        placedTower.transform.localPosition = new Vector2(0, 0);
        OnCloseRequested();
    }
 private void NextWave(object sender, EventArgTemplate <bool> success)
 {
     if (success.Attachment)
     {
         waves[CurrentWaveIndex].WaveCompleted -= NextWave;
         currentWaveIndex++;
         if (currentWaveIndex >= waves.Count)
         {
             SafeEventHandler.SafelyBroadcastAction(ref WavesCompleted);
         }
         else
         {
             InitCurrentWave();
         }
     }
 }
Exemplo n.º 7
0
 private void OnTargetAcquired(object sender, EventArgTemplate <GameObject> target)
 {
     damagingBehaviour.StartTargeting(target.Attachment);
     damagingBehaviour.StartAttacking(true);
 }
Exemplo n.º 8
0
 private void OnTowerPurchased(object sender, EventArgTemplate <TowerConfiguration> purchasedTower)
 {
     SafeEventHandler.SafelyBroadcastEvent <TowerConfiguration>(ref PurchasedTower, purchasedTower.Attachment, this);
 }
Exemplo n.º 9
0
 private void OnLevelCompleted(object sender, EventArgTemplate <bool> success)
 {
     CurrentState = success.Attachment ? State.GameWon : State.GameLost;
     SafeEventHandler.SafelyBroadcastEvent(ref GameFinished, success.Attachment, this);
 }