5 // Created by Killery on 2013/03/23.
6 // Copyright (c) 2013年 Killery. All rights reserved.
11 @implementation BattleView
16 hitSoundBasic = [[NSSound soundNamed:@"hitSound.mp3"] retain];
23 - (id)initWithFrame:(NSRect)frame
25 self = [super initWithFrame:frame];
34 -(void)mouseDown:(NSEvent *)theEvent{
41 -(void)drawImage:(NSImage*)image x:(float)x y:(float)y f:(float)frac{
43 frRect.size.height = image.size.height;
44 frRect.size.width = image.size.width;
52 drRect.size.height = image.size.height;
53 drRect.size.width = image.size.width;
55 [image drawInRect:drRect fromRect:frRect operation:NSCompositeSourceOver fraction:frac respectFlipped:YES hints:nil];
59 - (void)drawRect:(NSRect)dirtyRect
64 if(!battleVeryBegunFlag){
66 while (!(AUN[1] == U->number)) {
70 img = [U->C.imgb copy];
71 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
73 [self drawImage:img x:BT_POINTX1 y:BT_POINTY f:1.0];
77 while (!(DUN[1] == U->number)) {
81 img = [U->C.imgb copy];
82 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
84 [self drawImage:img x:BT_POINTX2 y:BT_POINTY f:1.0];
86 }else if(battleVeryBegunFlag && !BTunitAttackFlag1 && !BTunitAttackFlag2){
89 btDistanceX1 += BT_CHAMOVESPEED;
91 if(btDistanceX1 >= BT_CHADISTANCEDELTA)
92 btDistanceX1 = BT_CHADISTANCEDELTA;
94 while (!(AUN[1] == U->number)) {
98 img = [U->C.imgb copy];
99 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
101 [self drawImage:img x:BT_POINTX1 + btDistanceX1 y:BT_POINTY f:1.0];
105 btDistanceX2 += BT_CHAMOVESPEED;
107 if(btDistanceX2 >= BT_CHADISTANCEDELTA)
108 btDistanceX2 = BT_CHADISTANCEDELTA;
110 while (!(DUN[1] == U->number)) {
114 img = [U->C.imgb copy];
115 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
117 [self drawImage:img x:BT_POINTX2 - btDistanceX2 y:BT_POINTY f:1.0];
121 if(btDistanceX1 >= BT_CHADISTANCEDELTA && btDistanceX2 >= BT_CHADISTANCEDELTA){
122 baseDistanceCompFlag = true;
124 }else if(BTunitAttackFlag1 && !btHitFlag1){
127 while (!(DUN[1] == U->number)) {
131 img = [U->C.imgb copy];
132 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
134 [self drawImage:img x:BT_POINTX2 - btDistanceX2 y:BT_POINTY f:1.0];
138 while (!(AUN[1] == U->number)) {
142 img = [U->C.imgb copy];
143 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
145 if(btAttackMoveValue1 == 0){
147 }else if(btAttackMoveValue1 == 1){
148 btAttackMove1 += -20;
151 if(btAttackMove1 >= 80){
152 btAttackMoveValue1 = 1;
154 if(btAttackMove1 <= 0){
155 if(btAttackMoveValue1 < 2)
157 btAttackMoveValue1 = 2;
160 if(btAttackMoveValue1 < 2){
161 [self drawImage:img x:BT_POINTX1 + btDistanceX1 + btAttackMove1 y:BT_POINTY f:1.0];
163 [self drawImage:img x:BT_POINTX1 + btDistanceX1 y:BT_POINTY f:1.0];
169 }else if(BTunitAttackFlag2 && !btHitFlag2){
173 while (!(AUN[1] == U->number)) {
177 img = [U->C.imgb copy];
178 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
180 [self drawImage:img x:BT_POINTX1 + btDistanceX1 y:BT_POINTY f:1.0];
184 while (!(DUN[1] == U->number)) {
188 img = [U->C.imgb copy];
189 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
191 if(btAttackMoveValue2 == 0){
193 }else if(btAttackMoveValue2 == 1){
194 btAttackMove2 += -20;
197 if(btAttackMove2 >= 80){
198 btAttackMoveValue2 = 1;
200 if(btAttackMove2 <= 0){
201 if(btAttackMoveValue2 < 2)
203 btAttackMoveValue2 = 2;
206 if(btAttackMoveValue2 < 2){
207 [self drawImage:img x:BT_POINTX2 - btDistanceX2 - btAttackMove2 y:BT_POINTY f:1.0];
209 [self drawImage:img x:BT_POINTX2 - btDistanceX2 y:BT_POINTY f:1.0];
213 }else if(btHitFlag1){
219 while (!(AUN[1] == U->number)) {
223 img = [U->C.imgb copy];
224 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
226 if (btHitFlagCnt1 == 1)
227 [hitSoundBasic play];
228 if(btHitFlagCnt1 > 10)
232 [self drawImage:img x:BT_POINTX1 + btDistanceX1 y:BT_POINTY f:1.0];
237 while (!(DUN[1] == U->number)) {
241 img = [U->C.imgb copy];
242 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
244 if(btHitFlagCnt1%2 == 0) [self drawImage:img x:BT_POINTX2 - btDistanceX2 y:BT_POINTY f:1.0];
248 }else if(btHitFlag2){
252 while (!(DUN[1] == U->number)) {
256 img = [U->C.imgb copy];
257 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
259 if (btHitFlagCnt2 == 1)
260 [hitSoundBasic play];
261 if(btHitFlagCnt2 > 10)
265 [self drawImage:img x:BT_POINTX2 - btDistanceX2 y:BT_POINTY f:1.0];
270 while (!(AUN[1] == U->number)) {
274 img = [U->C.imgb copy];
275 [img setSize:NSMakeSize(BT_CHASIZEX, BT_CHASIZEY)];
277 if(btHitFlagCnt2%2 == 0) [self drawImage:img x:BT_POINTX1 + btDistanceX1 y:BT_POINTY f:1.0];