| | |
| | | // [ Date ]: Tuesday, January 16, 2018
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | |
| | | using UnityEngine;
|
| | | using System.Collections.Generic;
|
| | |
|
| | | public class DTCA713_tagMCDynamicBarrierState : DtcBasic
|
| | | { |
| | | public static readonly Dictionary<int, UnityEngine.AI.NavMeshObstacle> obstacleDict = new Dictionary<int, UnityEngine.AI.NavMeshObstacle>(); |
| | | public static readonly Dictionary<int, SFXController> sfxDict = new Dictionary<int, SFXController>(); |
| | | |
| | | {
|
| | | public static readonly Dictionary<int, UnityEngine.AI.NavMeshObstacle> obstacleDict = new Dictionary<int, UnityEngine.AI.NavMeshObstacle>();
|
| | | public static readonly Dictionary<int, SFXController> sfxDict = new Dictionary<int, SFXController>();
|
| | |
|
| | | public static void Clear()
|
| | | {
|
| | | foreach (var _item in obstacleDict.Values)
|
| | |
| | | }
|
| | |
|
| | | sfxDict.Clear();
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | public override void Done(GameNetPackBasic vNetPack)
|
| | | {
|
| | | base.Done(vNetPack);
|
| | |
| | | Vector3 _start = new Vector3(package.BarrierList[i].APosX, 0, package.BarrierList[i].APosY);
|
| | | Vector3 _end = new Vector3(package.BarrierList[i].BPosX, 0, package.BarrierList[i].BPosY);
|
| | |
|
| | | UnityEngine.AI.NavMeshObstacle _obstacle = SoMap.CreateImpasse.General(_start, _end);
|
| | | UnityEngine.AI.NavMeshObstacle _obstacle = null;
|
| | |
|
| | | if (package.BarrierList[i].Angle == 0)
|
| | | {
|
| | | _obstacle = SoMap.CreateImpasse.General(_start, _end);
|
| | | }
|
| | | else
|
| | | {
|
| | | _obstacle = SoMap.CreateImpasse.General(_start, _end, package.BarrierList[i].Angle);
|
| | | }
|
| | |
|
| | | if (obstacleDict.ContainsKey(id))
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
| | | |
| | | // A7 13 动态障碍物状态 #tagMCDynamicBarrierState |
| | | |
| | | public class HA713_tagMCDynamicBarrierState : GameNetPackBasic |
| | | { |
| | | public class HA713_tagMCDynamicBarrierState : GameNetPackBasic { |
| | | public byte State; // 是否有效 |
| | | public byte Count; |
| | | public tagMCDynamicBarrier[] BarrierList = null; |
| | | public tagMCDynamicBarrier[] BarrierList; |
| | | |
| | | public HA713_tagMCDynamicBarrierState() |
| | | { |
| | | public HA713_tagMCDynamicBarrierState () { |
| | | _cmd = (ushort)0xA713; |
| | | } |
| | | |
| | | public override void ReadFromBytes(byte[] vBytes) |
| | | { |
| | | TransBytes(out State, vBytes, NetDataType.BYTE); |
| | | TransBytes(out Count, vBytes, NetDataType.BYTE); |
| | | public override void ReadFromBytes (byte[] vBytes) { |
| | | TransBytes (out State, vBytes, NetDataType.BYTE); |
| | | TransBytes (out Count, vBytes, NetDataType.BYTE); |
| | | BarrierList = new tagMCDynamicBarrier[Count]; |
| | | for (int i = 0; i < Count; i++) |
| | | { |
| | | for (int i = 0; i < Count; i ++) { |
| | | BarrierList[i] = new tagMCDynamicBarrier(); |
| | | TransBytes(out BarrierList[i].APosX, vBytes, NetDataType.WORD); |
| | | TransBytes(out BarrierList[i].APosY, vBytes, NetDataType.WORD); |
| | | TransBytes(out BarrierList[i].BPosX, vBytes, NetDataType.WORD); |
| | | TransBytes(out BarrierList[i].BPosY, vBytes, NetDataType.WORD); |
| | | TransBytes (out BarrierList[i].APosX, vBytes, NetDataType.WORD); |
| | | TransBytes (out BarrierList[i].APosY, vBytes, NetDataType.WORD); |
| | | TransBytes (out BarrierList[i].BPosX, vBytes, NetDataType.WORD); |
| | | TransBytes (out BarrierList[i].BPosY, vBytes, NetDataType.WORD); |
| | | TransBytes (out BarrierList[i].Angle, vBytes, NetDataType.WORD); |
| | | } |
| | | } |
| | | |
| | | public struct tagMCDynamicBarrier |
| | | { |
| | | public struct tagMCDynamicBarrier { |
| | | public ushort APosX; |
| | | public ushort APosY; |
| | | public ushort BPosX; |
| | | public ushort BPosY; |
| | | public ushort Angle; |
| | | } |
| | | |
| | | } |
| | |
| | | return _obstacle; |
| | | } |
| | | |
| | | public static UnityEngine.AI.NavMeshObstacle General(Vector3 start, Vector3 end, float angle) |
| | | { |
| | | GameObject _impasse = new GameObject(); |
| | | |
| | | // 计算长度 |
| | | float _length = Vector3.Distance(end * .5f, start * .5f); |
| | | float _width = 1.5f; |
| | | |
| | | float _centerX; |
| | | float _centerZ; |
| | | |
| | | if (end.x > start.x) |
| | | { |
| | | _centerX = (end.x - start.x) * .5f + _width * .5f; |
| | | } |
| | | else |
| | | { |
| | | _centerX = (end.x - start.x) * .5f - _width * .5f; |
| | | } |
| | | |
| | | if (end.z > start.z) |
| | | { |
| | | _centerZ = (end.z - start.z) * .5f + _length * .5f; |
| | | } |
| | | else |
| | | { |
| | | _centerZ = (start.z - end.z) * .5f - _length * .5f; |
| | | } |
| | | |
| | | |
| | | #if UNITY_EDITOR |
| | | _impasse.name = "Obstacle_" + _length + "_" + _width; |
| | | #endif |
| | | _impasse.transform.position = new Vector3(_centerX, 0, _centerZ); |
| | | _impasse.transform.localScale = new Vector3(_length, 10, _width); |
| | | |
| | | UnityEngine.AI.NavMeshObstacle _obstacle = _impasse.AddComponent<UnityEngine.AI.NavMeshObstacle>(); |
| | | _obstacle.transform.eulerAngles = new Vector3(0, angle, 0); |
| | | _obstacle.carving = true; |
| | | return _obstacle; |
| | | } |
| | | |
| | | public static UnityEngine.AI.NavMeshObstacle General(Vector3 start, Vector3 end) |
| | | { |
| | | GameObject _impasse = new GameObject(); |