完善游戏流程

This commit is contained in:
bzx
2025-08-27 13:37:20 +08:00
parent 6249804143
commit a99dcbd827
176 changed files with 152275 additions and 126643 deletions

View File

@@ -49,7 +49,6 @@ public class Actions
public class EnemyMoveForward : Action
{
public SharedFloat dis;
public override TaskStatus OnUpdate()
{
Enemy enemy = transform.GetComponent<Enemy>();

View File

@@ -42,7 +42,7 @@ public class Conditionals
if (self == null) return TaskStatus.Failure;
GameObject target = null;
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[self.type][1];
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[self.type];
float minPriorityDis = 9999f;
GameObject priorityTarget = null;
@@ -128,7 +128,7 @@ public class Conditionals
self.ai.isStopped = false;
self.ai.destination = self.target.transform.position;
self.PlayWalkLocal();
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[self.type][1];
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[self.type];
Vector3 x0zSelf = self.transform.position.ReflectVectorXOZ();
Vector3 x0zTarget = self.target.transform.position.ReflectVectorXOZ();
float dis = Vector3.Distance(x0zTarget, x0zSelf);
@@ -149,7 +149,7 @@ public class Conditionals
if (self == null) return TaskStatus.Failure;
if (self.target == null) return TaskStatus.Failure;
TaskStatus res = TaskStatus.Failure;
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[self.type][1];
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[self.type];
float dis = UnityEngine.Vector3.Distance(self.target.transform.position, self.transform.position);
if (dis <= enemyInfo.MinAtkArea)
{

View File

@@ -1,23 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class BLR02Bullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.BLR02Bullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
}
}

View File

@@ -11,7 +11,7 @@ public class DoubleTubeBullet : Bullet
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.QuickBullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}

View File

@@ -1,22 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class DragonBossBullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.DragonBossBullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
}
}

View File

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

View File

@@ -1,21 +0,0 @@
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class ElectroBullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.ElectroBullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
}
}

View File

@@ -1,23 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class GRMIIBullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.GRMIIBullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
}
}

View File

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

View File

@@ -1,31 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using DragonLi.Frame;
using LitJson;
using Mirror;
using UnityEngine;
public class GatlingBullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.GatlingBullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public Dictionary<int, SettleInfo> keyValues = new Dictionary<int, SettleInfo>();
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
if (ownerIndex != -1)
{
GameManager.Ins.AddScore(ownerIndex.ToString(), (int)damage);
}
}
}

View File

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

View File

@@ -1,23 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class HR01Bullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.HR01Bullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
}
}

View File

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

View File

@@ -1,23 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class MR3Bullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.MR3Bullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
}
}

View File

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

View File

@@ -1,23 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class PHR01Bullet : Bullet
{
[Server]
public override void OnSpawn(int ownerIndex, Vector3 recoil, float recoilCount)
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.PHR01Bullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}
public override void OnApplyDamage(IDamagable damagable)
{
damagable.ApplyDamage(damage, ownerIndex, transform);
}
}

View File

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

View File

@@ -11,7 +11,7 @@ public class PistolBullet : Bullet
{
base.OnSpawn(ownerIndex, recoil, recoilCount);
type = BulletType.PistolBullet;
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type][1];
BulletInfo bulletInfo = GameManager.Ins.BulletInfos[type];
damage = bulletInfo.Damage;
deToughness = bulletInfo.DeToughness;
}

View File

@@ -2,16 +2,12 @@ using static XPlugin.Data.JsonLiteDB.JsonLiteDB;
public enum BulletType
{
QuickBullet = 0,
HR01Bullet = 1,
PHR01Bullet = 2,
MR3Bullet = 3,
GRMIIBullet = 4,
BLR02Bullet = 5,
GatlingBullet = 6,
ElectroBullet = 7,
DragonBossBullet = 8,
PistolBullet = 9
PistolBullet = 0,
QuickBullet = 1,
LaserBullet =2,
LightSphereBullet = 3,
BeamBullet = 4,
GrenadeBullet = 5,
}
public class BulletInfo

View File

@@ -6,7 +6,7 @@ public enum EnemyType
FatZombie=1,
ExplosionDog=2,
RunZombie=3,
DragonBoss = 4,
ZombieBoss = 4,
}
public class EnemyInfo

View File

@@ -6,7 +6,7 @@ public enum GunType
FireGun = 1,
LaserGun = 2,
LightSphereGun = 3,
Gun4 = 4,
BeamGun = 4,
BLR02Gun = 5,
GatlingGun = 6,
ElectroGun = 7,

View File

@@ -51,7 +51,7 @@ public class Airdrop : Agent
_transform = transform;
this.type = type;
this.lvl = lvl;
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[type][lvl];
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[type];
speed = enemyInfo.Speed;
health = enemyInfo.Hp;
originHealth = enemyInfo.Hp;

View File

@@ -195,7 +195,7 @@ public class Enemy : Agent
this.type = type;
state = EnemyState.Borning;
this.lvl = lvl;
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[type][lvl];
EnemyInfo enemyInfo = GameManager.Ins.EnemyInfos[type];
speed = enemyInfo.Speed;
atk = enemyInfo.Atk;
health = enemyInfo.Hp;
@@ -273,6 +273,13 @@ public class Enemy : Agent
}
}
private void LateUpdate()
{
Vector3 pos = transform.position;
pos.y = 0f; // 或者设置为地面高度
transform.position = pos;
}
#region --- ---
// 在本地播放行走Animancer or Animator
@@ -339,6 +346,8 @@ public class Enemy : Agent
s.Events(this).OnEnd = () =>
{
NetworkServer.Destroy(gameObject);
if(isServer)
GameManager.Ins.DeleteEnemy(id);
// client 本地死亡结束后的处理(通常由 server 决定是否销毁)
// 这里不直接销毁网络对象server 会在需要时 Destroy
};

View File

@@ -29,7 +29,7 @@ public class EnemyUI : NetworkBehaviour
// 0.2秒后展示ui防止在原点出现
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
{
if (_enemy.type == EnemyType.DragonBoss)
if (_enemy.type == EnemyType.ZombieBoss)
{
UIStateChange(2);
}
@@ -83,7 +83,7 @@ public class EnemyUI : NetworkBehaviour
[ClientRpc]
public void HpChange(EnemyType type, float currentBlood, float totalBlood)
{
float allLength = type == EnemyType.DragonBoss ? 3f : 1.58f;
float allLength = type == EnemyType.ZombieBoss ? 3f : 1.58f;
float lastValue = _lastHp / totalBlood;
float value = currentBlood / totalBlood;
blood2[0].size = new Vector2(value * allLength, 0.14f);

View File

@@ -45,6 +45,12 @@ public class GameLocal : MonoBehaviour
[NonSerialized]
public int GameMode = 0;
[NonSerialized]
public GameObject HitUI;
[NonSerialized]
public GameObject DieUI;
public Transform[] enemyStartPos;

View File

@@ -58,13 +58,13 @@ public class GameManager : NetworkBehaviour
// json数据库
private JsonLiteDB DB;
// 怪物信息集合
public Dictionary<EnemyType, Dictionary<int, EnemyInfo>> EnemyInfos = new Dictionary<EnemyType, Dictionary<int, EnemyInfo>>();
public Dictionary<EnemyType, EnemyInfo> EnemyInfos = new Dictionary<EnemyType, EnemyInfo>();
// 炮塔信息集合
public Dictionary<TowerType, Dictionary<int, TowerInfo>> TowerInfos = new Dictionary<TowerType, Dictionary<int, TowerInfo>>();
// 枪械信息集合
public Dictionary<GunType, Dictionary<int, GunInfo>> GunInfos = new Dictionary<GunType, Dictionary<int, GunInfo>>();
public Dictionary<GunType, GunInfo> GunInfos = new Dictionary<GunType, GunInfo>();
// 子弹信息集合
public Dictionary<BulletType, Dictionary<int, BulletInfo>> BulletInfos = new Dictionary<BulletType, Dictionary<int, BulletInfo>>();
public Dictionary<BulletType, BulletInfo> BulletInfos = new Dictionary<BulletType,BulletInfo>();
// 防线信息
public List<DefenseInfo> DefenseInfos = new List<DefenseInfo>();
// 剧情信息
@@ -116,8 +116,7 @@ public class GameManager : NetworkBehaviour
public GameState gameState = GameState.None;
[SoundGroup] public string JointIn;
[SoundGroup] public string roundSound;
public int roundWaveTime;
public int curRoundWaveTime;
@@ -181,19 +180,7 @@ public class GameManager : NetworkBehaviour
/// </summary>
public void CreateRound(int progress)
{
var combatUnitInfo= CombatUnitInfos[progress];
// if (combatUnitInfo != null)
// {
// for (int i = 0; i < combatUnitInfo.EnemyTypeList.Length; i++)
// {
// CoroutineTaskManager.Instance.WaitSecondTodo(() =>
// {
// CreateEnemy(
// (EnemyType)combatUnitInfo.EnemyTypeList[i],
// );
// }, combatUnitInfo.BornTime);
// }
// }
GetRoundEnemy();
}
[Server]
@@ -330,11 +317,14 @@ public class GameManager : NetworkBehaviour
}
}
public int curRoundEnemyCount;
/// <summary>
/// 创建敌方单位
/// </summary>
IEnumerator CreateEnemy(CombatUnitInfo info)
{
curRoundEnemyCount = info.EnemyTypeList.Length;
for (int i = 0; i < info.EnemyTypeList.Length; i++)
{
GameObject enemy = Instantiate(EnemyPres[info.EnemyTypeList[i]]);
@@ -379,8 +369,9 @@ public class GameManager : NetworkBehaviour
{
GameObject enemy = EnemyList[id].gameObject;
EnemyList.Remove(id);
curRoundEnemyCount--;
NetworkServer.Destroy(enemy);
if (EnemyList.Count == 0)
if (curRoundEnemyCount<=0)
{
CreateNextRound();
}
@@ -443,21 +434,11 @@ public class GameManager : NetworkBehaviour
roundWaveTime = 15;
curRoundWaveTime = 12;
TableReader infoReader = DB["EnemysInfo"].GetReader();
EnemyInfos.Clear();
while (infoReader.Read())
{
EnemyInfo info = new EnemyInfo(infoReader);
EnemyInfos.TryGetValue((EnemyType)info.Type, out Dictionary<int, EnemyInfo> infoList);
if (infoList == null)
{
Dictionary<int, EnemyInfo> list = new Dictionary<int, EnemyInfo>();
list.Add(info.Lvl, info);
EnemyInfos.Add((EnemyType)info.Type, list);
}
else
{
infoList.Add(info.Lvl, info);
}
EnemyInfos.Add((EnemyType)info.Type,info);
}
infoReader = DB["TowersInfo"].GetReader();
@@ -478,37 +459,19 @@ public class GameManager : NetworkBehaviour
}
infoReader = DB["GunsInfo"].GetReader();
GunInfos.Clear();
while (infoReader.Read())
{
GunInfo info = new GunInfo(infoReader);
GunInfos.TryGetValue((GunType)info.Type, out Dictionary<int, GunInfo> infoList);
if (infoList == null)
{
Dictionary<int, GunInfo> list = new Dictionary<int, GunInfo>();
list.Add(info.Lvl, info);
GunInfos.Add((GunType)info.Type, list);
}
else
{
infoList.Add(info.Lvl, info);
}
GunInfos.Add((GunType)info.Type,info);
}
infoReader = DB["BulletsInfo"].GetReader();
BulletInfos.Clear();
while (infoReader.Read())
{
BulletInfo info = new BulletInfo(infoReader);
BulletInfos.TryGetValue((BulletType)info.Type, out Dictionary<int, BulletInfo> infoList);
if (infoList == null)
{
Dictionary<int, BulletInfo> list = new Dictionary<int, BulletInfo>();
list.Add(info.Lvl, info);
BulletInfos.Add((BulletType)info.Type, list);
}
else
{
infoList.Add(info.Lvl, info);
}
BulletInfos.Add((BulletType)info.Type,info);
}
infoReader = DB["DefensesInfo"].GetReader();

View File

@@ -9,7 +9,7 @@ public class BLR02Gun : Launcher
if (isServer)
{
type = GunType.BLR02Gun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}

View File

@@ -11,7 +11,7 @@ public class DragonBossGun : Launcher
if (isServer)
{
type = GunType.DragonBossGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}

View File

@@ -9,7 +9,7 @@ public class ElectroGun : Launcher
if (isServer)
{
type = GunType.ElectroGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}

View File

@@ -13,7 +13,7 @@ public class GatlingGun : Launcher
if (isServer)
{
type = GunType.GatlingGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}

View File

@@ -26,7 +26,7 @@ public class Gun2 : Launcher
if (isServer && isClient && isOwned)
{
type = GunType.FireGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
// if (hand == HandType.Left)
@@ -41,8 +41,8 @@ public class Gun2 : Launcher
// 主机其他
else if (isServer && isClient)
{
type = GunType.Pistol;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
type = GunType.FireGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}
@@ -60,7 +60,7 @@ public class Gun2 : Launcher
}
shot.SetActive(false);
bullet_attack = 5;
bullet_attack = GameManager.Ins.BulletInfos[(BulletType)type].Damage;
}
public void Update()

View File

@@ -26,7 +26,7 @@ public class Gun3 : Launcher
if (isServer && isClient && isOwned)
{
type = GunType.LaserGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
if (hand == HandType.Left)
@@ -41,8 +41,8 @@ public class Gun3 : Launcher
// 主机其他
else if (isServer && isClient)
{
type = GunType.Pistol;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
type = GunType.LaserGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}

View File

@@ -15,7 +15,7 @@ public class Gun4 : Launcher
if (isServer && isClient && isOwned)
{
type = GunType.LightSphereGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
if (hand == HandType.Left)
@@ -30,8 +30,8 @@ public class Gun4 : Launcher
// 主机其他
else if (isServer && isClient)
{
type = GunType.Pistol;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
type = GunType.LightSphereGun;
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}

View File

@@ -11,7 +11,7 @@ public class Pistol : Launcher
if (isServer && isClient && isOwned)
{
type = GunType.Pistol;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
if (hand == HandType.Left)
@@ -27,7 +27,7 @@ public class Pistol : Launcher
else if (isServer && isClient)
{
type = GunType.Pistol;
GunInfo gunInfo = GameManager.Ins.GunInfos[type][1];
GunInfo gunInfo = GameManager.Ins.GunInfos[type];
shootRate = gunInfo.ShootRate;
recoil = gunInfo.Recoil;
}

View File

@@ -60,7 +60,6 @@ public class MRNetworkManager : NetworkRoomManager
if (newRoomGameObject == null)
newRoomGameObject = Instantiate(roomPlayerPrefab.gameObject, Vector3.zero, Quaternion.identity);
NetworkServer.AddPlayerForConnection(conn, newRoomGameObject);
GameManager.Ins.CreateDoor();
// if (clientIndex == 2)
// {
// Debug.Log("两个玩家进入房间,游戏开始");

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using DragonLi.Core;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
using UnityEngine.XR;
@@ -29,7 +30,7 @@ public enum HandState
HaveWeapon
}
public class Player : NetworkRoomPlayer
public class Player : NetworkRoomPlayer,IDamagable
{
public Transform LeftHand;
public Transform RightHand;
@@ -39,6 +40,18 @@ public class Player : NetworkRoomPlayer
public LayerMask AimLayer;
public bool isGameReady;
public bool IsAlive = true;
private float time = 0;
[Header("玩家最大血量")]
public float maxHp = 25000;
private float currentHp;
public float Health
{
get => currentHp;
set => currentHp = value;
}
#if UNITY_EDITOR
[DisplayOnly]
@@ -89,9 +102,43 @@ public class Player : NetworkRoomPlayer
GameManager.Ins.AddData(index);
Collider.enabled = true;
}
currentHp = maxHp;
isGameReady = false;
GameManager.Ins.players.Add(this);
}
public void SetBlood(float num)
{
currentHp += num;
EventDispatcher.TriggerEvent("HpChange", currentHp, maxHp);
}
public float OnReceiveDamage(float damage, object info, Transform _sender)
{
float curDamage = damage;
SetBlood(-curDamage);
if (currentHp <= 0 && IsAlive)
{
IsAlive = false;
GameLocal.Ins.DieUI.SetActive(true);
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
{
IsAlive = true;
GameLocal.Ins.DieUI.SetActive(false);
currentHp = maxHp;
EventDispatcher.TriggerEvent("HpChange", currentHp, maxHp);
time = 0f;
}, 5f, this);
}
else if (currentHp > 0)
{
GameLocal.Ins.HitUI.SetActive(true);
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
GameLocal.Ins.HitUI.SetActive(false), 1f, this);
}
return currentHp;
}
public void Update()
{
@@ -139,6 +186,12 @@ public class Player : NetworkRoomPlayer
}
}
}
[ServerCallback]
public void ApplyDamage(float value, object info, Transform _sender)
{
OnReceiveDamage(value, info, _sender);
}
[ServerCallback]
public void OnTriggerEnter(Collider other)
@@ -250,11 +303,11 @@ public class Player : NetworkRoomPlayer
switch (gunType)
{
case GunType.Pistol:
left = LoadGun(HandType.Left, gunType);
//left = LoadGun(HandType.Left, gunType);
right = LoadGun(HandType.Right, gunType);
break;
}
Launcher[] launchers = { left, right };
Launcher[] launchers = { null, right };
Guns.Add(launchers);
Swith2TargetGun(gunType);
}
@@ -467,6 +520,11 @@ public class Player : NetworkRoomPlayer
UpdateWeapons();
}
public Launcher CurUserGun()
{
return Guns[NowGunIndex][1];
}
#endregion
}

View File

@@ -152,8 +152,8 @@ namespace Common
_progress += 1;
yield return new WaitForSeconds(0.02f);
}
RequestAuthCount = 0;
WorldUIManager.Ins.Back();
Save();
}
else
{
@@ -171,15 +171,22 @@ namespace Common
_progress += 1;
yield return new WaitForSeconds(0.02f);
}
RequestAuthCount = 0;
WorldUIManager.Ins.Back();
Save();
}
else
{
PanelState.StateChange(1);
}
}
}
}
public void Save()
{
RequestAuthCount = 0;
GameManager.Ins.CreateDoor();
WorldUIManager.Ins.Back();
}
}
}

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using DragonLi.Core;
using LitJson;
using Mirror;
@@ -14,16 +16,45 @@ public class HUDPanel : MonoBehaviour
/// </summary>
public TextMeshProUGUI LessTimeText;
/// <summary>
/// 得分文本
/// 枪械剩余子弹
/// </summary>
public TextMeshProUGUI ScoreText;
public TextMeshProUGUI gunCountTxt;
/// <summary>
/// 枪械种类
/// </summary>
public Sprite[] gunIcons;
/// <summary>
/// 枪图片
/// </summary>
public Image gunImage;
/// <summary>
/// 警告节点
/// </summary>
public GameObject TimingWarning;
/// <summary>
/// 血条
/// </summary>
public Image blood2;
public GameObject hitEffect;
/// <summary>
/// 复活倒计时
/// </summary>
public GameObject dieUI;
public TextMeshProUGUI enemyDieCountTxt;
public Image fuHuoImage;
/// <summary>
/// 下一波倒计时
/// </summary>
@@ -39,15 +70,30 @@ public class HUDPanel : MonoBehaviour
OverlayUIManager.Ins.Cover("UI/HUDPanel", false);
}
private void Awake()
{
GameLocal.Ins.HitUI = hitEffect;
GameLocal.Ins.DieUI = dieUI;
}
public void Start()
{
// LoginPanel.Show();
EventDispatcher.AddEventListener<int>("NewWaveStart", NewWaveStart);
EventDispatcher.AddEventListener<float, float>("HpChange", HpChange);
EventDispatcher.AddEventListener<int>("UserGun", UserGun);
EventDispatcher.AddEventListener<int>("WinRound", ShowWinRound);
// //打开联控动画
// EventDispatcher.AddEventListener<int>("JoinControlStart", JoinControlStart);
// //关闭联控动画
// EventDispatcher.AddEventListener<int>("JoinControlEnd", JoinControlEnd);
}
public void HpChange(float currentHp, float maxHp)
{
blood2.fillAmount = currentHp / maxHp;
//DOTween.To(() => blood1.fillAmount, x => blood1.fillAmount = x, currentHp / maxHp, 0.5f);//血量变化
}
public void JoinControlStart(int playerIndex)
{
@@ -80,7 +126,7 @@ public class HUDPanel : MonoBehaviour
playerDictionary[key] = entry.Value;
}
ScoreText.text = playerDictionary[GameLocal.Ins.self.index].Score.ToString();
//ScoreText.text = playerDictionary[GameLocal.Ins.self.index].Score.ToString();
}
if (GameManager.Ins.GetLessTimeSeconds() <= 60)
{
@@ -109,11 +155,27 @@ public class HUDPanel : MonoBehaviour
int time = 3;
while (time>0)
{
icon.sprite = RoundIcon[time];
icon.sprite = RoundIcon[time-1];
yield return new WaitForSeconds(1f);
time--;
}
Round.SetActive(false);
GameManager.Ins.PlaySound2DRPC("");
}
public void ChangeGunIcon()
{
gunImage.sprite = gunIcons[GameLocal.Ins.self.NowGunIndex];
}
public void UserGun(int bullet)
{
gunCountTxt.text = bullet.ToString();
}
public void ShowWinRound(int index)
{
}
}

View File

@@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Boss : Zombie
{
public GameObject touObj;
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bda1de24e33862b4a87b1ca3c8b0366e
guid: 7a9642beeb36a70459577de297f945e0
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -24,6 +24,8 @@ public class Zombie : Enemy
public override void DoAttack()
{
base.DoAttack();
if(attackEffect==null)
return;
attackEffect.SetActive(true);
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
{

View File

@@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZombieDog : Zombie
{
public GameObject effect;
public AnimationClip selfDie;
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 1947c188149b6ed4085ad75f67ed63c4
guid: 4c29c546c9b794e448683390fefec46e
MonoImporter:
externalObjects: {}
serializedVersion: 2