备份最新逻辑

This commit is contained in:
oldpeper 2024-12-09 11:19:14 +08:00
parent e0f65e39fd
commit 6a9d101833
37 changed files with 760 additions and 167 deletions

View File

@ -0,0 +1,168 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4242684317348474596
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8340748226692247503}
- component: {fileID: 2193559726886732247}
- component: {fileID: 7756983643709839505}
m_Layer: 0
m_Name: Buttle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &8340748226692247503
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4242684317348474596}
serializedVersion: 2
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:
- {fileID: 9085113183165815074}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2193559726886732247
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4242684317348474596}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 722b0c792bd606a4590909aff1110a42, type: 3}
m_Name:
m_EditorClassIdentifier:
_sprite: {fileID: 1568058238041260136}
--- !u!58 &7756983643709839505
CircleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4242684317348474596}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 0.5
--- !u!1 &7731706439739415355
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9085113183165815074}
- component: {fileID: 1568058238041260136}
m_Layer: 0
m_Name: 9-Sliced
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9085113183165815074
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7731706439739415355}
serializedVersion: 2
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: 8340748226692247503}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1568058238041260136
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7731706439739415355}
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: 4
m_Sprite: {fileID: -5177388603050735206, guid: 8884154dfe85442a3a3578be807dbcdf, type: 3}
m_Color: {r: 0.06732824, g: 0.12882634, b: 0.8396226, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 2
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0

View File

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

View File

@ -138,13 +138,15 @@ GameObject:
- component: {fileID: 5537344553321071934}
- component: {fileID: 731921618462809821}
- component: {fileID: 1151588281664711620}
- component: {fileID: 8167203040827974690}
- component: {fileID: 5044662577549088348}
m_Layer: 0
m_Name: mouster
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &5537344553321071934
Transform:
m_ObjectHideFlags: 0
@ -231,3 +233,70 @@ MonoBehaviour:
strength: 0
dexterity: 0
criticalStrike: 0
entity:
hp: 0
injured: 0
cd: 0
nextAttack: 0
--- !u!58 &8167203040827974690
CircleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4177370848473932766}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 0.5
--- !u!50 &5044662577549088348
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4177370848473932766}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 7

View File

@ -11,6 +11,8 @@ GameObject:
- component: {fileID: 7977988578914188099}
- component: {fileID: 2859255379752948725}
- component: {fileID: 2502596842607686182}
- component: {fileID: 7804527126073873689}
- component: {fileID: 4310192076672108997}
m_Layer: 0
m_Name: player
m_TagString: Untagged
@ -97,3 +99,65 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 08c739e0deb0ffc468a5e540d85493d6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!58 &7804527126073873689
CircleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5832841353692456753}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 0.5
--- !u!50 &4310192076672108997
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5832841353692456753}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 7

View File

@ -713,7 +713,7 @@ Transform:
serializedVersion: 2
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_LocalScale: {x: 10, y: 10, z: 10}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1446036770}
@ -1125,7 +1125,7 @@ Transform:
m_GameObject: {fileID: 149161982}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 5.84, z: 0}
m_LocalPosition: {x: 0, y: 52.1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@ -1159,7 +1159,7 @@ Transform:
m_GameObject: {fileID: 165722399}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.17, y: 0, z: 0}
m_LocalPosition: {x: 21, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -2103,7 +2103,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0.00006866455}
m_AnchoredPosition: {x: 0, y: 0.00004777339}
m_SizeDelta: {x: 0, y: 300}
m_Pivot: {x: 0, y: 1}
--- !u!1 &252864277
@ -4622,7 +4622,7 @@ Camera:
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5
orthographic size: 54.101566
m_Depth: -1
m_CullingMask:
serializedVersion: 2
@ -7931,7 +7931,7 @@ Transform:
m_GameObject: {fileID: 899280137}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -4.49, z: 0}
m_LocalPosition: {x: 0, y: -51.3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@ -10301,7 +10301,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 16380662}
m_Direction: 2
m_Value: 0
m_Size: 1
m_Size: 0.9999967
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
@ -13927,13 +13927,17 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c6049ba73a04f7b4798beb79ef800b99, type: 3}
m_Name:
m_EditorClassIdentifier:
mousterPoint: {fileID: 0}
mousters: []
mousterPoint: {fileID: 494981768}
mousters:
- {fileID: 1928285456}
- {fileID: 372373523}
- {fileID: 165722400}
playerParent:
- {fileID: 1148942016}
- {fileID: 1708146007}
- {fileID: 2021164979}
_mousters: []
lookVec: {x: 0, y: 1, z: 0}
--- !u!4 &1446036770
Transform:
m_ObjectHideFlags: 0
@ -17704,7 +17708,7 @@ Transform:
m_GameObject: {fileID: 1708146006}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.53, y: 0, z: 0}
m_LocalPosition: {x: -24.5, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -20843,7 +20847,7 @@ Transform:
m_GameObject: {fileID: 1928285455}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.97, y: 0, z: 0}
m_LocalPosition: {x: -20.2, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -22565,7 +22569,7 @@ Transform:
m_GameObject: {fileID: 2021164978}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.18, y: 0, z: 0}
m_LocalPosition: {x: 21.9, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []

View File

@ -11,6 +11,11 @@ public static class BDebug
#endif
}
public static void LogWarning(object obj)
{
Debug.LogWarning(obj);
}
public static void LogError( object obj)
{
Debug.LogError(obj);

View File

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using cfg;
using cfg.BlacksmithData;
using Unity.Mathematics;
@ -14,6 +15,7 @@ public class BattleManager : MonoBehaviour
[SerializeField] private Transform[] mousters;
[SerializeField] private Transform[] playerParent;
public List<Mouster> Mousters => _mousters;
[SerializeField] private List<Mouster> _mousters=new List<Mouster>();
[SerializeField]
@ -22,11 +24,14 @@ public class BattleManager : MonoBehaviour
[SerializeField] private PlayerRunState[] playerItems;
[SerializeField] private List<MousterTeam> _mousterTeams = new List<MousterTeam>();
[SerializeField] private List<Bullet> _bullets = new List<Bullet>();
public float NowTime => nowTime;
private float nowTime=0;
public int HP => hp;
private int hp;
public int Injured => injured;
private int injured;
private bool player = false;
private int mousterIndex=0;
public BattleEquipment[] BattleEquipments => _battleEquipments;
@ -68,6 +73,8 @@ public class BattleManager : MonoBehaviour
_battleEquipments[i] = new BattleEquipment();
}
_battleEquipments[0].SetLock(true);
openVideoWeaponry = false;
openVideoSoldier = false;
}
@ -84,6 +91,10 @@ public class BattleManager : MonoBehaviour
public void OpenVideoSoldierEvent()
{
openVideoSoldier = true;
foreach (var battle in _battleEquipments)
{
battle.SetLock(true);
}
}
/// <summary>
/// 设置道具到指定单位
@ -225,27 +236,37 @@ public class BattleManager : MonoBehaviour
}
hp = allHP;
injured = 0;
BDebug.Log(hp);
nowTime = 0;
playerItems = new PlayerRunState[playerParent.Length];
for (int i = 0; i < playerParent.Length; i++)
{
var index = i;
PrefabPool.ins.LoadObj("Battle_player", (GameObject obj) =>
if (BattleEquipments[i].EquipmentLock)
{
obj.transform.parent = playerParent[index];
obj.transform.localPosition=Vector3.zero;
playerItems[index] = new PlayerRunState();
playerItems[index].player = obj.GetComponent<PlayerItem>();
playerItems[index].equipent = BattleEquipments[index];
playerItems[index].equipent.RestSkill();
});
PrefabPool.ins.LoadObj("Battle_player", (GameObject obj) =>
{
obj.transform.parent = playerParent[index];
obj.transform.localPosition=Vector3.zero;
playerItems[index] = new PlayerRunState();
playerItems[index].player = obj.GetComponent<PlayerItem>();
playerItems[index].equipent = BattleEquipments[index];
playerItems[index].RestState();
});
}
}
ResetLevelMouster();
player = true;
}
public void SetInjured(int num)
{
injured += num;
}
void ResetLevelMouster()
{
mousterIndex = 0;
@ -280,11 +301,11 @@ public class BattleManager : MonoBehaviour
nowTime += Time.deltaTime;
foreach (var mouster in _mousters)
{
AxisLookAt(mouster.transform, playerParent[0].position);
mouster.Move(playerParent[0]);
}
TeamUpdate();
BulletUpdata();
if (playerItems!=null)
{
foreach (var player in playerItems)
@ -314,31 +335,84 @@ public class BattleManager : MonoBehaviour
mousterIndex++;
}
}
else
{
var bo = true;
foreach (var unused in _mousterTeams.Where(mouster => mouster.Type!=MousterTeamType.end))
{
bo = false;
}
if (bo)
{
BDebug.LogWarning("end");
}
}
}
public void BulletUpdata()
{
for (int i = _bullets.Count-1; i >= 0; i--)
{
_bullets[i].BulletUpdate();
}
}
public void AddBullets(Bullet bullet )
{
_bullets.Add(bullet);
}
public void RemoveBullets(Bullet bullet)
{
_bullets.Remove(bullet);
PrefabPool.ins.RecycleObj(bullet.gameObject);
}
public void AddMouster()
{
var index = mousterIndex;
foreach (var entity in _mousterTeams[mousterIndex].moustList)
{
PrefabPool.ins.LoadObj(entity._data.Prefab, (GameObject obj) =>
{
obj.transform.parent = mousterPoint;
obj.transform.position=mousters[Random.Range(0,mousters.Length)].position;
var pos = new Vector3(Random.Range(mousters[0].position.x, mousters[1].position.x),
Random.Range(mousters[0].position.y, mousters[1].position.y), 0);
obj.transform.position=pos;
AxisLookAt(obj.transform, obj.transform.position - new Vector3(0, 2, 0));
var m = obj.GetComponent<Mouster>();
m.InitMousterData(entity);
_mousters.Add(m);
_mousterTeams[index].AddObj(m);
});
}
}
public void RemoveMouster(Mouster obj)
{
var index = mousterIndex;
if (mousterIndex>=MousterCount)
{
index = mousterIndex - 1;
}
bool bo = false;
foreach (var mouster in _mousterTeams)
{
mouster.Remove(obj,ref bo);
if (bo)
{
break;
}
}
_mousters.Remove(obj);
PrefabPool.ins.RecycleObj(obj.gameObject);
}
void AxisLookAt(Transform tr_self, Vector3 lookPos)
public void AxisLookAt(Transform tr_self, Vector3 lookPos)
{
Vector3 dir = lookPos - tr_self.position;
dir.z = 0;
float angle = Vector3.SignedAngle(Vector3.up, dir, Vector3.forward);
Quaternion rotation = Quaternion.Euler(0, 0, angle); //将欧拉角转换为四元数
tr_self.rotation = rotation;
@ -355,6 +429,8 @@ public class BattleEquipment
public int audioUniversalID=0;
public int audioWeaponID=0;
public int audioWeapon2ID=0;
public bool EquipmentLock => equipmentLock;
private bool equipmentLock = false;
public SkillState Weapon => weapon;
private SkillState weapon;
public SkillState Weapon2 => weapon2;
@ -368,31 +444,36 @@ public class BattleEquipment
public SkillState AudioWeapon2 => audioWeapon2;
private SkillState audioWeapon2;
public void SetLock(bool bo)
{
equipmentLock = bo;
}
public void RestSkill()
{
if (weaponID!=0)
{
weapon = new SkillState(weaponID);
weapon = new SkillState(weaponID,"weaponID");
}
if (weapon2ID!=0)
{
weapon2 = new SkillState(weapon2ID);
weapon2 = new SkillState(weapon2ID,"weapon2ID");
}
if (armorID!=0)
{
armor = new SkillState(armorID);
armor = new SkillState(armorID,"armorID");
}
if (audioUniversalID!=0)
{
audioUniversal = new SkillState(audioUniversalID);
audioUniversal = new SkillState(audioUniversalID,"audioUniversalID");
}
if (audioWeaponID!=0)
{
audioWeapon = new SkillState(audioWeaponID);
audioWeapon = new SkillState(audioWeaponID,"audioWeaponID");
}
if (audioWeapon2ID!=0)
{
audioWeapon2 = new SkillState(audioWeapon2ID);
audioWeapon2 = new SkillState(audioWeapon2ID,"audioWeapon2ID");
}
}
@ -416,44 +497,57 @@ public class SkillState
public SkillData data;
public float cd;
public float cdTime;
public List<Action> Actions = new List<Action>();
public int Attack => attack;
private int attack = 0;
public float Ratio => ratio;
private float ratio = 1;
public List<Action<SkillState>> Actions = new List<Action<SkillState>>();
public List<Action> WaitActions = new List<Action>();
public bool SkillLock => skillLock;
private bool skillLock = false;
public string Name => name;
private string name;
public SkillState(int _id)
public SkillState(int _id,string na)
{
if (_id==0)
{
id = 0;
return;
}
name = na;
id = _id;
itemData = JsonTab.Instance.tables.Item.Get(id);
var attributeData = JsonTab.Instance.tables.WeaponSkill.Get(id);
var weapon =
JsonTab.Instance.attributeData(itemData.Includearms, DataManager.GetDrawLevel(itemData.Includearms));
attack = weapon.Attack;
data = JsonTab.Instance.tables.Skill.Get(attributeData.Initialskill);
ratio = data.SkillDamage;
cd = data.SkillCD / 10000;
cdTime = BattleManager.ins.NowTime;
Actions = new List<Action>();
Actions = new List<Action<SkillState>>();
skillLock = false;
}
public void SkillCD()
{
skillLock = false;
// skillLock = false;
cdTime = BattleManager.ins.NowTime;
BDebug.LogWarning(name);
foreach (var a in Actions)
{
a?.Invoke();
a?.Invoke(this);
}
}
public void AddAction(Action action)
public void AddAction(Action<SkillState> action)
{
Actions.Add(action);
}
public void RemoveAction(Action action)
public void RemoveAction(Action<SkillState> action)
{
Actions.Remove(action);
}
@ -469,22 +563,19 @@ public class SkillState
public void SkillStateEvent()
{
if (skillLock)
{
foreach (var a in WaitActions)
{
a?.Invoke();
}
return;
}
// if (skillLock)
// {
// foreach (var a in WaitActions)
// {
// a?.Invoke();
// }
// return;
// }
if (BattleManager.ins.NowTime-cdTime>cd)
{
skillLock = true;
foreach (var a in Actions)
{
a?.Invoke();
}
// skillLock = true;
SkillCD();
}
}
@ -495,6 +586,12 @@ public class PlayerRunState
public PlayerItem player;
public BattleEquipment equipent;
public void RestState()
{
equipent.RestSkill();
player.SetData(equipent);
}
public void RunTimeMove()
{
equipent.RunTime();

View File

@ -0,0 +1,56 @@
using System;
using System.Collections;
using System.Collections.Generic;
using cfg.BlacksmithData;
using UnityEngine;
public class Bullet : MonoBehaviour
{
[SerializeField] private SpriteRenderer _sprite;
public int Attack => attack;
private int attack = 0;
private int num = 1;
public float Speed => speed;
private float speed=0;
public float NextTime;
private float time=0;
public bool Start => start;
private bool start=false;
public void SetAttack(ItemData itemData, int a,float sp= 1,int nu=1)
{
_sprite.sprite = AssetBundleManager.ins.Sprite(itemData.Icon, AtlasType.ItemIcon);
attack = a;
speed = sp;
num = nu;
time = BattleManager.ins.NowTime + 10;
start = true;
}
private void OnTriggerEnter2D(Collider2D other)
{
var mouster=other.GetComponent<Mouster>();
if (!start|| mouster == null) return;
mouster.SetInjured(Attack);
num -= 1;
if (num<=0)
{
start = false;
BattleManager.ins.RemoveBullets(this);
}
}
public void BulletUpdate()
{
if (!start)
{
return;
}
if (time<BattleManager.ins.NowTime)
{
start = false;
BattleManager.ins.RemoveBullets(this);
}
transform.Translate(transform.up*Speed* Time.deltaTime,Space.World);
}
}

View File

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

View File

@ -43,22 +43,24 @@ public class Mouster : MonoBehaviour
public void Move(Transform point)
{
if ((point.position-transform.position).magnitude>entity._data.Range)
if (transform.position.y - point.position.y>entity._data.Range)
{
float dis = Vector3.Distance(transform.position, point.position);
transform.position=Vector3.Lerp(transform.position, point.position, entity._data.Move*Time.deltaTime/dis);
transform.Translate(transform.up * entity._data.Move* Time.deltaTime,Space.World);
}
else
{
if (entity.nextAttack<BattleManager.ins.NowTime)
{
entity.SetInjured(entity._data.Attack);
entity.nextAttack = BattleManager.ins.NowTime + entity.cd;
BattleManager.ins.SetInjured(attack);
}
}
}
public void SetInjured(int attack)
{
entity.SetInjured(attack);
}
public void DeathEvent()
{
entity.DeathAction = null;

View File

@ -8,6 +8,7 @@ using UnityEngine;
public class MousterTeam
{
public List<MousterEntity> moustList = new List<MousterEntity>();
public List<Mouster> objlist = new List<Mouster>();
public MousterTeamType Type;
public MousterTeamEventType EventType;
public float dynamic = 0;
@ -77,6 +78,32 @@ public class MousterTeam
return moustList.Count(entity => !entity.Death);
}
public void AddObj(Mouster obj)
{
objlist.Add(obj);
}
public void Remove(Mouster obj, ref bool bo)
{
if (Type == MousterTeamType.end)
{
return;
}
foreach (var m in objlist)
{
if (m==obj)
{
objlist.Remove(obj);
bo = true;
if (objlist.Count==0)
{
Type = MousterTeamType.end;
}
return;
}
}
}
}
[Serializable]
public class MousterEntity
@ -107,6 +134,7 @@ public class MousterEntity
public void SetInjured(int num)
{
BDebug.Log(num);
injured += num;
if (injured <= hp) return;
death = true;

View File

@ -1,15 +1,64 @@
using System;
using System.Collections;
using System.Collections.Generic;
using cfg.BlacksmithData;
using UnityEngine;
using Random = UnityEngine.Random;
using Vector3 = System.Numerics.Vector3;
/// <summary>
/// 玩家战斗预制体资源
/// </summary>
public class PlayerItem : MonoBehaviour
{
private BattleEquipment _battleEquipment;
[SerializeField]
private List<GameObject> _gameObjects = new List<GameObject>();
public void SetData(BattleEquipment battleData)
{
_battleEquipment = battleData;
if (_battleEquipment.Weapon!=null)
{
_battleEquipment.Weapon.AddAction(SkillEvent);
}
if (_battleEquipment.Weapon2!=null)
{
_battleEquipment.Weapon2.AddAction(SkillEvent);
}
if (_battleEquipment.Armor!=null)
{
_battleEquipment.Armor.AddAction(SkillEvent);
}
if (_battleEquipment.AudioUniversal!=null)
{
_battleEquipment.AudioUniversal.AddAction(SkillEvent);
}
if (_battleEquipment.AudioWeapon!=null)
{
_battleEquipment.AudioWeapon.AddAction(SkillEvent);
}
if (_battleEquipment.AudioWeapon2!=null)
{
_battleEquipment.AudioWeapon2.AddAction(SkillEvent);
}
PrefabPool.ins.AddPond("Battle_Buttle", 12);
}
private void SkillEvent(SkillState data)
{
BDebug.LogWarning(data.Name);
PrefabPool.ins.LoadObj("Battle_Buttle", (GameObject obj) =>
{
obj.transform.parent = transform;
obj.transform.localPosition = UnityEngine.Vector3.zero;
BattleManager.ins.AxisLookAt(obj.transform,
BattleManager.ins.Mousters[Random.Range(0, BattleManager.ins.MousterCount)].transform.position);
BDebug.Log(data.Attack + " "+data.Ratio);
obj.GetComponent<Bullet>().SetAttack(data.itemData,(int)(data.Attack*data.Ratio),10,1);
BattleManager.ins.AddBullets(obj.GetComponent<Bullet>());
});
}
}

View File

@ -6,45 +6,61 @@ using UnityEngine;
public class PrefabPool : MonoBehaviour
{
public static PrefabPool ins;
private Dictionary<string, Stack<GameObject>> objDic;
private Dictionary<string, Queue<GameObject>> objDic;
private void Awake()
{
ins = this;
objDic = new Dictionary<string, Stack<GameObject>>();
objDic = new Dictionary<string, Queue<GameObject>>();
}
public void LoadObj(string key,Action<GameObject> action)
{
if (!objDic.ContainsKey(key)||objDic[key].Count==0)
{
//如果池中没有该游戏物体或者游戏物体的队列中已经没有剩余的游戏对象时。
//在这种情况下需要实例化一个新的物体,然后在判断是否需要在池中新加一个健值对还是直接放入队列中去
//然后把新生成的放入池中。
if (!objDic.ContainsKey(key)||objDic[key].Count==0) {
AssetBundleManager.ins.LoadAsset(key, (GameObject obj) =>
{
obj.name = key;
obj.SetActive(true);
action.Invoke(obj);
});
return;
}
else
var obj = objDic[key].Dequeue();
obj.SetActive(true);
action.Invoke(obj);
}
public void AddPond(string key,int num)
{
AssetBundleManager.ins.LoadAsset(key, (GameObject obj) =>
{
var obj = objDic[key].Pop();
obj.name = key;
obj.SetActive(true);
action.Invoke(obj);
}
for (int i = 0; i < num-1; i++)
{
var a = Instantiate(obj, transform);
a.name = key;
RecycleObj(a);
}
});
}
public void RecycleObj(GameObject obj)
{
if (!objDic.ContainsKey(obj.name))
{
var stack = new Stack<GameObject>();
objDic.Add(obj.name,stack);
//由于生成的预制体的name后面都会加上Clone所以我们需要将其去除
string name=obj.name;
//如果不存在该类的游戏物体就在对象池中加入,存在则直接加入
if (!objDic.ContainsKey(name)) {
objDic.Add(name, new Queue<GameObject>());
}
obj.transform.parent = transform;
obj.transform.localPosition=Vector3.zero;
obj.SetActive(false);
objDic[obj.name].Push(obj);
objDic[name].Enqueue(obj);
obj.SetActive(false);//记得将放入的游戏物体的属性设置为false
}
}

View File

@ -1 +1 @@
89268a239493235dff6299dffb3c7883
12546e258617ef4e0a8130d7caf429b3

View File

@ -22,19 +22,26 @@
"AssetTags": [],
"BundleID": 0
},
{
"Address": "Battle_Buttle",
"AssetPath": "Assets/Pack/Prefab/Buttle.prefab",
"AssetGUID": "96fdc88cb421d784a9bd971fc6dcc2ec",
"AssetTags": [],
"BundleID": 1
},
{
"Address": "Battle_mouster",
"AssetPath": "Assets/Pack/Prefab/Mouster/mouster.prefab",
"AssetGUID": "6bc73daca7a89a34582f00eaf7bf39ce",
"AssetTags": [],
"BundleID": 1
"BundleID": 2
},
{
"Address": "Battle_player",
"AssetPath": "Assets/Pack/Prefab/player/player.prefab",
"AssetGUID": "68c4f4b7b9e9eeb419816a6c216e8712",
"AssetTags": [],
"BundleID": 2
"BundleID": 3
}
],
"BundleList": [
@ -48,12 +55,22 @@
"Tags": [],
"DependIDs": []
},
{
"BundleName": "defaultpackage_assets_pack_prefab.bundle",
"UnityCRC": 0,
"FileHash": "514a5a045a49efe0ea3811a6f8235493",
"FileCRC": "00000000",
"FileSize": 4637,
"Encrypted": false,
"Tags": [],
"DependIDs": []
},
{
"BundleName": "defaultpackage_assets_pack_prefab_mouster.bundle",
"UnityCRC": 0,
"FileHash": "9c8871fcce83a92234cc8fc73595a93c",
"FileCRC": "00000000",
"FileSize": 6509,
"FileSize": 8116,
"Encrypted": false,
"Tags": [],
"DependIDs": []
@ -63,7 +80,7 @@
"UnityCRC": 0,
"FileHash": "7d484a4172c8e8d490265c4961bc812c",
"FileCRC": "00000000",
"FileSize": 2798,
"FileSize": 4342,
"Encrypted": false,
"Tags": [],
"DependIDs": []

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -38,16 +38,16 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_PixelRect:
serializedVersion: 2
x: 0
y: 43
width: 1920
height: 989
x: 8
y: 51
width: 1904
height: 973
m_ShowMode: 4
m_Title: Inspector
m_Title: Project
m_RootView: {fileID: 9}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
m_Maximized: 1
m_Maximized: 0
--- !u!114 &3
MonoBehaviour:
m_ObjectHideFlags: 52
@ -118,12 +118,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 30
width: 1920
height: 939
width: 1904
height: 923
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 127
controlID: 111
draggingID: 0
--- !u!114 &6
MonoBehaviour:
@ -140,12 +140,12 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 1463
x: 1456
y: 0
width: 457
height: 939
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
width: 448
height: 923
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 17}
m_Panes:
- {fileID: 17}
@ -168,8 +168,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 271
height: 571
width: 269
height: 579
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 18}
@ -187,23 +187,23 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: ConsoleWindow
m_Name: ProjectBrowser
m_EditorClassIdentifier:
m_Children: []
m_Position:
serializedVersion: 2
x: 0
y: 571
width: 1463
height: 368
m_MinSize: {x: 101, y: 121}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 20}
y: 579
width: 1456
height: 344
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
m_ActualView: {fileID: 16}
m_Panes:
- {fileID: 16}
- {fileID: 20}
m_Selected: 1
m_LastSelected: 0
m_Selected: 0
m_LastSelected: 1
--- !u!114 &9
MonoBehaviour:
m_ObjectHideFlags: 52
@ -224,8 +224,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1920
height: 989
width: 1904
height: 973
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
m_UseTopView: 1
@ -249,7 +249,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1920
width: 1904
height: 30
m_MinSize: {x: 0, y: 0}
m_MaxSize: {x: 0, y: 0}
@ -270,8 +270,8 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 969
width: 1920
y: 953
width: 1904
height: 20
m_MinSize: {x: 0, y: 0}
m_MaxSize: {x: 0, y: 0}
@ -294,12 +294,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1463
height: 939
width: 1456
height: 923
m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 16192}
vertical: 1
controlID: 64
controlID: 1395
draggingID: 0
--- !u!114 &13
MonoBehaviour:
@ -320,8 +320,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1463
height: 571
width: 1456
height: 579
m_MinSize: {x: 200, y: 50}
m_MaxSize: {x: 16192, y: 8096}
vertical: 0
@ -342,10 +342,10 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 271
x: 269
y: 0
width: 1192
height: 571
width: 1187
height: 579
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 19}
@ -374,10 +374,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 381
x: 271
y: 73
width: 1213
height: 426
width: 1190
height: 568
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
@ -395,8 +395,8 @@ MonoBehaviour:
m_SearchText:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 71137e95
m_LastClickedID: -1786899599
m_SelectedIDs: ce3102cc
m_LastClickedID: -872271410
m_ExpandedIDs: 2956c29689577ec10000000001fecd114886f92e
m_RenameOverlay:
m_UserAcceptedRename: 0
@ -435,10 +435,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 0
y: 644
width: 1462
height: 347
x: 8
y: 660
width: 1455
height: 323
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
@ -460,7 +460,7 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/Script/Battle
- Assets/Pack
m_Globs: []
m_OriginalText:
m_ImportLogFlags: 0
@ -468,30 +468,30 @@ MonoBehaviour:
m_ViewMode: 1
m_StartGridSize: 16
m_LastFolders:
- Assets/Script/Battle
- Assets/Pack
m_LastFoldersGridSize: 16
m_LastProjectPath: E:\Project\WXGame\Blacksmith
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 105}
m_SelectedIDs: 50780000
m_LastClickedID: 30800
m_ExpandedIDs: 000000008c7700008e7700009077000092770000947700009677000046780000487800005078000000ca9a3bffffff7f
scrollPos: {x: 0, y: 0}
m_SelectedIDs: e0770000
m_LastClickedID: 30688
m_ExpandedIDs: 00000000de770000e4770000e8770000ca780000cc780000d678000000ca9a3bffffff7f
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
m_OriginalName:
m_Name: Prefab
m_OriginalName: Prefab
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 0
m_UserData: 30924
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 11
m_OriginalEventType: 0
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 8}
m_SearchString:
@ -505,7 +505,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 000000008c7700008e77000090770000927700009477000096770000
m_ExpandedIDs: 00000000de770000e0770000e2770000e4770000e6770000e8770000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -530,24 +530,24 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_ListAreaState:
m_SelectedInstanceIDs: 44810000
m_LastClickedInstanceID: 33092
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c623000044860000228500003c0001002e000100be740000c4740000c2740000b4740000b2740000ba740000bc740000b0740000c0740000b6740000b87400009c7400008c740000867400009274000098740000967400009a74000090740000a07400008e740000847400009e740000000000004683000040830000388300005c830000aa780000d0690000e4690000f06a0000c06b0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
m_OriginalName:
m_Name: Mouster
m_OriginalName: Mouster
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 0
m_UserData: 31008
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 11
m_OriginalEventType: 0
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 8}
m_CreateAssetUtility:
@ -581,10 +581,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1463
y: 73
width: 456
height: 918
x: 1464
y: 81
width: 447
height: 902
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
@ -602,7 +602,7 @@ MonoBehaviour:
m_ControlHash: -371814159
m_PrefName: Preview_InspectorPreview
m_LastInspectedObjectInstanceID: -1
m_LastVerticalScrollValue: 216
m_LastVerticalScrollValue: 0
m_GlobalObjectId:
m_InspectorMode: 0
m_LockTracker:
@ -628,10 +628,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 0
y: 73
width: 270
height: 550
x: 8
y: 81
width: 268
height: 558
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
@ -645,9 +645,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 22740000
m_LastClickedID: 29730
m_ExpandedIDs: 70c5ffff16fbffffc06f00000271000016710000747200009472000022740000
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 3aa4fcffba44feffb6e9ffff16fbffff326f0000866f000022710000367100007e71000088710000247200009c720000bc7200001875000050750000687600009c760000f6760000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -691,10 +691,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 271
y: 73
width: 1190
height: 550
x: 277
y: 81
width: 1185
height: 558
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
@ -1066,9 +1066,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 129.77765, y: 785.37933, z: -4.4596725}
m_Target: {x: 2.6455626, y: -42.01993, z: -0.04728644}
speed: 2
m_Value: {x: 129.77765, y: 785.37933, z: -4.4596725}
m_Value: {x: 2.6455626, y: -42.01993, z: -0.04728644}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@ -1118,9 +1118,9 @@ MonoBehaviour:
speed: 2
m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size:
m_Target: 1173.4679
m_Target: 5.6561346
speed: 2
m_Value: 1173.4679
m_Value: 5.6561346
m_Ortho:
m_Target: 1
speed: 2
@ -1138,7 +1138,7 @@ MonoBehaviour:
m_FarClip: 10000
m_DynamicClip: 1
m_OcclusionCulling: 0
m_LastSceneViewRotation: {x: -0.08717229, y: 0.89959055, z: -0.21045254, w: -0.3726226}
m_LastSceneViewRotation: {x: -0.12690045, y: -0.09300026, z: 0.011951933, w: -0.9874758}
m_LastSceneViewOrtho: 0
m_ReplacementShader: {fileID: 0}
m_ReplacementString:
@ -1165,10 +1165,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 0
y: 644
width: 1462
height: 347
x: 8
y: 660
width: 1455
height: 323
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0