Compare commits

...

12 Commits

Author SHA1 Message Date
ean205
67a5a9da47 start of work on miniMap generation
-base structure of Tile script
-object for tile prefab(without parametrs)
2026-01-20 20:11:55 +03:00
e3f865116f refactor: gridGen
- configurable hex per frame count
 - restructure
 - comments
 - progress counters
2026-01-16 23:31:25 +03:00
e4e834d373 refactor: Hex, cell
cell - delete
Hex - refactor, feature
State: stable

В Hex перенесен функционал из cell.
2026-01-16 22:36:32 +03:00
4ffdf964a7 add fields to Hex class 2026-01-15 00:22:22 +03:00
18648ff71b mend 2026-01-14 22:03:47 +03:00
c5cbe75f50 mend 2026-01-14 22:02:26 +03:00
cb7ffd30b6 Merge branch 'master' of http://192.168.37.7:1212/PotatoPieGames/hexwar 2026-01-14 21:57:26 +03:00
e37ae1325e README update 2026-01-14 21:57:05 +03:00
21a9bf78ec README update 2026-01-14 21:53:26 +03:00
a1b2d2143f mend 2026-01-14 00:40:54 +03:00
075acdac54 Initialization on PC and READEME 2026-01-14 00:39:27 +03:00
ean205
ead50546ee Begining of work on Hex script 2026-01-13 20:06:41 +03:00
15 changed files with 317 additions and 122 deletions

Binary file not shown.

View File

@@ -1,63 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cell : MonoBehaviour
{
public Vector2Int pos = new Vector2Int(0, 0);
public float noiseValue;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
/*
GetComponent<SpriteRenderer>().color = new Color(noiseValue, noiseValue, noiseValue, 1);
noiseValue = Random.Range(0f, 1f);
*/
}
public void Init()
{
//Debug.Log(noiseValue);
noiseValue = Mathf.Pow(noiseValue, 1.7f);
float pow = 1.2f;
Color color;
if (noiseValue <= 0.35)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.2f, noiseValue * 0.2f, noiseValue + 0.1f);//âîäà
}
else if (noiseValue <= 0.5)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.4f, noiseValue+0.3f, noiseValue*0.4f);//íèçèíà
}
else if (noiseValue <= 0.8)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue * 0.2f, noiseValue + 0.3f, noiseValue * 0.2f);//ïîëå
}
else if (noiseValue <= 0.95)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.8f + 0.1f, noiseValue * 0.4f, noiseValue * 0.2f);//ãîðû
}
else
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.6f + 0.0f, noiseValue * 0.1f, noiseValue * 0.0f);//íåïðîõîäèìûé ïèê
}
GetComponent<SpriteRenderer>().color = color;
}
}

View File

@@ -7,63 +7,71 @@ public class gridGen : MonoBehaviour
public perlinNoise noise;
public GameObject hexPrefab;
public Transform mapStart;
private float translationVert;
public int x = 32;
public int y = 32;
public int generationStep = 128; //Êîëè÷åñòâî ãåíåðèðóåìûõ çà êàäð ãåêñîâ
public int progressNow = 0; //Ñêîëüêî óæå ñãåíåðèðîâàííî
public int progressTotal = -1; //Âñåãî ãåêñîâ íóæíî ñãåíåðèðîâàòü
//private float translationVert;
private float scaleY = Mathf.Sqrt(3) / 2;
private float scaleX = 1;
public int x = 32;//Ðàçìåð ñåòêè ïî x
public int y = 32;//Ðàçìåð ñåòêè ïî y
private int nowX;
private int nowY;
private float scaleY = Mathf.Sqrt(3) / 2; //Ðàñ÷èòûâàåì êîððåêòíûé ðàçìåð ãåêñà ïî Oy äëÿ òî÷íûõ ñäâèãîâ
private float scaleX = 1; //Ðàñ÷èòûâàåì êîððåêòíûé ðàçìåð ãåêñà ïî Ox äëÿ òî÷íûõ ñäâèãîâ
private int nowX; //Êîîðäèíàòà òåêóùåãî ãåêñà ïî Ox
private int nowY; //Êîîðäèíàòà òåêóùåãî ãåêñà ïî Oy
private int nowStep = 0;//Ñãåíåðèðîâàííî çà ýòîò êàäð
// Start is called before the first frame update
void Start()
{
/*
GameObject hex2 = Instantiate(hexPrefab);
hex2.transform.Translate(new Vector3(0, scaleY, 0));
GameObject hex3 = Instantiate(hexPrefab);
hex3.transform.Translate(new Vector3(0.75f*scaleX, 0.5f*scaleY, 0));
*/
progressTotal = x * y;//Ñ÷èòàåì ñêîëüêî âñåãî ãåêñîâ â ñåòêå
}
// Update is called once per frame
void Update()
{
if (nowX < x)
while (nowStep < generationStep && nowX < x) //Äåëàåì generationStep çà êàäð è ïðîâåðÿåì ÷òî ãåíåðàöèÿ åùå íóæíà
{
while (nowY < y)
if (nowY < y)//Ïðîâåðÿåì ÷òî ñòîëáåö åùå íå çàêîí÷åí
{
float modX = 0.25f;
float modY = 0;
float modX = 0.25f; //Ìíîæèòåëü äëÿ ñäâèãà ïî Ox
float modY = 0; //Áàçîâûé ìíîæèòåëü ñäâèãà ïî Oy
if (nowX % 2 == 1)
{
modY = 0.5f;
modY = 0.5f; //Ñäâèã êàæäîãî íå÷åòíîãî ñòîëáöà
}
initHex(mapStart.position.x + (scaleX * nowX) - (modX*scaleX*nowX), mapStart.position.y + (scaleY * nowY) + (modY*scaleY));
nowY++;
initHex(mapStart.position.x + (scaleX * nowX) - (modX * scaleX * nowX), mapStart.position.y + (scaleY * nowY) + (modY * scaleY));//Ñîçäàíèå ãåêñà ñî ñäâèãàìè
nowY++; //Óâåëè÷èâàåì íîìåð ñãåíåðèðîâàííîãî ãåêñà â ñòîëáöå
progressNow++;//Óâåëè÷èâàåì ñ÷åò÷èê ïðîãðåññà
nowStep++;//Óâåëè÷èâàåì ñ÷åò÷èê êîëè÷åñòâà ñãåíåðèðîâàííûõ çà êàäð ãåêñîâ
}
else //Åñëè ñòîëáåö çàîí÷èëñÿ ïåðåõîäèì ê ñëåäóþùåìó
{
nowX++;
nowY = 0;
}
}
if (nowStep == generationStep) nowStep = 0;//Ñáðàñûâàåì ñ÷åò÷èê ñãåíåðèðîâàííûõ çà êàäð ãåêñîâ
if (nowX == x) this.enabled = false;//Çàâåðøàåì ãåíåðàöèþ ïîñëå åå êîíöà
}
private void initHex(float x, float y)
{
GameObject hex = Instantiate(hexPrefab);
hex.transform.Translate(new Vector3(x, y, 0));
hex.GetComponent<cell>().noiseValue = noise.getNoise((float) nowX/this.x, (float) nowY /this.x, Mathf.Max(this.x, this.y));
hex.GetComponent<cell>().Init();
GameObject hex = Instantiate(hexPrefab);//Ñîçäàåì êëîí áàçîâîãî ãåêñà
hex.transform.Translate(new Vector3(x, y, 0));//Ñäâèãàåì êëîí íà íóæíóþ ïîçèöèþ â ñåòêå
hex.GetComponent<Hex>().InitializeHex(new Vector2Int(this.nowX, this.nowY), noise.getNoise((float)nowX / this.x, (float)nowY / this.x, Mathf.Max(this.x, this.y)), noise.seed);//Èíèöèàëèçèðóåì ëîãèêó ãåêñà
}
}

8
Assets/scripts/hex.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8da86797540d11543a330b02c1768147
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

128
Assets/scripts/hex/Hex.cs Normal file
View File

@@ -0,0 +1,128 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hex : MonoBehaviour
{
public enum landscapeTypes { water, land, hill, highHill, mountain, uncrosableMountain };
public enum stateTypes { idle, owned, battle };
public Vector2Int position;
public float noiseValue;
public landscapeTypes landType;
public int miniMapSeed;
public int income { get; private set; } //Ìîäèôèêàòîð ê äîõîäó â åäåíèöó âðåìåíè îò ýòîãî ãåêñà
public int ownerID;
public stateTypes state = stateTypes.idle;
//TODO ïåðåìåííàÿ äëÿ ïàìàòè ñîäåðæèìîãî
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void InitializeHex(Vector2Int pos, float noiseVal, int seed)
{
noiseValue = noiseVal;
position = pos;
//Debug.Log(noiseValue);
noiseValue = Mathf.Pow(noiseValue, 1.7f); //Óðåç÷åíèå ïåðåõîäîâ ëàíäøàôòà
miniMapSeed = seed + position.x * 100000 + position.y;
//Âûíåñòè ýòè âåëå÷èíû â íàñòðîéêè
float waterLevel = 0.34f;
float landLevel = 0.4f;
float hillLevel = 0.6f;
float highHillLevel = 0.75f;
float mountainLevel = 0.95f;
//Îïðåäåëåíèå òèïà ëàíäøàôòà
if (noiseValue <= waterLevel)
{
landType = landscapeTypes.water;
}
else if (noiseValue <= landLevel)
{
landType = landscapeTypes.land;
}
else if (noiseValue <= hillLevel)
{
landType = landscapeTypes.hill;
}
else if (noiseValue <= highHillLevel)
{
landType = landscapeTypes.highHill;
}
else if (noiseValue <= mountainLevel)
{
landType = landscapeTypes.mountain;
}
else
{
landType = landscapeTypes.uncrosableMountain;
}
InitializeTexture();
}
private void InitializeTexture()
{
Color color = new Color(0,0,0,0);
float pow = 1.2f; //ñòåïåíü â êîòîðóþ âîçâîäòèòñÿ øóì äëÿ äîïîëíèòåëüíîãî óðåç÷åíèÿ öâåòîâ'
float val = Mathf.Pow(noiseValue, pow);
switch (landType)
{
case landscapeTypes.water:
color = new Color(noiseValue * 0.2f, noiseValue * 0.2f, noiseValue + 0.1f);
break;
case landscapeTypes.land:
color = new Color(noiseValue * 0.3f, noiseValue + 0.3f, noiseValue * 0.3f);
break;
case landscapeTypes.hill:
color = new Color(noiseValue * 0.5f, noiseValue + 0.3f, noiseValue * 0.2f);
break;
case landscapeTypes.highHill:
color = new Color(noiseValue * 0.7f, noiseValue + 0.3f, noiseValue * 0.2f);
break;
case landscapeTypes.mountain:
color = new Color(noiseValue * 0.8f + 0.1f, noiseValue * 0.4f, noiseValue * 0.2f);
break;
case landscapeTypes.uncrosableMountain:
color = new Color(noiseValue * 0.6f + 0.0f, noiseValue * 0.1f, noiseValue * 0.0f);
break;
}
GetComponent<SpriteRenderer>().color = color;
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 62970f09f26042b4c8cf4ca27a04b8f1
guid: 39fcf992f203d70498433370e055f6ee
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class hexCulling : MonoBehaviour
{
public Camera camera;
public float baseX;
public float baseY;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.localScale = new Vector3(-1 * baseX * (10+camera.transform.position.z), -1 * baseX * (10+camera.transform.position.z), 3);
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1aec07be2f1cdd5438c819666796f8bf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MiniMapGenerator : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f818c27fab882aa4ea5ad1e4f175462f
guid: 966127aa560664d43bdb73e9824ae9f9
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,76 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tile : MonoBehaviour
{
public enum landscapeTypes { water, lowGround, midGround, highGround, mountain, uncrosableMountain };
public enum stateTypes { idle, occupied };
public Vector2Int position;
public float noiseValue;
public Hex.landscapeTypes mapType;
public stateTypes state = stateTypes.idle;
//TODO ïåðåìåííàÿ äëÿ ïàìàòè ñîäåðæèìîãî
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void InitializeTile(Vector2Int pos, float noiseVal)
{
noiseValue = noiseVal;
position = pos;
//Debug.Log(noiseValue);
noiseValue = Mathf.Pow(noiseValue, 1.7f); //Óðåç÷åíèå ïåðåõîäîâ ëàíäøàôòà
//Âûíåñòè ýòè âåëå÷èíû â íàñòðîéêè
float waterLevel = 0.34f;
float landLevel = 0.4f;
float hillLevel = 0.6f;
float highHillLevel = 0.75f;
float mountainLevel = 0.95f;
InitializeTexture();
}
private void InitializeTexture()
{
Color color = new Color(0, 0, 0, 0);
float pow = 1.2f; //ñòåïåíü â êîòîðóþ âîçâîäòèòñÿ øóì äëÿ äîïîëíèòåëüíîãî óðåç÷åíèÿ öâåòîâ'
float val = Mathf.Pow(noiseValue, pow);
GetComponent<SpriteRenderer>().color = color;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 452e22fcead7325429450f21972ae4b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -17,7 +17,7 @@ public class perlinNoise : MonoBehaviour
void Start()
{
if(seed == -1) { seed = (int) (Random.value * 1000000000); }
if(seed == -1) { seed = (int) (Random.value * int.MaxValue); }
Debug.Log(seed);
Random.InitState(seed);

Binary file not shown.

View File

@@ -1,2 +1,24 @@
# hexwar
# HexWar
### Основные принципы:
1. Уникальность
2. Масштабность
3. Стратегичность
Игра несет в себе идею того, что каждая новая партия будет уникальной и будет вынуждать игроков делать стратегические решения, которые почти невозможно проссчитать до игры. Партии будут масштабными и затяжными, это будет происходить за счет просторных карт и сложного рельефа который уникален для каждой партии.
---
### Концепция:
Игра проходит на глобальной карте с гексогональной сеткой, и у кажого гекса "внутри" есть еще мини-карта, но уже с квадратной сеткой. На мини-картах и происходят основные дейтвия игры, там можно создовать юнитов и постройки. Постройки могут создовать новых юнитов или добывать ресурсы, хотя некоторые имеют и особенные функции. Юниты же могут строить новые строения или выступать в роли боевых едениц.
---
### Техническая информация:
Платформы:
- Windows*
- Linux
- ~~*Android*~~*(Вероятно будет порт)*
*Целевая платформа