瀏覽代碼

功能逻辑

zhouhongyu 2 年之前
父節點
當前提交
92fbfae7ba

+ 66 - 11
3DModule/Assets/_DTYJ/Scripts/DaKeLiu/ChengKeCtrl.cs

@@ -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
             {

+ 1 - 1
3DModule/Assets/_DTYJ/Scripts/DaKeLiu/Chengke.cs

@@ -36,7 +36,7 @@ namespace DTYJ
         [ServerCallback]
         private void OnTriggerEnter(Collider other)
         {
-            if (other.name == "出站触发")
+            if (other.name == "出站触发"|| other.name == "出站触发_1")
             {
                 OnlineCtrl.Instance.chengKeCtrl.RemoveCK(gameObject);
             }

+ 7 - 5
3DModule/Assets/_DTYJ/Scripts/DaKeLiu/UIRenShuTongJi.cs

@@ -9,18 +9,20 @@ namespace DTYJ
     public class UIRenShuTongJi : MonoBehaviour
     {
         public Text text_zhantai, text_zhanting;
+        private Text textLabel;
         private void Start()
         {
+            textLabel = transform.Find("Image/Label").GetComponent<Text>();
             Utility.Update(2, () =>
             {
-                text_zhantai.text = (RenShuTrigger.dicCount["站台"] / 100f).ToString("#0.00");
-                text_zhanting.text = (RenShuTrigger.dicCount["站厅"] / 200f).ToString("#0.00");
-
+                text_zhantai.text = (RenShuTrigger.dicCount["站台"] / 500f).ToString("#0.00");
+                text_zhanting.text = (RenShuTrigger.dicCount["站厅"] / 700f).ToString("#0.00");
+                textLabel.text = $"乘客人数:{RenShuTrigger.dicCount["站台"] + RenShuTrigger.dicCount["站厅"]}";
 
                 var cmdObj = new KeLiu_opt();
                 cmdObj.kvp = new KeLiu_opt.Info[] {
-                    new KeLiu_opt.Info(){ postion = "站台", value =  RenShuTrigger.dicCount["站台"]/100f},
-                    new KeLiu_opt.Info(){ postion = "站厅 ", value =  RenShuTrigger.dicCount["站厅"]/200f}
+                    new KeLiu_opt.Info(){ postion = "站台", value =  RenShuTrigger.dicCount["站台"]/500f},
+                    new KeLiu_opt.Info(){ postion = "站厅 ", value =  RenShuTrigger.dicCount["站厅"]/700f}
                 };
 
                 NetworkAnimPlayer.instance?.SendCmdToServer(20501, cmdObj);

+ 1 - 1
3DModule/Assets/_DTYJ/Scripts/Data/DataModel.cs

@@ -283,7 +283,7 @@ namespace DTYJ
             /// </summary>
             public string postion;
             /// <summary>
-            /// ¿ÍÁ÷ ÈË/·ÖÖÓ
+            /// ¿ÍÁ÷ ÈË/ƽÃ×
             /// </summary>
             public float value;
         }

+ 1 - 0
3DModule/Assets/_DTYJ/Scripts/Online/Core/OnlineCtrl.Client.cs

@@ -122,6 +122,7 @@ namespace DTYJ
             mineRoleName = roleName;
             Main.Instance.uiMainMenu?.ClearPositionJump();
             Main.Instance.uiMainMenu?.InitPositionJump();
+            MainEntry.Sound.GetSoundGroup("GuangBo").Mute = false;
         }
 
         //        private void OnRoomList(RoomInfo[] roomInfos)

+ 2 - 1
3DModule/Assets/_DTYJ/Scripts/Online/Core/OnlineCtrl.Server.cs

@@ -148,9 +148,10 @@ namespace DTYJ
         }
 
         [Server]
-        public GameObject GenerateChengKe(GameObject prefab, Transform tfOriginal)
+        public GameObject GenerateChengKe(GameObject prefab, Transform tfOriginal, string roleName = null)
         {
             GameObject goCk = GameObject.Instantiate(prefab);
+            if (roleName != null) goCk.name = roleName;
             goCk.transform.position = tfOriginal.position;
             goCk.transform.rotation = tfOriginal.rotation;
             NetworkServer.Spawn(goCk);

+ 1 - 0
3DModule/Assets/_DTYJ/Scripts/Online/Network/OnlineNetworkManager.prefab

@@ -84,6 +84,7 @@ MonoBehaviour:
   - {fileID: 5755105735683557089, guid: 16cadddaa4f973b46924ded1987819c3, type: 3}
   - {fileID: 4288705241618932270, guid: 4a4def72f5dd23d47ac9c01ac59e9835, type: 3}
   - {fileID: 7163112414116571901, guid: ac2608ce1d6860e41b760099842d0493, type: 3}
+  - {fileID: 1586095880877352619, guid: f7cff2bca687fdc4782cfc954a2134ea, type: 3}
   snapshotSettings:
     bufferTimeMultiplier: 2
     bufferLimit: 32

+ 14 - 2
3DModule/Assets/_DTYJ/Scripts/Online/Network/Player.cs

@@ -135,7 +135,7 @@ namespace DTYJ
             }
             UpdateShowName();
         }
-        private readonly string[] gestureAnim = new string[] { "向右引导逃生", "向左引导逃生" };
+        private readonly string[] gestureAnim = new string[] { "向右引导逃生", "向左引导逃生", "广播:前往1出口", "广播:前往2出口" };
         [Client]
         private void Update()
         {
@@ -143,9 +143,21 @@ namespace DTYJ
             {
                 if (Input.GetKeyDown(KeyCode.T))
                 {
-                    Main.Instance.uiMainMenu.ShowFloatMenu("手势动作", gestureAnim, (strAnim) =>
+                    Main.Instance.uiMainMenu.ShowFloatMenu("乘客引导", gestureAnim, (strAnim) =>
                     {
                         GetComponent<Animator>().Play(strAnim);
+                        if (strAnim.Contains("广播"))
+                        {
+                            ControllerPanel.instance?.CmdPlayGuangBo(strAnim.Contains("1") ? 1 : 2);
+                        }
+                        else
+                        {
+                            //根据角色位置和手势方向  设置乘客出站
+                            var v = (Vector3.Dot(transform.forward, Vector3.right));
+                            bool dir = v > 0;
+                            dir = strAnim.Contains("右") ? dir : !dir;
+                            ControllerPanel.instance?.CmdSetCKChuZhan(dir ? 1 : 2);
+                        }
                     });
                 }
 

+ 24 - 0
3DModule/Assets/_DTYJ/Scripts/OptEquip/OptEquipItem_IBP_PBM.cs

@@ -0,0 +1,24 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace DTYJ
+{
+    public class OptEquipItem_IBP_PBM : OptEquipItem_WithAnim
+    {
+        public override void Exe(string cmd = null)
+        {
+            base.Exe(cmd);
+
+            var cmdObj = new IBP_KaiMen_opt();
+            cmdObj.platformDoorNo = id;
+            cmdObj.optCmd = equipName == "ÆÁ±ÎÃÅ¿ª" ? 1 : 0;
+
+            //CMDData data = new CMDData();
+            //data.cmd = 20204;
+            //data.data = cmdObj;
+            //NetworkAnimPlayer.instance.CmdSendCmdToServer(LitJson.JsonMapper.ToJson(data));
+            NetworkAnimPlayer.instance.SendCmdToServer(20308, cmdObj);
+        }
+    }
+}

+ 11 - 0
3DModule/Assets/_DTYJ/Scripts/OptEquip/OptEquipItem_IBP_PBM.cs.meta

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

+ 1 - 1
3DModule/Assets/_DTYJ/Scripts/Train/TrainCtrl.cs

@@ -125,7 +125,7 @@ namespace DTYJ
                 {
                     trainStop_xiaxing = trainInfo.trainNo;
                 }
-                if (trainInfo.blockNo == "T0201" && Mathf.Abs((float)trainInfo.offset - 5) < 0.3f)
+                if (trainInfo.blockNo == "T0203" && Mathf.Abs((float)trainInfo.offset - 5) < 0.3f)
                 {
                     trainStop_shangxing = trainInfo.trainNo;
                 }

+ 57 - 2
3DModule/Assets/_DTYJ/Scripts/UI/ControllerPanel.cs

@@ -6,6 +6,7 @@ using FLOW;
 using GFMain;
 using UnityCommon;
 using UnityEngine.UI;
+using GameFramework.Sound;
 
 namespace DTYJ
 {
@@ -18,6 +19,13 @@ namespace DTYJ
             ShowPanel(false);
             InitDeng();
             InitShuiZhai();
+
+            MainEntry.Sound.PlaySound("Assets/_DTYJ/Res/Sounds/人群嘈杂.mp3", "GuangBo", 1, new PlaySoundParams() { Loop = true });
+        }
+        [ClientRpc]
+        public void RpcSetSoundValue(float value)
+        {
+            MainEntry.Sound.GetSoundGroup("GuangBo").Volume = value;
         }
         public GameObject goPanelRoot;
         private void Update()
@@ -87,6 +95,13 @@ namespace DTYJ
         [Command(requiresAuthority = false)]
         public void CmdSetShuiZai(bool isOpen, float value)
         {
+            if (isOpen)
+            {//TODO 开启水灾 停止进出站 列车清空乘客  乘客全部出站
+                OnlineCtrl.Instance.chengKeCtrl.CountPerMin_ChuZhan = 0;
+                OnlineCtrl.Instance.chengKeCtrl.CountPerMin = 0;
+                OnlineCtrl.Instance.chengKeCtrl.ClearCkInTrain();
+                OnlineCtrl.Instance.chengKeCtrl.SetCKChuZhan(1);
+            }
             Debug.Log($"CmdSetShuiZai isOpen-{isOpen} value-{value}");
             RpcSetShuiZai(isOpen, value);
             if (isOpen)
@@ -172,6 +187,23 @@ namespace DTYJ
             if (goShaDai != null)
                 NetworkServer.Destroy(goShaDai);
         }
+        [Command(requiresAuthority = false)]
+        public void CmdSetCKChuZhan(int chukou)
+        {
+            RpcPlayGuangBo(chukou);
+            OnlineCtrl.Instance.chengKeCtrl.SetCKChuZhan(chukou);
+        }
+        [Command(requiresAuthority = false)]
+        public void CmdPlayGuangBo(int chukou)
+        {
+            RpcPlayGuangBo(chukou);
+            OnlineCtrl.Instance.chengKeCtrl.SetCKChuZhan(chukou);
+        }
+        [ClientRpc]
+        public void RpcPlayGuangBo(int chukou)
+        {
+            MainEntry.Sound.PlaySound($"Assets/_DTYJ/Res/Sounds/广播去{chukou}口.wav", "Default");
+        }
 
         private GameObject goTishiPai;
         [Command(requiresAuthority = false)]
@@ -359,7 +391,7 @@ namespace DTYJ
         {
             CmdSetJinZhanSpeed((int)value);
         }
-        int countGenerate = 50;
+        int countGenerate = 100;
         public Text addCKCount;
         public void OnSliderCKCount(float value)
         {
@@ -383,7 +415,7 @@ namespace DTYJ
 
         public void OnClickGenerateCK_Immidiately()
         {
-            CmdGenerateCK_Immidiately(countGenerate);
+            CmdGenerateCK_Immidiately(100);
         }
         [Command(requiresAuthority = false)]
         public void CmdGenerateCK_Immidiately(int count)
@@ -467,5 +499,28 @@ namespace DTYJ
             }
         }
         #endregion
+
+
+        public void OnHuoZai(bool v)
+        {
+            if (v)
+                CmdPlaceFire();
+            else
+                CmdRemoveFire();
+        }
+
+        private GameObject gohuoZai;
+        [Command(requiresAuthority = false)]
+        public void CmdPlaceFire()
+        {
+            if (gohuoZai == null)
+                gohuoZai = OnlineCtrl.Instance.GenerateNetworkObj(21);
+        }
+        [Command(requiresAuthority = false)]
+        public void CmdRemoveFire()
+        {
+            if (gohuoZai != null)
+                NetworkServer.Destroy(gohuoZai);
+        }
     }
 }

+ 21 - 0
3DModule/Assets/_DTYJ/Scripts/UI/CtrlPanel_Others.cs

@@ -0,0 +1,21 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace DTYJ
+{
+    public class CtrlPanel_Others : MonoBehaviour
+    {
+        // Start is called before the first frame update
+        void Start()
+        {
+        
+        }
+
+        // Update is called once per frame
+        void Update()
+        {
+        
+        }
+    }
+}

+ 11 - 0
3DModule/Assets/_DTYJ/Scripts/UI/CtrlPanel_Others.cs.meta

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

+ 9 - 8
3DModule/Assets/_DTYJ/Scripts/UI/UIMainMenu.cs

@@ -197,6 +197,7 @@ namespace DTYJ
                 {
                     if (v == MessageBoxParams.ResultType.Confirm)
                     {
+                        MainEntry.Sound.GetSoundGroup("GuangBo").Mute = true;
                         MainEntry.CameraCtrl.ToNone();
                         OnlineCtrl.Instance.RoleQuit();
                         goPane_角色选择.SetActive(true);
@@ -226,14 +227,14 @@ namespace DTYJ
             {
                 var tfP = tfRoot.GetChild(i).transform;
                 var btnName = tfP.name;
-                if (OnlineCtrl.Instance.mineRoleName == RoleName.站务员_站台)
-                {//限制站台站务员跳转的位置,因为水灾上下层进行了区分的
-                    if (!zhanwuyuanList.Contains(btnName)) continue;
-                }
-                else
-                {
-                    if (zhanwuyuanList.Contains(btnName)) continue;
-                }
+                //if (OnlineCtrl.Instance.mineRoleName == RoleName.站务员_站台)
+                //{//限制站台站务员跳转的位置,因为水灾上下层进行了区分的
+                //    if (!zhanwuyuanList.Contains(btnName)) continue;
+                //}
+                //else
+                //{
+                //    if (zhanwuyuanList.Contains(btnName)) continue;
+                //}
                 var btnNew = Instantiate(goBtnOrig, goBtnOrig.transform.parent);
                 btnNew.SetActive(true);
                 btnNew.GetComponentInChildren<Text>().text = btnName;