Manage multi scene

- Create position and check if user is in position to switch in the next scene.
 - When scene is load, we load all scene in the layer of name "exit".
 - Layer "exit" of map.json have a parametter "exitSceneKey" to identify next scene.
 - Add layer "start", the player could start in the scene on the object present in the layer of name "start".
This commit is contained in:
gparant 2020-05-09 21:28:50 +02:00
parent fb8d9bf9a8
commit 27c6034661
6 changed files with 162 additions and 26 deletions

View file

@ -27,6 +27,36 @@
"x":0,
"y":0
},
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 309, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":18,
"id":10,
"name":"exit",
"opacity":1,
"properties":[
{
"name":"exitSceneKey",
"type":"string",
"value":"floor1"
}],
"type":"tilelayer",
"visible":true,
"width":46,
"x":0,
"y":0
},
{
"data":[294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 294, 294, 294, 294, 294, 294, 294, 294, 294],
"height":18,
@ -104,7 +134,7 @@
"x":0,
"y":0
}],
"nextlayerid":10,
"nextlayerid":12,
"nextobjectid":1,
"orientation":"orthogonal",
"renderorder":"right-down",

View file

@ -9,6 +9,18 @@
"height":18,
"infinite":false,
"layers":[
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":18,
"id":12,
"name":"start",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":46,
"x":0,
"y":0
},
{
"data":[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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168],
"height":18,
@ -21,6 +33,24 @@
"x":0,
"y":0
},
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":18,
"id":11,
"name":"exit",
"opacity":1,
"properties":[
{
"name":"exitSceneKey",
"type":"string",
"value":"floor0"
}],
"type":"tilelayer",
"visible":true,
"width":46,
"x":0,
"y":0
},
{
"data":[4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 4797, 4798, 4799, 0, 0, 0, 0, 0, 4638, 4638, 4638, 4638, 4526, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 4729, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4638, 4638, 4638, 4638, 4526, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 4745, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4526, 4526, 4526, 4526, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 4761, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4639, 4639, 4639, 4639, 4526, 0, 0, 4526, 0, 0, 4526, 4526, 4526, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 4777, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4639, 4639, 4639, 4639, 4526, 0, 0, 4526, 0, 0, 4526, 0, 0, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 0, 0, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4526, 4526, 4526, 4526, 0, 0, 4526, 0, 0, 4526, 0, 0, 4526, 4638, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4650, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4638, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4638, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 0, 0, 4526, 4526, 4526, 0, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 0, 0, 4526, 4526, 0, 0, 0, 0, 0, 4526, 4526, 0, 0, 4526, 4526, 0, 0, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4729, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 4526, 4526, 4526, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4745, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 4526, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4761, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 4526, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 4777, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 4526, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 4526, 0, 0, 0, 0, 0, 0, 0, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526, 4526],
"height":18,
@ -104,7 +134,7 @@
"x":0,
"y":0
}],
"nextlayerid":11,
"nextlayerid":13,
"nextobjectid":1,
"orientation":"orthogonal",
"renderorder":"right-down",

View file

@ -20,10 +20,10 @@ export class MapController {
getMpas() {
this.App.get("/maps", (req: Request, res: Response) => {
return res.status(OK).send({
startMapKey: "floor0",
mapStart: {key: "floor0", url: "/map/files/Floor0"},
maps: [
{mapKey: "floor0", mapUrl: "/map/files/Floor0"},
{mapKey: "floor1", mapUrl: "/map/files/Floor1"},
{key: "floor0", url: "/map/files/Floor0"},
{key: "floor1", url: "/map/files/Floor1"},
]
});
});

View file

@ -18,6 +18,11 @@ export interface HasMovedEvent {
character: string;
}
export interface MapObject {
key: string,
url: string
}
export class GameManager {
status: number;
private ConnexionInstance: Connexion;
@ -25,6 +30,7 @@ export class GameManager {
private playerName: string;
SimplePeer : SimplePeerInterface;
private characterUserSelected: string;
Maps: Array<MapObject>;
constructor() {
this.status = StatusGameManagerEnum.IN_PROGRESS;
@ -43,8 +49,9 @@ export class GameManager {
}
loadMaps(){
return this.ConnexionInstance.loadMaps().then((maps) => {
return maps;
return this.ConnexionInstance.loadMaps().then((data) => {
this.Maps = data.maps;
return data;
}).catch((err) => {
throw err;
});

View file

@ -1,9 +1,9 @@
import {GameManager, gameManager, HasMovedEvent, StatusGameManagerEnum} from "./GameManager";
import {GameManager, gameManager, HasMovedEvent, MapObject, StatusGameManagerEnum} from "./GameManager";
import {GroupCreatedUpdatedMessageInterface, MessageUserPositionInterface} from "../../Connexion";
import {CurrentGamerInterface, GamerInterface, hasMovedEventName, Player} from "../Player/Player";
import {DEBUG_MODE, RESOLUTION, ROOM, ZOOM_LEVEL} from "../../Enum/EnvironmentVariable";
import {API_URL, DEBUG_MODE, RESOLUTION, ROOM, ZOOM_LEVEL} from "../../Enum/EnvironmentVariable";
import Tile = Phaser.Tilemaps.Tile;
import {ITiledMap, ITiledTileSet} from "../Map/ITiledMap";
import {ITiledMap, ITiledMapLayer, ITiledTileSet} from "../Map/ITiledMap";
import {cypressAsserter} from "../../Cypress/CypressAsserter";
import {PLAYER_RESOURCES} from "../Entity/PlayableCaracter";
import Circle = Phaser.Geom.Circle;
@ -42,6 +42,8 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
MapKey: string;
MapUrlFile: string;
PositionNextScene: Array<any> = new Array<any>();
constructor(MapKey : string = "", MapUrlFile: string = "") {
super({
key: MapKey
@ -67,12 +69,9 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
console.warn("Don't know how to handle tileset ", tileset)
return;
}
console.log(tileset);
console.log(tileset.name, `${this.MapUrlFile}/${tileset.image}`);
this.load.image(tileset.name, `${this.MapUrlFile}/${tileset.image}`);
})
});
console.log(this.MapKey, `${this.MapUrlFile}/${this.MapKey}.json`);
this.load.tilemapTiledJSON(this.MapKey, `${this.MapUrlFile}/${this.MapKey}.json`);
//add player png
@ -104,10 +103,16 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
//add layer on map
this.Layers = new Array<Phaser.Tilemaps.StaticTilemapLayer>();
let depth = -2;
this.map.layers.forEach((layer) => {
this.map.layers.forEach((layer : ITiledMapLayer) => {
if (layer.type === 'tilelayer') {
this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth));
}
if (layer.type === 'tilelayer' && layer.name === "exit") {
this.loadNextGame(layer);
}
if (layer.type === 'tilelayer' && layer.name === "start") {
this.startUser(layer);
}
if (layer.type === 'objectgroup' && layer.name === 'floorLayer') {
depth = 10000;
}
@ -129,7 +134,6 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
//notify game manager can to create currentUser in map
this.GameManager.createCurrentPlayer();
//initialise camera
this.initCamera();
@ -150,6 +154,62 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
this.circleTexture.refresh();
}
/**
* @param layer : ITiledMapLayer
*/
private loadNextGame(layer: ITiledMapLayer){
let properties : any = layer.properties;
let nextSceneKey = properties.find((property:any) => property.name === "exitSceneKey");
let nextMap : MapObject = gameManager.Maps.find((map: MapObject) => map.key === nextSceneKey.value);
let gameIndex = this.scene.getIndex(nextMap.key);
let game = null;
if(gameIndex === -1){
game = new GameScene(nextMap.key, `${API_URL}${nextMap.url}`);
this.scene.add(nextSceneKey, game, false);
}else{
game = this.scene.get(nextMap.key);
}
if(!game){
return;
}
let tiles : any = layer.data;
tiles.forEach((objectKey : number, key: number) => {
if(objectKey === 0){
return;
}
let y = (key / 45);
y = parseInt(`${y}`);
let x = key - (y * 46);
this.PositionNextScene.push({
xStart: (x * 32),
yStart: (y * 32),
xEnd: ((x +1) * 32),
yEnd: ((y + 1) * 32),
key: nextMap.key
})
});
}
/**
* @param layer
*/
private startUser(layer: ITiledMapLayer){
let tiles : any = layer.data;
tiles.forEach((objectKey : number, key: number) => {
if(objectKey === 0){
return;
}
let y = (key / 45);
y = parseInt(`${y}`);
let x = key - (y * 46);
this.startX = (x * 32);
this.startY = (y * 32);
});
}
//todo: in a dedicated class/function?
initCamera() {
this.cameras.main.setBounds(0,0, this.Map.widthInPixels, this.Map.heightInPixels);
@ -194,6 +254,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
createCurrentPlayer(UserId : string){
//initialise player
//TODO create animation moving between exit and strat
this.CurrentPlayer = new Player(
UserId,
this,
@ -220,7 +281,6 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
//pixel position toz tile position
let tile = this.Map.getTileAt(this.Map.worldToTileX(pointer.worldX), this.Map.worldToTileY(pointer.worldY));
if(tile){
console.log(tile)
this.CurrentPlayer.say("Your touch " + tile.layer.name);
}
});
@ -232,14 +292,25 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
*/
update(time: number, delta: number) : void {
this.CurrentPlayer.moveUser(delta);
if(
832 <= this.CurrentPlayer.x && this.CurrentPlayer.x <= 864
&& 0 <= this.CurrentPlayer.y && this.CurrentPlayer.y <= 64
){
//this.scene.start(Floor1Name);
let nextSceneKey = this.checkToExit();
if(nextSceneKey){
this.scene.start(nextSceneKey.key);
}
}
/**
*
*/
checkToExit(){
if(this.PositionNextScene.length === 0){
return null;
}
return this.PositionNextScene.find((position : any) => {
return position.xStart <= this.CurrentPlayer.x && this.CurrentPlayer.x <= position.xEnd
&& position.yStart <= this.CurrentPlayer.y && this.CurrentPlayer.y <= position.yEnd
})
}
/**
* Share position in scene
* @param UsersPosition

View file

@ -101,11 +101,9 @@ export class LogincScene extends Phaser.Scene implements GameSceneInterface {
return;
}
let scene: any = data[1];
scene.maps.forEach((map : any) => {
let game = new GameScene(map.mapKey, `${API_URL}${map.mapUrl}`);
this.scene.add(map.mapKey, game, false);
});
this.scene.start(scene.startMapKey);
let game = new GameScene(scene.mapStart.key, `${API_URL}${scene.mapStart.url}`);
this.scene.add(scene.mapStart.key, game, false);
this.scene.start(scene.mapStart.key);
}).catch((err) => {
console.error(err);
throw err;