Esempio n. 1
0
        /// <summary>
        /// Constructor for the bounds octree.
        /// </summary>
        /// <param name="initialWorldSize">Size of the sides of the initial node, in metres. The octree will never shrink smaller than this.</param>
        /// <param name="initialWorldPos">Position of the centre of the initial node.</param>
        /// <param name="minNodeSize">Nodes will stop splitting if the new nodes would be smaller than this (metres).</param>
        /// <param name="loosenessVal">Clamped between 1 and 2. Values > 1 let nodes overlap.</param>
        public BoundsQuadTree(LFloat initialWorldSize, LVector2 initialWorldPos, LFloat minNodeSize, LFloat loosenessVal)
        {
            if (minNodeSize > initialWorldSize)
            {
                Debug.Log("Minimum node size must be at least as big as the initial world size. Was: " +
                          minNodeSize + " Adjusted to: " + initialWorldSize);
                minNodeSize = initialWorldSize;
            }

            Count       = 0;
            initialSize = initialWorldSize;
            minSize     = minNodeSize;
            looseness   = LMath.Clamp(loosenessVal, 1.ToLFloat(), 2.ToLFloat());
            rootNode    = new BoundsQuadTreeNode(null, initialSize, minSize, looseness, initialWorldPos);
        }
Esempio n. 2
0
        public void Initialize(IContext context)
        {
            var config = _gameConfigService;

            foreach (var spawner in config.SpawnInfos)
            {
                if (spawner.Count <= 0)
                {
                    continue;
                }
                var entity = _context.PostCmdCreateBoidSpawner();
                entity->Spawn.Count        = spawner.Count;
                entity->Spawn.Position     = spawner.Position;
                entity->Spawn.Radius       = spawner.Radius;
                entity->BoidPrefab.AssetId = spawner.AssetId;
            }

            int playerId = 0;
            var count    = _globalStateService.ActorCount;

            for (int i = 0; i < count; i++)
            {
                var obstacleInfo = config.ObstacleInfos[i % config.ObstacleInfos.Count];
                var entity       = _context.PostCmdCreateBoidObstacle();
                entity->Transform.Position = obstacleInfo.Position;
                entity->Transform.Forward  = obstacleInfo.Forward;
                entity->Transform.Scale    = obstacleInfo.Scale;
                entity->Skill          = obstacleInfo.SkillData;
                entity->Move           = obstacleInfo.MoveData;
                entity->Prefab.AssetId = obstacleInfo.AssetId;
                entity->Player.LocalId = playerId++;//
                Debug.Log("Create ObstacleInfos " + entity->Player.LocalId);
            }

            foreach (var target in config.TargetInfos)
            {
                var entity = _context.PostCmdCreateBoidTarget();
                entity->Transform.Position = target.MoveInfo.GetPosition(0);
                entity->Transform.Scale    = 1;
                entity->MoveInfo           = target.MoveInfo;
                entity->Prefab.AssetId     = target.AssetId;
            }

            foreach (var spawner in config.SpawnInfos)
            {
                _gameStateService.CurEnemyCount += spawner.Count;
            }
        }