Пример #1
0
    void GenerateTierEntityChains(TierEntity firstEntity)
    {
        int regionCount = UnityEngine.Random.Range(randomMin, randomMax + 1);

        for (int a = 0; a < regionCount; a++)
        {
            int        constellationCount = UnityEngine.Random.Range(randomMin, randomMax + 1);
            int        regionRadius       = UnityEngine.Random.Range(radiusMin, radiusMax + 1);
            TierEntity newRegion          = new TierEntity(a, InteractionTier.Region, regionRadius, firstEntity);
            Debug.Log(newRegion);
            //firstEntity.childEntities.Add(a, newRegion);

            for (int b = 0; b < constellationCount; b++)
            {
                int        systemCount         = UnityEngine.Random.Range(randomMin, randomMax + 1);
                int        constellationRadius = UnityEngine.Random.Range(radiusMin, radiusMax + 1);
                TierEntity newConstellation    = new TierEntity(b, InteractionTier.Constellation, constellationRadius, newRegion);
                newRegion.childEntities.Add(b, newConstellation);

                for (int c = 0; c < systemCount; c++)
                {
                    int        planetCount  = UnityEngine.Random.Range(randomMin, randomMax + 1);
                    int        systemRadius = UnityEngine.Random.Range(radiusMin, radiusMax + 1);
                    TierEntity newSystem    = new TierEntity(c, InteractionTier.System, systemRadius, newConstellation);
                    newConstellation.childEntities.Add(c, newSystem);

                    for (int d = 0; d < planetCount; d++)
                    {
                        TierEntity newPlanet = new TierEntity(d, InteractionTier.Planet, newSystem);
                        newSystem.childEntities.Add(d, newPlanet);
                    }
                }
            }
        }
    }
Пример #2
0
    void SetEntityPositions(TierEntity _entity)
    {
        List <Vector2> childPosition = new List <Vector2> ();

        for (int a = 0; a < _entity.childEntities.Count; a++)
        {
            int     randomGridX   = UnityEngine.Random.Range(0, _entity.entityRadius);
            int     randomGridY   = UnityEngine.Random.Range(0, _entity.entityRadius);
            Vector2 positionCheck = new Vector2(randomGridX, randomGridY);
            Vector2 gridCenter    = new Vector2(_entity.entityRadius / 2, _entity.entityRadius / 2);

            while (childPosition.Contains(positionCheck) || positionCheck == gridCenter)
            {
                randomGridX   = UnityEngine.Random.Range(0, _entity.entityRadius);
                randomGridY   = UnityEngine.Random.Range(0, _entity.entityRadius);
                positionCheck = new Vector2(randomGridX, randomGridY);
            }
            childPosition.Add(positionCheck);
            _entity.childEntities [a].positionInGrid = gridPositionTable [(int)positionCheck.x, (int)positionCheck.y];
            if (_entity.entityTier != InteractionTier.System)
            {
                SetEntityPositions(_entity.childEntities [a]);
            }
        }
    }
Пример #3
0
 void SetTierSpaceElements()
 {
     if (activeTier == null)
     {
         activeTier = startingPlanet;
     }
     tierCounter = (int)InteractionTier.Planet;
 }
Пример #4
0
 void EnterHigherTierSpace()
 {
     tierCounter++;
     activeTier = activeTier.parentEntity;
     if (tierCounter == (int)InteractionTier.System)
     {
     }
     currentTier = InteractionTier.TierTransition;
 }
Пример #5
0
 void GenerateEnvironment()
 {
     for (int a = 0; a < clusterCount; a++)
     {
         int randomRadius = UnityEngine.Random.Range(radiusMin, radiusMax + 1);
         clusters [a] = new TierEntity(a, InteractionTier.Cluster, randomRadius, null);
     }
     //GenerateTierEntityChains (clusters [0]);
     SetStartingPlanet();
     SetEntityPositions(clusters [0]);
 }
        public void Handle(CreateEntityCommand <TierModel> command)
        {
            var equipment = this.equipmentRepository.FindById(command.Model.EquipmentItemId);
            var tier      = new TierEntity
            {
                Name          = command.Model.Name,
                Tier          = command.Model.Tier,
                EquipmentItem = equipment,
            };

            this.tierRepository.Add(tier);
        }
Пример #7
0
    void SetStartingPlanet()
    {
        int regionCount = clusters[0].childEntities.Count;

        int startRegion = UnityEngine.Random.Range(0, regionCount);

        TierEntity region             = clusters [0].childEntities [startRegion];
        int        constellationCount = region.childEntities.Count;
        int        startConstellation = UnityEngine.Random.Range(0, constellationCount);

        TierEntity constellation = region.childEntities [startConstellation];
        int        systemCount   = constellation.childEntities.Count;
        int        startSystem   = UnityEngine.Random.Range(0, systemCount);

        TierEntity system      = constellation.childEntities[startSystem];
        int        planetCount = system.childEntities.Count;
        int        startPlanet = UnityEngine.Random.Range(0, systemCount);

        startingPlanet = system.childEntities[startPlanet];
    }
Пример #8
0
        /*
         * public TierEntity (int _number, InteractionTier _tier, int _radius, TierEntity _parentEntity){
         *      number = _number;
         *      entityTier = _tier;
         *      entityRadius = _radius;
         *      parentEntity = _parentEntity;
         * }*/


        public TierEntity(int _number, InteractionTier _tier, int _radius, TierEntity _parentEntity)
        {
            number       = _number;
            entityTier   = _tier;
            entityRadius = _radius;
            parentEntity = _parentEntity;

            //Stops recursion if at local tier
            if (entityTier != InteractionTier.Planet)
            {
                //Number of sub entities
                int randomRange = UnityEngine.Random.Range(randomMin, randomMax + 1);
                //Generates sub entities
                for (int a = 0; a < randomRange; a++)
                {
                    int        randomRadius = UnityEngine.Random.Range(radiusMin, radiusMax + 1);
                    TierEntity newEntity    = new TierEntity(a, entityTier - 1, randomRadius, this);
                    childEntities.Add(a, newEntity);
                }
            }
        }
Пример #9
0
 public TierEntity(int _number, InteractionTier _tier, TierEntity _parentEntity)
 {
     number       = _number;
     entityTier   = _tier;
     parentEntity = _parentEntity;
 }