duelfi prod

This commit is contained in:
Sewmina 2025-08-16 18:31:38 +05:30
parent bcb1326d66
commit 12de395641
30 changed files with 2325 additions and 108 deletions

5
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"recommendations": [
"visualstudiotoolsforunity.vstuc"
]
}

10
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Unity",
"type": "vstuc",
"request": "attach"
}
]
}

106
.vscode/settings.json vendored
View File

@ -1,56 +1,56 @@
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.gitmodules": true,
"**/*.booproj": true,
"**/*.pidb": true,
"**/*.suo": true,
"**/*.user": true,
"**/*.userprefs": true,
"**/*.unityproj": true,
"**/*.dll": true,
"**/*.exe": true,
"**/*.pdf": true,
"**/*.mid": true,
"**/*.midi": true,
"**/*.wav": true,
"**/*.gif": true,
"**/*.ico": true,
"**/*.jpg": true,
"**/*.jpeg": true,
"**/*.png": true,
"**/*.psd": true,
"**/*.tga": true,
"**/*.tif": true,
"**/*.tiff": true,
"**/*.3ds": true,
"**/*.3DS": true,
"**/*.fbx": true,
"**/*.FBX": true,
"**/*.lxo": true,
"**/*.LXO": true,
"**/*.ma": true,
"**/*.MA": true,
"**/*.obj": true,
"**/*.OBJ": true,
"**/*.asset": true,
"**/*.cubemap": true,
"**/*.flare": true,
"**/*.mat": true,
"**/*.meta": true,
"**/*.prefab": true,
"**/*.unity": true,
"build/": true,
"Build/": true,
"Library/": true,
"library/": true,
"obj/": true,
"Obj/": true,
"ProjectSettings/": true,
"temp/": true,
"Temp/": true
},
"dotnet.preferCSharpExtension": true
"dotnet.preferCSharpExtension": true,
"dotnet.defaultSolution": "dinorun.sln"
}

File diff suppressed because one or more lines are too long

View File

@ -135,3 +135,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1f6ecf5e36f52b7ec9a7334911963287, type: 3}
m_Name:
m_EditorClassIdentifier:
movingItemSpeed: 1.2

8
Assets/Plugins.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 040811bd5987ec94d9b38ef18839e1a5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
mergeInto(LibraryManager.library, {
sendMessageToReact: function(status){
if (window.parent) {
window.parent.postMessage(message, "*"); // Replace "*" with your React app's origin for security
} else {
console.error("Parent window not found.");
}
}
})

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: f93bba9a4bf162c41bfebbdffa72e876
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,6 @@ public class AnimatedSprite : MonoBehaviour
private void Animate()
{
Debug.Log("Animating " + frame);
frame++;
if (frame >= sprites.Length)

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7a28cd2d6cd24bc4b92346feb7b993ac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class DuelFi
{
public const string VALIDATOR_DEV_URL = "https://validator.duelfi.io";
public const string VALIDATOR_PROD_URL = "https://validator.duelfi.io";
public static string VALIDATOR_URL = VALIDATOR_PROD_URL;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af241841496768b4cb94809af03d70ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HighscoreModeManager : MonoBehaviour
{
public static bool isPraticeMode= true;
public static string playerKey = "";
public static int leaderboarId = 0;
public static int highscore = 0;
void Awake()
{
#if UNITY_SERVER && !UNITY_EDITOR
return;
#endif
string url = Application.absoluteURL;
if (!string.IsNullOrEmpty(url))
{
// Extract query parameters
string isPractice = GetQueryParam(url, "isPractice") ?? "0";
string isDev = GetQueryParam(url, "isDev") ?? "0";
if(isDev == "1"){
DuelFi.VALIDATOR_URL = DuelFi.VALIDATOR_DEV_URL;
}else{
DuelFi.VALIDATOR_URL = DuelFi.VALIDATOR_PROD_URL;
}
if(isPractice == "1"){
isPraticeMode = true;
}else{
isPraticeMode = false;
playerKey = GetQueryParam(url, "playerKey");
leaderboarId = int.Parse(GetQueryParam(url, "leaderboardId"));
highscore = int.Parse(GetQueryParam(url, "highscore"));
Debug.Log("Dump parameters");
Debug.Log("highscore: " + highscore);
Debug.Log("playerKey: " + playerKey);
Debug.Log("leaderboarId: " + leaderboarId);
GameManager.Instance.SetHighscore(highscore);
}
}
}
string GetQueryParam(string url, string key)
{
if (!url.Contains("?")) return null;
string[] queries = url.Split('?')[1].Split('&');
foreach (string query in queries)
{
string[] pair = query.Split('=');
if (pair.Length == 2 && pair[0] == key) return pair[1];
}
return null;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ddd43dea8d96924cb3f4c9dd147e0f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
using UnityEngine;
public class JSBridge : MonoBehaviour
{
public static JSBridge instance;
void Awake()
{
instance = this;
}
public void OnClose(int status){
string message = "{\"type\": \"gameClose\", \"status\": " + status + "}";
Application.ExternalCall("sendMessageToReact", message);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 475eb393b2cc065428e01b39b5da2189
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,13 +11,15 @@ public class GameManager : MonoBehaviour
public float initialGameSpeed = 5f;
public float gameSpeedIncrease = 0.1f;
public static float timeElapsed = 0;
public float gameSpeed { get; private set; }
public TextMeshProUGUI gameOverText;
public TextMeshProUGUI scoreText;
public TextMeshProUGUI hiscoreText;
public Button retryButton;
public GameObject startScreen;
public GameObject practiceGameOver;
public GameObject duelGameOver;
public GameObject processingObject, closeButton;
private Player player;
private Spawner spawner;
@ -48,7 +50,12 @@ public class GameManager : MonoBehaviour
player = FindObjectOfType<Player>();
spawner = FindObjectOfType<Spawner>();
NewGame();
// NewGame();
startScreen.SetActive(true);
spawner.gameObject.SetActive(false);
player.gameObject.SetActive(false);
ShowGameOver(false);
UpdateHiscore();
}
public void NewGame()
{
@ -60,13 +67,14 @@ public class GameManager : MonoBehaviour
}
score = 0f;
timeElapsed = 0f;
gameSpeed = initialGameSpeed;
enabled = true;
player.gameObject.SetActive(true);
spawner.gameObject.SetActive(true);
gameOverText.gameObject.SetActive(false);
retryButton.gameObject.SetActive(false);
ShowGameOver(false);
startScreen.SetActive(false);
}
public void GameOver()
@ -76,20 +84,26 @@ public class GameManager : MonoBehaviour
player.gameObject.SetActive(false);
spawner.gameObject.SetActive(false);
gameOverText.gameObject.SetActive(true);
retryButton.gameObject.SetActive(true);
ShowGameOver(true);
GameOverHighscore();
UpdateHiscore();
}
private void Update()
{
gameSpeed += gameSpeedIncrease * Time.deltaTime;
score += gameSpeed * Time.deltaTime;
scoreText.text = Mathf.FloorToInt(score).ToString("D5");
if(player.gameObject.activeSelf){
gameSpeed += gameSpeedIncrease * Time.deltaTime;
score += gameSpeed * Time.deltaTime;
scoreText.text = Mathf.FloorToInt(score).ToString("D5");
timeElapsed += Time.deltaTime;
}
}
private void UpdateHiscore()
{
if(!HighscoreModeManager.isPraticeMode){
hiscoreText.text = Mathf.FloorToInt(HighscoreModeManager.highscore).ToString("D5");
return;
}
float hiscore = PlayerPrefs.GetFloat("hiscore", 0);
if (score > hiscore)
{
@ -98,4 +112,46 @@ public class GameManager : MonoBehaviour
}
hiscoreText.text = Mathf.FloorToInt(hiscore).ToString("D5");
}
public void SetHighscore(int highscore){
PlayerPrefs.SetFloat("highscore", highscore);
hiscoreText.text = Mathf.FloorToInt(highscore).ToString("D5");
}
public void ShowGameOver(bool show){
if(!show){
practiceGameOver.SetActive(false);
duelGameOver.SetActive(false);
return;
}
if(HighscoreModeManager.isPraticeMode){
practiceGameOver.SetActive(show);
}else{
duelGameOver.SetActive(show);
}
}
public void GameOverHighscore(){
if(HighscoreModeManager.isPraticeMode){
}else{
StartCoroutine(UpdateLeaderboard());
}
}
IEnumerator UpdateLeaderboard(){
yield return new WaitForSeconds(1f);
closeButton.SetActive(false);
processingObject.SetActive(true);
string url = $"{DuelFi.VALIDATOR_URL}/updateLeaderboardScore?leaderboard_id={HighscoreModeManager.leaderboarId}&player_key={HighscoreModeManager.playerKey}&score={Mathf.FloorToInt(score)}";
WWW www = new WWW(url);
yield return www;
if(www.error == null){
Debug.Log("Leaderboard updated successfully");
}else{
Debug.Log("Error updating leaderboard: " + www.error);
}
closeButton.SetActive(true);
processingObject.SetActive(false);
}
}

View File

@ -5,6 +5,7 @@ using UnityEngine;
public class Obstacle : MonoBehaviour
{
private float leftEdge;
public float movingItemSpeed = 1f;
private void Start()
{
@ -13,7 +14,7 @@ public class Obstacle : MonoBehaviour
private void Update()
{
transform.position += Vector3.left * GameManager.Instance.gameSpeed * Time.deltaTime;
transform.position += Vector3.left * GameManager.Instance.gameSpeed * Time.deltaTime * movingItemSpeed;
if (transform.position.x < leftEdge)
{
Destroy(gameObject);

View File

@ -1,8 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.TextCore.Text;
public class Player : MonoBehaviour
{
@ -31,16 +27,21 @@ public class Player : MonoBehaviour
{
direction = Vector3.down;
if (Input.GetButton("Jump"))
if (Input.GetButton("Jump") || jumpQueued)
{
direction = Vector3.up * jumpForce;
jumpQueued = false;
}
}
character.Move(direction * Time.deltaTime);
}
bool jumpQueued = false;
public void Jump(){
jumpQueued = true;
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Obstacle"))

View File

@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class ResponsiveCameraZoom : MonoBehaviour
{
public float defaultFov = 4; //FOV at 16:9
Camera cam;
void Awake()
{
cam = GetComponent<Camera>();
}
void Update()
{
float aspectRatio = (float)Screen.height / (float)Screen.width;
cam.orthographicSize = defaultFov * aspectRatio;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da8a81f8dd9f3db4d8c89b723be5672f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -43,7 +43,7 @@ public class Spawner : MonoBehaviour
spawnChance -= obj.spawnChance;
}
Invoke(nameof(Spawn), Random.Range(minSpawnRate, maxSpawnrate));
Invoke(nameof(Spawn), Random.Range(minSpawnRate, maxSpawnrate) * Mathf.Clamp(100f/ GameManager.timeElapsed,0.3f,1));
}
}

BIN
Assets/Sprites/Close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

View File

@ -0,0 +1,140 @@
fileFormatVersion: 2
guid: 5603332170ae8174696b770c6b2ce575
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 96
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"com.boxqkrtm.ide.cursor": "https://github.com/boxqkrtm/com.unity.ide.cursor.git",
"com.unity.collab-proxy": "2.8.2",
"com.unity.feature.2d": "2.0.0",
"com.unity.ide.rider": "3.0.24",
@ -8,6 +9,7 @@
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.7.5",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10",
"com.unity.ugui": "1.0.0",
"com.unity.visualscripting": "1.9.0",
"com.unity.modules.ai": "1.0.0",

View File

@ -1,5 +1,14 @@
{
"dependencies": {
"com.boxqkrtm.ide.cursor": {
"version": "https://github.com/boxqkrtm/com.unity.ide.cursor.git",
"depth": 0,
"source": "git",
"dependencies": {
"com.unity.test-framework": "1.1.9"
},
"hash": "38fecf55e4fd94ccfe58a92ed8ad1a529ba1694e"
},
"com.unity.2d.animation": {
"version": "9.0.3",
"depth": 1,
@ -174,6 +183,22 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.sysroot": {
"version": "2.0.10",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.sysroot.linux-x86_64": {
"version": "2.0.9",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.sysroot": "2.0.10"
},
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.33",
"depth": 0,
@ -206,6 +231,16 @@
},
"url": "https://packages.unity.com"
},
"com.unity.toolchain.win-x86_64-linux-x86_64": {
"version": "2.0.10",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.sysroot": "2.0.10",
"com.unity.sysroot.linux-x86_64": "2.0.9"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": {
"version": "1.0.0",
"depth": 0,

View File

@ -0,0 +1,16 @@
{
"MonoBehaviour": {
"Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
"DebugDataKind": 1,
"EnableArmv9SecurityFeatures": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"OptimizeFor": 0
}
}

View File

@ -0,0 +1,6 @@
{
"MonoBehaviour": {
"Version": 4,
"DisabledWarnings": ""
}
}

View File

@ -44,8 +44,8 @@ PlayerSettings:
m_HolographicTrackingLossScreen: {fileID: 0}
defaultScreenWidth: 1920
defaultScreenHeight: 1080
defaultScreenWidthWeb: 960
defaultScreenHeightWeb: 600
defaultScreenWidthWeb: 1280
defaultScreenHeightWeb: 768
m_StereoRenderingPath: 0
m_ActiveColorSpace: 1
m_SpriteBatchVertexThreshold: 300
@ -582,7 +582,7 @@ PlayerSettings:
webGLTemplate: APPLICATION:Default
webGLAnalyzeBuildSize: 0
webGLUseEmbeddedResources: 0
webGLCompressionFormat: 0
webGLCompressionFormat: 2
webGLWasmArithmeticExceptions: 0
webGLLinkerTarget: 1
webGLThreadsSupport: 0