student 1 dag geleden
bovenliggende
commit
4179f1d93c
20 gewijzigde bestanden met toevoegingen van 187 en 45 verwijderingen
  1. 0 0
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/data.json
  2. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/block1a-sheet0.webp
  3. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/block1a-sheet1.webp
  4. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/cats-sheet0.webp
  5. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/cats-sheet2.webp
  6. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/cats-sheet4.webp
  7. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet1.webp
  8. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet2.webp
  9. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet3.webp
  10. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet4.webp
  11. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet5.webp
  12. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet6.webp
  13. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/sprite3-sheet0.webp
  14. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/sprite3-sheet1.webp
  15. BIN
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/sprite3-sheet2.webp
  16. 1 1
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/offline.json
  17. 0 0
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/c3runtime.js
  18. 0 0
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/main.js
  19. 24 8
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/objRefTable.js
  20. 162 36
      Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/project/main.js

File diff suppressed because it is too large
+ 0 - 0
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/data.json


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/block1a-sheet0.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/block1a-sheet1.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/cats-sheet0.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/cats-sheet2.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/cats-sheet4.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet1.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet2.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet3.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet4.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet5.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/shared-0-sheet6.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/sprite3-sheet0.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/sprite3-sheet1.webp


BIN
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/images/sprite3-sheet2.webp


+ 1 - 1
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/offline.json

@@ -1 +1 @@
-{"version":1784108096521,"fileList":["scripts/main.js","scripts/c3runtime.js","scripts/objRefTable.js","scripts/project/main.js","scripts/c3main.js","scripts/dispatchworker.js","scripts/jobworker.js","data.json","scripts/modernjscheck.js","scripts/supportcheck.js","scripts/offlineclient.js","icons/loading-logo.png","icons/icon-16.png","icons/icon-32.png","icons/icon-64.png","icons/icon-128.png","icons/icon-256.png","icons/icon-512.png","media/congratulations.webm","media/click.webm","media/Button03.webm","media/cute-cat-352656.webm","media/win2.webm","media/timeup_.webm","media/click_sound.webm","media/playground.webm","box2d.wasm","box2d.wasm.js","style.css","images/shared-0-sheet0.webp","images/shared-0-sheet1.webp","images/shared-0-sheet2.webp","images/shared-0-sheet3.webp","images/shared-0-sheet4.webp","images/shared-0-sheet5.webp","images/block1a-sheet0.webp","images/block1a-sheet1.webp","images/cats-sheet0.webp","images/cats-sheet1.webp","images/cats-sheet2.webp","images/cats-sheet3.webp","images/cats-sheet4.webp","images/confettix-sheet0.webp","images/confettix-sheet1.webp","images/sprite3-sheet0.webp","images/sprite3-sheet1.webp","images/sprite3-sheet2.webp","images/scroll-sheet0.webp","images/btn_lvl-sheet0.webp","images/btn_lvl-sheet1.webp","scripts/register-sw.js"]}
+{"version":1785290924305,"fileList":["scripts/main.js","scripts/c3runtime.js","scripts/objRefTable.js","scripts/project/main.js","scripts/c3main.js","scripts/dispatchworker.js","scripts/jobworker.js","data.json","scripts/modernjscheck.js","scripts/supportcheck.js","scripts/offlineclient.js","icons/loading-logo.png","icons/icon-16.png","icons/icon-32.png","icons/icon-64.png","icons/icon-128.png","icons/icon-256.png","icons/icon-512.png","media/congratulations.webm","media/click.webm","media/Button03.webm","media/cute-cat-352656.webm","media/win2.webm","media/timeup_.webm","media/click_sound.webm","media/playground.webm","box2d.wasm.js","box2d.wasm","style.css","images/shared-0-sheet0.webp","images/shared-0-sheet1.webp","images/shared-0-sheet2.webp","images/shared-0-sheet3.webp","images/shared-0-sheet4.webp","images/shared-0-sheet5.webp","images/shared-0-sheet6.webp","images/block1a-sheet0.webp","images/block1a-sheet1.webp","images/cats-sheet0.webp","images/cats-sheet1.webp","images/cats-sheet2.webp","images/cats-sheet3.webp","images/cats-sheet4.webp","images/confettix-sheet0.webp","images/confettix-sheet1.webp","images/sprite3-sheet0.webp","images/sprite3-sheet1.webp","images/sprite3-sheet2.webp","images/scroll-sheet0.webp","images/btn_lvl-sheet0.webp","images/btn_lvl-sheet1.webp","scripts/register-sw.js"]}

File diff suppressed because it is too large
+ 0 - 0
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/c3runtime.js


File diff suppressed because it is too large
+ 0 - 0
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/main.js


+ 24 - 8
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/objRefTable.js

@@ -15,6 +15,7 @@ self.C3_GetObjectRefTable = function () {
 		C3.Behaviors.Sin,
 		C3.Plugins.Particles,
 		C3.Plugins.TiledBg,
+		C3.Plugins.Browser,
 		C3.Plugins.System.Cnds.IsGroupActive,
 		C3.Plugins.System.Cnds.OnLayoutStart,
 		C3.Plugins.System.Acts.SetLayerOpacity,
@@ -57,11 +58,12 @@ self.C3_GetObjectRefTable = function () {
 		C3.Behaviors.Tween.Acts.TweenTwoProperties,
 		C3.Plugins.Sprite.Exps.X,
 		C3.Plugins.Sprite.Exps.Y,
-		C3.Plugins.Sprite.Acts.Destroy,
+		C3.Behaviors.Tween.Cnds.OnTweensFinished,
+		C3.Plugins.Sprite.Cnds.OnDestroyed,
 		C3.Plugins.System.Cnds.PickByComparison,
+		C3.Plugins.Sprite.Acts.Destroy,
 		C3.Plugins.Sprite.Acts.SubInstanceVar,
 		C3.Plugins.System.Acts.Wait,
-		C3.Plugins.Sprite.Cnds.OnDestroyed,
 		C3.Plugins.Text.Cnds.CompareInstanceVar,
 		C3.Plugins.Touch.Cnds.IsTouchingObject,
 		C3.Plugins.System.Cnds.PickByHighestLowestValue,
@@ -92,8 +94,10 @@ self.C3_GetObjectRefTable = function () {
 		C3.Plugins.System.Acts.AddVar,
 		C3.Plugins.System.Acts.GoToLayoutByName,
 		C3.Plugins.LocalStorage.Acts.SetItem,
+		C3.Plugins.Browser.Acts.ConsoleLog,
 		C3.Plugins.System.Acts.RestartLayout,
 		C3.Plugins.Sprite.Acts.SetScale,
+		C3.Plugins.Text.Exps.Text,
 		C3.Plugins.Touch.Cnds.OnTouchStart,
 		C3.Plugins.Audio.Acts.SetMasterVolume,
 		C3.Plugins.Audio.Cnds.IsTagPlaying,
@@ -101,16 +105,16 @@ self.C3_GetObjectRefTable = function () {
 		C3.Plugins.System.Cnds.Else,
 		C3.Plugins.Function.Cnds.OnFunction,
 		C3.Plugins.Function.Acts.CallFunction,
-		C3.Plugins.LocalStorage.Acts.CheckItemExists,
+		C3.Plugins.TiledBg.Cnds.CompareY,
+		C3.Behaviors.DragnDrop.Acts.Drop,
+		C3.Behaviors.Tween.Acts.TweenOneProperty,
+		C3.Plugins.Sprite.Cnds.IsAnimPlaying,
 		C3.Plugins.LocalStorage.Cnds.OnItemExists,
 		C3.Plugins.LocalStorage.Acts.GetItem,
+		C3.Plugins.LocalStorage.Cnds.OnItemMissing,
 		C3.Plugins.LocalStorage.Cnds.OnItemGet,
 		C3.Plugins.LocalStorage.Exps.ItemValue,
-		C3.Plugins.TiledBg.Cnds.CompareY,
-		C3.Behaviors.DragnDrop.Acts.Drop,
-		C3.Behaviors.Tween.Acts.TweenOneProperty,
-		C3.Plugins.Sprite.Acts.SetAnim,
-		C3.Plugins.Sprite.Cnds.IsAnimPlaying
+		C3.Plugins.Sprite.Acts.SetAnim
 	];
 };
 self.C3_JsPropNameTable = [
@@ -144,6 +148,7 @@ self.C3_JsPropNameTable = [
 	{Cell: 0},
 	{uuid: 0},
 	{id: 0},
+	{moving: 0},
 	{Rotate: 0},
 	{Cats: 0},
 	{Textcountblock: 0},
@@ -174,6 +179,9 @@ self.C3_JsPropNameTable = [
 	{txtScore: 0},
 	{txt: 0},
 	{txtLevelDisplay: 0},
+	{Browser: 0},
+	{txtGiftValues: 0},
+	{txtGiftText: 0},
 	{Physics2: 0},
 	{blocks: 0},
 	{match: 0},
@@ -200,12 +208,17 @@ self.C3_JsPropNameTable = [
 	{data: 0},
 	{exitGame: 0},
 	{score: 0},
+	{gGiftValues: 0},
+	{gGiftText: 0},
 	{isShowComplete: 0},
 	{touchX: 0},
 	{touchY: 0},
 	{audio: 0},
 	{unlocked_level: 0},
 	{gameType: 0},
+	{InitGameSuccess: 0},
+	{InitUnLockSucess: 0},
+	{InitGameTypeSuccess: 0},
 	{cur_level: 0}
 ];
 
@@ -254,5 +267,8 @@ self.InstanceType = {
 	txtScore: class extends self.ITextInstance {},
 	txt: class extends self.ITextInstance {},
 	txtLevelDisplay: class extends self.ITextInstance {},
+	Browser: class extends self.IInstance {},
+	txtGiftValues: class extends self.ITextInstance {},
+	txtGiftText: class extends self.ITextInstance {},
 	blocks: class extends self.ISpriteInstance {}
 }

+ 162 - 36
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/catpuzzle/scripts/project/main.js

@@ -22,6 +22,9 @@ async function OnBeforeProjectStart(runtime)
 {
 	console.log("Construct3 Started");
 
+	// 1. Lấy gameType từ URL
+	LoadGameConfigFromUrl(runtime);
+
 	// Nhận dữ liệu từ MVC
 	window.addEventListener(
 		"message",
@@ -49,6 +52,113 @@ async function OnBeforeProjectStart(runtime)
 
 }
 
+
+
+function LoadGameConfigFromUrl(runtime)
+{
+	try
+	{
+		const params = new URLSearchParams(
+			window.location.search
+		);
+
+		const gameType =
+			params.get("gameType");
+
+
+		if (gameType)
+		{
+			runtime.globalVars.gameType = gameType;
+		}
+		else
+		{
+			runtime.globalVars.gameType = "Easy";
+		}
+
+
+		const maxLevel = parseInt(params.get("max_level"), 10);
+
+		if (Number.isInteger(maxLevel) && maxLevel >= 1)
+		{
+			runtime.globalVars.unlocked_level = maxLevel;
+		}
+		else
+		{
+			runtime.globalVars.unlocked_level = 1;
+		}
+
+
+		runtime.globalVars.InitGameTypeSuccess =1;
+
+		// Sau khi có gameType thì set cấu hình game
+		SetGameConfig(runtime);
+
+
+		console.log(
+			"GameType:",
+			runtime.globalVars.gameType,
+			"TotalTime:",
+			runtime.globalVars.totaltime,
+			"max_level:",
+			runtime.globalVars.unlocked_level
+		);
+
+	}
+	catch(error)
+	{
+		console.error(
+			"LoadGameConfigFromUrl Error:",
+			error
+		);
+
+		runtime.globalVars.gameType = "Easy";
+
+		SetGameConfig(runtime);
+	}
+}
+
+
+function SetGameConfig(runtime)
+{
+	switch(runtime.globalVars.gameType)
+	{
+		case "Easy":
+
+			runtime.globalVars.totaltime = 150;
+
+			break;
+
+
+		case "Medium":
+
+			runtime.globalVars.totaltime = 100;
+
+			break;
+
+
+		case "Hard":
+
+			runtime.globalVars.totaltime = 60;
+
+			break;
+
+
+		default:
+
+			runtime.globalVars.totaltime = 150;
+
+			break;
+	}
+
+
+	console.log(
+		"Set Total Time:",
+		runtime.globalVars.totaltime
+	);
+}
+
+
+
 function HandleMessage(runtime, event)
 {
 	 console.log("MESSAGE RECEIVED");
@@ -63,8 +173,8 @@ function HandleMessage(runtime, event)
 
 			console.log("INIT_GAME received: "+ event.data);
 
-			runtime.globalVars.gameType =
-				event.data.gameType ?? "";
+			//runtime.globalVars.gameType =
+			//	event.data.gameType ?? "";
 
 			runtime.globalVars.msisdn =
 				event.data.msisdn ?? "";
@@ -78,6 +188,8 @@ function HandleMessage(runtime, event)
 			runtime.globalVars.root =
 				event.data.root ?? "";
 
+			runtime.globalVars.InitGameTypeSuccess =1;
+
 			console.log(
 				"Game Init:",
 				runtime.globalVars.gameType,
@@ -158,50 +270,64 @@ async function SaveLevelResult(runtime)
 	try
 	{
 		console.log("Calling SaveLevelResult...");
-		
+
 		const body = {
-						token: runtime.globalVars.token,
-						msisdn: runtime.globalVars.msisdn,
-						transId: runtime.globalVars.transId,
-						level: runtime.globalVars.cur_level,
-						score: runtime.globalVars.score,
-						gameType: runtime.globalVars.gameType,
-						gameOver: 0
-					};
+			token: runtime.globalVars.token,
+			msisdn: runtime.globalVars.msisdn,
+			transId: runtime.globalVars.transId,
+			level: runtime.globalVars.cur_level,
+			score: runtime.globalVars.score,
+			gameType: runtime.globalVars.gameType,
+			gameOver: 0
+		};
+
 		console.log("Request Body:", body);
-		console.log("JSON:", JSON.stringify(body));
 
-		const response = await fetch(runtime.globalVars.root+"/Game/SaveLevelResult", 
-						{
-							method: "POST",
-							headers: {
-								"Content-Type": "application/json"
-							},
-							body: JSON.stringify(body)
-						});
+		const response = await fetch(
+			runtime.globalVars.root + "/Game/SaveLevelResult",
+			{
+				method: "POST",
+				headers: {
+					"Content-Type": "application/json"
+				},
+				body: JSON.stringify(body)
+			}
+		);
 
 		const result = await response.json();
 
 		console.log("Level Result:", result);
 
-		// Ví dụ dữ liệu trả về
-		runtime.globalVars.point =
-			result.point ?? "";
+		// Lưu dữ liệu gốc
+		runtime.globalVars.point = Number(result.point ?? 0);
+		runtime.globalVars.data = Number(result.data ?? 0);
+		runtime.globalVars.score = Number(result.score ?? 0);
+		runtime.globalVars.transId = result.transId ?? "";
 
-		runtime.globalVars.data =
-			result.data ?? "";
+		// Xác định phần thưởng
+		runtime.globalVars.gGiftValues = 0;
+		runtime.globalVars.gGiftText = "";
 
-		runtime.globalVars.score =
-			result.score ?? "";
-
-		runtime.globalVars.transId =
-			result.transId ?? "";
+		if (runtime.globalVars.point > 0)
+		{
+			runtime.globalVars.gGiftValues = runtime.globalVars.point;
+			runtime.globalVars.gGiftText = "Loyalty";
+		}
+		else if (runtime.globalVars.data > 0)
+		{
+			runtime.globalVars.gGiftValues = runtime.globalVars.data;
+			runtime.globalVars.gGiftText = "MB";
+		}
+		else if (runtime.globalVars.score > 0)
+		{
+			runtime.globalVars.gGiftValues = runtime.globalVars.score;
+			runtime.globalVars.gGiftText = "Score";
+		}
 
 		runtime.globalVars.showPrizePopup = 1;
-		console.log("Chuẩn bị gọi vào function trong event sheet:");
-		//runtime.callFunction("Quangbh");
-		console.log("Da goi goi vao function event sheet xong nhe!!!");
-		
+
+		console.log("Gift Type:", runtime.globalVars.gGiftText);
+		console.log("Gift Value:", runtime.globalVars.gGiftValues);
 	}
 	catch (error)
 	{
@@ -209,7 +335,7 @@ async function SaveLevelResult(runtime)
 	}
 	finally
 	{
-		levelSending = false;
+		
 	}
 }
 
@@ -233,7 +359,7 @@ function SaveExitGame(runtime)
 			form.appendChild(input);
 		}
 
-		add("token", runtime.globalVars.token);
+		//add("token", runtime.globalVars.token);
 		add("msisdn", runtime.globalVars.msisdn);
 		add("transId", runtime.globalVars.transId);
 		add("level", runtime.globalVars.cur_level);

Some files were not shown because too many files changed in this diff