Added hud buttons, fixed river generation, v1.2.0

This commit is contained in:
Nicola Sovic
2022-04-08 17:15:48 +02:00
parent 16568360a0
commit 8266248281
20 changed files with 1399 additions and 1540 deletions

View File

@@ -115,17 +115,12 @@ namespace Assets.Scripts
}
public void closeIntroduction()
{
audioHandler.playButtonClick();
uihandler.openTutorial();
}
public void closeTutorial()
{
audioHandler.playButtonClick();
uihandler.startGame();
EventSystem.current.SetSelectedGameObject(null);
}
}
}
}

View File

@@ -2,6 +2,7 @@ using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class Controls : MonoBehaviour
{
@@ -25,6 +26,7 @@ public class Controls : MonoBehaviour
{
if (!player.GetComponent<Player>().takeDamage(0))
{
EventSystem.current.SetSelectedGameObject(null);
if (!uihandler.isPlayerInFight())
{
checkNormalControls();

View File

@@ -155,7 +155,43 @@ public class NoiseGenerator
private float[] calculateSamplesRiver(GameObject tile)
{
Mesh mesh = tile.GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
float[] samples = calculateBasicSamples(tile);
bool isVertical = (rand.Next(0,2) == 0 ? true : false);
int startX = 0;
int startZ = 0;
if (isVertical)
{
startZ = (rand.Next(0, 2) == 0 ? 4 : -4);
startX = rand.Next(-4, 5);
}
else
{
startZ = rand.Next(-4, 5);
startX = (rand.Next(0, 2) == 0 ? 4 : -4);
}
for (int k = 0; k < vertices.Length; k++)
{
if (isVertical)
{
if (Mathf.Round(vertices[k].x) == startX && Mathf.Round(vertices[k].z) != 5 && Mathf.Round(vertices[k].z) != -5)
{
samples[k] = samples[k] - rand.Next(2, 4) + 0.5f;
}
}
else
{
if (Mathf.Round(vertices[k].x) != 5 && Mathf.Round(vertices[k].x) != -5 && Mathf.Round(vertices[k].z) == startZ)
{
samples[k] = samples[k] - rand.Next(2, 4) + 0.5f;
}
}
}
Debug.Log("River");
return samples;
}

View File

@@ -25,6 +25,7 @@ namespace Assets.Scripts
public GameObject introduction;
public GameObject tooltip;
public GameObject tutorial;
public GameObject buttonsHUD;
public UIState state;
@@ -42,14 +43,6 @@ namespace Assets.Scripts
if (state == UIState.GAME)
{
updatePlayerHUD();
Cursor.visible = false;
}
else
{
if (state != UIState.FIGHT && state != UIState.MAP && state != UIState.QUEST)
{
Cursor.visible = true;
}
}
}
@@ -60,7 +53,7 @@ namespace Assets.Scripts
public bool canPlayerMove()
{
if (state == UIState.GAME || state == UIState.MAP || state == UIState.CHARACTER || state == UIState.QUEST)
if (state == UIState.GAME || state == UIState.CHARACTER || state == UIState.QUEST)
{
return true;
}
@@ -74,6 +67,7 @@ namespace Assets.Scripts
public void startGame()
{
introduction.transform.localScale = new Vector3(0, 0, 0);
int index = GameObject.Find("dropSize").GetComponent<Dropdown>().value;
int cityAmount = 0;
switch (index)
@@ -93,7 +87,6 @@ namespace Assets.Scripts
}
GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>().resetGame(cityAmount);
setPlayerInformation();
tutorial.transform.localScale = new Vector3(0,0,0);
compass.transform.localScale = new Vector3(1, 1, 1);
showHUD();
state = UIState.GAME;
@@ -228,6 +221,7 @@ namespace Assets.Scripts
{
playerHUD.transform.localScale = new Vector3(1,1,1);
compass.transform.localScale = new Vector3(1, 1, 1);
buttonsHUD.transform.localScale = new Vector3(1, 1, 1);
}
public void openMainMenu()
@@ -238,7 +232,7 @@ namespace Assets.Scripts
public void switchPauseMenu()
{
if (state == UIState.GAME || state == UIState.CHARACTER || state == UIState.MAP || state == UIState.PAUSE || state == UIState.QUEST)
if (state == UIState.GAME || state == UIState.CHARACTER || state == UIState.PAUSE || state == UIState.QUEST)
{
if (state == UIState.PAUSE)
{
@@ -546,11 +540,6 @@ namespace Assets.Scripts
state = UIState.TUTORIAL;
}
public void openTutorial()
{
hideOtherElements(tutorial);
}
public void updateCreationInformation()
{
setPlayerInformation();

View File

@@ -12,7 +12,6 @@ namespace Assets.Scripts
FIGHT,
CHARACTERCREATION,
CHARACTER,
MAP,
DEATH,
OPTIONS,
GAME,