#YAMLINA description file for Space Invaders
#Unit Operations file

#Press space to shoot bullets
player_shoot_bullet:
  trigger: 
    type: push_button_1
  event: 
    type: spawn
    spawner: player
    #spawn_pos defines where the object is created. above_spawner spawns the object one object-height above the spawner
    spawn_pos: above_spawner 
    object_to_spawn: bullet
    
alien_shoot_bullet:
  trigger: 
    type: at_intervals
    interval: 3
  event:
    type: spawn
    #select_random is a 'special' spawner type that is further parameterised by the fromtype field
    spawner: select_random
    fromtype: alien
    spawn_pos: below_spawner
    object_to_spawn: alien_bullet
    
bullets_kill_player:
  trigger:
    type: collision
    coll_class_1: player
    coll_class_2: alien_bullet
  event_lose_life:
    type: change_guivar
    varname: lives
    change: -1
  event_reset_player:
    type: reset_location
    #The 1 here refers to the first collision class (i.e. the player). This will likely need refinement.
    target: 1 
  event_kill_bullet:
    type: kill_entity
    target: 2
    
bullets_kill_alien:
  trigger:
    type: collision
    coll_class_1: alien
    coll_class_2: bullet
  event_gain_score:
    type: change_guivar
    varname: score
    change: 10
  event_kill_alien:
    type: kill_entity
    target: 1
  event_kill_bullet:
    type: kill_entity
    target: 2
    
abullets_smash_defences:
    trigger:
        type: collision
        coll_class_1: alien_bullet
        coll_class_2: block
    event_destroy_bullet:
        type: kill_entity
        target: 1
        
bullets_smash_defences:
    trigger:
        type: collision
        coll_class_1: bullet
        coll_class_2: block
    event_destroy_bullet:
        type: kill_entity
        target: 1
    
game_over_win:
  trigger:
    type: pop_check_zero
    class: alien
  event_game_win:
    type: win_instance
    
game_over_lose:
  trigger:
    type: guivar_check_zero
    varname: lives
  event_game_over:
    type: lose_instance