-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatiment.lua
More file actions
2206 lines (2188 loc) · 82.3 KB
/
batiment.lua
File metadata and controls
2206 lines (2188 loc) · 82.3 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local batiment={}--gestion du batiment apres qu'il soit construit
if not functionload then
local function notgohtrouverbras(numero)
local sequenceData1 ={
{
name="bras",
frames={1,2,3,1},
time=300,
loopCount=1
} ,
{
name="cata1",
frames={4,5,6,6,4},
time=500,
loopCount=1
},
{
name="cata2",
frames={7,8,9,9,7},
time=500,
loopCount=1
},
{
name="cata3",
frames={10,11,12,12,10},
time=500,
loopCount=1
},
{
name="bali",
frames={13,14,15,15,13},
time=300,
loopCount=1
}
}
ibatiment[numero].bras=display.newSprite(imgbat.brascata, sequenceData1 )
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1
ibatiment[numero].bras.xScale=0.15
ibatiment[numero].bras.yScale=ibatiment[numero].bras.xScale
ibatiment[numero].bras.numgroup=mathfloor(ibatiment[numero].y1)+12+1024
group[ibatiment[numero].bras.numgroup]:insert(ibatiment[numero].bras)
end
function gohtrouverbras(numero)
local valuepause1=0
local valueplay1=false
local valueoldframe=nil
if ibatiment[numero].bras~=nil then
valuepause1=ibatiment[numero].bras.pause1
valueplay1=ibatiment[numero].bras.play1
valueoldframe=ibatiment[numero].bras.oldframe
display.remove(ibatiment[numero].bras)
end
local sequenceData=imgbat.tiranim[ibatiment[numero].type2][ibatiment[numero].niveau].property.seq or {frames={1,1},time=100,loopCount=1}
ibatiment[numero].bras=display.newSprite(imgbat.tiranim[ibatiment[numero].type2][ibatiment[numero].niveau].sheet,sequenceData)
-- local xoffset=imgbat.tiranim[ibatiment[numero].type2][ibatiment[numero].niveau].property.x or 0
-- local yoffset=imgbat.tiranim[ibatiment[numero].type2][ibatiment[numero].niveau].property.y or 0
ibatiment[numero].bras.anchorX=imgbat.tiranim[ibatiment[numero].type2][ibatiment[numero].niveau].property.anchorX or 0.5
ibatiment[numero].bras.anchorY=imgbat.tiranim[ibatiment[numero].type2][ibatiment[numero].niveau].property.anchorY or 0.5
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1--+xoffset
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1--+yoffset
ibatiment[numero].bras.xScale=imgbat.tiranim[ibatiment[numero].type2][ibatiment[numero].niveau].property.scale
ibatiment[numero].bras.yScale=ibatiment[numero].bras.xScale
ibatiment[numero].bras.numgroup=ibatiment[numero].group+2
group[ibatiment[numero].bras.numgroup]:insert(ibatiment[numero].bras)
ibatiment[numero].bras.angle=0
ibatiment[numero].bras.pause1=valuepause1
ibatiment[numero].bras.play1=valueplay1
ibatiment[numero].bras.oldframe=valueoldframe
end
local function animationamelio(frame,object)
local imgbouton=display.newImage(imbouton.batiment,frame)
imgbouton.x=object.x
imgbouton.y=object.y
imgbouton.xScale=object.xScale
imgbouton.yScale=object.yScale
imgbouton.fill.effect = "filter.exposure"
imgbouton.fill.effect.exposure=0
background:insert(imgbouton)
local objecttransition=function(obj)
display.remove(obj)
obj=nil
-- if obj~=nil then
-- background:remove(imgbouton)
-- imgbouton:removeSelf()
-- imgbouton=nil
-- end
end
transition.to(imgbouton,{time=65,rotation=30})
transition.to(imgbouton,{time=800,x=ibatiment[object.num].x1,y=ibatiment[object.num].y1,transition=easing.inOutCubic})
transition.to(imgbouton,{delay=600,time=250,alpha=0,xScale=object.xScale*2,yScale=object.yScale*2,transition=easing.outQuad})
transition.to(imgbouton.fill.effect,{delay=600,time=250,exposure=2,transition=easing.outQuad,onComplete=objecttransition})
print("affiche image")
end
local batiment_mt = { __index = batiment }
local soldatt=require("soldat")
local batimentbis1=require("batimentbis")
local attbatiment1=require("attbatiment")
local boutondev1remove=false --si on est entrain de faire disparaitre les boutons
local bpbatdisp=function(obj)
if boutondev1~=nil then
if lignesoldat~=nil then
for i=1,#lignesoldat do
boutondev1:remove(lignesoldat[i])
lignesoldat[i]:removeSelf()
lignesoldat[i]=nil
end
lignesoldat=nil
end
boutondev1:removeSelf()
boutondev1=nil
nivsup=nil
vendre=nil
choixgauche=nil
choixdroite=nil
bdrapeau=nil
end
boutondev1remove=false
end
function batiment:att(nume,instance3)
attaquebatiment(nume)
end
local function draptestautorise(event,typedaction,posxbat,posybat,drap)
local autorise=1
if typedaction~=nil then
selfx=typedaction.x
selfy=typedaction.y
end
if selfy+30<mayminuspos2+30 or selfy+30>maypos2-30 or selfx<maxminuspos2+30 or selfx>maxpos2-30 then
autorise=2
end
if modezombie or modepanique then
if autorise~=2 then
if ibatiment[drap.num].porte>(selfx-posxbat)*(selfx-posxbat)+(1.25*(selfy-posybat))*(1.25*(selfy-posybat)) then
autorise=0
if autorise==0 then
local i=1
while i<=obstaclenb do
if 3000>((selfx-obstacle[i].x)*(selfx-obstacle[i].x)+(selfy+30-obstacle[i].y)*(selfy+30-obstacle[i].y))then
autorise=1
i=obstaclenb+1
end
i=i+1
end
end
if autorise==0 then
local i=1
while i<=obstacle1nb do
if 20000>((selfx-obstacle1[i].x)*(selfx-obstacle1[i].x)+(selfy+30-obstacle1[i].y)*(selfy+30-obstacle1[i].y))then
autorise=1
i=obstacle1nb+1
end
i=i+1
end
end
if autorise==0 then
if obstacle0nb>=1 then
local i=1
while i<=obstacle0nb do
local rayon=500
if obstacle0[i].rayon~=nil then
rayon=obstacle0[i].rayon
end
if rayon>((selfx-obstacle0[i].x)*(selfx-obstacle0[i].x)+(selfy+30-obstacle0[i].y)*(selfy+30-obstacle0[i].y))then
autorise=1
i=obstacle0nb+1
end
i=i+1
end
end
end
end
print("modezombie")
else
autorise=1
end
else
if autorise==1 then
local i=2
if not goh then
while i<=cheminnb do
local rayonauto=2000
if chemin[i].rayon~=nil then
rayonauto=chemin[i].rayon
end
if rayonauto>((selfx-chemin[i].x)*(selfx-chemin[i].x)+(selfy-chemin[i].y+ibatiment[drap.num].pole)*(selfy-chemin[i].y+ibatiment[drap.num].pole))then
if ibatiment[drap.num].porte>(selfx-posxbat)*(selfx-posxbat)+(1.25*(selfy-posybat))*(1.25*(selfy-posybat)) then
autorise=0
i=cheminnb+1
end
end
i=i+1
end
else
while i<=cheminnb do
local coef=1
if chemin[i].mechant~=nil and not modepanique then
if chemin[i].mechant>1 then
coef=chemin[i].mechant*chemin[i].mechant
end
end
if 400*coef*cheminlargeur>((selfx-chemin[i].x)*(selfx-chemin[i].x)+(selfy-chemin[i].y+ibatiment[drap.num].pole)*(selfy-chemin[i].y+ibatiment[drap.num].pole))then
if ibatiment[drap.num].porte>(selfx-posxbat)*(selfx-posxbat)+(1.25*(selfy-posybat))*(1.25*(selfy-posybat)) then
autorise=0
i=cheminnb+1
end
end
i=i+1
end
end
else
autorise=1
end
end
return(autorise)
end
local function drapeauinit(numero)
local distmin=(chemin[2].x-ibatiment[numero].x1)^2+(chemin[2].y+ibatiment[numero].pole-ibatiment[numero].y1)^2
local chemini=2
for i=3,cheminnb,1 do
local dist1=(chemin[i].x-ibatiment[numero].x1)^2+(chemin[i].y+ibatiment[numero].pole-ibatiment[numero].y1)^2
if(distmin> dist1) then
distmin=dist1
chemini=i
end
end
ibatiment[numero].drap.x=chemin[chemini].x
ibatiment[numero].drap.y=chemin[chemini].y+ibatiment[numero].pole
if (chemin[chemini].x-ibatiment[numero].x1)^2+(chemin[chemini].y-ibatiment[numero].y1)^2<=1500 then -- recherche un point qui repond au critere (pas derriere un batiment)
local trouverpos=false
local dirchx=1
local dirchy=0
local direct=-1
local largeur=1
local largfai=0
local largfin=0
local testcoor={}
testcoor.x=chemin[chemini].x
testcoor.y=chemin[chemini].y
local trouverpos=false
local distancemin=-1
local ix,iy
while largeur<5 do --not trouverpos and
largfai=0
largfin=largfin+1
if largfin>=2 then
largfin=0
largeur=largeur+1
end
direct=direct+1
if direct>=4 then
direct=0
end
if direct==0 then
dirchx=1
dirchy=0
elseif direct==1 then
dirchx=0
dirchy=1
elseif direct==2 then
dirchx=-1
dirchy=0
elseif direct==3 then
dirchx=0
dirchy=-1
end
while largfai<=largeur do-- and not trouverpos do
largfai=largfai+1
testcoor.x=testcoor.x+7*dirchx*largfai
testcoor.y=testcoor.y+7*dirchy*largfai
local autorise1=true
if (testcoor.x-(ibatiment[numero].x1+ibatiment[numero].xbase))^2+(1.25*(testcoor.y-(ibatiment[numero].y1+ibatiment[numero].ybase)))^2>ibatiment[numero].porte*0.95 then
autorise1=false
end
if (testcoor.x-ibatiment[numero].x1)^2+(testcoor.y-ibatiment[numero].y1)^2<=1500*1.15 then
autorise1=false
end
local itrouver=-1
local mindistpoint=-1
if autorise1 then
local i=2
while i<cheminnb do
local rayonauto=2000
if chemin[i].rayon~=nil then
rayonauto=chemin[i].rayon
end
local distcalc =((testcoor.x-chemin[i].x)*(testcoor.x-chemin[i].x)+(testcoor.y-chemin[i].y+ibatiment[numero].pole)*(testcoor.y-chemin[i].y+ibatiment[numero].pole))
if rayonauto>distcalc and (distcalc<distancemin or distancemin==-1) then
itrouver=i
distancemin=distcalc
print("itrouver(1) "..distcalc.." ")
ix=testcoor.x
iy=testcoor.y
end
i=i+1
end
if itrouver==-1 then
autorise1=false
end
end
if autorise1 then
trouverpos=true
end
end
end
if trouverpos then
ibatiment[numero].drap.x=ix--testcoor.x
ibatiment[numero].drap.y=iy+ibatiment[numero].pole --testcoor.y+ibatiment[numero].pole
end
end
end
if not functionload then
if true then
solenmov=false
local var,xori,yori,self,numerobat,soldrap,solcercle,drapeau1,soldrapold
local self1={}
local selfori={}
local compteuropt=0
function removesoldrap()
if soldrap~=nil then
group[soldrap.group]:remove(soldrap)
soldrap:removeSelf()
soldrap=nil
end
end
function soldatdeplacer(event,self)--test de function
if "began" ==event.phase and not fenaff then --and not generalenmov then
var=0
self1.x=self.x
self1.y=self.y
selfori.x=self.x
selfori.y=self.y
numerobat=isoldat[event.target.id].numbat
self1.num=numerobat
clicsurqqcfunc()
if(enconst==1)then--corrige le probleme uniquement quand on clique pas en meme temps sur pouvoir et valider
removenbat()
end
geneclic1=timer.performWithDelay( 50,geneclic1 )
if fenaff==false and clicpause==0 and pv1clic==0 and pv2clic==0 and pv3clic==0 and clicconstruire==0 and clicinfanterie==0 and clicarcher==0 and clicpouvoir1==0 and clicpouvoir2==0 and clicpouvoir3==0 and pv2clicactiver==0 and pv1clicactiver==0 and boutondev==0 and drapeausolclic==0 then
var=0
self1.x=self.x
self1.y=self.y
end
elseif "moved" ==event.phase and not fenaff then --and generalenmov then
var=var+(event.x-event.xStart)^2+(event.x-event.yStart)^2
if var>=500 and soldrap==nil then
hideConstrucButton()
soldrap=display.newGroup()
soldrap.group=2048
group[soldrap.group]:insert(soldrap)
solcercle=display.newCircle(ibatiment[numerobat].x1+ibatiment[numerobat].xbase,(ibatiment[numerobat].y1+ibatiment[numerobat].pole+ibatiment[numerobat].ybase),mathsqrt(ibatiment[numerobat].porte)*0.95)--cercle=display.newCircle(event.target.x,event.target.y,mathsqrt(ibatiment[event.target.num].porte))
solcercle.yScale=0.80
solcercle:setStrokeColor(0,0.5,0,0.8)
solcercle:setFillColor(0,0,0,0.1)
solcercle.strokeWidth = 2
soldrap:insert(solcercle)
transition.from(solcercle,{time=500,transition=easing.outBack,xScale=solcercle.xScale*0.1,yScale=solcercle.xScale*0.1})
drapeau1=display.newImage(imbouton.batiment,9)
drapeau1.x=self1.x
drapeau1.y=self1.y
if not goh then
drapeau1.xScale=0.15
else
drapeau1.xScale=0.09
end
drapeau1.yScale=drapeau1.xScale
soldrap:insert(drapeau1)
soldrapold=display.newImage(imbouton.batiment,9)
soldrapold.x=ibatiment[numerobat].drap.x
soldrapold.y=ibatiment[numerobat].drap.y
if not goh then
soldrapold.xScale=0.15*apparence
else
soldrapold.xScale=0.09*apparence
end
soldrapold.yScale=soldrapold.xScale
soldrapold.alpha=0.5
soldrap:insert(soldrapold)
end
if soldrap~=nil then
self1.x =selfori.x+(event.x-event.xStart)/taille
self1.y =selfori.y+(event.y-event.yStart)/taille
local autorise=draptestautorise(event,self1,(ibatiment[numerobat].x1+ibatiment[numerobat].xbase),(ibatiment[numerobat].y1+ibatiment[numerobat].pole+ibatiment[numerobat].ybase),self1)
if autorise==0 then
drapeau1.x=self1.x
drapeau1.y=self1.y
else
compteuropt=compteuropt+1
if compteuropt>2 then
compteuropt=0
local xdirec=1
if drapeau1.x>self1.x then
xdirec=-1
end
local ydirec=1
if drapeau1.x>self1.y then
ydirec=-1
end
local distancemin=(self1.x-drapeau1.x)*(self1.x-drapeau1.x)+(self1.y-drapeau1.y)*(self1.y-drapeau1.y)
if distancemin>1000 then --1000
local limitex1carre=drapeau1.x+30*(-xdirec)
local limitex2carre=self1.x+30*(xdirec)
local limitey1carre=drapeau1.y+30*(-ydirec)
local limitey2carre=self1.y+30*(ydirec)
local ancienxvalide=drapeau1.x
local ancienyvalide=drapeau1.y
local testposbat={}
testposbat.x=drapeau1.x
testposbat.y=drapeau1.y
testposbat.num=numerobat
local i=limitex1carre
local varrandx=mathfloor(mathabs(limitex1carre-limitex2carre)*0.1)
if varrandx<1 then
varrandx=1
end
local varrandy=mathfloor(mathabs(limitey1carre-limitey2carre)*0.1)
if varrandy<1 then
varrandy=1
end
while i*xdirec<limitex2carre*(xdirec) do
testposbat.x=i
local j=limitey1carre
while j*ydirec<limitey2carre*(ydirec) do
testposbat.y=j
local autorise1=draptestautorise(event,testposbat,(ibatiment[numerobat].x1+ibatiment[numerobat].xbase),(ibatiment[numerobat].y1+ibatiment[numerobat].pole+ibatiment[numerobat].ybase),testposbat)
if autorise1==0 then
local distancemintest=(self1.x-testposbat.x)*(self1.x-testposbat.x)+(self1.y-testposbat.y)*(self1.y-testposbat.y)
if distancemin>distancemintest then
distancemin=distancemintest
ancienxvalide=testposbat.x
ancienyvalide=testposbat.y
end
end
j=j+varrandy*ydirec
end
i=i+varrandx*(xdirec)
end
drapeau1.x=ancienxvalide
drapeau1.y=ancienyvalide
end
end
end
end
elseif soldrap~=nil then
ibatiment[numerobat].drap.x=drapeau1.x
ibatiment[numerobat].drap.y=drapeau1.y
for k=nbsoldatg,0 do
if isoldat[k].numbat==numerobat then
if isoldat[k].vivant then
if mathsqrt(((drapeau1.x+isoldat[k].xposi-isoldat[k].x1)^2+(drapeau1.y+isoldat[k].yposi-isoldat[k].y1)^2))>60 then
if isoldat[k].encombat==1 then
isoldat[k].vivant=false
isoldat[k].endeplacement=1
end
end
end
end
end
if soldrap~=nil then
transition.to(solcercle,{time=500,transition=easing.outBack,xScale=solcercle.xScale*0.1,yScale=solcercle.xScale*0.1})
local function soldraptimer(event)
removesoldrap()
end
timer.performWithDelay(400,soldraptimer)
end
end
end
end
function finmiseajourevol(numero,dev)--fin de l'animation du devellopement du batiment
if ibatiment[numero].type1==1 or (modearmy and ibatiment[numero].type1==2) then
--resolution du problem lorsqu'on devellope le batiment et que le point de raliment des soldats est en dehors du cercle
if ibatiment[numero].niveau~=1 and (ibatiment[numero].drap.x-(ibatiment[numero].x1+ibatiment[numero].xbase))^2+(1.25*(ibatiment[numero].drap.y-(ibatiment[numero].y1+ibatiment[numero].ybase)))^2>ibatiment[numero].porte then
drapeauinit(numero)
end
if not modearmy then
gerergenerersoldat(numero,ibatiment[numero].niveau)
end
end
end
function miseajourvalevol(numero,statistique)--mise a jour d'information lorsque le batiment est a mitié fini d'etre develloper
if ibatiment[numero].pv3==true then
group[ibatiment[numero].bandepv3gr]:remove(ibatiment[numero].bandepv3)
ibatiment[numero].bandepv3:removeSelf()
end
ibatiment[numero].pv3=false
--debut retourdinformation
ibatiment[numero].heure=gettime()
if ibatiment[numero].vieenlevertt==nil then
ibatiment[numero].vieenlevertt=0
ibatiment[numero].heuredeb=ibatiment[numero].heure
else
ibatiment[numero].vieenlevertt=ibatiment[numero].vieenlevertt+ibatiment[numero].vieenlever
end
ibatiment[numero].vieenlever=0
retinfordredecreanb=retinfordredecreanb+1
if retinf.ordredecrea=="{" then
--retinf.ordredecrea=retinf.ordredecrea..[["]]retinfordredecreanb[["{"id":"]]..numero..[[",value":"]]..ibatiment[numero].type1..ibatiment[numero].type2..ibatiment[numero].niveau..[["}]]
else
retinf.ordredecrea=retinf.ordredecrea..[[,]] --"]]..numero.." "..ibatiment[numero].type1..ibatiment[numero].type2..ibatiment[numero].niveau..[["]]
end
retinf.ordredecrea=retinf.ordredecrea..[["]]..retinfordredecreanb..[[":{"id":"]]..numero..[[","value":"]]..ibatiment[numero].type1..ibatiment[numero].type2..ibatiment[numero].niveau..[["}]]
if issimulator then
local loadsave = require("loadsave")
loadsave.print_r (retinf.ordredecrea)
end
-- fin retourdinformation
ibatiment[numero].numsolarmy=1
if ibatiment[numero].type1==1 then--contact
ibatiment[numero].cadence=2000--permet d'afficher une baniere quand le bat a son pv3 actif
if ibatiment[numero].type2==0 then--infanterie
if ibatiment[numero].niveau==1 then
-- debut retourdinformation
--retinf.ordredecrea=retinf.ordredecrea.." x"..ibatiment[numero].x.." y"..ibatiment[numero].y
-- fin retourinformation
ibatiment[numero].message=texttraduction.batiment[1] --"Barrack"
ibatiment[numero].porte=10000 -- si modifier aussi modifer au donnée init a developement1 (un peu plus bas)
ibatiment[numero].nbunit=2
ibatiment[numero].armyt=45
elseif ibatiment[numero].niveau==2 then
ibatiment[numero].message=texttraduction.batiment[2] --"Fort"
ibatiment[numero].porte=12000
ibatiment[numero].nbunit=3
ibatiment[numero].armyt=30
elseif ibatiment[numero].niveau==3 then
ibatiment[numero].message=texttraduction.batiment[3] --"Fortress"
ibatiment[numero].porte=13500
ibatiment[numero].nbunit=3
ibatiment[numero].armyt=30
elseif ibatiment[numero].niveau==4 then
ibatiment[numero].message=texttraduction.batiment[4] --"Castle"
ibatiment[numero].porte=15500
ibatiment[numero].nbunit=4
ibatiment[numero].nbunittotal=ibatiment[numero].nbunit
ibatiment[numero].armyt=22
end
elseif ibatiment[numero].type2==1 then--geant
if ibatiment[numero].niveau==2 then
ibatiment[numero].message=texttraduction.batiment[5] --"Cave"
ibatiment[numero].porte=10000
ibatiment[numero].nbunit=1
ibatiment[numero].armyt=90
elseif ibatiment[numero].niveau==3 then
ibatiment[numero].message=texttraduction.batiment[6] --"Cavern"
ibatiment[numero].porte=10000
ibatiment[numero].nbunit=1
ibatiment[numero].armyt=90
elseif ibatiment[numero].niveau==4 then
ibatiment[numero].message=texttraduction.batiment[7] --"Antrum"
ibatiment[numero].porte=11000
ibatiment[numero].nbunit=2
ibatiment[numero].nbunittotal=ibatiment[numero].nbunit
ibatiment[numero].armyt=45
end
elseif ibatiment[numero].type2==2 then--cavalerie
if ibatiment[numero].niveau==2 then
ibatiment[numero].message=texttraduction.batiment[8] --"Farm"
ibatiment[numero].porte=70000
ibatiment[numero].nbunit=1
ibatiment[numero].armyt=90
elseif ibatiment[numero].niveau==3 then
ibatiment[numero].message=texttraduction.batiment[9] --"Stable"
ibatiment[numero].porte=80000
ibatiment[numero].nbunit=2
ibatiment[numero].armyt=45
elseif ibatiment[numero].niveau==4 then
ibatiment[numero].message=texttraduction.batiment[10] --"Paladin"
ibatiment[numero].porte=90000
ibatiment[numero].nbunit=2
ibatiment[numero].nbunittotal=ibatiment[numero].nbunit
ibatiment[numero].armyt=45
end
end
ibatiment[numero].armyt=ibatiment[numero].armyt*2
elseif ibatiment[numero].type1==2 then----tir--manipuler porter distance et vitesse avec precaution!!------
ibatiment[numero].nbunit=2
if ibatiment[numero].type2==0 then--archer--les variables inchanger sont conserver lors d'une evolution
if ibatiment[numero].niveau==1 then
local zone1bis=(ibatiment[numero].y1)/619*4 --deux données en une
local zone1y=mathfloor(zone1bis*0.5)+2
local zone2y=mathfloor((zone1bis)*0.5+0.5)+2
zone1bis=(ibatiment[numero].x1)/1229*6 --deux données en une
local zone1x=mathfloor(zone1bis*0.5)+2
local zone2x=mathfloor((zone1bis)*0.5+0.5)+2
ibatiment[numero].zone1=zone1y*3+zone1x
ibatiment[numero].zone2=zone2y*3+zone2x
-- debut retourdinformation
--retinf.ordredecrea=retinf.ordredecrea.." x"..ibatiment[numero].x.." y"..ibatiment[numero].y
-- fin retourdinformation
--print("init value type1=2,type2=0,n=1 :"..numero)
if goh then
ibatiment[numero].attaque=23
else
ibatiment[numero].attaque=17
end
ibatiment[numero].porte=20000
if goh then
ibatiment[numero].cadence=3000--40
else
ibatiment[numero].cadence=2500
end
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*400
ibatiment[numero].vitesse=1
ibatiment[numero].impact=0
ibatiment[numero].nbfleche=1--3
ibatiment[numero].fleche={}
ibatiment[numero].flecheinf={}
ibatiment[numero].message=texttraduction.batiment[11] --"Watchtower"
if statistique==nil then
for i=1,ibatiment[numero].nbfleche,1 do--remettre ce bloc au cas ou on augmente le nombre de projectile
ibatiment[numero].fleche[i]=0
end
if not goh then
ibatiment[numero].ypro=-21
ibatiment[numero].xpro=-1
else
ibatiment[numero].ypro=-23
ibatiment[numero].xpro=0
end
if not goh then
notgohtrouverbras(numero)
else
gohtrouverbras(numero)
end
ibatiment[numero].bras.angle=0
ibatiment[numero].bras.pause1=0
ibatiment[numero].bras.play1=false
ibatiment[numero].bras.oldframe=nil
-- local function animtirbatbras( event )
-- if ibatiment[numero].sup1~=1 then
-- if ibatiment[numero].bras.play1==true then
-- if jeupause.etat==1 then--technique numero 3 de mise en pause(plus de probleme avec les processeurs mtk et probleme de deferencement)
-- if ibatiment[numero].bras.pause1==0 then
-- ibatiment[numero].bras.pause1=1
-- ibatiment[numero].bras:pause()
-- end
-- else
-- if ibatiment[numero].bras.pause1==1 then
-- ibatiment[numero].bras.pause1=0
-- ibatiment[numero].bras:play()
-- end
-- if ibatiment[numero].bras.frame==4 and ibatiment[numero].bras.oldframe~=4 then
-- ibatiment[numero].bras.oldframe=4
-- ibatiment[numero].bras.play1=false
-- print("ibatiment.attaque "..ibatiment[numero].attaque)
-- demandepro(1,numero,ibatiment[numero].x1+ibatiment[numero].xpro,ibatiment[numero].y1+ibatiment[numero].ypro,ibatiment[numero],ibatiment[numero].pole) --,ibatiment[numero].zone1,ibatiment[numero].zone2)
-- else
-- ibatiment[numero].bras.oldframe=nil
-- end
-- end
-- end
-- else
-- Runtime:removeEventListener( "enterFrame",animtirbatbras)
-- end
-- end
-- Runtime:addEventListener("enterFrame",animtirbatbras)
end
elseif ibatiment[numero].niveau==2 then--fleche
ibatiment[numero].message=texttraduction.batiment[12] --"Crossbow"
if goh then
ibatiment[numero].attaque=99--63
else
ibatiment[numero].attaque=42--5
end
ibatiment[numero].porte=30000
if not goh then
ibatiment[numero].ypro=-20
ibatiment[numero].xpro=-4
else
ibatiment[numero].ypro=-46
ibatiment[numero].xpro=0
end
if not goh then
if ibatiment[numero].bras==nil then
notgohtrouverbras(numero)
end
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1
end
if niveauch==1 and tuto~=0 and not goh then
ibatiment[numero].attaque=ibatiment[numero].attaque*0.5
ibatiment[numero].cadence=12000
end
if goh then
ibatiment[numero].cadence=6500--4500
else
ibatiment[numero].cadence=6000--1000--40
end
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*200
ibatiment[numero].vitesse=1.2
local nbflecheancien=ibatiment[numero].nbfleche
if not goh then
ibatiment[numero].nbfleche=2
for i=nbflecheancien,ibatiment[numero].nbfleche,1 do
ibatiment[numero].fleche[i]=0
end
end
print("numerobat "..numero)
if niveauch==12 and modenormal and numero==3 then
if niveau12cercle~=nil then
if niveau12cercle==1 then
niveau12cercle=2
ibatiment[numero].porte=ibatiment[numero].porte*2.8
else
niveau12cercle=0
end
end
end
elseif ibatiment[numero].niveau==3 then
ibatiment[numero].message=texttraduction.batiment[13] --"Heavy tower"
ibatiment[numero].porte=40000
if goh then
ibatiment[numero].attaque=170--80
ibatiment[numero].cadence=5000--2500--60
else
ibatiment[numero].attaque=48
ibatiment[numero].cadence=3000--60
end
ibatiment[numero].armyt=200*2000/ibatiment[numero].cadence
ibatiment[numero].vitesse=1.3
if not goh then
ibatiment[numero].ypro=-21
ibatiment[numero].xpro=0
else
ibatiment[numero].ypro=-55
ibatiment[numero].xpro=0
end
if not goh then
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1
end
if niveauch==12 and modenormal and numero==3 then
if niveau12cercle~=nil then
if niveau12cercle==2 then
niveau12cercle=3
ibatiment[numero].porte=ibatiment[numero].porte*2.65
else
niveau12cercle=0
end
end
end
elseif ibatiment[numero].niveau==4 then
if statistique==nil and not goh then
ibatiment[numero].bras.xScale=0.2
ibatiment[numero].bras.yScale=ibatiment[numero].bras.xScale
ibatiment[numero].ypro=-23
ibatiment[numero].xpro=0.5
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1
end
ibatiment[numero].message=texttraduction.batiment[14] --"Ballista"
ibatiment[numero].porte=50000
if goh then
ibatiment[numero].attaque=200 --95
ibatiment[numero].cadence=8000--4000--90
else
ibatiment[numero].attaque=63
ibatiment[numero].cadence=4000--90
end
if goh then
ibatiment[numero].ypro=-67
ibatiment[numero].xpro=0
end
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*132
ibatiment[numero].vitesse=1.4
local nbflecheancien=ibatiment[numero].nbfleche
if goh then
ibatiment[numero].nbfleche=2
else
ibatiment[numero].nbfleche=3
end
for i=nbflecheancien,ibatiment[numero].nbfleche,1 do
ibatiment[numero].fleche[i]=0
end
if niveauch==12 and modenormal and numero==3 then
if niveau12cercle~=nil then
if niveau12cercle==3 then
niveau12cercle=0
ibatiment[numero].porte=ibatiment[numero].porte*2.5
else
niveau12cercle=0
end
end
end
end
if race==1 and not issimulator then
ibatiment[numero].porte=ibatiment[numero].porte*1.1
ibatiment[numero].attaque=ibatiment[numero].attaque*1.1
end
elseif ibatiment[numero].type2==1 then----boulet
if ibatiment[numero].niveau==2 then
ibatiment[numero].nbfleche=1
if statistique==nil and not goh then
ibatiment[numero].ypro=-27
ibatiment[numero].xpro=0
if ibatiment[numero].bras==nil then
notgohtrouverbras(numero)
end
ibatiment[numero].bras.xScale=ibatiment[numero].xScale
ibatiment[numero].bras.yScale=ibatiment[numero].yScale
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1+1
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1+3
end
if goh then
ibatiment[numero].ypro=-55
ibatiment[numero].xpro=3
end
ibatiment[numero].message=texttraduction.batiment[15] --"Catapult"
ibatiment[numero].porte=20000
ibatiment[numero].attaque=35
ibatiment[numero].cadence=2000--29
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*400
ibatiment[numero].vitesse=0.75
ibatiment[numero].impact=20.5
elseif ibatiment[numero].niveau==3 then
if statistique==nil and not goh then
ibatiment[numero].bras.xScale=ibatiment[numero].xScale
ibatiment[numero].bras.yScale=ibatiment[numero].yScale
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1-2
end
ibatiment[numero].message=texttraduction.batiment[16] --"Onager"
ibatiment[numero].porte=30000
ibatiment[numero].attaque=45
ibatiment[numero].cadence=2000--37
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*400
ibatiment[numero].vitesse=0.75
ibatiment[numero].impact=24
elseif ibatiment[numero].niveau==4 then
if statistique==nil and not goh then
ibatiment[numero].bras.xScale=ibatiment[numero].xScale
ibatiment[numero].bras.yScale=ibatiment[numero].yScale
ibatiment[numero].bras.x=ibatiment[numero].xpro+ibatiment[numero].x1
ibatiment[numero].bras.y=ibatiment[numero].ypro+ibatiment[numero].y1+2
end
if goh then
ibatiment[numero].ypro=-60
ibatiment[numero].xpro=3
end
ibatiment[numero].message=texttraduction.batiment[17] --"Trebuchet"
ibatiment[numero].porte=40000
ibatiment[numero].attaque=59
ibatiment[numero].cadence=2500--40
ibatiment[numero].armyt=2000/(ibatiment[numero].cadence)*400
ibatiment[numero].vitesse=0.8
ibatiment[numero].impact=29.7
end
if race==0 and not issimulator then
ibatiment[numero].porte=ibatiment[numero].porte*1.1
ibatiment[numero].attaque=ibatiment[numero].attaque*1.1
end
elseif ibatiment[numero].type2==2 then--lave
ibatiment[numero].attaquencours=0
if ibatiment[numero].niveau==2 then
ibatiment[numero].nbfleche=1
ibatiment[numero].message=texttraduction.batiment[18] --"Hot water"
ibatiment[numero].porte=12000
ibatiment[numero].attaque=45*0.4 --45*0.4 --13 -- duree d'anim 3000+500 entre tir attaque pendant 0.73 du temps 0.3 sec att 0.3 + att pd 3500 att=0, pd 2200 att=13+13/3*2200/300=45 donc attsec=45/(2200+3500)*1000=7.9
ibatiment[numero].cadence=2000 -- 3000+500 +2200(att)=5700 *attsec=45
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*30
ibatiment[numero].vitesse=1
ibatiment[numero].dureeliq=2200*2
if not goh then
ibatiment[numero].ypro=-20.5
ibatiment[numero].xpro=0.5
else
ibatiment[numero].ypro=-51.8
ibatiment[numero].xpro=0
end
elseif ibatiment[numero].niveau==3 then
ibatiment[numero].message=texttraduction.batiment[19] --"Lava"
ibatiment[numero].porte=15000
ibatiment[numero].attaque=67*0.4 --67*0.4-- 19 --modifier ici mettre le nombre que tu veux. De meme pour les autres niveaux -------------------------------------------------------------------------------------------------------------
ibatiment[numero].cadence=2000 -- pd 2350 att=19+19/3*2350/300=67 attsec=11.5
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*30
ibatiment[numero].vitesse=1
ibatiment[numero].dureeliq=2350*2
if not goh then
ibatiment[numero].ypro=-4.4
ibatiment[numero].xpro=7.1
else
ibatiment[numero].ypro=-15
ibatiment[numero].xpro=2.5
end
elseif ibatiment[numero].niveau==4 then
ibatiment[numero].message=texttraduction.batiment[20] --"Acid"
ibatiment[numero].porte=19000
ibatiment[numero].attaque=241*0.5*0.4 --241*0.5*0.4 --33
ibatiment[numero].cadence=2000 -- pd 2600 att=128 attsec=21.0
ibatiment[numero].armyt=2000/ibatiment[numero].cadence*30
ibatiment[numero].vitesse=1
ibatiment[numero].dureeliq=8000 --2600
if not goh then
ibatiment[numero].ypro=0
ibatiment[numero].xpro=0
else
ibatiment[numero].ypro=-56
ibatiment[numero].xpro=2.5
end
end
if race==2 and not issimulator then
ibatiment[numero].porte=ibatiment[numero].porte*1.1
ibatiment[numero].attaque=ibatiment[numero].attaque*1.1
end
--if ibatiment[numero].niveau==2 then
installationpique(numero)
--end
end
ibatiment[numero].cadence=ibatiment[numero].cadence*cadencegent
elseif ibatiment[numero].type1==3 then
if statistique==nil then
--print("evolution argentsec")
end
ibatiment[numero].message=texttraduction.batiment[21] --"Abandoned mine"
if ibatiment[numero].niveau==2 then
ibatiment[numero].message=texttraduction.batiment[22] --"Mine"
ibatiment[numero].argentsec=4--doit etre un multiple de 4
elseif ibatiment[numero].niveau==3 then
ibatiment[numero].message=texttraduction.batiment[23] --"Goblin mine"
isoldat[ibatiment[numero].numsol].vie=isoldat[ibatiment[numero].numsol].vie+150
isoldat[ibatiment[numero].numsol].vietotale=250
ibatiment[numero].argentsec=8
elseif ibatiment[numero].niveau==4 then
ibatiment[numero].message=texttraduction.batiment[24] --"Dwarf mine"
isoldat[ibatiment[numero].numsol].vie=isoldat[ibatiment[numero].numsol].vie+350
isoldat[ibatiment[numero].numsol].vietotale=600
ibatiment[numero].argentsec=12
end
end
ibatiment[numero].attsec=attaquebatsec[race+1][ibatiment[numero].type1][ibatiment[numero].type2+1][ibatiment[numero].niveau]
ibatiment[numero].typebat=ibatiment[numero].type1*3*5+(ibatiment[numero].type2)*5+ibatiment[numero].niveau-15
if savegameall.bonusbatiment[ibatiment[numero].typebat]~=nil then
for i=1,#savegameall.bonusbatiment.tableau[ibatiment[numero].type1] do
if savegameall.bonusbatiment[ibatiment[numero].typebat][savegameall.bonusbatiment.tableau[ibatiment[numero].type1][i]]~=nil then
local nbflecheancien
if savegameall.bonusbatiment.tableau[ibatiment[numero].type1][i]=="nbfleche" then
nbflecheancien=ibatiment[numero].nbfleche
end
ibatiment[numero][savegameall.bonusbatiment.tableau[ibatiment[numero].type1][i]]=(ibatiment[numero][savegameall.bonusbatiment.tableau[ibatiment[numero].type1][i]] or 1) + (savegameall.bonusbatiment[ibatiment[numero].typebat][savegameall.bonusbatiment.tableau[ibatiment[numero].type1][i]] or 0)
if savegameall.bonusbatiment.tableau[ibatiment[numero].type1][i]=="nbfleche" then
for j=nbflecheancien,ibatiment[numero].nbfleche,1 do
ibatiment[numero].fleche[j]=0
end
end
end
end
end
if ibatiment[numero].type1==3 then
if multi~=0 then
ibatiment[numero].argentsec=2*ibatiment[numero].argentsec
elseif modeinfini==true then
ibatiment[numero].argentsec=mathfloor(0.25*ibatiment[numero].argentsec)
end
ibatiment[numero].argentsec=mathfloor(ibatiment[numero].argentsec/dureepartie*mineimpact)*varminerevcorrectdif
if ibatiment[numero].argentsec==0 then
ibatiment[numero].argentsec=1
end
else
ibatiment[numero].armyt=ibatiment[numero].armyt*0.3
ibatiment[numero].armytt=ibatiment[numero].numsolarmy+ibatiment[numero].armyt*0.8
end
if numero==affinfotab.num and affinfotab.type==1 and removepartiel1==false and affinfogr.isVisible then
affinfo(numero,false)
end
end
function evolution(numero,dev,vitessedanim)--demande de devellopement du batiment -- non local
--0 pour niveau superieur, 1 pour collone gauche et 2 pour droite
if (dev==0)then
ibatiment[numero].niveau=ibatiment[numero].niveau+1
end
if(dev==1)then
ibatiment[numero].niveau=ibatiment[numero].niveau+1
ibatiment[numero].type2=1
end
if(dev==2)then
ibatiment[numero].niveau=ibatiment[numero].niveau+1
ibatiment[numero].type2=2
end
local animconst = require ( "constructanim" )
if ibatiment[numero].type1==2 and dev<3 then
ibatiment[numero].sup=1
end
if affinfotab.type==1 and affinfotab.num==numero and dev~=3 and affinfogr.isVisible then
affinfo(numero,false)
end
if dev<3 then
constructionanim(ibatiment[numero],0,vitessedanim)
end
end
function pasassezfric()--animation lorsqu'il manque de l'argent pour la faire
if tunemanque==false then
tunemanque=true
local tunexscale=tune.xScale
transition.to(tune,{time=500,transition=easing.inOutBack,x=tune.x1-60})