示例#1
0
        public static float3 GetTranslationComponentByHexCoordinates(HexCoordinates hexCoordinates)
        {
            EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
            Entity        hexCell       = HexCellService.FindBy(hexCoordinates);
            float3        translation   = float3.zero;

            if (Entity.Null != hexCell)
            {
                translation = entityManager.GetComponentData <Translation>(hexCell).Value;
            }

            translation.y += 0.10f;

            return(translation);
        }
示例#2
0
        public static Entity FindBy(HexCoordinates targetHexCoordinates)
        {
            EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

            NativeArray <Entity> hexCells = HexCellService.List(Allocator.TempJob);
            Entity neighborHexCell        = Entity.Null;

            foreach (Entity hexCell in hexCells)
            {
                HexCoordinates hexCellCoordinates = entityManager.GetComponentData <HexCoordinates>(hexCell);

                if (targetHexCoordinates == hexCellCoordinates)
                {
                    neighborHexCell = hexCell;
                }
            }

            hexCells.Dispose();

            return(neighborHexCell);
        }
        public Entity GetNeighborCell(HexDirection direction)
        {
            HexCoordinates targetHexCoordinates = GetTargetHexCoordinates(direction);

            return(HexCellService.FindBy(targetHexCoordinates));
        }