= před 4 roky
rodič
revize
f0e4577cfe
39 změnil soubory, kde provedl 1414 přidání a 425 odebrání
  1. 0 0
      Assets/Plugins/TextMesh Pro/Resources/Fonts & Materials/SOURCEHANSANSCN-NORMAL SDF.asset
  2. 20 30
      Assets/Resources/Dice/Dice.prefab
  3. 9 8
      Assets/Resources/Dice/DiceEntity.cs
  4. 8 5
      Assets/Resources/Dice/DiceUI.cs
  5. 1 1
      Assets/Resources/Entities/Bullet.cs
  6. 1 1
      Assets/Resources/Entities/EnemyArrow.cs
  7. 6 6
      Assets/Resources/Entities/EnemyBase.cs
  8. 1 1
      Assets/Resources/Entities/EnemyHeavy.cs
  9. 6 6
      Assets/Resources/Entities/EnemyHeavy.prefab
  10. 1 1
      Assets/Resources/Entities/EnemyMover.cs
  11. 2 2
      Assets/Resources/Entities/EnemyMover.prefab
  12. 29 0
      Assets/Resources/Entities/EnemyShooter.cs
  13. 11 0
      Assets/Resources/Entities/EnemyShooter.cs.meta
  14. binární
      Assets/Resources/Entities/EnemyShooter.png
  15. 134 0
      Assets/Resources/Entities/EnemyShooter.png.meta
  16. 226 0
      Assets/Resources/Entities/EnemyShooter.prefab
  17. 7 0
      Assets/Resources/Entities/EnemyShooter.prefab.meta
  18. 16 0
      Assets/Resources/Entities/EnemyShooterBullet.cs
  19. 11 0
      Assets/Resources/Entities/EnemyShooterBullet.cs.meta
  20. binární
      Assets/Resources/Entities/EnemyShooterBullet.png
  21. 2 2
      Assets/Resources/Entities/EnemyShooterBullet.png.meta
  22. 154 0
      Assets/Resources/Entities/EnemyShooterBullet.prefab
  23. 7 0
      Assets/Resources/Entities/EnemyShooterBullet.prefab.meta
  24. 16 16
      Assets/Resources/Entities/EntityBase.cs
  25. 26 11
      Assets/Resources/Entities/Player.cs
  26. 1 1
      Assets/Resources/Map/Wall.asset
  27. binární
      Assets/Resources/Map/Wall.png
  28. 113 0
      Assets/Resources/System/AspectUtility.cs
  29. 11 0
      Assets/Resources/System/AspectUtility.cs.meta
  30. 1 1
      Assets/Resources/System/AudioM.cs
  31. 12 3
      Assets/Resources/System/Spawner.cs
  32. 12 5
      Assets/Resources/System/StoryM.cs
  33. binární
      Assets/Resources/UI/bg0.png
  34. 134 0
      Assets/Resources/UI/bg0.png.meta
  35. binární
      Assets/Resources/UI/bg1.png
  36. 134 0
      Assets/Resources/UI/bg1.png.meta
  37. 300 323
      Assets/Scenes/SceneMain.unity
  38. 1 1
      ProjectSettings/Physics2DSettings.asset
  39. 1 1
      ProjectSettings/TagManager.asset

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
Assets/Plugins/TextMesh Pro/Resources/Fonts & Materials/SOURCEHANSANSCN-NORMAL SDF.asset


+ 20 - 30
Assets/Resources/Dice/Dice.prefab

@@ -11,8 +11,8 @@ GameObject:
   - component: {fileID: 1666923398196175547}
   - component: {fileID: 1666923398196175542}
   - component: {fileID: 1666923398196175541}
-  - component: {fileID: 1666923398196175540}
   - component: {fileID: 1666923398196175543}
+  - component: {fileID: 3203297832167130577}
   m_Layer: 10
   m_Name: Dice
   m_TagString: Dice
@@ -101,41 +101,15 @@ Rigidbody2D:
   m_Simulated: 1
   m_UseFullKinematicContacts: 0
   m_UseAutoMass: 0
-  m_Mass: 10000
+  m_Mass: 10
   m_LinearDrag: 0
   m_AngularDrag: 0.05
-  m_GravityScale: 1
+  m_GravityScale: 0.5
   m_Material: {fileID: 6200000, guid: e938aca3f71562d499deb20bf7e0edcd, type: 2}
   m_Interpolate: 0
   m_SleepingMode: 1
   m_CollisionDetection: 1
-  m_Constraints: 4
---- !u!61 &1666923398196175540
-BoxCollider2D:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1666923398196175546}
-  m_Enabled: 1
-  m_Density: 1
-  m_Material: {fileID: 6200000, guid: e938aca3f71562d499deb20bf7e0edcd, type: 2}
-  m_IsTrigger: 0
-  m_UsedByEffector: 0
-  m_UsedByComposite: 0
-  m_Offset: {x: 0, y: 0}
-  m_SpriteTilingProperty:
-    border: {x: 0, y: 0, z: 0, w: 0}
-    pivot: {x: 0.5, y: 0.5}
-    oldSize: {x: 1, y: 1}
-    newSize: {x: 1, y: 1}
-    adaptiveTilingThreshold: 0.5
-    drawMode: 0
-    adaptiveTiling: 0
-  m_AutoTiling: 0
-  serializedVersion: 2
-  m_Size: {x: 1, y: 1}
-  m_EdgeRadius: 0
+  m_Constraints: 5
 --- !u!114 &1666923398196175543
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -150,6 +124,22 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   key: 4
   canRestore: 1
+--- !u!58 &3203297832167130577
+CircleCollider2D:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1666923398196175546}
+  m_Enabled: 1
+  m_Density: 1
+  m_Material: {fileID: 6200000, guid: e938aca3f71562d499deb20bf7e0edcd, type: 2}
+  m_IsTrigger: 0
+  m_UsedByEffector: 0
+  m_UsedByComposite: 0
+  m_Offset: {x: 0, y: 0}
+  serializedVersion: 2
+  m_Radius: 0.6
 --- !u!1 &1666923398225157471
 GameObject:
   m_ObjectHideFlags: 0

+ 9 - 8
Assets/Resources/Dice/DiceEntity.cs

@@ -28,8 +28,8 @@ public class DiceEntity : MonoBehaviour {
         GetComponent<Rigidbody2D>().velocity = Vector2.zero;
         // 开始旋转
         transform.DORotate(new Vector3(0, 0, 360f * Mathf.RoundToInt(rollTime * 1.5f)), rollTime, RotateMode.FastBeyond360);
-        transform.DOScale(2, rollTime);
-        transform.DOMoveY(transform.position.y + 3, rollTime);
+        transform.DOScale(1, rollTime).SetRelative();
+        transform.DOMoveY(transform.position.y + 2, rollTime);
         StartCoroutine(Roll());
     }
     IEnumerator Roll() {
@@ -51,22 +51,23 @@ public class DiceEntity : MonoBehaviour {
         yield return new WaitForSeconds(0.5f);
         // 强调动画
         AudioM.Play("DicePickup2");
-        transform.DOScale(2.5f, 0.1f);
+        transform.DOScale(0.5f, 0.1f).SetRelative();
         yield return new WaitForSeconds(0.1f);
-        transform.DOScale(2.3f, 0.1f);
+        transform.DOScale(-0.2f, 0.1f).SetRelative();
         yield return new WaitForSeconds(0.7f);
         // 结束动画
-        transform.DOScale(1, endTime);
+        transform.DOScale(-1.3f, endTime).SetRelative();
         GameObject endObj = InputM.GetDiceUI(key);
-        Vector2 screenPos = RectTransformUtility.WorldToScreenPoint(Camera.allCameras[0], endObj.transform.position);
-        transform.DOMove((Vector2) Camera.allCameras[0].ScreenToWorldPoint(screenPos), endTime);
+        Vector2 screenPos = RectTransformUtility.WorldToScreenPoint(AspectUtility.cam, endObj.transform.position);
+        transform.DOMove((Vector2) AspectUtility.cam.ScreenToWorldPoint(screenPos), endTime);
         yield return new WaitForSeconds(endTime);
         // 设置
         InputM.SetKey(key, currentLetter);
         endObj.GetComponent<DiceUI>().isDropped = false;
         endObj.GetComponent<DiceUI>().UpdateColor();
         yield return new WaitForSeconds(0.1f);
-        Destroy(gameObject);
+        // 销毁
+        transform.localScale = Vector3.zero; Destroy(gameObject, 1);
     }
 
 

+ 8 - 5
Assets/Resources/Dice/DiceUI.cs

@@ -35,17 +35,20 @@ public class DiceUI : MonoBehaviour {
     public bool allowPress = true;
     void Update() {
         if (!Input.GetMouseButtonUp(0) || !(allowPress || Input.GetKey(KeyCode.LeftControl)) || 
-            !RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.allCameras[0])) return;
-        // ?
+            !RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, AspectUtility.cam)) return;
+        // µã»÷
         DropDice();
     }
 
     public bool isDropped = false;
     public void DropDice() {
-        Vector2 screenPos = RectTransformUtility.WorldToScreenPoint(Camera.allCameras[0], transform.position);
-        Vector2 currentPos = Camera.allCameras[0].ScreenToWorldPoint(screenPos);
+        Vector2 currentPos = AspectUtility.cam.ScreenToWorldPoint((Vector2) rectTransform.localPosition);
+        Vector2 currentPos2 = AspectUtility.cam.ScreenToWorldPoint((Vector2) rectTransform.localPosition + rectTransform.sizeDelta);
+        Vector2 currentScale = Vector2.one * 1.11f; //(currentPos2.x - currentPos.x);
+        Debug.Log("Dice scale: " + currentScale);
         DiceEntity diceNew = GameObject.Instantiate(InputM.instance.dicePrefab).GetComponent<DiceEntity>();
-        diceNew.transform.position = currentPos;
+        diceNew.transform.localScale = currentScale;
+        diceNew.transform.position = rectTransform.position;
         diceNew.key = keybind;
         isDropped = true;
         UpdateColor();

+ 1 - 1
Assets/Resources/Entities/Bullet.cs

@@ -6,7 +6,7 @@ public class Bullet : MonoBehaviour {
 
     private void OnCollisionEnter2D(Collision2D collision) {
         AudioM.Play("bullet_explode");
-        Destroy(gameObject);
+        transform.localScale = Vector3.zero; Destroy(gameObject, 1);
     }
 
 }

+ 1 - 1
Assets/Resources/Entities/EnemyArrow.cs

@@ -10,7 +10,7 @@ public class EnemyArrow : EnemyBase {
     internal override bool isPressingRight() => !movingLeft;
 
     internal override void OnHitEnemy(Collision2D collision) {
-        Destroy(gameObject);
+        transform.localScale = Vector3.zero; Destroy(gameObject, 1);
     }
 
 }

+ 6 - 6
Assets/Resources/Entities/EnemyBase.cs

@@ -7,21 +7,21 @@ public abstract class EnemyBase : EntityBase {
 
     public bool movingLeft = false;
     internal override void OnHitBorder() {
-        Destroy(gameObject);
+        transform.localScale = Vector3.zero; Destroy(gameObject, 1);
     }
 
     public int hp; internal int currentHp = -1;
     internal override void OnHitBullet() {
-        // 鍙椾激鍔ㄧ敾
+        // 受伤动画
         sprite.DOColor(new Color(1f, 0.5f, 0.5f), 0.04f).SetLoops(2, LoopType.Yoyo);
-        // 姝讳骸鍒ゆ柇
+        // 死亡判断
         if (currentHp == -1) currentHp = hp;
         currentHp--;
-        if (currentHp < 0) {
+        if (currentHp <= 0) {
             AudioM.Play("enemy_die");
             transform.localScale = Vector3.zero;
-            Destroy(gameObject, 1); // 闃叉�鍔ㄧ敾娌℃挱鏀惧畬瀵艰嚧鎶ラ敊
+            Destroy(gameObject, 1); // 防止动画没播放完导致报错
         }
     }
 
-}
+}

+ 1 - 1
Assets/Resources/Entities/EnemyHeavy.cs

@@ -17,7 +17,7 @@ public class EnemyHeavy : EnemyBase {
         turnCooldown -= Time.deltaTime;
         if (shouldTurn && turnCooldown <= 0f) {
             movingLeft = !movingLeft;
-            turnCooldown = 0.5f;
+            turnCooldown = 1f;
         }
     }
 

+ 6 - 6
Assets/Resources/Entities/EnemyHeavy.prefab

@@ -102,7 +102,7 @@ Rigidbody2D:
   m_Mass: 5
   m_LinearDrag: 0
   m_AngularDrag: 0.05
-  m_GravityScale: 1
+  m_GravityScale: 0.5
   m_Material: {fileID: 6200000, guid: 6a9410bb3043e384eba63a5622b25c09, type: 2}
   m_Interpolate: 0
   m_SleepingMode: 1
@@ -121,18 +121,18 @@ BoxCollider2D:
   m_IsTrigger: 0
   m_UsedByEffector: 0
   m_UsedByComposite: 0
-  m_Offset: {x: 0, y: 0.5}
+  m_Offset: {x: 0, y: 0.75}
   m_SpriteTilingProperty:
     border: {x: 0, y: 0, z: 0, w: 0}
     pivot: {x: 0.5, y: 0}
-    oldSize: {x: 1, y: 1}
+    oldSize: {x: 1.5, y: 1.5}
     newSize: {x: 1, y: 1}
     adaptiveTilingThreshold: 0.5
     drawMode: 0
     adaptiveTiling: 0
   m_AutoTiling: 0
   serializedVersion: 2
-  m_Size: {x: 1, y: 1}
+  m_Size: {x: 1.5, y: 1.5}
   m_EdgeRadius: 0
 --- !u!114 &9040011293892009549
 MonoBehaviour:
@@ -159,8 +159,8 @@ MonoBehaviour:
   filpSpeed: 0.3
   jumpBufferTime: 0.15
   jumpWolfTime: 0.2
-  baseMass: 3
+  baseMass: 5
   movingLeft: 0
-  hp: 15
+  hp: 12
   knockbackForceH: 30
   knockbackForceV: 8

+ 1 - 1
Assets/Resources/Entities/EnemyMover.cs

@@ -18,7 +18,7 @@ public class EnemyMover : EnemyBase {
         turnCooldown -= Time.deltaTime;
         if (shouldTurn && turnCooldown <= 0f) {
             movingLeft = !movingLeft;
-            turnCooldown = 0.5f;
+            turnCooldown = 1f;
         }
     }
 

+ 2 - 2
Assets/Resources/Entities/EnemyMover.prefab

@@ -102,7 +102,7 @@ Rigidbody2D:
   m_Mass: 1
   m_LinearDrag: 0
   m_AngularDrag: 0.05
-  m_GravityScale: 1
+  m_GravityScale: 0.5
   m_Material: {fileID: 6200000, guid: 6a9410bb3043e384eba63a5622b25c09, type: 2}
   m_Interpolate: 0
   m_SleepingMode: 1
@@ -161,6 +161,6 @@ MonoBehaviour:
   jumpWolfTime: 0.2
   baseMass: 1
   movingLeft: 0
-  hp: 6
+  hp: 5
   knockbackForceH: 40
   knockbackForceV: 10

+ 29 - 0
Assets/Resources/Entities/EnemyShooter.cs

@@ -0,0 +1,29 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class EnemyShooter : EnemyBase {
+
+    internal override bool isPressingCrouch() => false;
+    internal override bool isPressDownJump() => false;
+    internal override bool isPressingLeft() => false;
+    internal override bool isPressingRight() => false;
+    internal override void OnHitEnemy(Collision2D collision) {}
+
+    public float shootDelay = 5f, bulletSpeed = 1f; private float shootCooldown = 0f;
+    public GameObject bullet;
+    internal override void OnUpdate() {
+        if (!isLand) return;
+        shootCooldown += Time.deltaTime;
+        if (shootCooldown < shootDelay) return;
+        shootCooldown = 0f;
+        // TODO: ¹¥»÷ÒôЧ
+        // Éú³É×Óµ¯
+        GameObject newBullet = Instantiate(bullet, transform);
+        newBullet.transform.position += new Vector3(0.5f, -0.5f, 0);
+        newBullet.transform.SetParent(null);
+        newBullet.GetComponent<Rigidbody2D>().velocity = new Vector2((float) Modules.randomDefault.NextDouble() - 0.5f, 0.25f).normalized * bulletSpeed;
+    }
+
+
+}

+ 11 - 0
Assets/Resources/Entities/EnemyShooter.cs.meta

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

binární
Assets/Resources/Entities/EnemyShooter.png


+ 134 - 0
Assets/Resources/Entities/EnemyShooter.png.meta

@@ -0,0 +1,134 @@
+fileFormatVersion: 2
+guid: cd71811f0a949ae42a359249609c18d2
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 11
+  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: 7
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 32
+  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
+  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: Server
+    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: WebGL
+    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: 

+ 226 - 0
Assets/Resources/Entities/EnemyShooter.prefab

@@ -0,0 +1,226 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &6371604957627978580
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 6371604957627978583}
+  - component: {fileID: 6371604957627978536}
+  - component: {fileID: 6371604957627978537}
+  - component: {fileID: 6371604957627978582}
+  - component: {fileID: 6371604957627978543}
+  m_Layer: 8
+  m_Name: EnemyShooter
+  m_TagString: Enemy
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &6371604957627978583
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6371604957627978580}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: -1.08, y: 1.75, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children:
+  - {fileID: 8597255516571522798}
+  m_Father: {fileID: 0}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &6371604957627978536
+SpriteRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6371604957627978580}
+  m_Enabled: 1
+  m_CastShadows: 0
+  m_ReceiveShadows: 0
+  m_DynamicOccludee: 1
+  m_StaticShadowCaster: 0
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 0
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  m_StaticBatchInfo:
+    firstSubMesh: 0
+    subMeshCount: 0
+  m_StaticBatchRoot: {fileID: 0}
+  m_ProbeAnchor: {fileID: 0}
+  m_LightProbeVolumeOverride: {fileID: 0}
+  m_ScaleInLightmap: 1
+  m_ReceiveGI: 1
+  m_PreserveUVs: 0
+  m_IgnoreNormalsForChartDetection: 0
+  m_ImportantGI: 0
+  m_StitchLightmapSeams: 1
+  m_SelectedEditorRenderState: 0
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: -1
+  m_Sprite: {fileID: 21300000, guid: cd71811f0a949ae42a359249609c18d2, type: 3}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_FlipX: 0
+  m_FlipY: 0
+  m_DrawMode: 0
+  m_Size: {x: 1, y: 1}
+  m_AdaptiveModeThreshold: 0.5
+  m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 1
+  m_MaskInteraction: 0
+  m_SpriteSortPoint: 0
+--- !u!50 &6371604957627978537
+Rigidbody2D:
+  serializedVersion: 4
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6371604957627978580}
+  m_BodyType: 0
+  m_Simulated: 1
+  m_UseFullKinematicContacts: 0
+  m_UseAutoMass: 0
+  m_Mass: 1
+  m_LinearDrag: 0
+  m_AngularDrag: 0.05
+  m_GravityScale: 0.5
+  m_Material: {fileID: 6200000, guid: 6a9410bb3043e384eba63a5622b25c09, type: 2}
+  m_Interpolate: 0
+  m_SleepingMode: 1
+  m_CollisionDetection: 1
+  m_Constraints: 4
+--- !u!61 &6371604957627978582
+BoxCollider2D:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6371604957627978580}
+  m_Enabled: 1
+  m_Density: 1
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_UsedByEffector: 0
+  m_UsedByComposite: 0
+  m_Offset: {x: 0, y: 2.5}
+  m_SpriteTilingProperty:
+    border: {x: 0, y: 0, z: 0, w: 0}
+    pivot: {x: 0.5, y: 0}
+    oldSize: {x: 1, y: 3}
+    newSize: {x: 1, y: 1}
+    adaptiveTilingThreshold: 0.5
+    drawMode: 0
+    adaptiveTiling: 0
+  m_AutoTiling: 0
+  serializedVersion: 2
+  m_Size: {x: 0.9, y: 1}
+  m_EdgeRadius: 0
+--- !u!114 &6371604957627978543
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6371604957627978580}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 052f443851fac364f96fad4a5859910f, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  spriteNormal: {fileID: 21300000, guid: cd71811f0a949ae42a359249609c18d2, type: 3}
+  spriteDown: {fileID: 0}
+  canCrouch: 0
+  movementSpeed: 0
+  jumpForce: 20
+  horizontalF: 0.5
+  horizontalA: 0.3
+  jumpThreshold: 0.1
+  downA: 0.3
+  fallA: 0.1
+  filpSpeed: 1000000
+  jumpBufferTime: 0.2
+  jumpWolfTime: 0.2
+  baseMass: 5
+  movingLeft: 0
+  hp: 5
+  shootDelay: 1
+  bulletSpeed: 2.5
+  bullet: {fileID: 6338471913790559837, guid: 96699fe6403b7e24795680135973e8a7, type: 3}
+--- !u!1 &8597255516571522799
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 8597255516571522798}
+  - component: {fileID: 8597255516571522797}
+  m_Layer: 14
+  m_Name: ShooterBase
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &8597255516571522798
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8597255516571522799}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 6371604957627978583}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!61 &8597255516571522797
+BoxCollider2D:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8597255516571522799}
+  m_Enabled: 1
+  m_Density: 1
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_UsedByEffector: 0
+  m_UsedByComposite: 0
+  m_Offset: {x: 0, y: 0.1}
+  m_SpriteTilingProperty:
+    border: {x: 0, y: 0, z: 0, w: 0}
+    pivot: {x: 0, y: 0}
+    oldSize: {x: 0, y: 0}
+    newSize: {x: 0, y: 0}
+    adaptiveTilingThreshold: 0
+    drawMode: 0
+    adaptiveTiling: 0
+  m_AutoTiling: 0
+  serializedVersion: 2
+  m_Size: {x: 0.9, y: 0.2}
+  m_EdgeRadius: 0

+ 7 - 0
Assets/Resources/Entities/EnemyShooter.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: d42a80641c9239c4d908389f5fd27d4c
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 16 - 0
Assets/Resources/Entities/EnemyShooterBullet.cs

@@ -0,0 +1,16 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class EnemyShooterBullet : EnemyBase {
+
+    internal override bool isPressingCrouch() => false;
+    internal override bool isPressDownJump() => false;
+    internal override bool isPressingLeft() => movingLeft;
+    internal override bool isPressingRight() => !movingLeft;
+
+    internal override void OnHitEnemy(Collision2D collision) {
+        transform.localScale = Vector3.zero; Destroy(gameObject, 1);
+    }
+
+}

+ 11 - 0
Assets/Resources/Entities/EnemyShooterBullet.cs.meta

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

binární
Assets/Resources/Entities/EnemyShooterBullet.png


+ 2 - 2
Assets/Resources/Map/Wall.png.meta → Assets/Resources/Entities/EnemyShooterBullet.png.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 0eefa124a369acd48b78c018f5ee31a7
+guid: 45bdff39a3fe5d342b429941106756ad
 TextureImporter:
   internalIDToNameTable: []
   externalObjects: {}
@@ -47,7 +47,7 @@ TextureImporter:
   spriteMeshType: 1
   alignment: 0
   spritePivot: {x: 0.5, y: 0.5}
-  spritePixelsToUnits: 45
+  spritePixelsToUnits: 32
   spriteBorder: {x: 0, y: 0, z: 0, w: 0}
   spriteGenerateFallbackPhysicsShape: 1
   alphaUsage: 1

+ 154 - 0
Assets/Resources/Entities/EnemyShooterBullet.prefab

@@ -0,0 +1,154 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &6338471913790559837
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 6338471913790559838}
+  - component: {fileID: 6338471913790559834}
+  - component: {fileID: 6338471913790559833}
+  - component: {fileID: 6338471913790559832}
+  - component: {fileID: 2840634545719704270}
+  m_Layer: 13
+  m_Name: EnemyShooterBullet
+  m_TagString: Enemy
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &6338471913790559838
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6338471913790559837}
+  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_LocalPosition: {x: -0.33, y: 3.34, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &6338471913790559834
+SpriteRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6338471913790559837}
+  m_Enabled: 1
+  m_CastShadows: 0
+  m_ReceiveShadows: 0
+  m_DynamicOccludee: 1
+  m_StaticShadowCaster: 0
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 0
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  m_StaticBatchInfo:
+    firstSubMesh: 0
+    subMeshCount: 0
+  m_StaticBatchRoot: {fileID: 0}
+  m_ProbeAnchor: {fileID: 0}
+  m_LightProbeVolumeOverride: {fileID: 0}
+  m_ScaleInLightmap: 1
+  m_ReceiveGI: 1
+  m_PreserveUVs: 0
+  m_IgnoreNormalsForChartDetection: 0
+  m_ImportantGI: 0
+  m_StitchLightmapSeams: 1
+  m_SelectedEditorRenderState: 0
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 1
+  m_Sprite: {fileID: 21300000, guid: 45bdff39a3fe5d342b429941106756ad, type: 3}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_FlipX: 0
+  m_FlipY: 0
+  m_DrawMode: 0
+  m_Size: {x: 0.16, y: 0.16}
+  m_AdaptiveModeThreshold: 0.5
+  m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 1
+  m_MaskInteraction: 0
+  m_SpriteSortPoint: 0
+--- !u!50 &6338471913790559833
+Rigidbody2D:
+  serializedVersion: 4
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6338471913790559837}
+  m_BodyType: 0
+  m_Simulated: 1
+  m_UseFullKinematicContacts: 0
+  m_UseAutoMass: 0
+  m_Mass: 1
+  m_LinearDrag: 0
+  m_AngularDrag: 0.05
+  m_GravityScale: 0.1
+  m_Material: {fileID: 0}
+  m_Interpolate: 0
+  m_SleepingMode: 1
+  m_CollisionDetection: 0
+  m_Constraints: 4
+--- !u!58 &6338471913790559832
+CircleCollider2D:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6338471913790559837}
+  m_Enabled: 1
+  m_Density: 1
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_UsedByEffector: 0
+  m_UsedByComposite: 0
+  m_Offset: {x: 0, y: 0}
+  serializedVersion: 2
+  m_Radius: 0.25
+--- !u!114 &2840634545719704270
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6338471913790559837}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 03097d2a123acdd439036a6370f814d6, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  spriteNormal: {fileID: 0}
+  spriteDown: {fileID: 0}
+  canCrouch: 0
+  movementSpeed: 0
+  jumpForce: 20
+  horizontalF: 1
+  horizontalA: 0
+  jumpThreshold: 0.1
+  downA: 0
+  fallA: 0
+  filpSpeed: 100000
+  jumpBufferTime: 0
+  jumpWolfTime: 0
+  baseMass: 1
+  movingLeft: 0
+  hp: 1

+ 7 - 0
Assets/Resources/Entities/EnemyShooterBullet.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 96699fe6403b7e24795680135973e8a7
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 16 - 16
Assets/Resources/Entities/EntityBase.cs

@@ -22,20 +22,20 @@ public abstract class EntityBase : MonoBehaviour {
     internal bool towardsRight = true, isLand = false;
     void Update() {
         OnUpdate();
-        // 鑾峰彇褰撳墠鎯呭喌
+        // 获取当前情况
         float speedX = rb.velocity.x, speedY = rb.velocity.y;
         bool isCrouch = isPressingCrouch();
-        isLand = Physics2D.OverlapCircle(transform.position + Vector3.left * 0.1f, jumpThreshold, LayerMask.GetMask("Tilemap")) ||
+        isLand = Physics2D.OverlapCircle(transform.position + Vector3.left * 0.1f, jumpThreshold, LayerMask.GetMask("Tilemap")) || 
             Physics2D.OverlapCircle(transform.position + Vector3.left * -0.1f, jumpThreshold, LayerMask.GetMask("Tilemap"));
-        float moveHorizontal = (isCrouch && isLand ? 0.35f : 1) * // 涓嬭共鍑忛€�
-            (isPressingLeft() == isPressingRight() ? 0 : // 娌℃湁鍚屾椂鎸変綇宸﹀彸
-            (isPressingLeft() ? -1 : 1)); // 鑾峰彇鏂瑰悜
-        // 鍒ゆ柇璺宠穬
+        float moveHorizontal = (isCrouch && isLand ? 0.35f : 1) * // 下蹲减速
+            (isPressingLeft() == isPressingRight() ? 0 : // 没有同时按住左右
+            (isPressingLeft() ? -1 : 1)); // 获取方向
+        // 判断跳跃
         jumpBuffer -= Time.deltaTime; jumpWolf -= Time.deltaTime; jumping -= Time.deltaTime;
         if (isPressDownJump()) jumpBuffer = jumpBufferTime;
         if (isLand) jumpWolf = jumpWolfTime;
         if (jumpBuffer > 0 && jumpWolf > 0 && jumping < 0) {
-            // 鎾�斁闊虫晥
+            // 播放音效
             AudioM.Play("jump");
 
             speedY = jumpForce;
@@ -44,14 +44,14 @@ public abstract class EntityBase : MonoBehaviour {
         } else if (isCrouch) {
             speedY -= downA;
         }
-        // 鍔犻€熶笅钀�
+        // 加速下落
         if (speedY < 0) speedY -= fallA;
-        // 妯�悜绉诲姩
+        // 横向移动
         if (moveHorizontal != 0) {
             speedX = speedX * (1 - horizontalA) + movementSpeed * horizontalA * moveHorizontal;
         }
         speedX *= horizontalF;
-        // 韫蹭笅
+        // 蹲下
         if (canCrouch) {
             if (isCrouch) {
                 sprite.sprite = spriteDown;
@@ -63,11 +63,11 @@ public abstract class EntityBase : MonoBehaviour {
                 coll.offset = new Vector2(0, 0.7f);
             }
         }
-        // 璁剧疆
+        // 设置
         rb.velocity = new Vector2(speedX, speedY);
         rb.mass = baseMass * (towardsRight ? 1.2f : 0.8f);
         if (towardsRight != (Mathf.Abs(speedX) > filpSpeed ? speedX > 0 : towardsRight)) {
-            // 鍙嶅悜
+            // 反向
             towardsRight = !towardsRight;
             transform.DOScaleX(towardsRight ? 1 : -1, 0.1f);
         }
@@ -76,9 +76,9 @@ public abstract class EntityBase : MonoBehaviour {
     internal abstract bool isPressingRight();
     internal abstract bool isPressDownJump();
     internal abstract bool isPressingCrouch();
-    internal virtual void OnUpdate() { }
+    internal virtual void OnUpdate() {}
 
-    // 纰版挒妫€娴�
+    // 碰撞检测
     private void OnCollisionEnter2D(Collision2D collision) {
         if (collision.gameObject.CompareTag("Border")) OnHitBorder();
         if (collision.gameObject.CompareTag("Bullet")) OnHitBullet();
@@ -86,7 +86,7 @@ public abstract class EntityBase : MonoBehaviour {
         if (collision.gameObject.CompareTag("Player") && gameObject.CompareTag("Enemy")) OnHitEnemy(collision);
     }
     internal abstract void OnHitBorder();
-    internal virtual void OnHitBullet() { }
+    internal virtual void OnHitBullet() {}
     internal abstract void OnHitEnemy(Collision2D collision);
 
-}
+}

+ 26 - 11
Assets/Resources/Entities/Player.cs

@@ -27,19 +27,28 @@ public class Player : EntityBase {
     public float knockbackForceH = 30f, knockbackForceV = 15f;
     internal override void OnHitBorder() {
         Hurt();
-        transform.position = new Vector3(0, 8, 0);
+        resistanceTime = resistanceOnHurt * 1.5f;
+        transform.position = new Vector3(-6, 10, 0);
     }
     internal override void OnHitEnemy(Collision2D collision) {
-        Hurt();
-        int face = collision.transform.position.x < transform.position.x ? 1 : -1;
-        rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
+        if (Hurt()) {
+            int face = collision.transform.position.x < transform.position.x ? 1 : -1;
+            rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
+        }
     }
-    public void Hurt() {
-        hp--;
-        AudioM.Play("hurt");
-        rb.velocity = Vector2.zero;
-        DOTween.Kill("ScreenShake");
-        Camera.current.DOShakePosition(0.3f, 0.3f, 20).SetId("ScreenShake");
+    public float resistanceOnHurt = 1f; private float resistanceTime = 0f;
+    public bool Hurt() {
+        if (resistanceTime <= 0.001f) {
+            resistanceTime = resistanceOnHurt;
+            hp--;
+            AudioM.Play("hurt");
+            rb.velocity = Vector2.zero;
+            DOTween.Kill("ScreenShake");
+            Camera.current.DOShakePosition(0.3f, 0.3f, 20).SetId("ScreenShake");
+            return true;
+        } else {
+            return false;
+        }
     }
 
     // 治疗
@@ -58,6 +67,8 @@ public class Player : EntityBase {
     public float bulletSpeed = 50f, bulletKnockback = 1f;
     public GameObject bullet; public TMPro.TextMeshProUGUI textBullet;
     internal override void OnUpdate() {
+        // 无敌
+        if (resistanceTime > 0f) resistanceTime -= Time.deltaTime;
         // 治疗
         if (isPressingCrouch() && hp < 3 && isLand) {
             currentHealTime += Time.deltaTime;
@@ -84,7 +95,7 @@ public class Player : EntityBase {
             AudioM.Play("fire");
             currentBullet--; currentShootDelay = shootDelay;
             Vector2 fromPos = transform.position + Vector3.up * 0.55f;
-            Vector2 toPos = Camera.allCameras[0].ScreenToWorldPoint(Input.mousePosition);
+            Vector2 toPos = AspectUtility.cam.ScreenToWorldPoint(Input.mousePosition);
             Vector2 shootVector = (toPos - fromPos).normalized;
             GameObject newBullet = Instantiate(bullet, fromPos, Quaternion.identity);
             newBullet.GetComponent<Rigidbody2D>().velocity = bulletSpeed * shootVector;
@@ -95,6 +106,10 @@ public class Player : EntityBase {
             currentShootDelay -= Time.deltaTime;
         }
         // 更新 UI
+        {
+
+        }
+        // ���� UI
         textBullet.text = currentReloadDelay > 0f ?
             "".PadLeft(maxBullet - Mathf.RoundToInt(currentReloadDelay / reloadDelay * maxBullet), "|".ToCharArray().First()) :
             "".PadLeft(currentBullet, "|".ToCharArray().First());

+ 1 - 1
Assets/Resources/Map/Wall.asset

@@ -12,7 +12,7 @@ MonoBehaviour:
   m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0}
   m_Name: Wall
   m_EditorClassIdentifier: 
-  m_Sprite: {fileID: 21300000, guid: 0eefa124a369acd48b78c018f5ee31a7, type: 3}
+  m_Sprite: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
   m_Transform:
     e00: 1

binární
Assets/Resources/Map/Wall.png


+ 113 - 0
Assets/Resources/System/AspectUtility.cs

@@ -0,0 +1,113 @@
+using UnityEngine;
+
+public class AspectUtility : MonoBehaviour {
+
+    public float _wantedAspectRatio = 1.5f;
+    public bool landscapeModeOnly = true;
+    static public bool _landscapeModeOnly = true;
+    static float wantedAspectRatio;
+    public static Camera cam;
+    public static Camera backgroundCam;
+
+    void Awake() {
+        _landscapeModeOnly = landscapeModeOnly;
+        cam = Camera.allCameras[0];
+        wantedAspectRatio = _wantedAspectRatio;
+        SetCamera();
+    }
+
+    public static void SetCamera() {
+        float currentAspectRatio = 0.0f;
+        if (Screen.orientation == ScreenOrientation.LandscapeRight ||
+            Screen.orientation == ScreenOrientation.LandscapeLeft) {
+            Debug.Log("Landscape detected...");
+            currentAspectRatio = (float) Screen.width / Screen.height;
+        } else {
+            Debug.Log("Portrait detected...?");
+            if (Screen.height  > Screen.width && _landscapeModeOnly) {
+                currentAspectRatio = (float) Screen.height / Screen.width;
+            } else {
+                currentAspectRatio = (float) Screen.width / Screen.height;
+            }
+        }
+        // If the current aspect ratio is already approximately equal to the desired aspect ratio,
+        // use a full-screen Rect (in case it was set to something else previously)
+
+        Debug.Log("currentAspectRatio = " + currentAspectRatio + ", wantedAspectRatio = " + wantedAspectRatio);
+
+        if ((int) (currentAspectRatio * 100) / 100.0f == (int) (wantedAspectRatio * 100) / 100.0f) {
+            cam.rect = new Rect(0.0f, 0.0f, 1.0f, 1.0f);
+            if (backgroundCam) {
+                Destroy(backgroundCam.gameObject);
+            }
+            return;
+        }
+
+        // Pillarbox
+        if (currentAspectRatio > wantedAspectRatio) {
+            float inset = 1.0f - wantedAspectRatio/currentAspectRatio;
+            cam.rect = new Rect(inset/2, 0.0f, 1.0f-inset, 1.0f);
+        }
+        // Letterbox
+        else {
+            float inset = 1.0f - currentAspectRatio/wantedAspectRatio;
+            cam.rect = new Rect(0.0f, inset/2, 1.0f, 1.0f-inset);
+        }
+        if (!backgroundCam) {
+            // Make a new camera behind the normal camera which displays black; otherwise the unused space is undefined
+            backgroundCam = new GameObject("BackgroundCam", typeof(Camera)).GetComponent<Camera>();
+            backgroundCam.depth = int.MinValue;
+            backgroundCam.clearFlags = CameraClearFlags.SolidColor;
+            backgroundCam.backgroundColor = Color.black;
+            backgroundCam.cullingMask = 0;
+        }
+    }
+
+    public static int screenHeight {
+        get {
+            return (int) (Screen.height * cam.rect.height);
+        }
+    }
+
+    public static int screenWidth {
+        get {
+            return (int) (Screen.width * cam.rect.width);
+        }
+    }
+
+    public static int xOffset {
+        get {
+            return (int) (Screen.width * cam.rect.x);
+        }
+    }
+
+    public static int yOffset {
+        get {
+            return (int) (Screen.height * cam.rect.y);
+        }
+    }
+
+    public static Rect screenRect {
+        get {
+            return new Rect(cam.rect.x * Screen.width, cam.rect.y * Screen.height, cam.rect.width * Screen.width, cam.rect.height * Screen.height);
+        }
+    }
+
+    public static Vector3 mousePosition {
+        get {
+            Vector3 mousePos = Input.mousePosition;
+            mousePos.y -= (int) (cam.rect.y * Screen.height);
+            mousePos.x -= (int) (cam.rect.x * Screen.width);
+            return mousePos;
+        }
+    }
+
+    public static Vector2 guiMousePosition {
+        get {
+            Vector2 mousePos = Event.current.mousePosition;
+            mousePos.y = Mathf.Clamp(mousePos.y, cam.rect.y * Screen.height, cam.rect.y * Screen.height + cam.rect.height * Screen.height);
+            mousePos.x = Mathf.Clamp(mousePos.x, cam.rect.x * Screen.width, cam.rect.x * Screen.width + cam.rect.width * Screen.width);
+            return mousePos;
+        }
+    }
+}

+ 11 - 0
Assets/Resources/System/AspectUtility.cs.meta

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

+ 1 - 1
Assets/Resources/System/AudioM.cs

@@ -11,7 +11,7 @@ public class AudioM : MonoBehaviour {
             audios = new();
             Resources.LoadAll<AudioClip>("").ToList().ForEach(a => audios.Add(a.name, a));
         }
-        AudioSource.PlayClipAtPoint(audios[name], Camera.allCameras[0].transform.position, volume);
+        AudioSource.PlayClipAtPoint(audios[name], AspectUtility.cam.transform.position, volume);
     }
 
     private void Awake() {

+ 12 - 3
Assets/Resources/System/Spawner.cs

@@ -5,14 +5,23 @@ using UnityEngine;
 public class Spawner : MonoBehaviour {
     public GameObject prefeb;
     public EnemyType type;
-    public enum EnemyType { Arrow, Mover, Heavy }
+    public enum EnemyType { Arrow, Mover, Heavy, Shooter }
     public GameObject parent;
     public void Spawn() {
         GameObject obj = Instantiate(prefeb, transform);
         obj.transform.parent = parent.transform;
         obj.GetComponent<EnemyBase>().movingLeft = transform.localScale.x < 0;
-        if (type == EnemyType.Arrow) {
-            obj.transform.position += Mathf.RoundToInt((float) Modules.randomDefault.NextDouble() - 0.15f) * Vector3.down * 0.8f;
+        switch (type) {
+            case EnemyType.Arrow:
+                obj.transform.position += Mathf.RoundToInt((float) Modules.randomDefault.NextDouble() - 0.15f) * Vector3.down;
+                break;
+            case EnemyType.Shooter:
+                obj.transform.localScale = Vector3.one;
+                obj.transform.position += Modules.randomDefault.Next(-2, 2) * Vector3.left;
+                break;
         }
     }
+    private void Awake() {
+        GameObject.Destroy(GetComponent<SpriteRenderer>());
+    }
 }

+ 12 - 5
Assets/Resources/System/StoryM.cs

@@ -23,8 +23,9 @@ public class StoryM : MonoBehaviour {
         DOTween.Kill("StoryFont"); textStory.DOColor(Color.white, 0.25f).SetId("StoryFont");
         DOTween.Kill("StoryBackground"); shapeBack.DOScaleX((textStory.rectTransform.rect.width + 40f) / 100f, 0.15f).SetId("StoryBackground");
         // 消失
-        float time = 1.5f + (isCn ? textCn.Length / 1.5f : textEn.Split(" ").Length / 2f);
-        StopCoroutine(nameof(WaitForHideStoryText)); StartCoroutine(WaitForHideStoryText(time));
+        float time = 1.5f + (isCn ? textCn.Length / 3f : textEn.Split(" ").Length / 3f);
+        StopCoroutine("WaitForHideStoryText"); StartCoroutine("WaitForHideStoryText", time);
+        Debug.Log(time + " -> " + textCn);
         return time;
     }
     IEnumerator WaitForStoryText(string textCh, string textEn = "English") {
@@ -33,6 +34,7 @@ public class StoryM : MonoBehaviour {
     IEnumerator WaitForHideStoryText(float delay) {
         yield return new WaitForSeconds(delay);
         textStory.text = "";
+        Debug.Log(delay);
         DOTween.Kill("StoryBackground"); shapeBack.DOScaleX(0, 0.2f).SetId("StoryBackground");
     }
 
@@ -52,7 +54,8 @@ public class StoryM : MonoBehaviour {
         }
         // 实际刷怪
         spawners[type].Shuffle();
-        for (int i = 0; i < Mathf.Min(6, count); i++) {
+        for (int i = 0; i < count; i++) {
+            if (i >= spawners[type].Count) i = 0;
             spawners[type][i].Spawn();
         }
     }
@@ -81,10 +84,14 @@ public class StoryM : MonoBehaviour {
             canSpawnArrow = true;
             Spawn(Spawner.EnemyType.Mover, 3);
             SetStoryText("先刷几个瞎晃悠的", "");
-            yield return new WaitForSeconds(4f);
+            yield return new WaitForSeconds(3f);
+
+            Spawn(Spawner.EnemyType.Shooter);
+            SetStoryText("炮塔!", "");
+            yield return new WaitForSeconds(2f);
 
             Spawn(Spawner.EnemyType.Heavy, 2);
-            SetStoryText("然后是两个贼硬的……", "");
+            SetStoryText("最后是两个贼硬的……", "");
             yield return StartCoroutine(WaitUntilClear(2));
 
             canSpawnArrow = false;

binární
Assets/Resources/UI/bg0.png


+ 134 - 0
Assets/Resources/UI/bg0.png.meta

@@ -0,0 +1,134 @@
+fileFormatVersion: 2
+guid: 402451a85ddddfb4c8c08e9abe58b4ae
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 11
+  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: 35
+  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
+  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: Server
+    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: WebGL
+    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: 

binární
Assets/Resources/UI/bg1.png


+ 134 - 0
Assets/Resources/UI/bg1.png.meta

@@ -0,0 +1,134 @@
+fileFormatVersion: 2
+guid: ff8a49df24e42834586285d878866a93
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 11
+  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
+  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: Server
+    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: WebGL
+    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: 

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 300 - 323
Assets/Scenes/SceneMain.unity


+ 1 - 1
ProjectSettings/Physics2DSettings.asset

@@ -53,4 +53,4 @@ Physics2DSettings:
   m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
   m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
   m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
-  m_LayerCollisionMatrix: bbffffffbbf7ffff88f7fffffff7ffffbbf7ffffbbf7ffffc8f7ffffffe7ffffffd7fffffff3fffffff5ffff01c0ffff7fe7ffffffd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+  m_LayerCollisionMatrix: bb9fffffbb97ffff8897ffffffd7ffffbb97ffffbb97ffffc897ffffffa7ffffff97fffffff3ffffff95ffff0180ffff7fa7ffff8092ffff08c2ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

+ 1 - 1
ProjectSettings/TagManager.asset

@@ -24,7 +24,7 @@ TagManager:
   - Marker
   - Bullet
   - EnemyArrow
-  - 
+  - EnemyBase
   - 
   - 
   - 

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů