Example #1
0
        public static StartSceneConfig GetGate(int zone)
        {
            List <StartSceneConfig> zoneGates = StartSceneConfigCategory.Instance.Gates[zone];

            int n = RandomHelper.RandomNumber(0, zoneGates.Count);

            return(zoneGates[n]);
        }
Example #2
0
        public static long GetMapID(int zone)
        {
            List <StartSceneConfig> maps = StartSceneConfigCategory.Instance.Maps[zone];

            int n = RandomHelper.RandomNumber(0, maps.Count);

            return(maps[n].SceneId);
        }
Example #3
0
        public static void BuildHotfix(CodeOptimization codeOptimization, GlobalConfig globalConfig)
        {
            string[] logicFiles = Directory.GetFiles(Define.BuildOutputDir, "Hotfix_*");
            foreach (string file in logicFiles)
            {
                File.Delete(file);
            }

            int    random    = RandomHelper.RandomNumber(100000000, 999999999);
            string logicFile = $"Hotfix_{random}";

            List <string> codes;

            switch (globalConfig.CodeMode)
            {
            case CodeMode.Client:
                codes = new List <string>()
                {
                    "Hotfix/Share/",
                    "Hotfix/Client/",
                    "HotfixView/Client/",
                };
                codes = GetRelativeDirs(codes);
                break;

            case CodeMode.Server:
                codes = new List <string>()
                {
                    "Hotfix/Share/",
                    "Hotfix/Server/",
                    "Hotfix/Client/",
                };
                codes = GetRelativeDirs(codes);
                break;

            case CodeMode.ClientServer:
                codes = new List <string>()
                {
                    "Hotfix/Share/",
                    "Hotfix/Client/",
                    "HotfixView/Client/",
                    "Hotfix/Server/",
                };
                codes = GetRelativeDirs(codes);
                break;

            default:
                throw new Exception("not found enum");
            }

            BuildAssemblieEditor.BuildMuteAssembly(logicFile, codes, new[] { Path.Combine(Define.BuildOutputDir, "Model.dll") }, codeOptimization);
        }
Example #4
0
        public override AChannel ConnectChannel(IPEndPoint remoteEndPoint)
        {
            uint     localConn = (uint)RandomHelper.RandomNumber(1000, int.MaxValue);
            KChannel oldChannel;

            if (this.localConnChannels.TryGetValue(localConn, out oldChannel))
            {
                this.localConnChannels.Remove(oldChannel.LocalConn);
                oldChannel.Dispose();
            }

            KChannel channel = new KChannel(localConn, this.socket, remoteEndPoint, this);

            this.localConnChannels[channel.LocalConn] = channel;
            return(channel);
        }
Example #5
0
        public static void BuildLogic()
        {
            string[] logicFiles = Directory.GetFiles(Define.BuildOutputDir, "Logic_*");
            foreach (string file in logicFiles)
            {
                File.Delete(file);
            }

            int    random    = RandomHelper.RandomNumber(100000000, 999999999);
            string logicFile = $"Logic_{random}";

            BuildAssemblieEditor.BuildMuteAssembly(logicFile, new []
            {
                "Codes/Hotfix/",
                "Codes/HotfixView/",
            }, new[] { Path.Combine(Define.BuildOutputDir, "Data.dll") }, CodeOptimization.Debug);
        }
Example #6
0
        /// <summary>
        /// 以pos为中心各自在宽和高的左右 前后两个方向延伸
        /// </summary>
        /// <param name="self"></param>
        /// <param name="pos"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public static Vector3 FindRandomPointWithRectangle(this PathfindingComponent self, Vector3 pos, int width, int height)
        {
            if (self.NavMesh == 0)
            {
                throw new Exception($"pathfinding ptr is zero: {self.DomainScene().Name}");
            }

            if (width > PathfindingComponent.FindRandomNavPosMaxRadius * 0.001f || height > PathfindingComponent.FindRandomNavPosMaxRadius * 0.001f)
            {
                throw new Exception($"pathfinding rectangle is too large,width: {width} height: {height}, max: {PathfindingComponent.FindRandomNavPosMaxRadius}");
            }

            float x = RandomHelper.RandomNumber(-width, width);
            float z = RandomHelper.RandomNumber(-height, height);

            Vector3 findpos = new Vector3(pos.x + x, pos.y, pos.z + z);

            return(self.RecastFindNearestPoint(findpos));
        }
Example #7
0
        public static Vector3 FindRandomPointWithRaduis(this PathfindingComponent self, Vector3 pos, float raduis)
        {
            if (self.NavMesh == 0)
            {
                throw new Exception($"pathfinding ptr is zero: {self.DomainScene().Name}");
            }

            if (raduis > PathfindingComponent.FindRandomNavPosMaxRadius * 0.001f)
            {
                throw new Exception($"pathfinding raduis is too large,cur: {raduis}, max: {PathfindingComponent.FindRandomNavPosMaxRadius}");
            }

            int   degrees = RandomHelper.RandomNumber(0, 360);
            float r       = RandomHelper.RandomNumber(0, (int)(raduis * 1000)) / 1000f;

            float x = r * Mathf.Cos(MathHelper.DegToRad(degrees));
            float z = r * Mathf.Sin(MathHelper.DegToRad(degrees));

            Vector3 findpos = new Vector3(pos.x + x, pos.y, pos.z + z);

            return(self.RecastFindNearestPoint(findpos));
        }
Example #8
0
 public static int RandomArray_Len2(this int[] array)
 {
     return(RandomHelper.RandomNumber(array[0], array[1]));
 }