int getSpriteNum() { int n = 13 + color * 2 + spriteCount; if (_State.isFlee()) { if (blink && (spriteCount & 1) == 1) { n = 13 + color * 2 + spriteCount; } else { n = 21 + spriteCount; } } return(n); }
public void setState(GhostState newState) { if (newState.isEye()) { // état demandé : yeux avec déplacement yeux State = GhostState.EYE; strategy = Strategy.EYE; } else if (newState.isFlee()) { // état demandé : fuite if (!State.isEye()) { // fuit seulement si pas en état yeux fleeTime = Constants.TIME_FLEE; blink = false; if (!strategy.isHouse()) { strategy = Strategy.FLEE; _DesiredDirection = CurrentDirection; CurrentDirection = CurrentDirection.Opposite; } State = GhostState.FLEE; } } else if (newState.isRest()) { fleeTime = Constants.TIME_REST; strategy = Strategy.FLEE; _DesiredDirection = CurrentDirection; CurrentDirection = CurrentDirection.Opposite; State = GhostState.REST; } else if (newState.isHouse()) { // état demandé : chasse avec déplacement maison strategy = Strategy.HOUSE; houseTime = color * Constants.TIME_HOUSE; State = GhostState.HOUSE; } else if (newState.isHunt()) { // état demandé : chasse avec déplacement chasse strategy = Strategy.HUNT; State = GhostState.HUNT; } else if (newState.isRandom()) { // état demandé : chasse avec déplacement aléatoire strategy = Strategy.RANDOM; randomTime = Constants.TIME_RANDOM_OFFSET + color * Constants.TIME_RANDOM_K; State = GhostState.HUNT; } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { GhostState state = value as GhostState; if (state != null) { if (state.isFlee()) { return(Application.Current.Resources["ghostFuite"]); } if (state.isEye()) { return(Application.Current.Resources["ghostEye"]); } return(parameter); } return(parameter); }