demo——第一关

This commit is contained in:
wulongxiao 2024-12-02 23:38:32 +08:00
parent fb8fd6d8f5
commit 3723cc9e7a
41 changed files with 3153 additions and 2596 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,123 @@
fileFormatVersion: 2
guid: f839f967b811d6843a7cbbea3ecc9a6f
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
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
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: 100
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
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 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
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -0,0 +1,123 @@
fileFormatVersion: 2
guid: 3051e860ed5b2324fb5ca5c57328cf45
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
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
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: 100
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
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 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
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -1,9 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 0b7f4c0bf370dd74294b1b582f239100 guid: 0b7f4c0bf370dd74294b1b582f239100
TextureImporter: TextureImporter:
fileIDToRecycleName: {} internalIDToNameTable: []
externalObjects: {} externalObjects: {}
serializedVersion: 7 serializedVersion: 12
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
enableMipMap: 0 enableMipMap: 0
@ -23,6 +23,8 @@ TextureImporter:
isReadable: 0 isReadable: 0
streamingMipmaps: 0 streamingMipmaps: 0
streamingMipmapsPriority: 0 streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0 grayScaleToAlpha: 0
generateCubemap: 6 generateCubemap: 6
cubemapConvolution: 0 cubemapConvolution: 0
@ -31,9 +33,9 @@ TextureImporter:
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
serializedVersion: 2 serializedVersion: 2
filterMode: -1 filterMode: 1
aniso: -1 aniso: 1
mipBias: -100 mipBias: 0
wrapU: 1 wrapU: 1
wrapV: 1 wrapV: 1
wrapW: 1 wrapW: 1
@ -54,11 +56,16 @@ TextureImporter:
textureType: 8 textureType: 8
textureShape: 1 textureShape: 1
singleChannelComponent: 0 singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0 maxTextureSizeSet: 0
compressionQualitySet: 0 compressionQualitySet: 0
textureFormatSet: 0 textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
cookieLightType: 1
platformSettings: platformSettings:
- serializedVersion: 2 - serializedVersion: 3
buildTarget: DefaultTexturePlatform buildTarget: DefaultTexturePlatform
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -69,7 +76,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Standalone buildTarget: Standalone
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -80,7 +88,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: iPhone buildTarget: iPhone
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -91,7 +100,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Android buildTarget: Android
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -102,7 +112,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Windows Store Apps buildTarget: Windows Store Apps
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -113,7 +124,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: WebGL buildTarget: WebGL
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -124,6 +136,7 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet: spriteSheet:
serializedVersion: 2 serializedVersion: 2
sprites: [] sprites: []
@ -131,10 +144,13 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: e7d1db0e1bc714b4ba24747cc6bd90a4 spriteID: e7d1db0e1bc714b4ba24747cc6bd90a4
internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []
weights: [] weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag: spritePackingTag:
pSDRemoveMatte: 0 pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0 pSDShowRemoveMatteOption: 0

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -1,9 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: b32c4df4af5cdc44f8fa0b0e8327403f guid: b32c4df4af5cdc44f8fa0b0e8327403f
TextureImporter: TextureImporter:
fileIDToRecycleName: {} internalIDToNameTable: []
externalObjects: {} externalObjects: {}
serializedVersion: 7 serializedVersion: 12
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
enableMipMap: 0 enableMipMap: 0
@ -23,6 +23,8 @@ TextureImporter:
isReadable: 0 isReadable: 0
streamingMipmaps: 0 streamingMipmaps: 0
streamingMipmapsPriority: 0 streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0 grayScaleToAlpha: 0
generateCubemap: 6 generateCubemap: 6
cubemapConvolution: 0 cubemapConvolution: 0
@ -31,9 +33,9 @@ TextureImporter:
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
serializedVersion: 2 serializedVersion: 2
filterMode: -1 filterMode: 1
aniso: -1 aniso: 1
mipBias: -100 mipBias: 0
wrapU: 1 wrapU: 1
wrapV: 1 wrapV: 1
wrapW: 1 wrapW: 1
@ -54,11 +56,16 @@ TextureImporter:
textureType: 8 textureType: 8
textureShape: 1 textureShape: 1
singleChannelComponent: 0 singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0 maxTextureSizeSet: 0
compressionQualitySet: 0 compressionQualitySet: 0
textureFormatSet: 0 textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
cookieLightType: 1
platformSettings: platformSettings:
- serializedVersion: 2 - serializedVersion: 3
buildTarget: DefaultTexturePlatform buildTarget: DefaultTexturePlatform
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -69,7 +76,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Standalone buildTarget: Standalone
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -80,7 +88,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: iPhone buildTarget: iPhone
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -91,7 +100,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Android buildTarget: Android
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -102,7 +112,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Windows Store Apps buildTarget: Windows Store Apps
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -113,7 +124,8 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
- serializedVersion: 2 forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: WebGL buildTarget: WebGL
maxTextureSize: 2048 maxTextureSize: 2048
resizeAlgorithm: 0 resizeAlgorithm: 0
@ -124,6 +136,7 @@ TextureImporter:
allowsAlphaSplitting: 0 allowsAlphaSplitting: 0
overridden: 0 overridden: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet: spriteSheet:
serializedVersion: 2 serializedVersion: 2
sprites: [] sprites: []
@ -131,10 +144,13 @@ TextureImporter:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: e7d1db0e1bc714b4ba24747cc6bd90a4 spriteID: e7d1db0e1bc714b4ba24747cc6bd90a4
internalID: 0
vertices: [] vertices: []
indices: indices:
edges: [] edges: []
weights: [] weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag: spritePackingTag:
pSDRemoveMatte: 0 pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0 pSDShowRemoveMatteOption: 0

View File

Before

Width:  |  Height:  |  Size: 422 KiB

After

Width:  |  Height:  |  Size: 422 KiB

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class Attack : MonoBehaviour public class Attack : Palye
{ {
[Header("发射的子弹")] [Header("发射的子弹")]
public GameObject bullet; public GameObject bullet;
@ -72,7 +72,7 @@ public class Attack : MonoBehaviour
GameObject newBullet = Instantiate(bullet, canvas.transform); GameObject newBullet = Instantiate(bullet, canvas.transform);
newBullet.transform.position = transform.position; newBullet.transform.position = transform.position;
newBullet.GetComponent<bullet>().Init(target.gameObject, bulletSpeed); newBullet.GetComponent<bullet>().Init(target.gameObject, bulletSpeed);
newBullet.GetComponent<bullet>().user = this;
Debug.Log("射击敌人:" + target.name); Debug.Log("射击敌人:" + target.name);
} }
} }

View File

@ -23,6 +23,7 @@ public class Monster_tip : MonoBehaviour
} }
else else
{ {
//这里写直接跳过等待时间,开始游戏 //这里写直接跳过等待时间,开始游戏
} }

View File

@ -0,0 +1,90 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using UnityEngine;
public class Palye : Fun
{
[Header("血量")] public float hp = 100f;//血量
[Header("掉落")] public float gold = 10f;
public float Hp
{
get => hp;
set
{
hp = value;
}
}
[Header("物理护甲")] public int physicalArmor = 10;//物理护甲
[Header("魔法护甲")] public int magicArmor = 5;//魔法护甲
public List<BUff> buffList = new List<BUff>();
//public List<>;
// Start is called before the first frame update
async void Start()
{
UpdateBuff();
}
/// <summary>
/// 角色死亡
/// </summary>
public virtual void die()
{
Debug.Log(gameObject.name + "死亡");
Destroy(gameObject);
Debug.Log("死亡");
}
/// <summary>
/// 单位更新buff
/// </summary>
async void UpdateBuff()//单位buff更新
{
while (true)
{
List<BUff> deleteArr = new List<BUff>();
foreach (BUff buffItem in buffList)
{
if (buffItem.executionInterval <= 0)
{
buffItem.executionInterval = buffItem.executionInterval_max;
buffItem.Funaction.Invoke(buffItem.value);
}
buffItem.executionInterval -= 0.1f;
buffItem.timeLeft -= 0.1f;
if (buffItem.timeLeft <= 0)
{
deleteArr.Add(buffItem);
}
}
foreach (BUff item in deleteArr)
{
buffList.Remove(item);
}
await Task.Delay(100);//buff检测最小时间0.1秒执行一次
}
}
// Update is called once per frame
void Update()
{
if (hp <= 0)
{
die();
if(Progress_Display.Instance==null) return;
Progress_Display.Instance.huadongClick(gold);
}
}
}

View File

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

View File

@ -14,7 +14,9 @@ public class Penal : MonoBehaviour
public Button PanelBTNNext; public Button PanelBTNNext;
public Button PanelBTNClose; public Button PanelBTNClose;
public GameObject djs;
public int wipe_outnumber=0;
// Start is called before the first frame update // Start is called before the first frame update
private void Awake() private void Awake()
@ -26,11 +28,11 @@ public class Penal : MonoBehaviour
Panel.SetActive(false); Panel.SetActive(false);
againBTNNext.onClick.AddListener(()=> { againBTNNext.onClick.AddListener(() => {
SceneManager.LoadScene(SceneManager.GetActiveScene().name); SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}); });
PanelBTNNext.onClick.AddListener(()=> { }); PanelBTNNext.onClick.AddListener(() => { });
PanelBTNClose.onClick.AddListener(()=> { PanelBTNClose.onClick.AddListener(() => {
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false; UnityEditor.EditorApplication.isPlaying = false;
#else #else
@ -45,7 +47,10 @@ public class Penal : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (wipe_outnumber == 10)
{
GameVictory();
}
} }
public void GameVictory() public void GameVictory()
@ -72,19 +77,25 @@ public class Penal : MonoBehaviour
PanelBTNClose.gameObject.SetActive(true); PanelBTNClose.gameObject.SetActive(true);
} }
public void Daojishi(float number)
{
StartCoroutine(daojishi(number));
}
IEnumerator daojishi(float number)
{ //public void Daojishi(float number)
float temp = number; //{
while (temp > 0.01f) // StartCoroutine(daojishi(number));
{ //}
djs.GetComponent<Text>().text = temp.ToString(); //IEnumerator daojishi(float number)
temp -= 1; //{
yield return new WaitForSeconds(1); // float temp = number;
} // while (temp > 0.01f)
djs.SetActive(false); // {
} // djs.GetComponent<Text>().text = temp.ToString();
// temp -= 1;
// yield return new WaitForSeconds(1);
// }
// djs.SetActive(false);
//}
} }

View File

@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Progress_Display : MonoBehaviour
{
public static Progress_Display Instance;
public Image huadongImg;
public float count;
public Text huadongTxt;
// Start is called before the first frame update
void Start()
{
Instance = this;
}
public void huadongClick(float count)
{
if ((this.count +count)>20)
{
this.count = 20;
}
else
{
this.count += count;
}
huadongImg.fillAmount = this.count / 20;
huadongTxt.text = this.count + "/20";
}
}

View File

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

View File

@ -9,7 +9,10 @@ public class bullet : MonoBehaviour
[Header("飞行的速度,不需要给,动态创建时给")] [Header("飞行的速度,不需要给,动态创建时给")]
public float speed; public float speed;
[Header("子弹的伤害,可以给默认是50")] [Header("子弹的伤害,可以给默认是50")]
public float changehp=50; public float changehp=100;
public Palye user;
public DamageType damageType = DamageType.noAttributeDamage;
// Start is called before the first frame update // Start is called before the first frame update
void Update() void Update()
{ {
@ -37,7 +40,7 @@ public class bullet : MonoBehaviour
transform.position += direction * speed * Time.deltaTime; transform.position += direction * speed * Time.deltaTime;
// 如果子弹非常接近目标,视为命中 // 如果子弹非常接近目标,视为命中
if (Vector3.Distance(transform.position, tagpos.transform.position) < 0.1f) if (Vector3.Distance(transform.position, tagpos.transform.position) < 10f)
{ {
HitTarget(); HitTarget();
} }
@ -49,12 +52,22 @@ public class bullet : MonoBehaviour
npcInfo enemy = tagpos.GetComponent<npcInfo>(); npcInfo enemy = tagpos.GetComponent<npcInfo>();
if (enemy != null) if (enemy != null)
{ {
enemy.ChangeHp(-changehp); // 假设子弹造成10点伤害
enemy.bloodLoss(new object[] { enemy , changehp, damageType, user });
Debug.Log("击中敌人"); Debug.Log("击中敌人");
//BUff buff = new BUff();
//buff.timeLeft = 5;
//buff.executionInterval_max = 0.1f;
//buff.Funaction = enemy.poisoning;
//buff.value = new object[] { enemy,user };
//enemy.buffList.Add(buff);
} }
// 销毁子弹 // 销毁子弹
Destroy(gameObject); Destroy(gameObject);
} }
} }

View File

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

View File

@ -0,0 +1,99 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
public enum DamageType
{
physicalDamage,//物理伤害
magicDamage,//魔法伤害
noAttributeDamage,//无属性伤害
}
//public class prefabObjects
//{
// public string targetAudience = "targetAudience";
// public string myPalye = "myPalye";
//}
public class BUff
{
public float timeLeft = 0;//剩余时间
public float executionInterval = 0;//buff执行间隔
public float executionInterval_max = 100;//buff执行间隔
public Action<object[]> Funaction;//调用的函数
public object[] value;//调用函数的值
}
public class Fun : Base
{
//// 通过方法名调用对应的方法
//public void CallMethodByName(string methodName)
//{
// // 获取当前类的Type
// Type type = this.GetType();
// // 获取方法信息
// MethodInfo methodInfo = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
// if (methodInfo != null)
// {
// // 调用该方法
// methodInfo.Invoke(this,null ); // null代表无参数
// }
// else
// {
// Debug.LogError("方法未找到: " + methodName);
// }
//}
/// <summary>
/// 中毒 //目标 // 自己
/// </summary>
/// <param name="objects"></param>
public void poisoning(object[] objects)
{
Palye targetAudience = (Palye)objects[0];
Palye myPalye = (Palye)objects[1];
Debug.Log("触发中毒");
Debug.Log(myPalye.name);
}
/// <summary>
/// 扣血 传入参数 目标,伤害值,攻击类型,使用者
/// </summary>
/// <param name="objects"></param>
public void bloodLoss(object[] objects)//目标,伤害值,攻击类型,使用者
{
Palye targetAudience = (Palye)objects[0];
float harm = (float)objects[1];
DamageType damageType = (DamageType)objects[2];
Palye UserObj = (Palye)objects[3];
float finalDamage = harm;
switch (damageType)
{
case DamageType.physicalDamage://物理伤害
finalDamage -= targetAudience.physicalArmor;
break;
case DamageType.magicDamage://魔法伤害
finalDamage -= targetAudience.magicArmor;
break;
case DamageType.noAttributeDamage://无属性伤害
finalDamage -= 0;
break;
}
if (finalDamage < 0)
{
finalDamage = 0;
}
targetAudience.Hp -= finalDamage;
}
}

View File

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

View File

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Global : MonoBehaviour
{
//public class FuncClass
// {
// public string Name;
// public List<string> Value;
// public FuncClass(string _Name, List<string> _Value)
// {
// Name = _Name;
// Value = _Value;
// }
// }
//public Dictionary<string, List<FuncClass>> funcClasses = new List<FuncClass>
//{
// new FuncClass("poisoning",new List<string>{
// })
//};
}

View File

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

View File

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

View File

@ -0,0 +1,34 @@
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class EventPopUp : MonoBehaviour
{
public string text = "";
public Image Image;
public Text textobg;
public float time = 5f;
async void Start()
{
Canvas canvas = GetComponentInParent<Canvas>();
float canvasHeight = canvas.GetComponent<RectTransform>().rect.height;
transform.DOMoveY(canvasHeight - (canvasHeight*0.3f), 1.5f);
await Task.Delay(500);
Image.DOColor(new Color(1f, 1f, 1f, 0f), time);
textobg.DOColor(new Color(1f, 1f, 1f, 0f), time);
await Task.Delay(5100);
Destroy(gameObject);
}
// Update is called once per frame
void Update()
{
if (textobg != null)
{
textobg.text = text;
}
}
}

View File

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

View File

@ -0,0 +1,66 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System.Threading.Tasks;
public class ImageLoader : MonoBehaviour
{
// 缓存字典
private Dictionary<string, Sprite> imageCache = new Dictionary<string, Sprite>();
//private async void Start()
//{
// GetComponent<Image>().sprite = await LoadImageAsync("https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/goods/mall/c7860d8909194d479b6f27ccb922e863.png");
//}
// 异步加载图片
public async Task<Sprite> LoadImageAsync(string url)
{
// 如果缓存中已经有图片,则直接返回缓存的图片
if (imageCache.ContainsKey(url))
{
Debug.Log("Image found in cache.");
return imageCache[url];
}
// 如果缓存中没有图片,则异步加载
using (UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(url))
{
// 等待请求完成
//await webRequest.SendWebRequest().ToTask();
// 发送请求并等待响应
var operation = webRequest.SendWebRequest();
while (!operation.isDone)
await Task.Yield(); // 等待请求完成使用await以非阻塞的方式处理
// 检查请求是否成功
if (webRequest.result == UnityWebRequest.Result.Success)
{
// 获取下载的纹理
Texture2D texture = ((DownloadHandlerTexture)webRequest.downloadHandler).texture;
// 将纹理缓存
imageCache[url] = TextureToSprite(texture);
return imageCache[url];
}
else
{
Debug.LogError("Failed to load image: " + webRequest.error);
return null;
}
}
}
// 将Texture2D转换为Sprite
Sprite TextureToSprite(Texture2D texture)
{
// 使用纹理的尺寸创建一个Sprite
return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
}
// 加载并显示图片
//public async void LoadAndDisplayImage(string url, Renderer renderer)
//{
// Texture2D texture = await LoadImageAsync(url);
// if (texture != null)
// {
// renderer.material.mainTexture = texture;
// }
//}
}

View File

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

View File

@ -0,0 +1,125 @@
using DG.Tweening;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class Base : MonoBehaviour
{
private List<string> LoadClassName = new List<string>() { "ImageLoader" , "Global" };//写入需要全局自动实例化的类
public Button retbutton;
public GameObject ClosureObj;
public static GameObject GlobalObj;
private void Awake()
{
Application.targetFrameRate = Mathf.RoundToInt(55f); // 设置目标帧率
initializeGlobal();
if (retbutton != null)
{
retbutton.onClick.AddListener(() => CancelOnClick(retbutton, ClosureObj));
}
}
private void initializeGlobal()
{
if (GlobalObj == null)
{
GlobalObj = new GameObject("GlobalObj");
DontDestroyOnLoad(GlobalObj);
foreach (string className in LoadClassName) {
CallClassByString(className);
}
}
}
// 用于通过类名字符串动态调用类和方法
public void CallClassByString(string className)
{
// 获取类的 Type 对象
Type type = Type.GetType(className);
if (type != null)
{
GlobalObj.AddComponent(type);
}
else
{
Console.WriteLine("Class not found.");
}
}
public async Task ButtonClickAnimationAsync(GameObject button,float max=1.25f,float timemultiple = 1)//按钮动画
{
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
Sequence mySequence = DOTween.Sequence();
mySequence.Append(button.transform.DOScale(max, 0.1f* timemultiple)) // 第一个动画
.Append(button.transform.DOScale(1f, 0.2f* timemultiple)).OnComplete(() => {
// 动画播放完成后执行的代码
tcs.SetResult(true);
}); // 第二个动画
await tcs.Task;
}
public void addEventPopUp(string Details,float time = 5f)//添加弹窗
{
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
prefab.GetComponent<EventPopUp>().time = time;
Canvas canvas = GetComponentInParent<Canvas>();
prefab.GetComponent<EventPopUp>().text = Details;
Instantiate(prefab, canvas.transform);
}
//logoPanel.ServerResponse TestserverResponse;
//protected Dictionary<string, string> testhead;
//public async void testLogo()//测试登录
//{
// LoginAndGetToken.loginbody body = new LoginAndGetToken.loginbody
// {
// userName = "15151658596",
// password = "123456",
// verifyCode = 111111
// };
// string loginResponse = await web.SendRequest(web.URL + "/snail/user/login", "POST", JsonUtility.ToJson(body));
// logoPanel.ServerResponse response = JsonUtility.FromJson<logoPanel.ServerResponse>(loginResponse);
// if (response != null && response.code == 200 && response.data != null)
// {
// TestserverResponse = response;
// addEventPopUp("测试登录成功");
// testhead = new Dictionary<string, string>
// {
// { "Authorization", TestserverResponse.data.token }
// };
// return;
// }
// addEventPopUp(response.message);
// testhead = new Dictionary<string, string>();
//}
public bool IsGreaterThanZeroDecimal(string text)//判断必须为小数而且大于0
{
// 使用正则表达式匹配大于0的小数
string pattern = @"^(?!0(\.0+)?$)(\d+(\.\d+)?|\.\d+)$";
Regex regex = new Regex(pattern);
return regex.IsMatch(text);
}
public async void CancelOnClick(Button button,GameObject my_gameObject = null)//取消按钮
{
await ButtonClickAnimationAsync(button.gameObject);
if (my_gameObject != null)
{
Destroy(my_gameObject);
return;
}
Destroy(gameObject);
}
}

View File

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

View File

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

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : Base
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

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

View File

@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class test1 : Base
{
// Start is called before the first frame update
async void Start()
{
GetComponent<Image>().sprite = await GlobalObj.GetComponent<ImageLoader>().LoadImageAsync("https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/goods/mall/c7860d8909194d479b6f27ccb922e863.png");
}
// Update is called once per frame
void Update()
{
}
}

View File

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

View File

@ -2,25 +2,8 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class npcInfo : MonoBehaviour public class npcInfo : Palye
{ {
[Header("Hp默认为100")]
public float Hp=100;
public void ChangeHp(float number)
{
if ((this.Hp+ number) <=0)
{
PlayerInfo.instance.ChangeGold(10);
Destroy(this.gameObject);
return;
}
Debug.Log("改变血量");
this.Hp += number;
}
public void ClearNpc()
{
Destroy(this.gameObject);
}
} }

View File

@ -1,48 +1,80 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class npcInit : MonoBehaviour public class npcInit : MonoBehaviour
{ {
[Header("Ô¤ÖÆÌå")] [Header("怪物预制体")]
public GameObject npcPrefab; public GameObject npcPrefab;
[Header("·¾¶")] [Header("·¾¶")]
public List<Transform> path = new List<Transform>(); public List<Transform> path = new List<Transform>();
[Header("ÐèÒªµÄ×Üʱ¼ä")] [Header("移动需要的总时间")]
public float moveNeedTimer; public float moveNeedTimer;
[Header("生成一只怪物的间隔")]
public float getOneNpcTimer;
[Header("生成的npc数量")]
public int npcNumber;
[Header("迎战按钮")]
public Button FightBtn;
[Header("技能UI")]
public GameObject JnPanel;
private bool isStrat=false;
private float timer=0;//计时器
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
Penal.instance.Daojishi(5f);
StartCoroutine(getmouse()); FightBtn.onClick.AddListener(() =>
{
FightBtn.gameObject.SetActive(false);
FightBtn.interactable=false;
JnPanel.gameObject.SetActive(true);
isStrat =true;
GameObject go = Instantiate(npcPrefab, this.transform);
go.GetComponent<npcMove>().Init(path, moveNeedTimer);
go.transform.position = path[0].transform.position;
npcNumber--;
});
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (!isStrat)
}
void GetMouse()
{
GameObject go = Instantiate(npcPrefab, this.transform);
go.transform.position = path[0].transform.position;
go.GetComponent<npcMove>().Init(path, moveNeedTimer);
}
IEnumerator getmouse()
{
yield return new WaitForSeconds(5f);
int index = 0;
while (index<=4)
{ {
GetMouse(); return;
index++; }
yield return new WaitForSeconds(3f);
timer += Time.deltaTime;
if (timer > getOneNpcTimer)
{
timer = 0;
if (npcNumber > 0)
{
GameObject go = Instantiate(npcPrefab, this.transform);
go.GetComponent<npcMove>().Init(path, moveNeedTimer);
go.transform.position = path[0].transform.position;
npcNumber--;
}
else
{
isStrat = false;
}
} }
} }
} }

View File

@ -9,16 +9,15 @@ public class npcMove : MonoBehaviour
public List<Transform> path=new List<Transform>(); public List<Transform> path=new List<Transform>();
public float moveNeedTimer; public float moveNeedTimer;
public void Init(List<Transform> path,float moveNeedTimer) public void Init(List<Transform> path,float moveNeedTimer)
{ {
this.path = path; this.path = path;
this.moveNeedTimer = moveNeedTimer; this.moveNeedTimer = moveNeedTimer;
StartCoroutine(move());
}
IEnumerator move()
{
// 将路径点转换为 Vector3 数组 // 将路径点转换为 Vector3 数组
Vector3[] pathPoints = new Vector3[this.path.Count]; Vector3[] pathPoints = new Vector3[this.path.Count];
for (int i = 0; i < path.Count; i++) for (int i = 0; i < path.Count; i++)
@ -27,12 +26,11 @@ public class npcMove : MonoBehaviour
} }
// 使用 DOPath 沿着路径移动到目标点,并禁用旋转变化 // 使用 DOPath 沿着路径移动到目标点,并禁用旋转变化
yield return this.transform.DOPath(pathPoints, moveNeedTimer, PathType.Linear) this.transform.DOPath(pathPoints, moveNeedTimer, PathType.Linear)
.SetOptions(false) // 禁用旋转 .SetOptions(false) // 禁用旋转
.SetEase(Ease.InOutSine) .SetEase(Ease.InOutSine)
.WaitForCompletion(); .WaitForCompletion();
//移动到终点
PlayerInfo.instance.ChangeHp(-1);
Destroy(this.gameObject);
} }
} }

View File

@ -17,17 +17,17 @@ public class paotaInfo : MonoBehaviour
void Start() void Start()
{ {
Init(); Init();
UpBTN.onClick.AddListener(()=> { //UpBTN.onClick.AddListener(()=> {
UpLevel(); // UpLevel();
}); ////});
UpBTN.gameObject.SetActive(false); //UpBTN.gameObject.SetActive(false);
PlayerInfo.instance.OnGoldReachedThreshold += ShowUpBTN; //PlayerInfo.instance.OnGoldReachedThreshold += ShowUpBTN;
} }
private void OnDestroy() private void OnDestroy()
{ {
PlayerInfo.instance.OnGoldReachedThreshold -= ShowUpBTN; // PlayerInfo.instance.OnGoldReachedThreshold -= ShowUpBTN;
} }
void ShowUpBTN() { void ShowUpBTN() {
@ -40,10 +40,11 @@ public class paotaInfo : MonoBehaviour
_CircleCollider2D.radius = fanweiNumber; _CircleCollider2D.radius = fanweiNumber;
} }
void UpLevel() public void UpLevel()
{ {
float a = fanweiNumber * 1.5f; float a = fanweiNumber * 1.5f;
fanwei.sizeDelta = new Vector2(a * 2f, a * 2f); fanwei.sizeDelta = new Vector2(a * 2f, a * 2f);
_CircleCollider2D.radius = a; _CircleCollider2D.radius = a;
Progress_Display.Instance.huadongClick(-3);
} }
} }

View File

@ -37,8 +37,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: -0.000026703, y: 12}
m_SizeDelta: {x: 26, y: 52} m_SizeDelta: {x: 49.1762, y: 40.5179}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &313496254141504926 --- !u!222 &313496254141504926
CanvasRenderer: CanvasRenderer:
@ -68,9 +68,9 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: 973e7adeb1f1b154e874e1debf556b49, type: 3} m_Sprite: {fileID: 21300000, guid: f839f967b811d6843a7cbbea3ecc9a6f, type: 3}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 1
m_FillCenter: 1 m_FillCenter: 1
m_FillMethod: 4 m_FillMethod: 4
m_FillAmount: 1 m_FillAmount: 1
@ -111,3 +111,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: cf61882f89d37574f996c1de92e60de5, type: 3} m_Script: {fileID: 11500000, guid: cf61882f89d37574f996c1de92e60de5, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
tagpos: {fileID: 0}
speed: 0
changehp: 50