Game Development Reference
In-Depth Information
canPlay = false;
}
if ( f.step >= 8 && c.value == 2 ) {
canPlay = false;
}
}
if ( canPlay ) {
var pa:PlayerActionClient;
pa = new PlayerActionClient();
pa.setCardId(c.id);
pa.setDiscard(discard?1:0);
m_pulse.sendGameStateAction(pa);
m_countDown.stop();
if ( m_countDown.parent != null )
removeChild(m_countDown);
m_pulse.nextTurn();
}
return canPlay;
}
If the timer runs out, the callback for the timer, onTimerUp , is called. We choose a
random card from the hand trying to play it; if we cannot, then we simply discard
the card.
public function onTimerUp(e:Event):void {
// auto play for the player
// Play a random card
// if cannot play, throw it.
var rand:int;
rand = (Math.random()*1000)%3;
var card:Card;
card = m_mgr.getMyHand()[rand];
if ( !_playCard(card, false) )
_playCard(card, true);
}
If the player plays the card, the mouse event is handled by the card instance, passed
to the card manager and then finally the following playCard method is called:
public function playCard(c:Card):Boolean {
var ret:Boolean;
ret = _playCard(c, m_discard.discard());
m_discard.reset();
return ret;
}
 
Search WWH ::




Custom Search