|
|
@@ -1,7 +1,9 @@
|
|
|
+using GFMain;
|
|
|
using Mirror;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using UnityCommon;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.AI;
|
|
|
@@ -28,9 +30,11 @@ namespace DTYJ
|
|
|
NetworkServer.Destroy(ck);
|
|
|
});
|
|
|
listChengKeChuZhan.Clear();
|
|
|
+ maxCount_ChuZhan = 0;
|
|
|
|
|
|
RenShuTrigger.dicCount["站台"] = 0;
|
|
|
RenShuTrigger.dicCount["站厅"] = 0;
|
|
|
+ personTotalCount = 0;
|
|
|
}
|
|
|
[Server]
|
|
|
public void GenerateImmidiately(int count)
|
|
|
@@ -47,8 +51,22 @@ namespace DTYJ
|
|
|
else if (listChengKeJinZhan.Contains(go))
|
|
|
{
|
|
|
listChengKeJinZhan.Remove(go);
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < listQueue.Count; ++i)
|
|
|
+ {
|
|
|
+ if (listQueue[i].Contains(go))
|
|
|
+ {
|
|
|
+ listQueue[i].Remove(go);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
NetworkServer.Destroy(go);
|
|
|
+ personTotalCount--;
|
|
|
+ if (personTotalCount < 0)
|
|
|
+ {
|
|
|
+ personTotalCount = 0;
|
|
|
+ }
|
|
|
}
|
|
|
Dictionary<string, List<GameObject>> dicCkInTrain = new Dictionary<string, List<GameObject>>();
|
|
|
public void SetCKInTrain(string trainNo, GameObject goCk)
|
|
|
@@ -71,6 +89,22 @@ namespace DTYJ
|
|
|
}
|
|
|
//UpdateCKPosition();
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 设置进站未上车的乘客出站
|
|
|
+ /// </summary>
|
|
|
+ public void SetCKChuZhan(int exitPort)
|
|
|
+ {
|
|
|
+ foreach (var item in listChengKeJinZhan)
|
|
|
+ {
|
|
|
+ var targetP = exitPort == 1 ? GetSpawnPoint_ChuZhan_target_1() : GetSpawnPoint_ChuZhan_target_2();
|
|
|
+ item.GetComponent<NavMeshAgent>().SetDestination(targetP.position);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < listQueue.Count; ++i)
|
|
|
+ {
|
|
|
+ listQueue[i].Clear();
|
|
|
+ }
|
|
|
+ cursor = -1;
|
|
|
+ }
|
|
|
public void GenerateInTrain(string trainNo)
|
|
|
{
|
|
|
if (TrainCtrl.TrainCtrlDic.ContainsKey(trainNo))
|
|
|
@@ -80,7 +114,7 @@ namespace DTYJ
|
|
|
for (int i = 0; i < points.Count; ++i)
|
|
|
{
|
|
|
var tfOrg = points[i];
|
|
|
- var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg);
|
|
|
+ var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg, $"列车角色{i}");
|
|
|
goNew.name = "Train" + trainNo;
|
|
|
var agent = goNew.GetComponent<NavMeshAgent>();
|
|
|
agent.enabled = false;
|
|
|
@@ -95,6 +129,17 @@ namespace DTYJ
|
|
|
dicCkInTrain[trainNo].Remove(goCk);
|
|
|
}
|
|
|
}
|
|
|
+ public void ClearCkInTrain()
|
|
|
+ {
|
|
|
+ foreach (var k in dicCkInTrain.Values)
|
|
|
+ {
|
|
|
+ foreach (var v in k)
|
|
|
+ {
|
|
|
+ RemoveCK(v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dicCkInTrain.Clear();
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 上车
|
|
|
@@ -141,7 +186,7 @@ namespace DTYJ
|
|
|
{//延时两秒 等车门打开
|
|
|
var xiacheCount = dicCkInTrain[trainNo].Count * 0.6f;
|
|
|
|
|
|
- var targetP = GetSpawnPoint_ChuZhan_target();
|
|
|
+ var targetP = GetSpawnPoint_ChuZhan_target_1();
|
|
|
for (int i = 0; i < xiacheCount; ++i)
|
|
|
{
|
|
|
dicCkInTrain[trainNo][i].GetComponent<NavMeshAgent>().SetDestination(targetP.position);
|
|
|
@@ -153,8 +198,9 @@ namespace DTYJ
|
|
|
private Transform tfSpawnPointRoot;
|
|
|
private Transform tfSpawnPointRoot_chuzhan;//出站出生点
|
|
|
private Transform tfSpawnPointRoot_chuzhan_target;//出站目标点
|
|
|
+ private Transform tfSpawnPointRoot_chuzhan_target_2;//出站目标点
|
|
|
private Transform tfSpawnPointRoot_zhanting;//站厅
|
|
|
- public int maxCount = 5000;
|
|
|
+ public int maxCount = 50000;
|
|
|
public int maxCount_ChuZhan = 50;
|
|
|
public ChengKeCtrl()
|
|
|
{
|
|
|
@@ -162,9 +208,10 @@ namespace DTYJ
|
|
|
tfSpawnPointRoot = GameObject.Find("角色默认位置/乘客位置/进站出生点/2号口").transform;
|
|
|
tfSpawnPointRoot_chuzhan = GameObject.Find("角色默认位置/乘客位置/出站出生点").transform;
|
|
|
tfSpawnPointRoot_chuzhan_target = GameObject.Find("角色默认位置/乘客位置/出站目标点").transform;
|
|
|
+ tfSpawnPointRoot_chuzhan_target_2 = GameObject.Find("角色默认位置/乘客位置/出站目标点_2").transform;
|
|
|
tfSpawnPointRoot_zhanting = GameObject.Find("角色默认位置/乘客位置/站厅").transform;
|
|
|
var points = tfRoot.GetComponentsInChildren<Transform>();
|
|
|
- listPoints_zhantai.AddRange(points);
|
|
|
+ listPoints_zhantai.AddRange(points.Skip(1).ToArray());
|
|
|
for (int i = 0; i < listPoints_zhantai.Count; i++)
|
|
|
{
|
|
|
listQueue.Add(new List<GameObject>());
|
|
|
@@ -209,10 +256,14 @@ namespace DTYJ
|
|
|
{
|
|
|
return tfSpawnPointRoot_chuzhan.GetChild(UnityEngine.Random.Range(0, tfSpawnPointRoot_chuzhan.childCount));
|
|
|
}
|
|
|
- private Transform GetSpawnPoint_ChuZhan_target()
|
|
|
+ private Transform GetSpawnPoint_ChuZhan_target_1()
|
|
|
{
|
|
|
return tfSpawnPointRoot_chuzhan_target.GetChild(UnityEngine.Random.Range(0, tfSpawnPointRoot_chuzhan_target.childCount));
|
|
|
}
|
|
|
+ private Transform GetSpawnPoint_ChuZhan_target_2()
|
|
|
+ {
|
|
|
+ return tfSpawnPointRoot_chuzhan_target_2.GetChild(UnityEngine.Random.Range(0, tfSpawnPointRoot_chuzhan_target_2.childCount));
|
|
|
+ }
|
|
|
|
|
|
public void StartProgress()
|
|
|
{
|
|
|
@@ -237,6 +288,10 @@ namespace DTYJ
|
|
|
countPerSec_chuzhan -= count_chuzhan;//小数部分
|
|
|
if (UnityEngine.Random.Range(0, 1f) < countPerSec_chuzhan)
|
|
|
GenereatePerson_ChuZhan(1);
|
|
|
+
|
|
|
+ float soundValue = personTotalCount / 300f;
|
|
|
+ soundValue = Mathf.Clamp(soundValue, 0f, 1f);
|
|
|
+ ControllerPanel.instance.RpcSetSoundValue(Mathf.Clamp(soundValue, 0f, 1f));
|
|
|
}
|
|
|
private int personTotalCount = 0;
|
|
|
private int personTotalCount_chuzhan = 0;
|
|
|
@@ -259,8 +314,8 @@ namespace DTYJ
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
var tfOrg = GetSpawnPoint();
|
|
|
- var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg);
|
|
|
- goNew.name = "GenereatePerson";
|
|
|
+ var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg, $"进站角色{i}");
|
|
|
+ //goNew.name = "GenereatePerson";
|
|
|
var nowCursor = cursorMoveNext;
|
|
|
listQueue[nowCursor].Add(goNew);
|
|
|
var agent = goNew.GetComponent<NavMeshAgent>();
|
|
|
@@ -280,7 +335,7 @@ namespace DTYJ
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
var tfOrg = tfSpawnPointRoot_zhanting.GetChild(i);// GetSpawnPoint();
|
|
|
- var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg);
|
|
|
+ var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg, $"立即生成角色{i}");
|
|
|
goNew.name = "GenereatePerson_immidiately";
|
|
|
var nowCursor = cursorMoveNext;
|
|
|
listQueue[nowCursor].Add(goNew);
|
|
|
@@ -301,7 +356,7 @@ namespace DTYJ
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
var tfOrg = GetSpawnPoint_ChuZhan();
|
|
|
- var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg);
|
|
|
+ var goNew = OnlineCtrl.Instance.GenerateChengKe(GetRolePrefab(), tfOrg, $"出站角色{i}");
|
|
|
goNew.name = "GenereatePerson_ChuZhan";
|
|
|
var agent = goNew.GetComponent<NavMeshAgent>();
|
|
|
agent.Warp(tfOrg.position);
|
|
|
@@ -313,7 +368,7 @@ namespace DTYJ
|
|
|
};
|
|
|
listChengKeChuZhan.Add(goNew);
|
|
|
|
|
|
- var targetP = GetSpawnPoint_ChuZhan_target();
|
|
|
+ var targetP = GetSpawnPoint_ChuZhan_target_1();
|
|
|
agent.SetDestination(targetP.position);
|
|
|
++personTotalCount_chuzhan;
|
|
|
}
|
|
|
@@ -333,7 +388,7 @@ namespace DTYJ
|
|
|
/// <summary>
|
|
|
/// 每分钟进站人数
|
|
|
/// </summary>
|
|
|
- private float CountPerMin
|
|
|
+ public float CountPerMin
|
|
|
{
|
|
|
set
|
|
|
{
|