1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.fourisland.fourpuzzle.database;
import com.fourisland.fourpuzzle.transition.FadeTransition;
import com.fourisland.fourpuzzle.transition.InTransition;
import com.fourisland.fourpuzzle.transition.MultidirectionalTransition;
import com.fourisland.fourpuzzle.transition.OutTransition;
import com.fourisland.fourpuzzle.transition.SquareTransition;
import com.fourisland.fourpuzzle.transition.Transition;
import com.fourisland.fourpuzzle.transition.TransitionDirection;
import com.fourisland.fourpuzzle.transition.TransitionUnsupportedException;
/**
*
* @author hatkirby
*/
public enum Transitions {
TitleExit(TransitionDirection.Out, new FadeTransition(TransitionDirection.Out)),
TitleToMap(TransitionDirection.In, new FadeTransition(TransitionDirection.In)),
MapExit(TransitionDirection.Out, new SquareTransition(TransitionDirection.Out)),
MapEnter(TransitionDirection.In, new SquareTransition(TransitionDirection.In)),
MapToTitle(TransitionDirection.Out, new FadeTransition(TransitionDirection.Out)),
TitleEnter(TransitionDirection.In, new FadeTransition(TransitionDirection.In)),
MapToGameOver(TransitionDirection.Out, new FadeTransition(TransitionDirection.Out)),
GameOverEnter(TransitionDirection.In, new FadeTransition(TransitionDirection.In)),
GameOverToTitle(TransitionDirection.Out, new FadeTransition(TransitionDirection.Out));
private final TransitionDirection dir;
private Transition trans;
private Transitions(TransitionDirection dir, Transition trans)
{
this.dir = dir;
if (isTransitionSupported(dir, trans))
{
this.trans = trans;
} else {
throw new TransitionUnsupportedException(trans.getClass().getName(), dir);
}
}
Transition getValue()
{
return trans;
}
void setValue(Transition trans)
{
if (isTransitionSupported(dir, trans))
{
this.trans = trans;
} else {
throw new TransitionUnsupportedException(trans.getClass().getName(), dir);
}
}
private boolean isTransitionSupported(TransitionDirection dir, Transition trans)
{
if (trans instanceof MultidirectionalTransition)
{
return (((MultidirectionalTransition) trans).getDirection() == dir);
} else if (trans instanceof OutTransition)
{
return (dir == TransitionDirection.Out);
} else if (trans instanceof InTransition)
{
return (dir == TransitionDirection.In);
}
return false;
}
}
|