class 'complete_stars' (Script)

function complete_stars:__init() super()

 self.exeOne=true
 self.load=false
end

function complete_stars:on_attach()
 if self.exeOne then
  self.arr_comleteComb1={true,true,false,false,false,false,false,true,true,false,false,false}
 self.arr_comleteComb2={false,false,true,false,false,false,false,false,true,true,false,false}
 self.arr_comleteComb3={false,true,false,false,true,false,false,true,false,true,false,true}
 self.arr_comleteComb4={true,false,true,false,false,false,false,false,false,true,false,true}

 self.doing='0'
 self.CLICK='click'
 self.comp1='1'
 self.comp2='2'
 self.comp3='3'
 self.comp4='4'

 if self.load then
 else
     self.grup1Comp=true
     self.grup2Comp=true
     self.grup3Comp=true
     self.grup4Comp=true
 end








 local scene = self:scene()

 self.arr_starsObject={}
 self.arr_maskObject={}

 for i=1,12 do
  self.arr_starsObject[i]=scene:object('star'..i)
  self.arr_maskObject[i]=scene:object('mask'..i)
 end
 end
 self.exeOne=false
 self.load=false
end

function complete_stars:on_lb_down()
 self.doing= self.CLICK

end

function complete_stars:compComb()
 local ikval1=true
 local ikval2=true
 local ikval3=true
 local ikval4=true
 local compComb1=true
 local compComb2=true
 local compComb3=true
 local compComb4=true
 for i=1,12 do

  if self.arr_starsObject[i]:visible()==self.arr_comleteComb1[i] then
   ikval1=true
  else
   ikval1=false
  end

   if self.arr_starsObject[i]:visible()==self.arr_comleteComb2[i] then
   ikval2=true
  else
   ikval2=false
   end

   if self.arr_starsObject[i]:visible()==self.arr_comleteComb3[i] then
   ikval3=true
  else
   ikval3=false
   end

   if self.arr_starsObject[i]:visible()==self.arr_comleteComb4[i] then
   ikval4=true
  else
   ikval4=false
  end

   compComb1=compComb1 and ikval1 and self.grup1Comp
   compComb2=compComb2 and ikval2 and self.grup2Comp
   compComb3=compComb3 and ikval3 and self.grup3Comp
   compComb4=compComb4 and ikval4 and self.grup4Comp
 end


 if (compComb1) then
  self.doing=self.comp1
  self.grup1Comp=false
  self:clin_map()
  self:scene():execute_action('comb1')
  self:scene():play_sound('g_comb_complete')
 end

 if (compComb2) then
  self.doing=self.comp2
  self.grup2Comp=false
  self:clin_map()
  self:scene():execute_action('comb2')
  self:scene():play_sound('g_comb_complete')
 end

 if (compComb3) then
  self.doing=self.comp3
  self.grup3Comp=false
  self:clin_map()
  self:scene():execute_action('comb3')
  self:scene():play_sound('g_comb_complete')
 end

 if (compComb4) then
  self.doing=self.comp4
  self.grup4Comp=false
  self:clin_map()
  self:scene():execute_action('comb4')
  self:scene():play_sound('g_comb_complete')
 end

end

function complete_stars:on_update(dt)

if self.doing== self.CLICK then
 self.doing='0'
 self:compComb()
end

 if not(self.grup1Comp or self.grup2Comp or self.grup3Comp or self.grup4Comp) then
     self:scene():play_sound('g_complete')
  self:scene():execute_action('complite_stars')
 end
end

function complete_stars:clin_map()
 for i=1,12 do
  self.arr_starsObject[i]:hide()
  self.arr_maskObject[i]:show()
 end
end

function complete_stars:save(os)
    os:save(0) -- version
    os:save(self.grup1Comp)
    os:save(self.grup2Comp)
    os:save(self.grup3Comp)
    os:save(self.grup4Comp)
end

function complete_stars:load(is)
    local ver = is:load()
    self.grup1Comp= is:load()
    self.grup2Comp=  is:load()
    self.grup3Comp=   is:load()
    self.grup4Comp =   is:load()
    self.load=true
end