Exemplo n.º 1
0
    private static void SpawnFOWTeamViewObjects(int[] teams, LeanGameObjectPool pool, ActiveMap map)
    {
        //aca debo entregar una lista con todas las entidades que generan vision de un team y cual es su rango.
        var visionPointOfTeam = SightSystem.GetVisionPointsForEachTeam(teams);

        foreach (var point in visionPointOfTeam)
        {
            //debo agragarle la altura
            var elevation = MapUtilities.GetElevationOfPosition(point.center);
            var fixPositionNoElevation = map.layout.HexToWorld(point.center);
            var fixScale = map.layout.size * point.radius;

            var position      = new Vector3((float)fixPositionNoElevation.x, (float)fixPositionNoElevation.y + elevation);
            var scale         = new Vector3((float)fixScale.x, (float)fixScale.y) * 2;
            var spawnedObject = pool.Spawn(position, Quaternion.identity);
            spawnedObject.transform.localScale = scale;
        }
    }
Exemplo n.º 2
0
    public void TestElevatioFunction_OnDouble_T()
    {
        var geoMap = new Dictionary <Hex, GeographicTile>
        {
            {
                new Hex(0, 0),
                new GeographicTile()
                {
                    heightLevel = MapHeight.l0,
                    slopeData   = new SlopeData()
                    {
                        isSlope        = true,
                        heightSide_0tr = MapHeight.l1,
                        heightSide_1r  = MapHeight.l0,
                        heightSide_2dr = MapHeight.l0,
                        heightSide_3dl = MapHeight.l0,
                        heightSide_4l  = MapHeight.l0,
                        heightSide_5tl = MapHeight.l1
                    }
                }
            }
        };
        RuntimeMap map       = new RuntimeMap(geoMap, 100);
        var        layout    = new Layout(Orientation.pointy, new FixVector2(1, 1), new FixVector2(0, 0));
        ActiveMap  activeMap = new ActiveMap(map, layout);


        var elevation1 = MapUtilities.GetElevationOfPosition(new FractionalHex(Fix64.Zero, Fix64.Zero), activeMap);
        var elevation2 = MapUtilities.GetElevationOfPosition(new FractionalHex(-(Fix64)0.2886835f, (Fix64)0.577367f, -(Fix64)0.2886835f), activeMap);
        var elevation3 = MapUtilities.GetElevationOfPosition(new FractionalHex((Fix64)0.2886835f, -(Fix64)0.577367f, (Fix64)0.2886835f), activeMap);
        var elevation4 = MapUtilities.GetElevationOfPosition(new FractionalHex((Fix64)0.2886835f, (Fix64)0.2886835f, -(Fix64)0.577367f), activeMap);

        //var elevation5 = activeMap.GetElevationOfPosition(new FractionalHex(-(Fix64)0.5f, Fix64.Zero, (Fix64)0.5));
        //var elevation6 = activeMap.GetElevationOfPosition(new FractionalHex(-(Fix64)0.25f, Fix64.Zero, (Fix64)0.25f));

        Assert.AreEqual(50, elevation1);
        Assert.AreEqual(100, elevation2);
        Assert.AreEqual(0, elevation3);
        Assert.AreEqual(100, elevation4);
        //Assert.AreEqual(0, elevation5);
        //Assert.AreEqual(0, elevation6);
    }
Exemplo n.º 3
0
    private void Update()
    {
        var activeMap = MapManager.ActiveMap;

        if (MapManager.ActiveMap == null)
        {
            return;
        }

        FractionalHex hexCoords;

        switch (mode)
        {
        case PosListenerMode.HEX_POS:
            if (entityFilter.EntityManager.HasComponent <HexPosition>(entityFilter.Entity))
            {
                hexCoords = entityFilter.EntityManager.GetComponentData <HexPosition>(entityFilter.Entity).HexCoordinates;
            }
            else
            {
                return;
            }
            break;

        case PosListenerMode.BUILDING:
            if (entityFilter.EntityManager.HasComponent <Building>(entityFilter.Entity))
            {
                hexCoords = (FractionalHex)entityFilter.EntityManager.GetComponentData <Building>(entityFilter.Entity).position;
            }
            else
            {
                return;
            }
            break;

        case PosListenerMode.RESOURCE:
            if (entityFilter.EntityManager.HasComponent <ResourceSource>(entityFilter.Entity))
            {
                hexCoords = (FractionalHex)entityFilter.EntityManager.GetComponentData <ResourceSource>(entityFilter.Entity).position;
            }
            else
            {
                return;
            }
            break;

        case PosListenerMode.SUBSTITUTE:
            if (entityFilter.EntityManager.HasComponent <Substitute>(entityFilter.Entity))
            {
                hexCoords = (FractionalHex)entityFilter.EntityManager.GetComponentData <Substitute>(entityFilter.Entity).position;
            }
            else
            {
                return;
            }
            break;

        default:
            return;
        }

        Fix64 radius = Fix64.Zero;

        if (entityFilter.EntityManager.HasComponent <Collider>(entityFilter.Entity))
        {
            radius = entityFilter.EntityManager.GetComponentData <Collider>(entityFilter.Entity).Radius;
        }


        float elevation     = MapUtilities.GetElevationOfPosition(hexCoords);
        var   worldPosition = activeMap.layout.HexToWorld(hexCoords);

        //this takes into consideration the radius of the object. so the visuals are not cutted when walking into another hex. the point goes down by the radius.
        var coordinateForZValue = hexCoords - new FractionalHex(-(Fix64)0.5, (Fix64)1, -(Fix64)0.5) * radius;
        // if the y coordinate is lower, it must be closer
        float zCoordinate = minZValue + coordinateForZValue.Round().r - AGENTS_EXTRA_Z_VALUE;


        transform.localPosition = new Vector3((float)worldPosition.x, (float)worldPosition.y + elevation, zCoordinate);
    }