예제 #1
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     UIInputEvent.RegisterListener(GetUIInput);
     CellConvertEvent.RegisterListener(CellConverted);
     DeathEvent.RegisterListener(OnDeathEvent);
     //Load all the needed scenes for the games start
     LoadScenes();
     InstatiateScenes();
 }
예제 #2
0
 private void CellConverted(CellConvertEvent ccei)
 {
     for (int i = 0; i < cellsLeftToConvert.Count; i++)
     {
         if (cellsLeftToConvert[i].GetInstanceId() == ccei.CovertedCell.GetInstanceId())
         {
             cellsLeftToConvert.RemoveAt(i);
             if (cellsLeftToConvert.Count == 0)
             {
                 StopGame();
                 WinEvent wei = new WinEvent();
                 wei.FireEvent();
             }
         }
     }
 }
예제 #3
0
    public void BodyEntered(Node body)
    {
        if (body.IsInGroup("RedBlob"))
        {
            //Set the infected bool to true to change the sprite
            infected = true;
            //Fire the convert event to notify the cell list in main to remove the cell from the unconverted list
            CellConvertEvent ccei = new CellConvertEvent();
            ccei.CovertedCell = this;
            ccei.FireEvent();
            //Swap out sprites to the red converted sprite
            blueSprite.Hide();
            redSprite.Show();
        }
        PlayAudioEvent paei = new PlayAudioEvent();

        paei.soundEffectType = SoundEffectType.HIT;
        paei.AudioTarget     = (Node2D)this;
        paei.FireEvent();
    }