public Ground_ GenerateGround(float temperature, float moisture)
    {
        List <Ground_> groundsToRandomGeneration = new List <Ground_>();

        foreach (Ground_ ground in grounds)
        {
            ground.Build();
            int generationChances = GetGenerationChances(ground, temperature, moisture);
            for (int i = 1; i < generationChances; i++)
            {
                groundsToRandomGeneration.Add(ground);
            }
        }

        if (groundsToRandomGeneration.Count > 0)
        {
            Ground_ randomGround = groundsToRandomGeneration[Random.Range(0, groundsToRandomGeneration.Count)];
            randomGround.sprite = randomGround.graphics_.ingame_.sprites[Random.Range(0, randomGround.graphics_.ingame_.sprites.Count)];

            return(randomGround);
        }
        else
        {
            return(null);
        }
    }
    public int GetGenerationChances(Ground_ ground, float temperature, float moisture)
    {
        int          generationChances = 0;
        GroundStats_ groundStats       = ground.mechanics_.stats_;

        if (groundStats.biome.IsSupported(temperature, moisture))
        {
            generationChances = groundStats.biome.GetGenerationChances(temperature, moisture);
        }
        return(generationChances);
    }
    public void OnPointerClick(PointerEventData eventData)
    {
        switch (eventData.button)
        {
        case PointerEventData.InputButton.Left:
            Vector3 clickedWorldPoint = Camera.main.ScreenToWorldPoint(eventData.position);
            tilePosition      = baseGroundTilemap.WorldToCell(clickedWorldPoint);
            fixedTilePosition = new Vector3Int(tilePosition.x - 5, tilePosition.y - 5, 0);
            Ground_ selectedTileGround = baseGroundTilemap.GetTile(fixedTilePosition) as Ground_;
            bottomUi.LoadUI(selectedTileGround);
            break;

        case PointerEventData.InputButton.Right:
            ((PlayerBehaviour_)player.mechanics_.behaviour_).DefaultAction(eventData, gameObject, "Ground");
            break;

        case PointerEventData.InputButton.Middle:
            //Desplegar menú flotante con opciones de interacción
            break;

        default:
            break;
        }
    }
示例#4
0
 public void LoadUI(Ground_ selectedTileGround)
 {
     ClearRightContainer();
     currentSelectedObject = null;
     Instantiate(selectedTileGround.graphics_.ui_.bottomUi, rightContainer_.transform);
 }