Enemy1行动路径优化
This commit is contained in:
@@ -8,35 +8,35 @@ using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
|
||||
public class CheckEnemyState : Conditional
|
||||
public class CheckEnemyState : Conditional
|
||||
{
|
||||
public SharedInt curEnemyState;
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
public SharedInt curEnemyState;
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
|
||||
if (transform.GetComponent<Enemy>().enemyState == (EnemyState)curEnemyState.Value)
|
||||
{
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
public class SetEnemyState : Action
|
||||
{
|
||||
public SharedInt curEnemyState;
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
var enemy= transform.GetComponent<Enemy>();
|
||||
if (enemy != null)
|
||||
{
|
||||
enemy.enemyState = (EnemyState)curEnemyState.Value;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return base.OnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public class MoveToPlayerNearby3 : Action
|
||||
if (transform.GetComponent<Enemy>().enemyState == (EnemyState)curEnemyState.Value)
|
||||
{
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
public class SetEnemyState : Action
|
||||
{
|
||||
public SharedInt curEnemyState;
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
var enemy = transform.GetComponent<Enemy>();
|
||||
if (enemy != null)
|
||||
{
|
||||
enemy.enemyState = (EnemyState)curEnemyState.Value;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return base.OnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public class MoveToPlayerNearby3 : Action
|
||||
{
|
||||
public SharedGameObject self;
|
||||
public SharedFloat minRange = new SharedFloat { Value = 3f };
|
||||
@@ -52,7 +52,7 @@ using UnityEngine.AI;
|
||||
{
|
||||
base.OnStart();
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
|
||||
|
||||
// 随机优先级,降低 agent 之间争路
|
||||
agent.avoidancePriority = Random.Range(0, 100);
|
||||
agent.obstacleAvoidanceType = ObstacleAvoidanceType.HighQualityObstacleAvoidance;
|
||||
@@ -75,7 +75,7 @@ using UnityEngine.AI;
|
||||
{
|
||||
// 从 Manager 或其他地方拿到所有敌人的引用列表
|
||||
List<Enemy> allEnemies = GameManager.Ins.curEnemyList;
|
||||
|
||||
|
||||
Vector3 bestPos = Vector3.zero;
|
||||
float bestScore = -1f;
|
||||
|
||||
@@ -132,7 +132,7 @@ using UnityEngine.AI;
|
||||
// 最后随机返回一个点
|
||||
return player.position + Random.insideUnitSphere * (minRange.Value + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
// 调试画出可行区域
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
@@ -144,433 +144,524 @@ using UnityEngine.AI;
|
||||
|
||||
public class MoveToPlayerFront : Action
|
||||
{
|
||||
public SharedFloat minDistance = new SharedFloat { Value = 3f };
|
||||
public SharedFloat maxDistance = new SharedFloat { Value = 5f };
|
||||
public SharedFloat minAngle = new SharedFloat { Value = 30f };
|
||||
public SharedFloat maxAngle = new SharedFloat { Value = 40f };
|
||||
// 添加静态字典记录每个怪物的移动状态
|
||||
private static Dictionary<GameObject, bool> hasMoved = new Dictionary<GameObject, bool>();
|
||||
public SharedFloat minDistance = 3f; // 最小距离
|
||||
public SharedFloat maxDistance = 8f; // 最大距离
|
||||
public SharedFloat minAngle = 30f; // 最小角度(度)
|
||||
public SharedFloat maxAngle = 40f; // 最大角度(度)
|
||||
public SharedFloat attackRange = 10f; // 攻击范围
|
||||
public SharedFloat attackInterval = 1f; // 攻击间隔(秒)
|
||||
|
||||
//分散参数
|
||||
public SharedFloat minSeparation = 2.5f;//最小间距
|
||||
public int maxPlacementAttempts = 15;//最大尝试次数
|
||||
|
||||
private NavMeshAgent agent;
|
||||
private bool hasReachedPosition;
|
||||
private Vector3 finalPosition; // 存储最终位置
|
||||
private Transform playerTransform;
|
||||
private bool hasReachedDestination;
|
||||
private float lastAttackTime;
|
||||
private Enemy1 enemyComponent;
|
||||
private Vector3 targetPosition;
|
||||
|
||||
// 添加静态字典记录每个敌人的移动状态
|
||||
private static Dictionary<int, bool> hasMovedDict = new Dictionary<int, bool>();
|
||||
private int instanceID;
|
||||
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
instanceID = gameObject.GetInstanceID();
|
||||
}
|
||||
//静态列表跟踪所有小兵位置
|
||||
private static List<Vector3> occupiedPositions = new List<Vector3>();
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
// 检查是否已经移动过
|
||||
if (hasMovedDict.ContainsKey(instanceID) && hasMovedDict[instanceID])
|
||||
{
|
||||
hasReachedPosition = true;
|
||||
return;
|
||||
}
|
||||
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
agent.autoBraking = true;
|
||||
playerTransform = GameManager.Ins.player.transform;
|
||||
enemyComponent = GetComponent<Enemy1>();
|
||||
|
||||
agent.stoppingDistance = 0.1f;
|
||||
agent.autoBraking = true;
|
||||
|
||||
// 计算玩家正前方扇形区域内的随机位置
|
||||
finalPosition = CalculateFrontPosition();
|
||||
// 计算分散位置
|
||||
targetPosition = CalculateFrontPosition();
|
||||
agent.SetDestination(targetPosition);
|
||||
hasReachedDestination = false;
|
||||
|
||||
if (agent.isActiveAndEnabled)
|
||||
{
|
||||
agent.SetDestination(finalPosition);
|
||||
hasReachedPosition = false;
|
||||
}
|
||||
//添加到已占用位置列表
|
||||
occupiedPositions.Add(targetPosition);
|
||||
|
||||
//初始化攻击计时器
|
||||
lastAttackTime = Time.time;
|
||||
}
|
||||
|
||||
public override void OnEnd()
|
||||
{
|
||||
//从占用列表中移除
|
||||
occupiedPositions.Remove(targetPosition);
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
// 如果已经移动过,直接返回成功
|
||||
if (hasMovedDict.ContainsKey(instanceID) && hasMovedDict[instanceID])
|
||||
// 1. 如果还没到达目标位置,继续移动
|
||||
if (!hasReachedDestination)
|
||||
{
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
|
||||
if (hasReachedPosition)
|
||||
{
|
||||
//标记为已移动
|
||||
hasMovedDict[instanceID] = true;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
|
||||
// 检查是否到达目标位置
|
||||
if (!agent.pathPending && agent.remainingDistance <= agent.stoppingDistance)
|
||||
{
|
||||
// 完全停止导航系统
|
||||
agent.isStopped = true;
|
||||
agent.ResetPath();
|
||||
agent.enabled = false; // 禁用导航组件
|
||||
|
||||
// 固定位置
|
||||
transform.position = finalPosition;
|
||||
|
||||
// 添加物理约束(如果有刚体)
|
||||
Rigidbody rb = GetComponent<Rigidbody>();
|
||||
if (rb != null)
|
||||
if (!agent.pathPending && agent.remainingDistance <= agent.stoppingDistance)
|
||||
{
|
||||
rb.isKinematic = true;
|
||||
rb.velocity = Vector3.zero;
|
||||
rb.angularVelocity = Vector3.zero;
|
||||
// 到达后停止移动并保持原位
|
||||
agent.isStopped = true;
|
||||
hasReachedDestination = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
|
||||
// 标记为已移动
|
||||
hasMoved[gameObject] = true;
|
||||
hasReachedPosition = true;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
|
||||
// 2. 持续面向玩家
|
||||
FacePlayer();
|
||||
|
||||
// 3. 在攻击范围内且冷却结束,执行攻击
|
||||
if (CanAttackPlayer())
|
||||
{
|
||||
AttackPlayer();
|
||||
}
|
||||
|
||||
// 4. 保持在原位执行攻击
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
|
||||
|
||||
private Vector3 CalculateFrontPosition()
|
||||
{
|
||||
Transform player = GameManager.Ins.player.transform;
|
||||
Vector3 playerPos = player.position;
|
||||
Vector3 playerForward = player.forward;
|
||||
int attempts = 0;
|
||||
Vector3 candidatePosition;
|
||||
bool positionValid;
|
||||
|
||||
// 随机角度 (30-40度之间,随机左右侧)
|
||||
float randomAngle = Random.Range(minAngle.Value, maxAngle.Value) *
|
||||
(Random.value > 0.5f ? 1f : -1f);
|
||||
do
|
||||
{
|
||||
// 1. 生成候选位置
|
||||
candidatePosition = CalculateRandomFrontPosition();
|
||||
|
||||
// 随机距离
|
||||
// 2. 检查位置是否有效
|
||||
positionValid = IsPositionValid(candidatePosition);
|
||||
|
||||
// 3. 增加尝试计数
|
||||
attempts++;
|
||||
|
||||
} while (!positionValid && attempts < maxPlacementAttempts);
|
||||
|
||||
return candidatePosition;
|
||||
}
|
||||
|
||||
private Vector3 CalculateRandomFrontPosition()
|
||||
{
|
||||
//获取玩家前方向
|
||||
Vector3 playerForward = playerTransform.forward;
|
||||
playerForward.y = 0;
|
||||
playerForward.Normalize();
|
||||
|
||||
//随机角度(30-40°之间,随机左右)
|
||||
float randomAngle = Random.Range(minAngle.Value, maxAngle.Value);
|
||||
randomAngle *= (Random.value > 0.5f) ? 1 : -1;//随机左右方向
|
||||
|
||||
//随机距离
|
||||
float randomDistance = Random.Range(minDistance.Value, maxDistance.Value);
|
||||
|
||||
// 计算方向向量 (玩家前方旋转随机角度)
|
||||
Quaternion rotation = Quaternion.Euler(0f, randomAngle, 0f);
|
||||
//计算方向向量
|
||||
Quaternion rotation = Quaternion.Euler(0, randomAngle, 0);
|
||||
Vector3 direction = rotation * playerForward;
|
||||
|
||||
// 计算目标位置
|
||||
Vector3 targetPos = playerPos + direction * randomDistance;
|
||||
//计算目标位置
|
||||
Vector3 targetPosition = playerTransform.position + direction * randomDistance;
|
||||
|
||||
// 确保位置在NavMesh上
|
||||
if (NavMesh.SamplePosition(targetPos, out NavMeshHit hit, 5f, NavMesh.AllAreas)) // 增加采样范围
|
||||
//NavMesh采样
|
||||
if(NavMesh.SamplePosition(targetPosition,out NavMeshHit hit, 2f, NavMesh.AllAreas))
|
||||
{
|
||||
// 确保不会出现在半空中
|
||||
if (Mathf.Abs(hit.position.y - playerPos.y) > 2f)
|
||||
{
|
||||
// 如果高度差太大,调整到玩家高度
|
||||
return new Vector3(hit.position.x, playerPos.y, hit.position.z);
|
||||
}
|
||||
return hit.position;
|
||||
}
|
||||
|
||||
// 如果采样失败,使用玩家位置(确保不会出现在半空中)
|
||||
return playerPos + Vector3.up * 0.1f; // 稍微高于地面
|
||||
return playerTransform.position + playerForward * minDistance.Value;
|
||||
}
|
||||
|
||||
// 当敌人被销毁时清理记录
|
||||
public override void OnEnd()
|
||||
private bool IsPositionValid(Vector3 position)
|
||||
{
|
||||
if (hasMovedDict.ContainsKey(instanceID))
|
||||
//检查是否与其他小怪距离太近
|
||||
foreach(Vector3 occupiedPos in occupiedPositions)
|
||||
{
|
||||
hasMovedDict.Remove(instanceID);
|
||||
if (Vector3.Distance(position, occupiedPos) < minSeparation.Value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SetAttackState : Action
|
||||
{
|
||||
public SharedBool attackState;
|
||||
|
||||
// 添加静态字典记录每个敌人的攻击状态
|
||||
private static Dictionary<int, bool> attackStateSet = new Dictionary<int, bool>();
|
||||
private int instanceID;
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
instanceID = gameObject.GetInstanceID();
|
||||
//检查与玩家的距离
|
||||
float distanceToPlayer = Vector3.Distance(position, playerTransform.position);
|
||||
if (distanceToPlayer < minDistance.Value || distanceToPlayer > maxDistance.Value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//检查NavMesh是否可以行走
|
||||
if(!NavMesh.SamplePosition(position,out NavMeshHit hit, 0.5f, NavMesh.AllAreas))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
private void FacePlayer()
|
||||
{
|
||||
// 如果已经设置过攻击状态,直接返回成功
|
||||
if (attackStateSet.ContainsKey(instanceID) && attackStateSet[instanceID])
|
||||
//平滑转向玩家
|
||||
Vector3 direction = (playerTransform.position - transform.position).normalized;
|
||||
direction.y = 0;
|
||||
if (direction != Vector3.zero)
|
||||
{
|
||||
return TaskStatus.Success;
|
||||
Quaternion targetRotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.Slerp(
|
||||
transform.rotation,
|
||||
targetRotation,
|
||||
Time.deltaTime * 5f
|
||||
);
|
||||
}
|
||||
|
||||
Enemy1 enemy = GetComponent<Enemy1>();
|
||||
if (enemy != null)
|
||||
{
|
||||
enemy.SetAttackState(attackState.Value);
|
||||
|
||||
// 标记为已设置
|
||||
attackStateSet[instanceID] = true;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
|
||||
// 当敌人被销毁时清理记录
|
||||
public override void OnEnd()
|
||||
private bool CanAttackPlayer()
|
||||
{
|
||||
if (attackStateSet.ContainsKey(instanceID))
|
||||
// 1. 检查距离
|
||||
float distance = Vector3.Distance(transform.position, playerTransform.position);
|
||||
if (distance > attackRange.Value) return false;
|
||||
|
||||
// 2. 检查攻击冷却
|
||||
if (Time.time - lastAttackTime < attackInterval.Value) return false;
|
||||
|
||||
//// 3. 检查视线(可选)
|
||||
//RaycastHit hit;
|
||||
//if (Physics.Raycast(transform.position, playerTransform.position - transform.position, out hit, attackRange.Value))
|
||||
//{
|
||||
// return hit.transform == playerTransform;
|
||||
//}
|
||||
|
||||
return true; ;
|
||||
}
|
||||
|
||||
private void AttackPlayer()
|
||||
{
|
||||
if (enemyComponent != null)
|
||||
{
|
||||
attackStateSet.Remove(instanceID);
|
||||
enemyComponent.Attack();
|
||||
lastAttackTime = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
// 调试可视化
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (!Application.isPlaying || playerTransform == null) return;
|
||||
|
||||
Gizmos.color = Color.cyan;
|
||||
Gizmos.DrawSphere(agent.destination, 0.5f);
|
||||
|
||||
// 绘制扇形区域
|
||||
DrawAngleSector(minAngle.Value, maxAngle.Value, minDistance.Value, maxDistance.Value);
|
||||
}
|
||||
|
||||
private void DrawAngleSector(float minDeg, float maxDeg, float minDist, float maxDist)
|
||||
{
|
||||
Gizmos.color = new Color(1, 0.5f, 0, 0.3f);
|
||||
|
||||
// 绘制左右扇形
|
||||
DrawSingleSector(minDeg, maxDeg, minDist, maxDist);
|
||||
DrawSingleSector(-minDeg, -maxDeg, minDist, maxDist);
|
||||
}
|
||||
|
||||
private void DrawSingleSector(float startDeg, float endDeg, float minDist, float maxDist)
|
||||
{
|
||||
Vector3 playerPos = playerTransform.position;
|
||||
Vector3 baseDir = playerTransform.forward;
|
||||
|
||||
int segments = 10;
|
||||
float angleStep = (endDeg - startDeg) / segments;
|
||||
|
||||
// 绘制外弧
|
||||
for (int i = 0; i <= segments; i++)
|
||||
{
|
||||
float angle = startDeg + i * angleStep;
|
||||
Quaternion rot = Quaternion.Euler(0, angle, 0);
|
||||
Vector3 dir = rot * baseDir;
|
||||
Vector3 point = playerPos + dir * maxDist;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
float prevAngle = startDeg + (i - 1) * angleStep;
|
||||
Quaternion prevRot = Quaternion.Euler(0, prevAngle, 0);
|
||||
Vector3 prevDir = prevRot * baseDir;
|
||||
Vector3 prevPoint = playerPos + prevDir * maxDist;
|
||||
|
||||
Gizmos.DrawLine(prevPoint, point);
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制内弧
|
||||
for (int i = 0; i <= segments; i++)
|
||||
{
|
||||
float angle = startDeg + i * angleStep;
|
||||
Quaternion rot = Quaternion.Euler(0, angle, 0);
|
||||
Vector3 dir = rot * baseDir;
|
||||
Vector3 point = playerPos + dir * minDist;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
float prevAngle = startDeg + (i - 1) * angleStep;
|
||||
Quaternion prevRot = Quaternion.Euler(0, prevAngle, 0);
|
||||
Vector3 prevDir = prevRot * baseDir;
|
||||
Vector3 prevPoint = playerPos + prevDir * minDist;
|
||||
|
||||
Gizmos.DrawLine(prevPoint, point);
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制连接线
|
||||
Vector3 startMin = playerPos + Quaternion.Euler(0, startDeg, 0) * baseDir * minDist;
|
||||
Vector3 startMax = playerPos + Quaternion.Euler(0, startDeg, 0) * baseDir * maxDist;
|
||||
Vector3 endMin = playerPos + Quaternion.Euler(0, endDeg, 0) * baseDir * minDist;
|
||||
Vector3 endMax = playerPos + Quaternion.Euler(0, endDeg, 0) * baseDir * maxDist;
|
||||
|
||||
Gizmos.DrawLine(startMin, startMax);
|
||||
Gizmos.DrawLine(endMin, endMax);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测boss是否到阶段血量
|
||||
/// </summary>
|
||||
public class CheckEnemyHp : Conditional
|
||||
{
|
||||
public SharedFloat hpIndex;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
var curHpIndex = transform.GetComponent<Enemy>().health/transform.GetComponent<Enemy>().maxHealth;
|
||||
if (curHpIndex <= hpIndex.Value)
|
||||
{
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
public class UserSkill : Action
|
||||
{
|
||||
public Enemy EnemyObj;
|
||||
public SharedFloat hpIndex;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
EnemyObj = transform.GetComponent<Enemy>();
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if (EnemyObj == null)
|
||||
return TaskStatus.Failure;
|
||||
var curHpIndex = EnemyObj.health/EnemyObj.maxHealth;
|
||||
if (curHpIndex <= hpIndex.Value)
|
||||
{
|
||||
EnemyObj.userSillIng = false;
|
||||
}
|
||||
var isUserIng = EnemyObj.userSillIng;
|
||||
if (isUserIng) return TaskStatus.Running;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossIsUserSkill : Conditional
|
||||
{
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
if(curEnemy.userSillIng)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossIsAttackState : Conditional
|
||||
{
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
if(curEnemy.isAttack)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossIsQteAttack : Conditional
|
||||
{
|
||||
public SharedBool isQteAttack;
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if(isQteAttack.Value)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class WaitAllPetDie : Action
|
||||
{
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if (GameManager.Ins.IsAllBossPetDie())
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
if (curEnemy)
|
||||
{
|
||||
curEnemy.isShield = false;
|
||||
curEnemy.shieldObj.SetActive(false);
|
||||
}
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
public class IsBossGunDie : Conditional
|
||||
{
|
||||
public SharedString GunIdStr;
|
||||
|
||||
private List<int> gunIdList;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
gunIdList=new List<int>();
|
||||
string[] str=GunIdStr.Value.Split(',');
|
||||
foreach (var item in str)
|
||||
{
|
||||
gunIdList.Add(int.Parse(item));
|
||||
}
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
foreach (var id in gunIdList)
|
||||
{
|
||||
if (curEnemy.components[id] != null && !curEnemy.components[id].isDead)
|
||||
{
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossQteAttack : Action
|
||||
{
|
||||
private Enemy _curEnemy;
|
||||
|
||||
public float QteTime;
|
||||
public SharedBool IsQteAttacked;
|
||||
public SharedBool IsStopQteAttacked;
|
||||
private float _currentQteTime;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
//QteTime = 5;
|
||||
_curEnemy = GetComponent<Enemy>();
|
||||
if (_curEnemy)
|
||||
{
|
||||
IsQteAttacked.Value = false;
|
||||
_curEnemy.StartQteAttack();
|
||||
}
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
_currentQteTime += Time.deltaTime;
|
||||
if (_curEnemy.components[^1] != null && _curEnemy.components[^1].isDead)
|
||||
{
|
||||
IsStopQteAttacked.Value =true;
|
||||
_curEnemy.StopQteAttack();
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
if (_currentQteTime >= QteTime)
|
||||
{
|
||||
IsStopQteAttacked.Value =false;
|
||||
_curEnemy.ThreeAttackMode();
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
public class CooldownTick : Action
|
||||
{
|
||||
public SharedFloat cooldownTimer;
|
||||
public SharedBool skillReady;
|
||||
|
||||
public SharedFloat hp;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
var curHpIndex = curEnemy.health/curEnemy.maxHealth;
|
||||
if (curHpIndex <= hp.Value)
|
||||
{
|
||||
skillReady.Value = false;
|
||||
cooldownTimer.Value = 15;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
if (cooldownTimer.Value > 0f) {
|
||||
cooldownTimer.Value -= Time.deltaTime;
|
||||
if (cooldownTimer.Value <= 0f) {
|
||||
cooldownTimer.Value = 0f;
|
||||
skillReady.Value = true;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
}
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
public class ReleaseSkill : Action
|
||||
{
|
||||
public SharedFloat cooldownTimer;
|
||||
public SharedBool skillReady;
|
||||
public float skillCooldown = 15f;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
// 进入冷却
|
||||
cooldownTimer.Value = skillCooldown;
|
||||
skillReady.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
public class NormalAttack : Action
|
||||
{
|
||||
private Enemy1 enemy;
|
||||
public SharedFloat hpIndex;
|
||||
|
||||
public override void OnAwake()
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
enemy = GetComponent<Enemy1>();
|
||||
var curHpIndex = transform.GetComponent<Enemy>().health / transform.GetComponent<Enemy>().maxHealth;
|
||||
if (curHpIndex <= hpIndex.Value)
|
||||
{
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
public class UserSkill : Action
|
||||
{
|
||||
public Enemy EnemyObj;
|
||||
public SharedFloat hpIndex;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
EnemyObj = transform.GetComponent<Enemy>();
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if (EnemyObj == null)
|
||||
return TaskStatus.Failure;
|
||||
var curHpIndex = EnemyObj.health / EnemyObj.maxHealth;
|
||||
if (curHpIndex <= hpIndex.Value)
|
||||
{
|
||||
EnemyObj.userSillIng = false;
|
||||
}
|
||||
var isUserIng = EnemyObj.userSillIng;
|
||||
if (isUserIng) return TaskStatus.Running;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossIsUserSkill : Conditional
|
||||
{
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
if (curEnemy.userSillIng)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossIsAttackState : Conditional
|
||||
{
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
if (curEnemy.isAttack)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossIsQteAttack : Conditional
|
||||
{
|
||||
public SharedBool isQteAttack;
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if (isQteAttack.Value)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class WaitAllPetDie : Action
|
||||
{
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if (GameManager.Ins.IsAllBossPetDie())
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
if (curEnemy)
|
||||
{
|
||||
curEnemy.isShield = false;
|
||||
curEnemy.shieldObj.SetActive(false);
|
||||
}
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
public class IsBossGunDie : Conditional
|
||||
{
|
||||
public SharedString GunIdStr;
|
||||
|
||||
private List<int> gunIdList;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
gunIdList = new List<int>();
|
||||
string[] str = GunIdStr.Value.Split(',');
|
||||
foreach (var item in str)
|
||||
{
|
||||
gunIdList.Add(int.Parse(item));
|
||||
}
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
foreach (var id in gunIdList)
|
||||
{
|
||||
if (curEnemy.components[id] != null && !curEnemy.components[id].isDead)
|
||||
{
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public class BossQteAttack : Action
|
||||
{
|
||||
private Enemy _curEnemy;
|
||||
|
||||
public float QteTime;
|
||||
public SharedBool IsQteAttacked;
|
||||
public SharedBool IsStopQteAttacked;
|
||||
private float _currentQteTime;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
//QteTime = 5;
|
||||
_curEnemy = GetComponent<Enemy>();
|
||||
if (_curEnemy)
|
||||
{
|
||||
IsQteAttacked.Value = false;
|
||||
_curEnemy.StartQteAttack();
|
||||
}
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
_currentQteTime += Time.deltaTime;
|
||||
if (_curEnemy.components[^1] != null && _curEnemy.components[^1].isDead)
|
||||
{
|
||||
IsStopQteAttacked.Value = true;
|
||||
_curEnemy.StopQteAttack();
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
if (_currentQteTime >= QteTime)
|
||||
{
|
||||
IsStopQteAttacked.Value = false;
|
||||
_curEnemy.ThreeAttackMode();
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
public class CooldownTick : Action
|
||||
{
|
||||
public SharedFloat cooldownTimer;
|
||||
public SharedBool skillReady;
|
||||
|
||||
public SharedFloat hp;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
var curHpIndex = curEnemy.health / curEnemy.maxHealth;
|
||||
if (curHpIndex <= hp.Value)
|
||||
{
|
||||
skillReady.Value = false;
|
||||
cooldownTimer.Value = 15;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
if (cooldownTimer.Value > 0f)
|
||||
{
|
||||
cooldownTimer.Value -= Time.deltaTime;
|
||||
if (cooldownTimer.Value <= 0f)
|
||||
{
|
||||
cooldownTimer.Value = 0f;
|
||||
skillReady.Value = true;
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
}
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
public class ReleaseSkill : Action
|
||||
{
|
||||
public SharedFloat cooldownTimer;
|
||||
public SharedBool skillReady;
|
||||
public float skillCooldown = 15f;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
//// 你的普攻逻辑
|
||||
//Debug.Log("执行普攻");
|
||||
//Enemy curEnemy = GetComponent<Enemy>();
|
||||
//curEnemy.Attack();
|
||||
if(enemy != null && !enemy.isAttack)
|
||||
{
|
||||
enemy.Attack();
|
||||
}
|
||||
base.OnStart();
|
||||
// 进入冷却
|
||||
cooldownTimer.Value = skillCooldown;
|
||||
skillReady.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
public class IsSkillReady : Conditional
|
||||
|
||||
public class NormalAttack : Action
|
||||
{
|
||||
public override void OnStart()
|
||||
{
|
||||
public SharedBool skillReady;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
return skillReady.Value ? TaskStatus.Success : TaskStatus.Failure;
|
||||
}
|
||||
// 你的普攻逻辑
|
||||
Debug.Log("执行普攻");
|
||||
Enemy curEnemy = GetComponent<Enemy>();
|
||||
curEnemy.Attack();
|
||||
}
|
||||
}
|
||||
|
||||
public class ConditionalStopQte : Conditional
|
||||
public class IsSkillReady : Conditional
|
||||
{
|
||||
public SharedBool skillReady;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
public SharedBool IsStopQteAttack;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if(!IsStopQteAttack.Value)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
return skillReady.Value ? TaskStatus.Success : TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
public class ConditionalStopQte : Conditional
|
||||
{
|
||||
public SharedBool IsStopQteAttack;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if (!IsStopQteAttack.Value)
|
||||
return TaskStatus.Success;
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class Enemy : MonoBehaviour
|
||||
|
||||
public bool userSillIng;
|
||||
|
||||
public bool isAttack { get; set; }
|
||||
public bool isAttack;
|
||||
|
||||
public EnemyComponent[] components;
|
||||
|
||||
@@ -98,14 +98,14 @@ public class Enemy : MonoBehaviour
|
||||
public GameObject shieldObj;
|
||||
|
||||
public bool isBoss;
|
||||
|
||||
|
||||
public bool isShield;//是否是无敌
|
||||
|
||||
|
||||
public bool isShield = false;//是否是无敌
|
||||
|
||||
public float dieTime;
|
||||
|
||||
private EnemyData _info;
|
||||
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
InitAnimator();
|
||||
@@ -139,12 +139,12 @@ public class Enemy : MonoBehaviour
|
||||
|
||||
public virtual void Attack()
|
||||
{
|
||||
isAttack = true;
|
||||
|
||||
}
|
||||
|
||||
public virtual void StopAttack()
|
||||
{
|
||||
isAttack=false;
|
||||
|
||||
}
|
||||
|
||||
public virtual void OneAttackMode()
|
||||
|
||||
@@ -5,7 +5,6 @@ using BehaviorDesigner.Runtime;
|
||||
using DG.Tweening;
|
||||
using DragonLi.Behaviour;
|
||||
using DragonLi.Frame;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
@@ -17,9 +16,6 @@ public class Enemy1 : Enemy
|
||||
|
||||
private bool _isShow;
|
||||
|
||||
//控制攻击状态变量
|
||||
private bool shouldAttack = false;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@@ -68,16 +64,6 @@ public class Enemy1 : Enemy
|
||||
isShield = false;
|
||||
transform.LookAt(new Vector3(playerPos.position.x, transform.position.y, playerPos.position.z));
|
||||
|
||||
//移除距离判断,直接根据攻击状态决定是否攻击
|
||||
if (shouldAttack)
|
||||
{
|
||||
ShotGun();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAttackState(bool attack)
|
||||
{
|
||||
shouldAttack = attack;
|
||||
}
|
||||
|
||||
public override void Dead()
|
||||
|
||||
@@ -15,21 +15,21 @@ using Random = UnityEngine.Random;
|
||||
/// </summary>
|
||||
public enum GamePlace
|
||||
{
|
||||
Test=-1,
|
||||
Company1Floor=0,
|
||||
LiaoningAnShan=1,
|
||||
HangZhouLongHuTianJie=2,
|
||||
Nanjing_Yuhua_Wanxiang=3,
|
||||
Nanjing_Xianlin_WanDaMao=4,
|
||||
Yangzhou_Hanjiang_Tansuozhongxin=5,
|
||||
Yangzhou_Hanjiang_TansuoZhongxin_wai=-5,
|
||||
Zhejiang_Jinhua_KeJiGuan=6,
|
||||
Guangzhou_Panyv_Zhanting=7,
|
||||
Anhui_Wuhu_Guanwei=8,
|
||||
Shandong_Jining_Shangchang = 9 ,
|
||||
Shandong_Jining_Shangchang_nei=-9,
|
||||
ShanDong_Langfang_QingzhouTaihuacheng =10,
|
||||
Hubei_Xiangyang_Kejiguan=11,
|
||||
Test = -1,
|
||||
Company1Floor = 0,
|
||||
LiaoningAnShan = 1,
|
||||
HangZhouLongHuTianJie = 2,
|
||||
Nanjing_Yuhua_Wanxiang = 3,
|
||||
Nanjing_Xianlin_WanDaMao = 4,
|
||||
Yangzhou_Hanjiang_Tansuozhongxin = 5,
|
||||
Yangzhou_Hanjiang_TansuoZhongxin_wai = -5,
|
||||
Zhejiang_Jinhua_KeJiGuan = 6,
|
||||
Guangzhou_Panyv_Zhanting = 7,
|
||||
Anhui_Wuhu_Guanwei = 8,
|
||||
Shandong_Jining_Shangchang = 9,
|
||||
Shandong_Jining_Shangchang_nei = -9,
|
||||
ShanDong_Langfang_QingzhouTaihuacheng = 10,
|
||||
Hubei_Xiangyang_Kejiguan = 11,
|
||||
}
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
@@ -41,35 +41,35 @@ public class GameManager : MonoBehaviour
|
||||
public bool isTimeEnd = true;
|
||||
// json数据库
|
||||
private JsonLiteDB DB;
|
||||
|
||||
|
||||
// Enemy子弹数据
|
||||
public Dictionary<int, BulletData> EnemyBulletDataDic = new Dictionary<int, BulletData>();
|
||||
|
||||
|
||||
// Player子弹数据
|
||||
public Dictionary<int, BulletData> PlayerBulletDataDic = new Dictionary<int, BulletData>();
|
||||
|
||||
|
||||
public Dictionary<int, PropData> PropDataDic = new Dictionary<int, PropData>();
|
||||
|
||||
public Dictionary<int,BossPosData> BossPosDataDic = new Dictionary<int, BossPosData>();
|
||||
|
||||
|
||||
public List<Enemy> curEnemyList=new List<Enemy>();
|
||||
|
||||
public Dictionary<int, BossPosData> BossPosDataDic = new Dictionary<int, BossPosData>();
|
||||
|
||||
|
||||
public List<Enemy> curEnemyList = new List<Enemy>();
|
||||
public Dictionary<int, EnemyData> EnemyDataDic = new Dictionary<int, EnemyData>();
|
||||
|
||||
|
||||
[Header("道具")]
|
||||
public GameObject EnergyPumpPre;
|
||||
public GameObject gameStartPointPre;
|
||||
public GameObject enemyDoorPre;
|
||||
|
||||
[Header("敌人")]
|
||||
[Header("敌人")]
|
||||
public GameObject[] enemyPre;
|
||||
|
||||
public GameObject callEffectPre;//召唤特效
|
||||
|
||||
[Header("玩家")]
|
||||
[Header("玩家")]
|
||||
public GameObject playerPre;
|
||||
public GameObject player;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 血包
|
||||
/// </summary>
|
||||
@@ -88,7 +88,7 @@ public class GameManager : MonoBehaviour
|
||||
public bool GameStart = false;
|
||||
|
||||
public bool isGameEnd = false;
|
||||
|
||||
|
||||
public int EnergyPumpTag = 0;
|
||||
|
||||
public float EnergyPumpFillAmount = 0;
|
||||
@@ -97,13 +97,13 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
public float buffAtk = 0f;
|
||||
public float buffDef = 0f;
|
||||
|
||||
public LoginInfo loginInfo=new LoginInfo();
|
||||
|
||||
|
||||
public LoginInfo loginInfo = new LoginInfo();
|
||||
|
||||
public Enemy curBoss;
|
||||
|
||||
public int curLevel = 0;
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Ins = this;
|
||||
@@ -147,14 +147,14 @@ public class GameManager : MonoBehaviour
|
||||
request.AddHeader("Content-Type", "application/json");
|
||||
request.Send();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新配置表
|
||||
/// </summary>
|
||||
public void InitData()
|
||||
{
|
||||
string text = "";
|
||||
string text0 = Resources.Load<TextAsset>(string.Format("zh/{0}Data",GameInit.Ins.gamePlace)).text;
|
||||
string text0 = Resources.Load<TextAsset>(string.Format("zh/{0}Data", GameInit.Ins.gamePlace)).text;
|
||||
GetReaderJson(text0);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class GameManager : MonoBehaviour
|
||||
DateTime dateTime = DateTimeOffset.FromUnixTimeSeconds(timestamp).DateTime;
|
||||
return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
|
||||
public void GetReaderJson(string text)
|
||||
{
|
||||
DB = new JsonLiteDB();
|
||||
@@ -178,23 +178,23 @@ public class GameManager : MonoBehaviour
|
||||
EnemyData info = new EnemyData(infoReader);
|
||||
EnemyDataDic.Add(info.Id, info);
|
||||
}
|
||||
|
||||
|
||||
// 敌人子弹数据
|
||||
TableReader EnemyBulletReader = DB["EnemyBulletData"].GetReader();
|
||||
EnemyBulletDataDic.Clear();
|
||||
while (EnemyBulletReader.Read())
|
||||
{
|
||||
BulletData data = new BulletData(EnemyBulletReader);
|
||||
EnemyBulletDataDic.Add(data.ID,data);
|
||||
EnemyBulletDataDic.Add(data.ID, data);
|
||||
}
|
||||
|
||||
|
||||
// 玩家子弹数据
|
||||
TableReader PlayerBulletReader = DB["PlayerBulletData"].GetReader();
|
||||
PlayerBulletDataDic.Clear();
|
||||
while (PlayerBulletReader.Read())
|
||||
{
|
||||
BulletData data = new BulletData(PlayerBulletReader);
|
||||
PlayerBulletDataDic.Add(data.ID,data);
|
||||
PlayerBulletDataDic.Add(data.ID, data);
|
||||
}
|
||||
|
||||
// 道具表
|
||||
@@ -203,26 +203,26 @@ public class GameManager : MonoBehaviour
|
||||
while (PropReader.Read())
|
||||
{
|
||||
PropData data = new PropData(PropReader);
|
||||
PropDataDic.Add(data.PropId,data);
|
||||
PropDataDic.Add(data.PropId, data);
|
||||
}
|
||||
|
||||
|
||||
// Boss位置
|
||||
TableReader BossPosReader = DB["BossPosData"].GetReader();
|
||||
BossPosDataDic.Clear();
|
||||
while (BossPosReader.Read())
|
||||
{
|
||||
BossPosData data = new BossPosData(BossPosReader);
|
||||
BossPosDataDic.Add(data.ID,data);
|
||||
BossPosDataDic.Add(data.ID, data);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get sn
|
||||
/// </summary>
|
||||
public string GetPicoSn()
|
||||
public string GetPicoSn()
|
||||
{
|
||||
string res = "UnityEditor";
|
||||
|
||||
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
||||
res = PXR_Enterprise.StateGetDeviceInfo(SystemInfoEnum.EQUIPMENT_SN);
|
||||
#endif
|
||||
@@ -257,9 +257,9 @@ public class GameManager : MonoBehaviour
|
||||
CurEnemyDie();
|
||||
GameEndPanel.Show(isWin);
|
||||
}
|
||||
public GameObject CreateEnemy(int id,Vector3 pos,Vector3 eulerAngles,bool isBoss)
|
||||
public GameObject CreateEnemy(int id, Vector3 pos, Vector3 eulerAngles, bool isBoss)
|
||||
{
|
||||
GameObject go=Instantiate(enemyPre[id],pos,Quaternion.identity);
|
||||
GameObject go = Instantiate(enemyPre[id], pos, Quaternion.identity);
|
||||
go.transform.localEulerAngles = eulerAngles;
|
||||
Enemy enemy = go.GetComponent<Enemy>();
|
||||
enemy.Init();
|
||||
@@ -269,58 +269,58 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
curEnemyList.Add(enemy);
|
||||
}
|
||||
curEnemyList.Add(enemy);
|
||||
}
|
||||
return go;
|
||||
}
|
||||
|
||||
public GameObject CreateCallEnemyEffect(Vector3 pos)
|
||||
{
|
||||
GameObject go=Instantiate(callEffectPre,pos,quaternion.identity);
|
||||
GameObject go = Instantiate(callEffectPre, pos, quaternion.identity);
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
Destroy(go);
|
||||
},3f);
|
||||
}, 3f);
|
||||
return go;
|
||||
}
|
||||
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
PXR_Enterprise.UnBindEnterpriseService();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public void CreateEnergyPump(Vector3 pos)
|
||||
{
|
||||
isGamePlay = false;
|
||||
GameObject EnergyPump = Instantiate(EnergyPumpPre);
|
||||
//EnergyPump.transform.position = pos;
|
||||
EnergyPump.transform.position = new Vector3(2,0,2);
|
||||
EnergyPump.transform.position = new Vector3(2, 0, 2);
|
||||
if (GameInit.Ins.gamePlace == GamePlace.Nanjing_Xianlin_WanDaMao)
|
||||
{
|
||||
EnergyPump.transform.position = new Vector3(-1.2f,0,1.5f);
|
||||
EnergyPump.transform.position = new Vector3(-1.2f, 0, 1.5f);
|
||||
}
|
||||
if (GameInit.Ins.gamePlace == GamePlace.Nanjing_Yuhua_Wanxiang)
|
||||
{
|
||||
EnergyPump.transform.position = new Vector3(-3,0,2);
|
||||
EnergyPump.transform.position = new Vector3(-3, 0, 2);
|
||||
}
|
||||
if (GameInit.Ins.gamePlace == GamePlace.Yangzhou_Hanjiang_Tansuozhongxin)
|
||||
{
|
||||
EnergyPump.transform.position = new Vector3(-1.2f,0,0f);
|
||||
EnergyPump.transform.position = new Vector3(-1.2f, 0, 0f);
|
||||
}
|
||||
if (GameInit.Ins.gamePlace == GamePlace.Yangzhou_Hanjiang_TansuoZhongxin_wai)
|
||||
{
|
||||
EnergyPump.transform.position = new Vector3(0,0,2f);
|
||||
EnergyPump.transform.position = new Vector3(0, 0, 2f);
|
||||
}
|
||||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Jinhua_KeJiGuan)
|
||||
{
|
||||
EnergyPump.transform.position = new Vector3(0,0,2f);
|
||||
EnergyPump.transform.position = new Vector3(0, 0, 2f);
|
||||
}
|
||||
if (GameInit.Ins.gamePlace == GamePlace.Guangzhou_Panyv_Zhanting)
|
||||
{
|
||||
EnergyPump.transform.position = new Vector3(0,0,2f);
|
||||
EnergyPump.transform.position = new Vector3(0, 0, 2f);
|
||||
}
|
||||
if (GameInit.Ins.gamePlace == GamePlace.ShanDong_Langfang_QingzhouTaihuacheng)
|
||||
{
|
||||
@@ -348,16 +348,16 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
point.transform.position = Vector3.zero;
|
||||
}
|
||||
|
||||
|
||||
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
if(isGamePlay)
|
||||
if (isGamePlay)
|
||||
return;
|
||||
Destroy(point.gameObject);
|
||||
GamePlay();
|
||||
}, 5f);
|
||||
}
|
||||
public GameObject CreateEnemyDoor(Vector3 pos, Vector3 angle,Vector3 scale)
|
||||
public GameObject CreateEnemyDoor(Vector3 pos, Vector3 angle, Vector3 scale)
|
||||
{
|
||||
GameObject crack = Instantiate(enemyDoorPre);
|
||||
crack.transform.position = new Vector3(pos.x, pos.y, pos.z);
|
||||
@@ -375,7 +375,7 @@ public class GameManager : MonoBehaviour
|
||||
GameObject atkBuff = Instantiate(AtkBuffPre);
|
||||
atkBuff.transform.position = new Vector3(pos.x, 0, pos.z);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建防御BUFF
|
||||
/// </summary>
|
||||
@@ -402,28 +402,28 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
GameObject prop = Instantiate(weaponItemPre);
|
||||
prop.GetComponent<WeaponProp>().Init(type);
|
||||
prop.transform.position = new Vector3(pos.x,1f,pos.z);
|
||||
prop.transform.position = new Vector3(pos.x, 1f, pos.z);
|
||||
}
|
||||
|
||||
|
||||
public bool isFirstGetWeapon;
|
||||
public void EnemyDisGetWeapon(Vector3 pos)
|
||||
{
|
||||
|
||||
|
||||
bool isGet = Random.Range(0, 100) > 70;
|
||||
if (!isGet) return;
|
||||
|
||||
|
||||
int index = Random.Range(0, 100);
|
||||
int id = 2;
|
||||
if (index <= 10)
|
||||
id = Random.Range(8, 10);
|
||||
if(index is > 10 and <= 50)
|
||||
id= Random.Range(5, 8);
|
||||
if(index is > 50)
|
||||
id= Random.Range(2, 5);
|
||||
if (index is > 10 and <= 50)
|
||||
id = Random.Range(5, 8);
|
||||
if (index is > 50)
|
||||
id = Random.Range(2, 5);
|
||||
CreatePlayerWeapon((PlayerWeaponType)id, pos);
|
||||
if (!isFirstGetWeapon)
|
||||
{
|
||||
GameInit.Ins.PlayAudio("1.5",GameInit.Ins.self.transform,true);
|
||||
GameInit.Ins.PlayAudio("1.5", GameInit.Ins.self.transform, true);
|
||||
isFirstGetWeapon = true;
|
||||
}
|
||||
}
|
||||
@@ -432,7 +432,7 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
foreach (var enemy in curEnemyList)
|
||||
{
|
||||
if(enemy!=null)
|
||||
if (enemy != null)
|
||||
enemy.Dead();
|
||||
}
|
||||
curEnemyList.Clear();
|
||||
@@ -443,7 +443,7 @@ public class GameManager : MonoBehaviour
|
||||
int count = 0;
|
||||
foreach (var enemy in curEnemyList)
|
||||
{
|
||||
if(enemy!=null)
|
||||
if (enemy != null)
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
public void CreatePlayer()
|
||||
{
|
||||
player=Instantiate(playerPre);
|
||||
player = Instantiate(playerPre);
|
||||
}
|
||||
|
||||
public bool IsAllBossPetDie()
|
||||
@@ -477,57 +477,57 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
BossPosData data = BossPosDataDic[curLevel];
|
||||
GameObject door = null;
|
||||
if(curLevel!=0)
|
||||
door=CreateEnemyDoor(data.DoorPos, data.DoorAng,Vector3.one*data.DoorScale);
|
||||
if (curLevel != 0)
|
||||
door = CreateEnemyDoor(data.DoorPos, data.DoorAng, Vector3.one * data.DoorScale);
|
||||
switch (curLevel)
|
||||
{
|
||||
case 0:
|
||||
CreateEnemy(0, data.BossPos, Vector3.zero,true);
|
||||
CreateEnemy(0, data.BossPos, Vector3.zero, true);
|
||||
break;
|
||||
case 1:
|
||||
//舰载机
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
door.GetComponent<EnemyDoor>().desTime = 6;
|
||||
door.GetComponent<EnemyDoor>().InitData();
|
||||
},1f);
|
||||
door.GetComponent<EnemyDoor>().desTime = 6;
|
||||
door.GetComponent<EnemyDoor>().InitData();
|
||||
}, 1f);
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
CreateEnemy(2, data.BossPos,data.BossAng,true);
|
||||
},3f);
|
||||
CreateEnemy(2, data.BossPos, data.BossAng, true);
|
||||
}, 3f);
|
||||
break;
|
||||
case 2:
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
door.GetComponent<EnemyDoor>().desTime = 10;
|
||||
door.GetComponent<EnemyDoor>().InitData();
|
||||
},1f);
|
||||
}, 1f);
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
CreateEnemy(3, data.BossPos,data.BossAng,true);
|
||||
},3f);
|
||||
CreateEnemy(3, data.BossPos, data.BossAng, true);
|
||||
}, 3f);
|
||||
break;
|
||||
case 3:
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
door.GetComponent<EnemyDoor>().desTime = 10;
|
||||
door.GetComponent<EnemyDoor>().InitData();
|
||||
},1f);
|
||||
}, 1f);
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
CreateEnemy(5, data.BossPos,data.BossAng,true);
|
||||
},3f);
|
||||
CreateEnemy(5, data.BossPos, data.BossAng, true);
|
||||
}, 3f);
|
||||
break;
|
||||
case 4:
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
door.GetComponent<EnemyDoor>().desTime = 6;
|
||||
door.GetComponent<EnemyDoor>().InitData();
|
||||
},1f);
|
||||
}, 1f);
|
||||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||||
{
|
||||
CreateEnemy(7, data.BossPos,data.BossAng,true);
|
||||
},1f);
|
||||
CreateEnemy(7, data.BossPos, data.BossAng, true);
|
||||
}, 1f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -536,7 +536,7 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
isGameEnd = true;
|
||||
ShowEndGameUI(true);
|
||||
GameInit.Ins.PlayAudio("1.17",GameInit.Ins.self.transform,true);
|
||||
GameInit.Ins.PlayAudio("1.17", GameInit.Ins.self.transform, true);
|
||||
AudioManager.Ins?.SoundPlay("bgm4", true);
|
||||
}
|
||||
|
||||
@@ -554,4 +554,4 @@ public class GameManager : MonoBehaviour
|
||||
CurEnemyDie();
|
||||
AudioManager.Ins?.SoundPlay("bgm4", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user