Compare commits
8 Commits
21a9bf78ec
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67a5a9da47 | ||
| e3f865116f | |||
| e4e834d373 | |||
| 4ffdf964a7 | |||
| 18648ff71b | |||
| c5cbe75f50 | |||
| cb7ffd30b6 | |||
| e37ae1325e |
BIN
Assets/Scenes/Game.unity
LFS
BIN
Assets/Scenes/Game.unity
LFS
Binary file not shown.
@@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -7,63 +7,71 @@ public class gridGen : MonoBehaviour
|
|||||||
public perlinNoise noise;
|
public perlinNoise noise;
|
||||||
public GameObject hexPrefab;
|
public GameObject hexPrefab;
|
||||||
public Transform mapStart;
|
public Transform mapStart;
|
||||||
private float translationVert;
|
|
||||||
|
|
||||||
public int x = 32;
|
public int generationStep = 128; //Êîëè÷åñòâî ãåíåðèðóåìûõ çà êàäð ãåêñîâ
|
||||||
public int y = 32;
|
public int progressNow = 0; //Ñêîëüêî óæå ñãåíåðèðîâàííî
|
||||||
|
public int progressTotal = -1; //Âñåãî ãåêñîâ íóæíî ñãåíåðèðîâàòü
|
||||||
|
//private float translationVert;
|
||||||
|
|
||||||
private float scaleY = Mathf.Sqrt(3) / 2;
|
public int x = 32;//Ðàçìåð ñåòêè ïî x
|
||||||
private float scaleX = 1;
|
public int y = 32;//Ðàçìåð ñåòêè ïî y
|
||||||
|
|
||||||
private int nowX;
|
private float scaleY = Mathf.Sqrt(3) / 2; //Ðàñ÷èòûâàåì êîððåêòíûé ðàçìåð ãåêñà ïî Oy äëÿ òî÷íûõ ñäâèãîâ
|
||||||
private int nowY;
|
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
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
/*
|
progressTotal = x * y;//Ñ÷èòàåì ñêîëüêî âñåãî ãåêñîâ â ñåòêå
|
||||||
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));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (nowX < x)
|
while (nowStep < generationStep && nowX < x) //Äåëàåì generationStep çà êàäð è ïðîâåðÿåì ÷òî ãåíåðàöèÿ åùå íóæíà
|
||||||
{
|
{
|
||||||
|
|
||||||
while (nowY < y)
|
if (nowY < y)//Ïðîâåðÿåì ÷òî ñòîëáåö åùå íå çàêîí÷åí
|
||||||
{
|
{
|
||||||
float modX = 0.25f;
|
float modX = 0.25f; //Ìíîæèòåëü äëÿ ñäâèãà ïî Ox
|
||||||
float modY = 0;
|
float modY = 0; //Áàçîâûé ìíîæèòåëü ñäâèãà ïî Oy
|
||||||
|
|
||||||
if (nowX % 2 == 1)
|
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));
|
initHex(mapStart.position.x + (scaleX * nowX) - (modX * scaleX * nowX), mapStart.position.y + (scaleY * nowY) + (modY * scaleY));//Ñîçäàíèå ãåêñà ñî ñäâèãàìè
|
||||||
nowY++;
|
nowY++; //Óâåëè÷èâàåì íîìåð ñãåíåðèðîâàííîãî ãåêñà â ñòîëáöå
|
||||||
|
progressNow++;//Óâåëè÷èâàåì ñ÷åò÷èê ïðîãðåññà
|
||||||
|
nowStep++;//Óâåëè÷èâàåì ñ÷åò÷èê êîëè÷åñòâà ñãåíåðèðîâàííûõ çà êàäð ãåêñîâ
|
||||||
}
|
}
|
||||||
|
else //Åñëè ñòîëáåö çàîí÷èëñÿ ïåðåõîäèì ê ñëåäóþùåìó
|
||||||
{
|
{
|
||||||
nowX++;
|
nowX++;
|
||||||
nowY = 0;
|
nowY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (nowStep == generationStep) nowStep = 0;//Ñáðàñûâàåì ñ÷åò÷èê ñãåíåðèðîâàííûõ çà êàäð ãåêñîâ
|
||||||
|
|
||||||
|
if (nowX == x) this.enabled = false;//Çàâåðøàåì ãåíåðàöèþ ïîñëå åå êîíöà
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initHex(float x, float y)
|
private void initHex(float x, float y)
|
||||||
{
|
{
|
||||||
GameObject hex = Instantiate(hexPrefab);
|
GameObject hex = Instantiate(hexPrefab);//Ñîçäàåì êëîí áàçîâîãî ãåêñà
|
||||||
hex.transform.Translate(new Vector3(x, y, 0));
|
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();
|
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);//Èíèöèàëèçèðóåì ëîãèêó ãåêñà
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,19 @@ using UnityEngine;
|
|||||||
public class Hex : MonoBehaviour
|
public class Hex : MonoBehaviour
|
||||||
{
|
{
|
||||||
public enum landscapeTypes { water, land, hill, highHill, mountain, uncrosableMountain };
|
public enum landscapeTypes { water, land, hill, highHill, mountain, uncrosableMountain };
|
||||||
|
public enum stateTypes { idle, owned, battle };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Vector2Int position;
|
public Vector2Int position;
|
||||||
public float noiseValue;
|
public float noiseValue;
|
||||||
public landscapeTypes landType;
|
public landscapeTypes landType;
|
||||||
public int miniMapSeed;
|
public int miniMapSeed;
|
||||||
|
|
||||||
public int income; //Ìîäèôèêàòîð ê äîõîäó â åäåíèöó âðåìåíè îò ýòîãî ãåêñà
|
public int income { get; private set; } //Ìîäèôèêàòîð ê äîõîäó â åäåíèöó âðåìåíè îò ýòîãî ãåêñà
|
||||||
|
public int ownerID;
|
||||||
|
public stateTypes state = stateTypes.idle;
|
||||||
|
|
||||||
//TODO ïåðåìåííàÿ äëÿ ïàìàòè ñîäåðæèìîãî
|
//TODO ïåðåìåííàÿ äëÿ ïàìàòè ñîäåðæèìîãî
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
@@ -25,4 +31,98 @@ public class Hex : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
8
Assets/scripts/miniMap.meta
Normal file
8
Assets/scripts/miniMap.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1aec07be2f1cdd5438c819666796f8bf
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/scripts/miniMap/MiniMapGenerator.cs
Normal file
18
Assets/scripts/miniMap/MiniMapGenerator.cs
Normal 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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 62970f09f26042b4c8cf4ca27a04b8f1
|
guid: 966127aa560664d43bdb73e9824ae9f9
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
76
Assets/scripts/miniMap/Tile.cs
Normal file
76
Assets/scripts/miniMap/Tile.cs
Normal 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/scripts/miniMap/Tile.cs.meta
Normal file
11
Assets/scripts/miniMap/Tile.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 452e22fcead7325429450f21972ae4b9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -17,7 +17,7 @@ public class perlinNoise : MonoBehaviour
|
|||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(seed == -1) { seed = (int) (Random.value * 1000000000); }
|
if(seed == -1) { seed = (int) (Random.value * int.MaxValue); }
|
||||||
Debug.Log(seed);
|
Debug.Log(seed);
|
||||||
|
|
||||||
Random.InitState(seed);
|
Random.InitState(seed);
|
||||||
|
|||||||
Binary file not shown.
@@ -16,9 +16,9 @@
|
|||||||
---
|
---
|
||||||
### Техническая информация:
|
### Техническая информация:
|
||||||
Платформы:
|
Платформы:
|
||||||
- :fa-windows: Windows***
|
- Windows*
|
||||||
- :fa-linux: Linux
|
- Linux
|
||||||
- ~~:fa-android: *Android*~~*(Вероятно будет порт)*
|
- ~~*Android*~~*(Вероятно будет порт)*
|
||||||
|
|
||||||
**Целевая платформа*
|
*Целевая платформа
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user