After remove

This commit is contained in:
Finnchen123
2024-09-02 19:20:39 +02:00
parent 1235d5ff0c
commit be0adf7eb6
1506 changed files with 7 additions and 164696 deletions

View File

@@ -1,123 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts
{
public class BasicSkill
{
int level;
int baseDamage;
int secondaryConsumption;
int cooldown;
int maxCooldown;
string skillname;
string description;
Texture skillIcon;
GameObject skillAnimation;
public BasicSkill(int baseDamage, int secondaryConsumption, int maxCooldown, string name, string skillIconPath, GameObject skillAnimation)
{
this.baseDamage = baseDamage;
this.secondaryConsumption = secondaryConsumption;
this.maxCooldown = maxCooldown;
cooldown = 0;
level = 1;
skillname = name;
skillIcon = Resources.Load<Texture>(skillIconPath);
this.skillAnimation = skillAnimation;
}
public void setDescription(string desc)
{
description = desc;
}
public int calculateDamage(int attribute, bool isCrit)
{
cooldown = maxCooldown;
if (isCrit)
{
return (baseDamage + attribute)* level * 2;
}
return (baseDamage + attribute) * level ;
}
public bool canPlayerCast(int playerSecondary)
{
bool result = false;
if (playerSecondary >= secondaryConsumption && cooldown == 0)
{
result = true;
}
return result;
}
public void display(GameObject image, GameObject desc, int playerSecondary)
{
image.GetComponent<RawImage>().texture = skillIcon;
if (canPlayerCast(playerSecondary))
{
desc.GetComponent<Text>().text = TextHandler.getText(skillname) + "(" + secondaryConsumption + ")";
}
else
{
desc.GetComponent<Text>().text = "(" + secondaryConsumption + " mana) " + "("+cooldown+" cd)";
}
}
public void displaySkill(GameObject image, GameObject desc)
{
image.GetComponent<RawImage>().texture = skillIcon;
desc.GetComponent<Text>().text = TextHandler.getText(skillname) + "(Mana: " + secondaryConsumption + "): \r\n" + TextHandler.getText(skillname+"Desc");
}
public void reduceCooldown()
{
if (cooldown > 0)
{
cooldown--;
}
}
public int getSecondaryConsumption()
{
return secondaryConsumption;
}
public void playSound(AudioHandler audioHandler)
{
switch (skillname)
{
case "Slash":
audioHandler.playHit();
break;
case "Block":
break;
case "Execution":
audioHandler.playHit();
break;
case "Stab":
audioHandler.playDaggerHit();
break;
case "SmokeScreen":
break;
case "Heartstop":
audioHandler.playDaggerHit();
break;
case "Icicle":
audioHandler.playIceHit();
break;
case "Teleport":
break;
case "Fireball":
audioHandler.playExplosion();
break;
}
}
}
}

View File

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

View File

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

View File

@@ -1,36 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChoppingBehaviour : StateMachineBehaviour
{
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Log("Started animation " + stateInfo.ToString());
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
//{
//
//}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Log("Stopped animation " + stateInfo.ToString());
}
// OnStateMove is called right after Animator.OnAnimatorMove()
//override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
//{
// // Implement code that processes and affects root motion
//}
// OnStateIK is called right after Animator.OnAnimatorIK()
//override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
//{
// // Implement code that sets up animation IK (inverse kinematics)
//}
}

View File

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

View File

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

View File

@@ -1,57 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Assets.Scripts.Player;
using UnityEngine;
namespace Assets.Scripts.Classes
{
public class BasicClass
{
public string classname;
protected int dexterityBonus;
protected int intelligenceBonus;
protected int strengthBonus;
protected int healthBonus;
protected int secondaryBonus;
protected string leftHandName;
protected string rightHandName;
public BasicClass()
{
classname = "";
dexterityBonus = 0;
intelligenceBonus = 0;
strengthBonus = 0;
healthBonus = 0;
secondaryBonus = 0;
rightHandName = "";
leftHandName = "";
}
public void applyBonus(PlayerObject player)
{
player.changeStats(strengthBonus, healthBonus, dexterityBonus, intelligenceBonus, secondaryBonus);
}
public void loadHandObjects()
{
GameObject leftHandPrefab = Resources.Load<GameObject>("Prefabs/"+leftHandName);
GameObject rightHandPrefab = Resources.Load<GameObject>("Prefabs/"+rightHandName);
GameObject leftHandParent = GameObject.Find("leftHand");
GameObject rightHandParent = GameObject.Find("rightHand");
if(leftHandPrefab != null){
GameObject leftHand = GameObject.Instantiate(leftHandPrefab, leftHandParent.transform);
}
if(rightHandPrefab != null){
GameObject rightHand = GameObject.Instantiate(rightHandPrefab, rightHandParent.transform);
}
}
}
}

View File

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

View File

@@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts.Classes
{
class DruidClass : BasicClass
{
public DruidClass() : base()
{
classname = "Druid";
dexterityBonus = 1;
intelligenceBonus = 1;
strengthBonus = -2;
healthBonus = -10;
secondaryBonus = 20;
leftHandName = "smallShield";
rightHandName = "wand";
}
}
}

View File

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

View File

@@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Classes
{
class MageClass : BasicClass
{
public MageClass() : base()
{
classname = "Mage";
dexterityBonus = 0;
intelligenceBonus = 2;
strengthBonus = -2;
healthBonus = -10;
secondaryBonus = 10;
leftHandName = "orb";
rightHandName = "wand";
}
}
}

View File

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

View File

@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Classes
{
class ThiefClass : BasicClass
{
public ThiefClass() : base()
{
classname = "Thief";
dexterityBonus = 2;
intelligenceBonus = -1;
strengthBonus = -1;
healthBonus = 0;
secondaryBonus = 0;
leftHandName = "smallShield";
rightHandName = "dagger";
}
}
}

View File

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

View File

@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Classes
{
class WarriorClass : BasicClass
{
public WarriorClass() : base()
{
classname = "Warrior";
dexterityBonus = 0;
intelligenceBonus = -2;
strengthBonus = 2;
healthBonus = 10;
secondaryBonus = -10;
leftHandName = "shield";
rightHandName = "sword";
}
}
}

View File

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

View File

@@ -1,280 +0,0 @@
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ContentGenerator : MonoBehaviour
{
public GameObject[] enemies;
public GameObject[] trees;
public GameObject[] stones;
public GameObject grass;
public GameObject boss;
public GameObject npc;
public GameObject house;
static System.Random rand = new System.Random();
public GameObject generateEnemy()
{
int index = rand.Next(0, enemies.Length);
return enemies[index];
}
public GameObject generateContent(string tiletype)
{
switch (tiletype.ToLower())
{
case "plain":
return generateTileContent();
case "mountains":
return generateStoneTileContent();
case "forest":
return generateTreeTileContent();
case "hills":
return generateHillTileContent();
case "desert":
return generateDesertTileContent();
case "city":
return generateCityTileContent();
}
return null;
}
public GameObject generateTileContent()
{
int chance = rand.Next(1, 101);
if (chance < 50)
{
return null;
}
else if (chance >= 50 && chance < 90)
{
if (rand.Next(0,2) == 0)
{
return trees[rand.Next(0, trees.Length)];
}
else
{
return stones[rand.Next(0, stones.Length)];
}
}
else if (chance >= 90 && chance < 95)
{
return generateEnemy();
}
else if(chance >= 95 && chance < 99)
{
return boss;
}
else
{
return npc;
}
}
public GameObject generateStoneTileContent()
{
int chance = rand.Next(1, 101);
if (chance < 60)
{
return null;
}
else if (chance >= 60 && chance < 90)
{
return stones[rand.Next(0, stones.Length)];
}
else if (chance >= 90 && chance < 95)
{
return generateEnemy();
}
else if (chance >= 95 && chance < 99)
{
return boss;
}
else
{
return npc;
}
}
public GameObject generateTreeTileContent()
{
int chance = rand.Next(1, 101);
if (chance < 60)
{
return trees[rand.Next(0, trees.Length)];
}
else if (chance >= 60 && chance < 90)
{
return stones[rand.Next(0, stones.Length)];
}
else if (chance >= 90 && chance < 95)
{
return generateEnemy();
}
else if (chance >= 95 && chance < 99)
{
return boss;
}
else
{
return npc;
}
}
public GameObject generateDesertTileContent()
{
int chance = rand.Next(1, 101);
if (chance < 50)
{
return null;
}
else if (chance >= 50 && chance < 90)
{
return stones[rand.Next(0, stones.Length)];
}
else if (chance >= 90 && chance < 95)
{
return generateEnemy();
}
else if (chance >= 95 && chance < 99)
{
return boss;
}
else
{
return npc;
}
}
public GameObject generateHillTileContent()
{
int chance = rand.Next(1, 101);
if (chance < 75)
{
return null;
}
else if (chance >= 75 && chance < 90)
{
return stones[rand.Next(0, stones.Length)];
}
else if (chance >= 90 && chance < 95)
{
return generateEnemy();
}
else if (chance >= 95 && chance < 99)
{
return boss;
}
else
{
return npc;
}
}
public GameObject loadObject(JToken json)
{
GameObject result = gameObject;
string name = json["objectname"].ToString().Replace("(Clone)", "");
if (name.ToLower().Contains("rock") || name.ToLower().Contains("ore"))
{
foreach (GameObject stone in stones)
{
if (stone.name == name)
{
result = stone;
break;
}
}
}
else if(name.ToLower().Contains("tree"))
{
foreach (GameObject tree in trees)
{
if (tree.name == name)
{
result = tree;
break;
}
}
}
else if(name.ToLower().Contains("npc")){
result = npc;
}
else if(name.ToLower().Contains("house")){
result = house;
}
return result;
}
public GameObject loadEnemy(JToken json)
{
GameObject result = gameObject;
string name = json["enemyname"].ToString().Replace("(Clone)", "");
if (name.Split(' ').Length > 1)
{
name = name.Split(' ')[1];
}
if (name == "(Boss)")
{
result = boss;
}
else
{
switch (name)
{
case "Metal":
name = "SlimeMetalIdle";
break;
case "MiniBoss":
name = "SlimeMiniBossIdle";
break;
case "Forest":
name = "SlimeForestIdle";
break;
case "Mage":
name = "SlimeMageIdle";
break;
case "Warrior":
name = "SlimeWarriorIdle";
break;
default:
name = "SlimeBaseIdle";
break;
}
foreach (GameObject enemy in enemies)
{
if (enemy.name == name)
{
result = enemy;
break;
}
}
}
return result;
}
public GameObject generateCityTileContent(){
int chance = rand.Next(1, 101);
if (chance < 10)
{
return null;
}
else if (chance >= 10 && chance < 25)
{
return house;
}
else if (chance >= 25 && chance < 55)
{
return trees[rand.Next(0, trees.Length)];
}
else if (chance >= 55 && chance < 85)
{
return stones[rand.Next(0, stones.Length)];
}
else
{
return npc;
}
}
}

View File

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

View File

@@ -1,274 +0,0 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.UI;
using Assets.Scripts.Player;
using Assets.Scripts.InteractableObjects;
public class Controls : MonoBehaviour
{
GameObject player;
GameObject fight;
GameObject worldGen;
GameObject playerCam;
UIHandler uihandler;
Vector3 input;
Vector2 view;
PlayerInput playerInput;
MoveDirection direction;
public Vector2 sensitivityController = new Vector2(0,0);
public Vector2 sensitivityMouse = new Vector2(0,0);
float multiplier = 0.01f; //DEV Purpose only
void Start()
{
player = GameObject.Find("Player");
fight = GameObject.Find("Fight");
worldGen = GameObject.Find("WorldGenerator");
playerCam = GameObject.Find("Main Camera");
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
input = new Vector3();
view = new Vector2();
playerInput = GetComponent<PlayerInput>();
direction = MoveDirection.None;
}
// Update is called once per frame
void Update()
{
if (uihandler.state == UIState.GAME && playerInput.currentActionMap.name != "MainGame")
{
playerInput.SwitchCurrentActionMap("MainGame");
}
if (uihandler.state != UIState.GAME && playerInput.currentActionMap.name != "Menu")
{
playerInput.SwitchCurrentActionMap("Menu");
}
if (!player.GetComponent<PlayerGameObject>().takeDamage(0))
{
if (!uihandler.isPlayerInFight())
{
if (uihandler.canPlayerRotate())
{
if(playerInput.currentControlScheme == "Controller"){
playerCam.GetComponent<PlayerCamera>().lookAround(view, sensitivityController * multiplier);
player.GetComponent<PlayerGameObject>().rotate(view, sensitivityController * multiplier);
}
else{
playerCam.GetComponent<PlayerCamera>().lookAround(view, sensitivityMouse * multiplier);
player.GetComponent<PlayerGameObject>().rotate(view, sensitivityMouse * multiplier);
}
}
if (uihandler.canPlayerMove())
{
player.GetComponent<PlayerGameObject>().move(input);
}
}
}
}
public void FixedUpdate()
{
if (direction != MoveDirection.None)
{
AxisEventData data = new AxisEventData(EventSystem.current);
data.moveDir = direction;
data.selectedObject = EventSystem.current.currentSelectedGameObject;
ExecuteEvents.Execute(data.selectedObject, data, ExecuteEvents.moveHandler);
}
if (playerInput.currentControlScheme == "Controller")
{
if (Cursor.lockState != CursorLockMode.Locked)
{
Cursor.lockState = CursorLockMode.Locked;
}
GameObject.Find("txtInteract").GetComponent<Text>().text = GameObject.Find("txtInteract").GetComponent<Text>().text.Replace("[E]", "[ButtonEast]");
GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text = GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text.Replace("[E]", "[ButtonEast]");
GameObject.Find("txtTutorialGoal").GetComponent<Text>().text = GameObject.Find("txtTutorialGoal").GetComponent<Text>().text.Replace("[ESC]", "[Start]");
}
else
{
if (uihandler.canPlayerRotate())
{
Cursor.lockState = CursorLockMode.Locked;
}
else
{
Cursor.lockState = CursorLockMode.Confined;
}
GameObject.Find("txtInteract").GetComponent<Text>().text = GameObject.Find("txtInteract").GetComponent<Text>().text.Replace("[ButtonEast]", "[E]");
GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text = GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text.Replace("[E]", "[ButtonEast]");
GameObject.Find("txtTutorialGoal").GetComponent<Text>().text = GameObject.Find("txtTutorialGoal").GetComponent<Text>().text.Replace("[Start]", "[ESC]");
}
}
public void OnLooking(InputValue value)
{
view = value.Get<Vector2>();
}
public void OnMovement(InputValue value)
{
try
{
input = value.Get<Vector3>();
}
catch
{
if (value.Get<Vector2>().x < 0)
{
direction = MoveDirection.Left;
}
else if (value.Get<Vector2>().x > 0)
{
direction = MoveDirection.Right;
}
else if (value.Get<Vector2>().y < 0)
{
direction = MoveDirection.Down;
}
else if (value.Get<Vector2>().y > 0)
{
direction = MoveDirection.Up;
}
}
}
public void OnInteraction()
{
if (uihandler.canPlayerMove())
{
GameObject target = playerCam.GetComponent<PlayerCamera>().interactWithObject();
if (target != null)
{
switch (target.tag.Split(':')[1])
{
case "Enemy":
fight.GetComponent<Fight>().startFight(worldGen.GetComponent<WorldGenerator>().getCurrentTile(), target, player);
break;
case "Tree":
player.GetComponent<PlayerGameObject>().getPlayer().getStat("TreeCount").changeAmount(1);
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Wood"));
break;
case "Stone":
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Rock"));
break;
case "NPC":
break;
case "Door":
break;
case "Chest":
break;
case "Ore":
if (target.name.ToLower().Contains("iron"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Iron ore"));
}
else if (target.name.ToLower().Contains("gold"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Gold ore"));
}
else if (target.name.ToLower().Contains("copper"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Copper ore"));
}
else if (target.name.ToLower().Contains("tin"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Tin ore"));
}
player.GetComponent<PlayerGameObject>().getPlayer().getStat("OreCount").changeAmount(1);
break;
}
target.GetComponent<InteractableObject>().OnInteraction(player);
}
}
}
public void OnInventory()
{
uihandler.switchInventory();
}
public void OnQuestlog()
{
uihandler.switchQuestLog();
}
public void OnPause()
{
uihandler.switchPauseMenu();
}
public void OnSkillOne()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(1);
}
}
public void OnSkillTwo()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(2);
}
}
public void OnSkillThree()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(3);
}
}
public void OnSkillFour()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(4);
}
}
public void OnSkillFive()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(5);
}
}
public void OnSkillSix()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(6);
}
}
public void OnDisarm()
{
if (player.GetComponent<PlayerGameObject>().isArmed)
{
player.GetComponent<Animator>().SetTrigger("WeaponHandling");
player.GetComponent<Animator>().SetBool("isArmed", true);
player.GetComponent<PlayerGameObject>().isArmed = false;
player.GetComponent<Animator>().SetInteger("objectCategory", 0);
}
else
{
player.GetComponent<Animator>().SetTrigger("WeaponHandling");
player.GetComponent<Animator>().SetBool("isArmed", false);
player.GetComponent<PlayerGameObject>().isArmed = true;
player.GetComponent<Animator>().SetInteger("objectCategory", 0);
}
}
}

View File

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

View File

@@ -1,131 +0,0 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Assets.Scripts.Player;
using Assets.Scripts.InteractableObjects;
public class Fight : MonoBehaviour
{
GameObject tile;
GameObject enemy;
GameObject player;
System.Random rand = new System.Random();
UIHandler uihandler;
public void startFight(GameObject tile, GameObject enemy, GameObject player)
{
this.tile = tile;
this.enemy = enemy;
this.player = player;
enemy.GetComponent<Enemy>().scaleEnemy(player.GetComponent<PlayerGameObject>());
enemy.transform.rotation = Quaternion.Euler(0, GameObject.Find("Main Camera").transform.rotation.y, 0);
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
uihandler.openFight();
uihandler.updateFightInterface(enemy, player);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnActionOne"));
}
private void endFight()
{
uihandler.closeFight();
}
public void playerAction(int index)
{
int playerDamage = 0;
int skillnumber = -1;
bool escapedSuccesfully = false;
switch (index)
{
case 1:
if (rand.Next(1, 11) <= 3)
{
escapedSuccesfully = true;
endFight();
uihandler.showMessage("INFORMATION;" + TextHandler.getText("escape"));
}
else
{
uihandler.showMessage("ERROR;" + TextHandler.getText("escapeFail"));
}
break;
case 2:
//User waits
break;
case 3:
playerDamage = player.GetComponent<PlayerGameObject>().calculateDamage();
break;
case 4:
skillnumber = 0;
break;
case 5:
skillnumber = 1;
break;
case 6:
skillnumber = 2;
break;
}
if (skillnumber != -1)
{
playerDamage = player.GetComponent<PlayerGameObject>().castSkill(skillnumber);
}
player.GetComponent<PlayerGameObject>().reduceCooldown(skillnumber);
player.GetComponent<PlayerGameObject>().regainSecondary();
bool isDead = enemy.GetComponent<Enemy>().takeDamage(playerDamage);
if (isDead)
{
if (enemy.GetComponent<Enemy>().getEnemyName() == "Slime (Boss)")
{
SteamWorksHandler.getStandardAchievement("BossAchievement");
}
endFight();
tile.GetComponent<Tile>().enemyKilled(enemy);
player.GetComponent<PlayerGameObject>().enemyKilled();
player.GetComponent<PlayerGameObject>().gainExperience(enemy.GetComponent<Enemy>().getExperience());
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(enemy.GetComponent<Enemy>().getItem());
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("kill", enemy, 1);
}
else
{
int chance = escapedSuccesfully ? 3 : 10;
if (rand.Next(1, 11) <= chance)
{
enemyAction();
uihandler.updateFightInterface(enemy, player);
}
}
}
public void enemyAction()
{
int enemyDamage = -1;
// { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence };
int[] enemyStats = enemy.GetComponent<Enemy>().getStats();
int index = rand.Next(0, 2);
if (index == 1 && enemyStats[2] <= 0)
{
index = 0;
}
switch (index)
{
case 0:
enemyDamage = enemy.GetComponent<Enemy>().calculateDamage();
break;
case 1:
enemyDamage = enemy.GetComponent<Enemy>().calculateHeavy();
break;
}
if (player.GetComponent<PlayerGameObject>().takeDamage(enemyDamage))
{
SteamWorksHandler.getStandardAchievement("DeathAchievement");
uihandler.showDeathScreen();
}
}
}

View File

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

View File

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

View File

@@ -1,123 +0,0 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
public class AudioHandler : MonoBehaviour
{
public AudioClip buttonClick;
public AudioClip damage;
public AudioClip explosion;
public AudioClip hit;
public AudioClip hitDagger;
public AudioClip IceHit;
public AudioClip LevelUp;
public AudioClip jump;
AudioSource cameraAudio;
AudioSource playerAudio;
// Start is called before the first frame update
public void Start()
{
cameraAudio = GameObject.Find("Main Camera").GetComponent<AudioSource>();
playerAudio = GameObject.Find("Player").GetComponent<AudioSource>();
}
public void playButtonClick()
{
cameraAudio.mute = true;
playerAudio.clip = buttonClick;
playerAudio.Play();
cameraAudio.mute = false;
}
public void playDamage()
{
cameraAudio.mute = true;
playerAudio.clip = damage;
playerAudio.Play();
cameraAudio.mute = false;
}
public void playExplosion()
{
cameraAudio.mute = true;
playerAudio.clip = explosion;
playerAudio.Play();
cameraAudio.mute = false;
}
public void playHit()
{
cameraAudio.mute = true;
playerAudio.clip = hit;
playerAudio.Play();
cameraAudio.mute = false;
}
public void playDaggerHit()
{
cameraAudio.mute = true;
playerAudio.clip = hitDagger;
playerAudio.Play();
cameraAudio.mute = false;
}
public void playIceHit()
{
cameraAudio.mute = true;
playerAudio.clip = IceHit;
playerAudio.Play();
cameraAudio.mute = false;
}
public void playJump()
{
cameraAudio.mute = true;
playerAudio.clip = jump;
playerAudio.Play();
cameraAudio.mute = false;
}
public void playLevelUp()
{
cameraAudio.mute = true;
playerAudio.clip = LevelUp;
playerAudio.Play();
cameraAudio.mute = false;
}
public void changeVolumeMusic()
{
cameraAudio.volume = GameObject.Find("slideMusic").GetComponent<Slider>().value;
int volume = (int)(cameraAudio.volume * 100);
GameObject.Find("txtMusic").GetComponent<Text>().text = TextHandler.getText("music") + " (" + volume + "%)";
}
public void changeVolumeEffects()
{
playerAudio.volume = GameObject.Find("slideEffects").GetComponent<Slider>().value;
int volume = (int)(playerAudio.volume * 100);
GameObject.Find("txtEffects").GetComponent<Text>().text = TextHandler.getText("effects") + " (" + volume + "%)";
}
public void setSlider()
{
GameObject.Find("slideEffects").GetComponent<Slider>().value = playerAudio.volume;
GameObject.Find("slideMusic").GetComponent<Slider>().value = cameraAudio.volume;
}
public string saveAudioSettings()
{
string result = "";
float music = GameObject.Find("slideMusic").GetComponent<Slider>().value;
float effects = GameObject.Find("slideEffects").GetComponent<Slider>().value;
result = result + "Music:" + music + "\r\n";
result = result + "Effects:" + effects;
return result;
}
}

View File

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

View File

@@ -1,151 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using Assets.Scripts.Player;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Assets.Scripts
{
public class ButtonHandler : MonoBehaviour
{
UIHandler uihandler;
PlayerGameObject player;
AudioHandler audioHandler;
WorldGenerator worldGenerator;
GameObject fight;
private void Start()
{
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
player = GameObject.Find("Player").GetComponent<PlayerGameObject>();
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
audioHandler = GameObject.Find("AudioHandler").GetComponent<AudioHandler>();
fight = GameObject.Find("Fight");
}
public void openOptions()
{
audioHandler.playButtonClick();
uihandler.openOptions();
}
public void closeOptions()
{
audioHandler.playButtonClick();
uihandler.closeOptions();
}
public void exitToMenu()
{
audioHandler.playButtonClick();
uihandler.openMainMenu();
}
public void closePauseMenu()
{
audioHandler.playButtonClick();
uihandler.closePauseMenu();
}
public void upgradeStrength()
{
audioHandler.playButtonClick();
player.upgradeStrength();
}
public void upgradeDexterity()
{
audioHandler.playButtonClick();
player.upgradeDexterity();
}
public void upgradeIntelligence()
{
audioHandler.playButtonClick();
player.upgradeIntelligence();
}
public void upgradeHealth()
{
audioHandler.playButtonClick();
player.upgradeHealth();
}
public void upgradeSecondary()
{
audioHandler.playButtonClick();
player.upgradeSecondary();
}
public void saveOptions()
{
string saveText = "";
audioHandler.playButtonClick();
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
saveText = saveText + uihandler.saveLanguage() + "\r\n";
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
GameObject.Find("Controls").GetComponent<Controls>().sensitivityMouse = new Vector2(
GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value,
GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value
);
GameObject.Find("Controls").GetComponent<Controls>().sensitivityController = new Vector2(
GameObject.Find("slideSensitivityControllerHorizontal").GetComponent<Slider>().value,
GameObject.Find("slideSensitivityControllerVertical").GetComponent<Slider>().value
);
saveText = saveText + "SensitivityController:"+GameObject.Find("slideSensitivityControllerHorizontal").GetComponent<Slider>().value + "/" + GameObject.Find("slideSensitivityControllerVertical").GetComponent<Slider>().value + "\r\n";
saveText = saveText + "SensitivityMouse:"+GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value + "/" + GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value;
FileHandler.saveOptions(saveText);
uihandler.closeOptions();
}
public void closeIntroduction()
{
audioHandler.playButtonClick();
uihandler.startGame();
}
public void switchQuestlog()
{
audioHandler.playButtonClick();
uihandler.switchQuestLog();
}
public void switchOptions()
{
audioHandler.playButtonClick();
uihandler.switchPauseMenu();
}
public void switchInventory()
{
audioHandler.playButtonClick();
uihandler.switchInventory();
}
public void saveGame()
{
audioHandler.playButtonClick();
FileHandler.generateDirectory();
string saveString = "{\r\n";
saveString = saveString + "\"player\": {\r\n" + player.saveGame() + "\r\n},\r\n";
saveString = saveString + "\"world\": {\r\n" + worldGenerator.saveGame() + "\r\n},\r\n";
saveString = saveString + "\"inventory\": {\r\n" + GameObject.Find("Inventory").GetComponent<Inventory>().saveGame() + "\r\n},\r\n";
saveString = saveString + "\"questlog\": {\r\n" + GameObject.Find("QuestLog").GetComponent<QuestLog>().saveGame() + "\r\n}\r\n";
saveString = saveString + "\r\n}";
FileHandler.saveGame(saveString, "./save.json");
}
public void castSkill(int index){
fight.GetComponent<Fight>().playerAction(index);
}
public void switchOptionView(string key){
uihandler.showOptionView(key);
}
public void closeTutorial(){
uihandler.closeTutorial();
}
}
}

View File

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

View File

@@ -1,55 +0,0 @@
using Assets.Scripts.Player;
using Steamworks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts
{
class EasterEggHandler
{
public static void applyEasterEgg(string playername)
{
if (playername.ToLower().Length > 0)
{
applyNameEasterEgg(playername.ToLower());
}
}
private static void applyNameEasterEgg(string playername)
{
//TODO: Create achievements fitting of their contribution... no game changing things, except godmode
switch (playername)
{
case "threetimes8":
break;
case "finnchen123":
break;
case "thefluffeypanda":
break;
case "nicola":
SteamWorksHandler.getGodModeAchievement();
break;
}
}
public static bool isGodMode(PlayerObject player)
{
bool result = false;
if (player != null)
{
if (player.getPlayerName() != null)
{
if (player.getPlayerName().ToLower() == "nicola")
{
result = true;
}
}
}
return result;
}
}
}

View File

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

View File

@@ -1,208 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine.Localization.Settings;
using Assets.Scripts.Player;
namespace Assets.Scripts
{
public class FileHandler
{
static StreamWriter sw;
static string settingsPath = "./settings.txt";
public static void saveGame(string data, string path)
{
sw = new StreamWriter(path);
sw.Write(data);
sw.Flush();
sw.Close();
}
public static void loadGame(PlayerGameObject player, WorldGenerator worldGenerator, Inventory inventory, QuestLog questLog)
{
if (hasSaveFile())
{
string[] lines = File.ReadAllLines("./save.json");
string jsonString = "";
foreach (string line in lines)
{
jsonString = jsonString + line.Replace("\r\n", "");
}
JObject json = JsonConvert.DeserializeObject<JObject>(jsonString);
player.loadPlayer(json["player"]);
worldGenerator.loadWorld(json["world"]);
inventory.loadInventory(json["inventory"]);
questLog.loadQuests(json["questlog"]);
}
}
public static void saveOptions(string saveText){
sw = new StreamWriter(settingsPath);
sw.Write(saveText);
sw.Flush();
sw.Close();
}
public static void loadOptions(bool isIngame){
if (!File.Exists(settingsPath))
{
sw = File.CreateText(settingsPath);
sw.WriteLine("Music:0.5");
sw.WriteLine("Effects:0.5");
sw.WriteLine("Resolution:1");
sw.WriteLine("Mode:0");
sw.WriteLine("Language:en");
sw.WriteLine("SensitivityMouse:1/1");
sw.WriteLine("SensitivityController:1/1");
sw.Flush();
sw.Close();
}
string[] lines = File.ReadAllLines(settingsPath);
foreach(string line in lines){
switch(line.Split(":")[0]){
case "Music":
GameObject.Find("Main Camera").GetComponent<AudioSource>().volume = float.Parse(line.Split(':')[1]);
break;
case "Effects":
GameObject.Find("Player").GetComponent<AudioSource>().volume = float.Parse(line.Split(':')[1]);
break;
case "Resolution":
switch(line.Split(":")[1].ToLower()){
case "0":
Screen.SetResolution(800, 600, Screen.fullScreenMode);
break;
case "1":
Screen.SetResolution(1280, 800, Screen.fullScreenMode);
break;
case "2":
Screen.SetResolution(1920, 1080, Screen.fullScreenMode);
break;
}
break;
case "Mode":
switch(line.Split(":")[1].ToLower()){
case "0":
Screen.fullScreenMode = FullScreenMode.Windowed;
break;
case "1":
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
break;
case "2":
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
break;
}
break;
case "Language":
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(line.Split(":")[1]);
break;
case "SensitivityMouse":
if(isIngame){
GameObject.Find("Controls").GetComponent<Controls>().sensitivityMouse = new Vector2(
float.Parse(line.Split(':')[1].Split("/")[0]),
float.Parse(line.Split(':')[1].Split("/")[1])
);
}
break;
case "SensitivityController":
if(isIngame){
GameObject.Find("Controls").GetComponent<Controls>().sensitivityController = new Vector2(
float.Parse(line.Split(':')[1].Split("/")[0]),
float.Parse(line.Split(':')[1].Split("/")[1])
);
}
break;
}
}
}
public static void loadOptionDisplay(){
string[] lines = File.ReadAllLines(settingsPath);
foreach(string line in lines){
switch(line.Split(":")[0]){
case "Music":
GameObject.Find("slideMusic").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
break;
case "Effects":
GameObject.Find("slideEffects").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
break;
case "Resolution":
GameObject.Find("dropResolution").GetComponent<Dropdown>().value = int.Parse(line.Split(':')[1]);
break;
case "Mode":
GameObject.Find("dropMode").GetComponent<Dropdown>().value = int.Parse(line.Split(':')[1]);
break;
case "Language":
GameObject.Find("dropLanguage").GetComponent<Dropdown>().value = line.Split(':')[1].Equals("en") ? 1 : 0;
break;
case "SensitivityMouse":
GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value = float.Parse(line.Split(':')[1].Split("/")[0]);
GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value = float.Parse(line.Split(':')[1].Split("/")[1]);
break;
case "SensitivityController":
GameObject.Find("slideSensitivityControllerHorizontal").GetComponent<Slider>().value = float.Parse(line.Split(':')[1].Split("/")[0]);
GameObject.Find("slideSensitivityControllerVertical").GetComponent<Slider>().value = float.Parse(line.Split(':')[1].Split("/")[1]);
break;
}
}
}
public static string generateJSON(string key, object value)
{
return "\"" + key + "\": " + value;
}
public static bool hasSaveFile()
{
return File.Exists("./save.json");
}
public static void saveTile(string content, string path)
{
sw = new StreamWriter(path);
sw.Write(content);
sw.Flush();
sw.Close();
}
public static void saveNoise(string content, string path)
{
sw = new StreamWriter(path, true);
sw.Write(content);
sw.Flush();
sw.Close();
}
public static void generateDirectory()
{
if (Directory.Exists("./save/"))
{
foreach (string file in Directory.GetFiles("./save/"))
{
File.Delete(file);
}
}
else
{
Directory.CreateDirectory("./save/");
}
}
public static string loadTile(string path)
{
string result = "";
string[] lines = File.ReadAllLines(path);
foreach (string line in lines)
{
result = result + line.Replace("\r\n", "");
}
return result;
}
}
}

View File

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

View File

@@ -1,59 +0,0 @@
using Assets.Scripts.Races;
using Assets.Scripts.Classes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Assets.Scripts
{
public class SceneHandler : MonoBehaviour
{
static bool sceneSwitched = false;
private void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
bool hasSceneHandler = false;
foreach (Object o in FindObjectsOfType(typeof(MonoBehaviour)))
{
if (o.name == "SceneHandlerLoaded")
{
hasSceneHandler = true;
break;
}
}
if (!hasSceneHandler)
{
DontDestroyOnLoad(this.gameObject);
this.gameObject.name = "SceneHandlerLoaded";
}
}
public void openMenuScene()
{
SceneManager.LoadSceneAsync("MenuScene", LoadSceneMode.Single);
}
public void openGameScene()
{
SceneManager.LoadSceneAsync("GameScene", LoadSceneMode.Single);
}
public static void switchGameToMenu()
{
if (!sceneSwitched)
{
SceneManager.LoadSceneAsync("MenuScene", LoadSceneMode.Single);
sceneSwitched = true;
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (scene.name == "GameScene")
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().openIntroduction();
}
}
}
}

View File

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

View File

@@ -1,135 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Steamworks;
using Assets.Scripts;
using Assets.Scripts.Player;
public class SteamWorksHandler : MonoBehaviour
{
/* Steam Achievements
* FORMAT = Requirement: Message
* (Currently dropped) Playing for 5 hours: Got nothing else to do?
* (Currently dropped) Playing for 10 hours: Look at THAT sunset!
* (Currently dropped) Playing for 20 hours: You want coffee to your bagel?
* (Currently dropped) Playing for 40 hours: I guess I have a true fan here
* (Currently dropped) Playing for 80 hours: You should consider going outside
*/
static int counterForest = 0;
public static void getForestAchievement(string tiletype)
{
if (counterForest != -1 && !isGodMode())
{
if (tiletype.ToLower() == "forest")
{
counterForest++;
}
else
{
counterForest = 0;
}
if (counterForest >= 5)
{
if (SteamManager.Initialized)
{
SteamUserStats.SetAchievement("ForestAchievement");
SteamUserStats.StoreStats();
}
counterForest = -1;
}
}
}
public static void getStandardAchievement(string name)
{
if (!isGodMode())
{
if (SteamManager.Initialized)
{
SteamUserStats.SetAchievement(name);
SteamUserStats.StoreStats();
}
}
}
public static void getGodModeAchievement()
{
if (SteamManager.Initialized)
{
SteamUserStats.SetAchievement("GodAchievement");
SteamUserStats.StoreStats();
}
}
public static void getSlimeAchievement(int killcount)
{
string name = "";
switch (killcount)
{
case 1:
name = "Kill1Slime";
break;
case 10:
name = "Kill10Slime";
break;
case 50:
name = "Kill50Slime";
break;
case 100:
name = "Kill100Slime";
break;
case 500:
name = "Kill500Slime";
break;
case 1000:
name = "Kill1000Slime";
break;
}
if (!isGodMode())
{
if (SteamManager.Initialized)
{
SteamUserStats.SetAchievement(name);
SteamUserStats.StoreStats();
}
}
}
private static bool isGodMode()
{
return EasterEggHandler.isGodMode(GameObject.Find("Player").GetComponent<PlayerGameObject>().getPlayer());
}
public static void getItemAchievement(Item item)
{
if (SteamManager.Initialized)
{
if (!isGodMode())
{
SteamUserStats.SetAchievement("ItemAchievement");
SteamUserStats.StoreStats();
switch (item.getRarity())
{
case ItemRarity.COMMON:
SteamUserStats.SetAchievement("CommonAchievement");
SteamUserStats.StoreStats();
break;
case ItemRarity.RARE:
SteamUserStats.SetAchievement("RareAchievement");
SteamUserStats.StoreStats();
break;
case ItemRarity.EPIC:
SteamUserStats.SetAchievement("EpicAchievement");
SteamUserStats.StoreStats();
break;
case ItemRarity.LEGENDARY:
SteamUserStats.SetAchievement("LegendaryAchievement");
SteamUserStats.StoreStats();
break;
}
}
}
}
}

View File

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

View File

@@ -1,66 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Localization.Settings;
public class TextHandler : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public static string getText(string key){
bool hasLeftBracket = false;
bool hasRightBracket = false;
if(key.Contains("(")){
hasLeftBracket = true;
key = key.Replace("(","");
}
if(key.Contains(")")){
hasRightBracket = true;
key = key.Replace(")","");
}
if(key[0].Equals(Char.ToUpperInvariant(key[0]))){
key = Char.ToLowerInvariant(key[0]) + key.Substring(1);
}
string text = LocalizationSettings.StringDatabase.GetLocalizedString("MyTexts",key);
if(hasLeftBracket){
text = "(" + text;
}
if(hasRightBracket){
text = text + ")";
}
return text;
}
public static string translate(string text){
string result = "";
string[] parts = text.Split(" ");
for(int i = 0; i < parts.Length; i++){
try{
int.Parse(parts[i]);
result += parts[i] + " ";
}
catch(Exception){
if(parts[i].Contains("/")){
result += parts[i] + " ";
}
else{
result += getText(parts[i]) + " ";
}
}
}
return result;
}
}

View File

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

View File

@@ -1,547 +0,0 @@
using Assets.Scripts.Classes;
using Assets.Scripts.Player;
using Assets.Scripts.Races;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;
using Assets.Scripts.InteractableObjects;
namespace Assets.Scripts
{
public class UIHandler : MonoBehaviour
{
public GameObject compass;
public GameObject information;
public GameObject fight;
public GameObject message;
public GameObject deathscreen;
public GameObject options;
public GameObject pauseMenu;
public GameObject playerHUD;
public GameObject questlog;
public GameObject introduction;
public GameObject tutorial;
public GameObject inventory;
public GameObject waterLayer;
public UIState state;
// Start is called before the first frame update
void Start()
{
FileHandler.loadOptions(true);
}
// Update is called once per frame
void Update()
{
if (state == UIState.GAME || state == UIState.FIGHT)
{
if (GameObject.Find("Player").GetComponent<PlayerGameObject>().getPlayerStat("Killcount").getAmount() == -1)
{
GameObject.Find("Player").GetComponent<PlayerGameObject>().getPlayerStat("Killcount").changeAmount(1);
}
updatePlayerHUD();
switchWaterLayer();
updateCoordinates();
if (EventSystem.current.currentSelectedGameObject != null)
{
EventSystem.current.SetSelectedGameObject(null);
}
}
}
private void updateCoordinates()
{
GameObject coordinates = GameObject.Find("txtCoordinates");
Vector3 position = GameObject.Find("Player").transform.position;
string tiletype = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>().getCurrentTile().GetComponent<Tile>().getTileType().ToString();
if (tiletype != null)
{
tiletype = tiletype.Replace("Tile", "");
}
coordinates.GetComponent<Text>().text = TextHandler.getText(tiletype.ToLower()) + "(" + (int)position.x + "/" + (int)position.y + "/" + (int)position.z + ")";
}
private void switchWaterLayer()
{
if (GameObject.Find("Player").transform.position.y < -1)
{
waterLayer.transform.localScale = new Vector3(1, 1, 1);
}
else
{
waterLayer.transform.localScale = new Vector3(0, 0, 0);
}
}
private void updatePlayerHUD()
{
updateHUD(GameObject.Find("Player").GetComponent<PlayerGameObject>());
}
public bool canPlayerMove()
{
if (state == UIState.GAME || state == UIState.CHARACTER || state == UIState.QUEST || state == UIState.INVENTORY)
{
return true;
}
return false;
}
public bool canPlayerRotate()
{
if (state == UIState.GAME)
{
return true;
}
return false;
}
public bool isPlayerInFight()
{
return state == UIState.FIGHT;
}
public void startGame()
{
introduction.transform.localScale = new Vector3(0, 0, 0);
tutorial.transform.localScale = new Vector3(1, 1, 1);
showHUD();
state = UIState.TUTORIAL;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnCloseTutorial"));
}
public void openOptions()
{
FileHandler.loadOptionDisplay();
hideOtherElements(options);
state = UIState.PAUSEOPTIONS;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnAudio"));
showOptionView("audio");
}
public void closeOptions()
{
state = UIState.PAUSE;
openPauseMenu();
}
public void switchInventory()
{
if (state == UIState.INVENTORY)
{
closeInventory();
}
else
{
openInventory();
}
}
public void openInventory()
{
hideOtherElements(inventory);
state = UIState.INVENTORY;
EventSystem.current.SetSelectedGameObject(GameObject.Find("bagOne"));
}
public void closeInventory()
{
inventory.transform.localScale = new Vector3(0, 0, 0);
GameObject.Find("pnlInventoryActions").transform.localScale = new Vector3(0, 0, 0);
showHUD();
state = UIState.GAME;
}
public void openFight()
{
GameObject.Find("txtRounds").GetComponent<Text>().text = "-1";
hideOtherElements(fight);
playerHUD.transform.localScale = new Vector3(1, 1, 1);
state = UIState.FIGHT;
}
public void closeFight()
{
fight.transform.localScale = new Vector3(0, 0, 0);
showHUD();
state = UIState.GAME;
}
public void showHUD()
{
playerHUD.transform.localScale = new Vector3(1, 1, 1);
compass.transform.localScale = new Vector3(1, 1, 1);
}
public void openMainMenu()
{
GameObject.Find("SceneHandlerLoaded").GetComponent<SceneHandler>().openMenuScene();
}
public void switchPauseMenu()
{
if (state == UIState.GAME || state == UIState.CHARACTER || state == UIState.PAUSE || state == UIState.QUEST || state == UIState.INVENTORY || state == UIState.INTRODUCTION)
{
if (state == UIState.PAUSE)
{
closePauseMenu();
}
else
{
if (state == UIState.GAME)
{
openPauseMenu();
}
else
{
hideOtherElements(null);
showHUD();
state = UIState.GAME;
}
}
}
}
public void switchQuestLog()
{
if (state == UIState.QUEST)
{
closeQuestLog();
}
else
{
openQuestLog();
}
}
public void openQuestLog()
{
questlog.GetComponent<QuestLog>().showQuests();
state = UIState.QUEST;
hideOtherElements(questlog);
EventSystem.current.SetSelectedGameObject(GameObject.Find("scrollQuestlog"));
}
public void closeQuestLog()
{
questlog.transform.localScale = new Vector3(0, 0, 0);
state = UIState.GAME;
showHUD();
}
public string saveVideoSettings()
{
GameObject resolution = GameObject.Find("dropResolution");
GameObject mode = GameObject.Find("dropMode");
string result = "";
switch (resolution.GetComponent<Dropdown>().value)
{
case 0:
Screen.SetResolution(800, 600, Screen.fullScreenMode);
break;
case 1:
Screen.SetResolution(1280, 800, Screen.fullScreenMode);
break;
case 2:
Screen.SetResolution(1920, 1080, Screen.fullScreenMode);
break;
}
switch (mode.GetComponent<Dropdown>().value)
{
case 0:
if (Screen.fullScreenMode != FullScreenMode.Windowed)
{
Screen.fullScreenMode = FullScreenMode.Windowed;
}
break;
case 1:
if (Screen.fullScreenMode != FullScreenMode.ExclusiveFullScreen)
{
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
}
break;
case 2:
if (Screen.fullScreenMode != FullScreenMode.FullScreenWindow)
{
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
}
break;
}
result = result + "Resolution:" + resolution.GetComponent<Dropdown>().value + "\r\n";
result = result + "Mode:" + mode.GetComponent<Dropdown>().value;
return result;
}
public string saveLanguage()
{
GameObject language = GameObject.Find("dropLanguage");
string result = "";
switch (language.GetComponent<Dropdown>().value)
{
case 0:
result = "de";
break;
case 1:
result = "en";
break;
}
result = "Language:" + result;
return result;
}
public void openPauseMenu()
{
hideOtherElements(pauseMenu);
state = UIState.PAUSE;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnContinue"));
}
public void closePauseMenu()
{
pauseMenu.transform.localScale = new Vector3(0, 0, 0);
showHUD();
state = UIState.GAME;
}
public void showDeathScreen()
{
state = UIState.DEATH;
PlayerObject player = GameObject.Find("Player").GetComponent<PlayerGameObject>().getPlayer();
GameObject statText = GameObject.Find("txtDeathStats");
string text = statText.GetComponent<Text>().text;
text = text.Replace("NAME", player.getPlayerName());
text = text.Replace("RACE", player.getRace().racename);
text = text.Replace("CLASS", player.getClass().classname);
text = text.Replace("LEVEL", player.getStat("Level").getAmount().ToString());
text = text.Replace("KILLS", player.getStat("Killcount").getAmount().ToString());
text = text.Replace("HEALTH", player.getStat("MaxHealth").getAmount().ToString());
text = text.Replace("SECONDARY", player.getStat("MaxSecondary").getAmount().ToString());
text = text.Replace("INT", player.getStat("Intelligence").getAmount().ToString());
text = text.Replace("STR", player.getStat("Strength").getAmount().ToString());
text = text.Replace("DEX", player.getStat("Dexterity").getAmount().ToString());
text = text.Replace("TREES", player.getStat("TreeCount").getAmount().ToString());
text = text.Replace("ORES", player.getStat("OreCount").getAmount().ToString());
text = text.Replace("DIFFICULTY", player.getDifficulty() == 0 ? "Easy" : player.getDifficulty() == 1 ? "Normal" : "Hard");
statText.GetComponent<Text>().text = text;
hideOtherElements(deathscreen);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnMenu"));
}
public void hideOtherElements(GameObject obj)
{
for (int i = 0; i < GameObject.Find("Canvas").transform.childCount; i++)
{
if (!GameObject.Find("Canvas").transform.GetChild(i).gameObject.Equals(obj))
{
GameObject.Find("Canvas").transform.GetChild(i).localScale = new Vector3(0, 0, 0);
}
}
if (obj != null)
{
obj.transform.localScale = new Vector3(1, 1, 1);
}
if (obj != fight)
{
showHUD();
}
}
public void displayInformation(string information)
{
GameObject.Find("txtObjectName").GetComponent<Text>().text = information;
this.information.transform.localScale = new Vector3(1, 1, 1);
}
public void hideInformation()
{
information.transform.localScale = new Vector3(0, 0, 0);
}
public void showMessage(string message)
{
this.message.GetComponent<LogWriter>().addMessage(message);
}
public void updateFightInterface(GameObject enemy, GameObject player)
{
updateFightInterfaceEnemy(enemy);
updateFightInterfaceActions(player.GetComponent<PlayerGameObject>());
GameObject.Find("txtRounds").GetComponent<Text>().text = (int.Parse(GameObject.Find("txtRounds").GetComponent<Text>().text) + 1).ToString();
}
private void updateFightInterfaceActions(PlayerGameObject player)
{
GameObject skillOne = GameObject.Find("btnActionTwo");
GameObject skillTwo = GameObject.Find("btnActionThree");
GameObject skillThree = GameObject.Find("btnActionFour");
player.displayAction(0, skillOne.transform.Find("imgAction").gameObject, skillOne.transform.Find("descAction").gameObject);
player.displayAction(1, skillTwo.transform.Find("imgAction").gameObject, skillTwo.transform.Find("descAction").gameObject);
player.displayAction(2, skillThree.transform.Find("imgAction").gameObject, skillThree.transform.Find("descAction").gameObject);
}
private void updateFightInterfaceEnemy(GameObject enemy)
{
// { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence };
int[] enemyStats = enemy.GetComponent<Enemy>().getStats();
GameObject foreground = GameObject.Find("healthForegroundEnemy");
GameObject background = GameObject.Find("healthBackgroundEnemy");
GameObject text = GameObject.Find("healthTextEnemy");
updateBar(foreground, background, text, enemyStats[1], enemyStats[0]);
foreground = GameObject.Find("secondaryForegroundEnemy");
background = GameObject.Find("secondaryBackgroundEnemy");
text = GameObject.Find("secondaryTextEnemy");
updateBar(foreground, background, text, enemyStats[3], enemyStats[2]);
}
public void adjustInformation(PlayerGameObject player)
{
Dictionary<string, int> equipment = inventory.GetComponent<Inventory>().getEquipmentBonus();
GameObject.Find("txtStrength").GetComponent<Text>().text = "STR: " + player.getPlayerStat("Strength").getAmount() + " (+" + equipment["STR"] + ")";
GameObject.Find("txtDexterity").GetComponent<Text>().text = "DEX: " + player.getPlayerStat("Dexterity").getAmount() + " (+" + equipment["DEX"] + ")";
GameObject.Find("txtIntelligence").GetComponent<Text>().text = "INT: " + player.getPlayerStat("Intelligence").getAmount() + " (+" + equipment["INT"] + ")";
GameObject.Find("txtHealth").GetComponent<Text>().text = TextHandler.getText("health") + " " + player.getPlayerStat("MaxHealth").getAmount() + " (+" + equipment["HP"] + ")";
GameObject.Find("txtSecondary").GetComponent<Text>().text = "Mana: " + player.getPlayerStat("MaxSecondary").getAmount() + " (+" + equipment["MP"] + ")";
player.updateName(GameObject.Find("txtName").GetComponent<Text>());
updatePoints(player.getPlayerStat("Points").getAmount());
}
private void updatePoints(int points)
{
GameObject strength = GameObject.Find("btnStrengthIncrease");
GameObject dexterity = GameObject.Find("btnDexterityIncrease");
GameObject intelligence = GameObject.Find("btnIntelligenceIncrease");
GameObject health = GameObject.Find("btnHealthIncrease");
GameObject secondary = GameObject.Find("btnSecondaryIncrease");
GameObject txtPoints = GameObject.Find("txtPoints");
txtPoints.GetComponent<Text>().text = TextHandler.getText("points") + " " + points;
if (points > 0)
{
strength.transform.localScale = new Vector3(1, 1, 1);
dexterity.transform.localScale = new Vector3(1, 1, 1);
intelligence.transform.localScale = new Vector3(1, 1, 1);
health.transform.localScale = new Vector3(1, 1, 1);
secondary.transform.localScale = new Vector3(1, 1, 1);
}
else
{
strength.transform.localScale = new Vector3(0, 0, 0);
dexterity.transform.localScale = new Vector3(0, 0, 0);
intelligence.transform.localScale = new Vector3(0, 0, 0);
health.transform.localScale = new Vector3(0, 0, 0);
secondary.transform.localScale = new Vector3(0, 0, 0);
}
}
public void updateHUD(PlayerGameObject player)
{
Dictionary<string, int> equipment = inventory.GetComponent<Inventory>().getEquipmentBonus();
GameObject information = GameObject.Find("txtPlayerInformationHUD");
player.updateNameHUD(information.GetComponent<Text>());
GameObject foreground = GameObject.Find("healthForegroundPlayer");
GameObject background = GameObject.Find("healthBackgroundPlayer");
GameObject text = GameObject.Find("healthTextPlayer");
updateBar(foreground, background, text, player.getPlayerStat("MaxHealth").getAmount() + equipment["HP"], player.getPlayerStat("Health").getAmount());
foreground = GameObject.Find("secondaryForegroundPlayer");
background = GameObject.Find("secondaryBackgroundPlayer");
text = GameObject.Find("secondaryTextPlayer");
updateBar(foreground, background, text, player.getPlayerStat("MaxSecondary").getAmount() + equipment["MP"], player.getPlayerStat("Secondary").getAmount());
}
public void updateBar(GameObject bar, GameObject barBackground, GameObject textField, int maxValue, int minValue)
{
string text = minValue + "/" + maxValue;
double percentage = 0;
if (maxValue > 0)
{
percentage = (1 / (double)maxValue) * minValue;
}
float change = (float)(barBackground.GetComponent<RectTransform>().rect.width - (barBackground.GetComponent<RectTransform>().rect.width * percentage));
if (textField != null)
{
textField.GetComponent<Text>().text = text;
}
bar.GetComponent<RectTransform>().offsetMax = new Vector2(-change, bar.GetComponent<RectTransform>().offsetMax.y);
}
public void openIntroduction()
{
GameObject.Find("AudioHandler").GetComponent<AudioHandler>().Start();
if (PlayerPrefs.GetInt("isLoad") == 0)
{
GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>().resetGame(PlayerPrefs.GetInt("cityAmount"));
GameObject.Find("Player").GetComponent<PlayerGameObject>().generatePlayer();
hideOtherElements(introduction);
state = UIState.INTRODUCTION;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnClose"));
}
else
{
FileHandler.loadGame(GameObject.Find("Player").GetComponent<PlayerGameObject>(), GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>(), GameObject.Find("Inventory").GetComponent<Inventory>(), GameObject.Find("QuestLog").GetComponent<QuestLog>());
hideOtherElements(introduction);
introduction.transform.localScale = new Vector3(0, 0, 0);
tutorial.transform.localScale = new Vector3(0, 0, 0);
showHUD();
state = UIState.GAME;
}
updatePlayerHUD();
}
public void closeTutorial()
{
tutorial.transform.localScale = new Vector3(0, 0, 0);
state = UIState.GAME;
}
public void showOptionView(string key)
{
GameObject optionContent = GameObject.Find("pnlContent");
for (int i = 0; i < optionContent.transform.childCount; i++)
{
if (optionContent.transform.GetChild(i).name.ToLower().Contains(key))
{
optionContent.transform.GetChild(i).transform.localScale = new Vector3(1, 1, 1);
}
else
{
optionContent.transform.GetChild(i).transform.localScale = new Vector3(0, 0, 0);
}
}
}
public void switchLanguage()
{
GameObject language = GameObject.Find("dropLanguage");
switch (language.GetComponent<Dropdown>().value)
{
case 0:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("de");
break;
case 1:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("en");
break;
}
}
}
}

View File

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

View File

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

View File

@@ -1,54 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Assets.Scripts.Player;
namespace Assets.Scripts.InteractableObjects
{
public class Chest : InteractableObject
{
bool gotItem = false;
public override void handleInteraction(GameObject player){
keepAlive = true;
if (gotItem)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("alreadyLooted"));
}
else
{
gameObject.transform.Find("Lid").GetComponent<Animator>().Play("ChestOpen");
Item item;
int luck = player.GetComponent<PlayerGameObject>().getPlayerStat("Luck").getAmount();
int type = new System.Random().Next(3);
switch (type)
{
case 0:
// Maybe add luck to increase chance for equipment
item = new Equipment(luck);
break;
/*case 1:
//Removed lore for now... no idea for lore
break;*/
default:
item = new Item(luck, false);
break;
}
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(item);
}
gotItem = true;
}
public bool saveChest(){
return gotItem;
}
public void loadChest(bool gotItem){
this.gotItem = gotItem;
if(gotItem){
gameObject.transform.Find("Lid").GetComponent<Animator>().Play("ChestOpen");
}
}
}
}

View File

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

View File

@@ -1,55 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Newtonsoft.Json.Linq;
namespace Assets.Scripts.InteractableObjects
{
public class Door : InteractableObject
{
public bool hasInteracted = false;
bool isOpen = false;
public override void handleInteraction(GameObject player)
{
keepAlive = true;
if (hasInteracted)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("triedHouse"));
}
else
{
int openChance = new System.Random().Next(4);
if(openChance == 0){
gameObject.GetComponent<Animator>().Play("DoorOpen");
Destroy(gameObject.GetComponent<BoxCollider>());
isOpen = true;
}
else{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("lockedHouse"));
}
}
hasInteracted = true;
}
public string saveHouse(){
string result = "";
result = result + FileHandler.generateJSON("objectname", "\"" + transform.parent.name + "\",\r\n");
result = result + FileHandler.generateJSON("hasInteracted", "\"" + hasInteracted + "\",\r\n");
result = result + FileHandler.generateJSON("isOpen", "\"" + isOpen + "\",\r\n");
result = result + FileHandler.generateJSON("gotItem", "\"" + transform.parent.Find("chest").Find("Body").GetComponent<Chest>().saveChest() + "\"");
return result;
}
public void loadHouse(JToken json){
hasInteracted = bool.Parse(json["hasInteracted"].ToString());
isOpen = bool.Parse(json["isOpen"].ToString());
transform.parent.Find("chest").Find("Body").GetComponent<Chest>().loadChest(bool.Parse(json["gotItem"].ToString()));
if(isOpen){
gameObject.GetComponent<Animator>().Play("DoorOpen");
Destroy(gameObject.GetComponent<BoxCollider>());
}
}
}
}

View File

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

View File

@@ -1,104 +0,0 @@
using Assets.Scripts;
using Assets.Scripts.Player;
using Assets.Scripts.Slimes;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts.InteractableObjects
{
public class Enemy : InteractableObject
{
System.Random rand = new System.Random();
BasicSlime slime;
SlimeFactory factory = new SlimeFactory();
public SlimeType slimeType;
public override void handleInteraction(GameObject player)
{
keepAlive = true;
}
public void scaleEnemy(PlayerGameObject player)
{
if (slime == null)
{
switch (slimeType)
{
case SlimeType.MAGE:
slime = factory.generateMageSlime(player);
break;
case SlimeType.NORMAL:
slime = factory.generateNormalSlime(player);
break;
case SlimeType.METAL:
slime = factory.generateMetalSlime(player);
break;
case SlimeType.WARRIOR:
slime = factory.generateWarriorSlime(player);
break;
case SlimeType.FOREST:
slime = factory.generateForestSlime(player);
break;
case SlimeType.BOSS:
slime = factory.generateBossSlime(player);
break;
}
}
}
public int[] getStats()
{
return slime.getStats();
}
public string getEnemyName()
{
return slimeType.ToString().ToLower() + " slime";
}
public int calculateDamage()
{
return slime.calculateDamage(rand);
}
public int calculateHeavy()
{
return slime.calculateHeavy(rand);
}
public bool takeDamage(int amount)
{
return slime.takeDamage(amount, rand);
}
public int getExperience()
{
return slime.getExperience();
}
public Item getItem()
{
return slime.getItem();
}
public string saveEnemy()
{
string result = "";
result = result + FileHandler.generateJSON("enemytype", "\"" + slimeType.ToString().ToLower() + "\"");
if (slime != null)
{
result = result + ",\r\n" + slime.saveSlime();
}
return result;
}
public void loadEnemy(JToken json)
{
slime = new BasicSlime(json);
slimeType = (SlimeType)Enum.Parse(typeof(SlimeType), json["enemytype"].ToString());
}
}
}

View File

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

View File

@@ -1,71 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using Assets.Scripts.Player;
using UnityEngine;
namespace Assets.Scripts.InteractableObjects
{
public abstract class InteractableObject : MonoBehaviour
{
public AnimationClip clip;
private bool particlePlayed;
private bool animationPlayed;
public bool keepAlive;
// Start is called before the first frame update
void Start()
{
particlePlayed = false;
animationPlayed = false;
keepAlive = false;
}
// Update is called once per frame
void Update()
{
destroyObject();
}
public void OnInteraction(GameObject player)
{
StartCoroutine(playParticle(player));
StartCoroutine(playAnimation(player));
handleInteraction(player);
}
public abstract void handleInteraction(GameObject player);
IEnumerator playParticle(GameObject player)
{
if (GetComponent<ParticleSystem>() != null)
{
Vector3 playerPos = player.transform.position;
playerPos.y = transform.position.y;
Quaternion newRotation = Quaternion.LookRotation(playerPos - transform.position, transform.TransformDirection(Vector3.up));
ParticleSystem particleSystem = GetComponent<ParticleSystem>();
ParticleSystem.ShapeModule shape = particleSystem.shape;
shape.rotation = newRotation.eulerAngles;
particleSystem.Play();
yield return new WaitUntil(() => !particleSystem.isPlaying);
}
particlePlayed = true;
}
IEnumerator playAnimation(GameObject player)
{
if (clip != null)
{
player.GetComponent<Animator>().Play(clip.name);
yield return new WaitForSeconds(clip.length);
}
animationPlayed = true;
}
public void destroyObject()
{
if (particlePlayed && animationPlayed && !keepAlive)
{
Destroy(gameObject);
}
}
}
}

View File

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

View File

@@ -1,43 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts.InteractableObjects
{
public class NPC : InteractableObject
{
bool hasQuest = true;
public override void handleInteraction(GameObject player)
{
keepAlive = true;
if (hasQuest)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;"+TextHandler.getText("gotQuest"));
GameObject.Find("QuestLog").GetComponent<QuestLog>().addQuest();
hasQuest = false;
}
else
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("noQuest"));
}
GameObject.Find("QuestLog").GetComponent<QuestLog>().removeQuests();
}
public bool receivedQuest(){
return !hasQuest;
}
public void loadQuest(string receivedQuest){
this.hasQuest = !bool.Parse(receivedQuest);
}
public string saveNPC(){
string result = "";
result = result + FileHandler.generateJSON("objectname", "\"" + name + "\",");
result = result + FileHandler.generateJSON("receivedQuest", "\"" + !hasQuest + "\"");
return result;
}
}
}

View File

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

View File

@@ -1,15 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts.InteractableObjects
{
public class Ore : InteractableObject
{
public override void handleInteraction(GameObject player)
{
player.GetComponent<Animator>().SetInteger("objectCategory", 2);
player.GetComponent<Animator>().SetTrigger("Interaction");
}
}
}

View File

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

View File

@@ -1,15 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts.InteractableObjects
{
public class Stone : InteractableObject
{
public override void handleInteraction(GameObject player)
{
player.GetComponent<Animator>().SetInteger("objectCategory", 2);
player.GetComponent<Animator>().SetTrigger("Interaction");
}
}
}

View File

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

View File

@@ -1,15 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts.InteractableObjects
{
public class Tree : InteractableObject
{
public override void handleInteraction(GameObject player)
{
player.GetComponent<Animator>().SetInteger("objectCategory", 1);
player.GetComponent<Animator>().SetTrigger("Interaction");
}
}
}

View File

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

View File

@@ -1,438 +0,0 @@
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Assets.Scripts
{
public class Inventory : MonoBehaviour
{
public GameObject head;
public GameObject chest;
public GameObject feet;
public GameObject ring;
public GameObject amulet;
public GameObject leftHand;
public GameObject rightHand;
public GameObject itemDisplay;
public GameObject[] bags;
public GameObject[] slots;
Dictionary<string, int> statBoost;
public int currentBag = -1;
public GameObject currentSlot;
// Start is called before the first frame update
void Start()
{
createStatBoost();
itemDisplay.transform.localScale = new Vector3(0,0,0);
changeCurrentBag(0);
}
// Update is called once per frame
void Update()
{
checkInventoryColors();
checkEquipColors();
}
private void createStatBoost()
{
statBoost = new Dictionary<string, int>();
statBoost.Add("HP", 0);
statBoost.Add("MP", 0);
statBoost.Add("MPR", 0);
statBoost.Add("STR", 0);
statBoost.Add("DEX", 0);
statBoost.Add("INT", 0);
statBoost.Add("LCK", 0);
}
void OnDisable(){
statBoost = new Dictionary<string, int>();
}
public void addItem(Item item)
{
if (item != null)
{
bool itemAdded = false;
for (int i = 0; i < bags.Length; i++)
{
for (int j = 0; j < slots.Length; j++)
{
if (slots[j].GetComponent<InventorySlot>().getItem(i) == null)
{
slots[j].GetComponent<InventorySlot>().setItem(item, i);
itemAdded = true;
slots[j].transform.Find("slotItem").GetComponent<RawImage>().color = item.rarityColor;
slots[j].transform.Find("slotItem").GetComponent<RawImage>().texture = item.image;
break;
}
}
if (itemAdded)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;"+TextHandler.getText("gotItem"));
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("collect", item, 1);
SteamWorksHandler.getItemAchievement(item);
break;
}
}
if (!itemAdded)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("noSpace"));
}
}
}
public void changeCurrentBag(int index)
{
if (currentBag != -1)
{
bags[currentBag].transform.parent.Find("Selected").GetComponent<RawImage>().color = Color.white;
}
currentBag = index;
bags[currentBag].transform.parent.Find("Selected").GetComponent<RawImage>().color = Color.cyan;
checkInventoryColors();
foreach(GameObject slot in slots)
{
slot.GetComponent<InventorySlot>().updateCurrentBag(currentBag);
}
}
private void checkInventoryColors()
{
Item item;
for (int i = 0; i < slots.Length; i++)
{
item = slots[i].GetComponent<InventorySlot>().getItem(currentBag);
if (item != null)
{
slots[i].transform.Find("slotItem").GetComponent<RawImage>().color = item.rarityColor;
slots[i].transform.Find("slotItem").GetComponent<RawImage>().texture = item.image;
}
else
{
slots[i].transform.Find("slotItem").GetComponent<RawImage>().color = new Color(1,1,1,0);
slots[i].transform.Find("slotItem").GetComponent<RawImage>().texture = null;
}
}
}
private void checkEquipColors()
{
GameObject slot = head;
Item item;
for (int i = 0; i < 7; i++)
{
switch (i)
{
case 0:
slot = head;
break;
case 1:
slot = rightHand;
break;
case 2:
slot = leftHand;
break;
case 3:
slot = amulet;
break;
case 4:
slot = feet;
break;
case 5:
slot = chest;
break;
case 6:
slot = ring;
break;
}
item = slot.GetComponent<InventorySlot>().getEquip();
if (item != null)
{
slot.transform.Find("slotItem").GetComponent<RawImage>().color = item.rarityColor;
slot.transform.Find("slotItem").GetComponent<RawImage>().texture = item.image;
}
else
{
slot.transform.Find("slotItem").GetComponent<RawImage>().color = Color.white;
}
}
}
public void calculateStatBoost(Dictionary<string, int> attributes, bool isAddition)
{
foreach (string key in attributes.Keys)
{
if (isAddition)
{
statBoost[key] = statBoost[key] + attributes[key];
}
else
{
statBoost[key] = statBoost[key] - attributes[key];
}
}
}
public Dictionary<string, int> getEquipmentBonus()
{
createStatBoost();
GameObject equip = head;
for (int i = 0; i < 7; i++)
{
switch (i)
{
case 0:
equip = head;
break;
case 1:
equip = rightHand;
break;
case 2:
equip = leftHand;
break;
case 3:
equip = amulet;
break;
case 4:
equip = feet;
break;
case 5:
equip = chest;
break;
case 6:
equip = ring;
break;
}
if (equip.GetComponent<InventorySlot>().getEquip() != null)
{
calculateStatBoost(equip.GetComponent<InventorySlot>().getEquip().getAttributes(), true);
}
}
return statBoost;
}
public string saveGame()
{
string result = "";
int counter = 0;
GameObject equip = head;
string slotname = "";
result = result + "\"equipment\": {\r\n";
for (int i = 0; i < 7; i++)
{
switch (i)
{
case 0:
equip = head;
slotname = "head";
break;
case 1:
equip = rightHand;
slotname = "rightHand";
break;
case 2:
equip = leftHand;
slotname = "leftHand";
break;
case 3:
equip = amulet;
slotname = "amulet";
break;
case 4:
equip = feet;
slotname = "feet";
break;
case 5:
equip = chest;
slotname = "chest";
break;
case 6:
equip = ring;
slotname = "ring";
break;
}
if (equip.GetComponent<InventorySlot>().getEquip() != null)
{
result = result + "\""+slotname+"\": {\r\n";
result = result + equip.GetComponent<InventorySlot>().saveGame();
result = result + "\r\n}";
}
else
{
result = result + "\"" + slotname + "\": \"empty\"";
}
if (i != 6)
{
result = result + ",\r\n";
}
}
result = result + "\r\n},\r\n";
result = result + "\"bags\": {\r\n";
foreach (GameObject slot in slots)
{
result = result + "\"slot" + counter + "\": {\r\n";
result = result + slot.GetComponent<InventorySlot>().saveGame();
result = result + "\r\n}";
if (counter < slots.Length - 1)
{
result = result + ",\r\n";
}
counter++;
}
result = result + "\r\n}";
return result;
}
public void loadInventory(JToken json)
{
loadEquipment(json["equipment"]);
var jsonData = JObject.Parse(json["bags"].ToString()).Children();
List<JToken> tokens = jsonData.Children().ToList();
int counter = 0;
foreach (JToken slot in tokens)
{
if (slot["bag1"].ToString() != "empty")
{
slots[counter].GetComponent<InventorySlot>().loadSlot(slot["bag1"], 0);
}
if (slot["bag2"].ToString() != "empty")
{
slots[counter].GetComponent<InventorySlot>().loadSlot(slot["bag2"], 1);
}
if (slot["bag3"].ToString() != "empty")
{
slots[counter].GetComponent<InventorySlot>().loadSlot(slot["bag3"], 2);
}
counter++;
}
}
private void loadEquipment(JToken slot)
{
GameObject equip = head;
string slotname = "";
for (int i = 0; i < 7; i++)
{
switch (i)
{
case 0:
equip = head;
slotname = "head";
break;
case 1:
equip = rightHand;
slotname = "rightHand";
break;
case 2:
equip = leftHand;
slotname = "leftHand";
break;
case 3:
equip = amulet;
slotname = "amulet";
break;
case 4:
equip = feet;
slotname = "feet";
break;
case 5:
equip = chest;
slotname = "chest";
break;
case 6:
equip = ring;
slotname = "ring";
break;
}
if (slot[slotname].ToString() != "empty")
{
equip.GetComponent<InventorySlot>().loadSlot(slot[slotname], -1);
createStatBoost();
calculateStatBoost(equip.GetComponent<InventorySlot>().getEquip().getAttributes(), true);
}
}
}
public void trashItem(){
InventorySlot invSlot = currentSlot.GetComponent<InventorySlot>();
if (invSlot.place == ItemPlace.BAG)
{
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("collect", invSlot.getItem(invSlot.getCurrentBag()), -1);
invSlot.removeItem();
}
else
{
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("collect", invSlot.getEquip(), -1);
invSlot.removeEquip();
}
hideSlotOptions();
}
public void equipItem(){
InventorySlot invSlot = currentSlot.GetComponent<InventorySlot>();
if(invSlot.place == ItemPlace.BAG){
Equipment save = (Equipment)invSlot.getItem(currentBag);
InventorySlot equipSlot;
switch(save.getPlace()){
case ItemPlace.HELMET:
equipSlot = head.GetComponent<InventorySlot>();
break;
case ItemPlace.BOOTS:
equipSlot = feet.GetComponent<InventorySlot>();
break;
case ItemPlace.AMULET:
equipSlot = amulet.GetComponent<InventorySlot>();
break;
case ItemPlace.ARMOR:
equipSlot = chest.GetComponent<InventorySlot>();
break;
case ItemPlace.RING:
equipSlot = ring.GetComponent<InventorySlot>();
break;
case ItemPlace.RIGHTHAND:
equipSlot = rightHand.GetComponent<InventorySlot>();
break;
case ItemPlace.LEFTHAND:
equipSlot = leftHand.GetComponent<InventorySlot>();
break;
default:
equipSlot = invSlot;
break;
}
if(equipSlot.getEquip() != null){
invSlot.setItem(equipSlot.getEquip(), currentBag);
calculateStatBoost(equipSlot.getEquip().getAttributes(), false);
}
else{
invSlot.removeItem();
}
equipSlot.setEquip(save);
calculateStatBoost(equipSlot.getEquip().getAttributes(), true);
}
else{
addItem(invSlot.getEquip());
calculateStatBoost(invSlot.getEquip().getAttributes(), false);
invSlot.removeEquip();
}
hideSlotOptions();
}
public void hideSlotOptions(){
GameObject.Find("pnlInventoryActions").transform.localScale = new Vector3(0,0,0);
GameObject.Find("btnEquip").transform.Find("Text").GetComponent<Text>().text = TextHandler.getText("equip");
GameObject.Find("btnEquip").GetComponent<Button>().interactable = true;
EventSystem.current.SetSelectedGameObject(currentSlot);
}
}
}

View File

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

View File

@@ -1,227 +0,0 @@
using Assets.Scripts.Player;
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Assets.Scripts
{
public class InventorySlot : MonoBehaviour
{
Item[] items = new Item[3];
int currentBag = 0;
public ItemPlace place;
Equipment equip;
Inventory inventory;
private void Start()
{
inventory = GameObject.Find("Inventory").GetComponent<Inventory>();
loadImages();
}
public void updateCurrentBag(int currentBag)
{
this.currentBag = currentBag;
}
public int getCurrentBag()
{
return currentBag;
}
public void setItem(Item item, int bag)
{
items[bag] = item;
}
public Item getItem(int bag)
{
return items[bag];
}
public void removeItem()
{
items[currentBag] = null;
}
public void removeItem(int bag)
{
items[bag] = null;
}
public void showTooltip()
{
Item item = getItemForTooltip();
if (item != null)
{
inventory.itemDisplay.transform.Find("itemImage").GetComponent<RawImage>().texture = item.image;
inventory.itemDisplay.transform.Find("itemImage").GetComponent<RawImage>().color = item.rarityColor;
inventory.itemDisplay.transform.Find("itemName").GetComponent<Text>().text = TextHandler.translate(item.getName());
inventory.itemDisplay.transform.Find("itemStats").GetComponent<Text>().text = item.getInformation();
inventory.itemDisplay.transform.localScale = new Vector3(1, 1, 1);
}
}
public void showTooltipSelect(){
GameObject current = EventSystem.current.currentSelectedGameObject;
Item item = current.GetComponent<InventorySlot>().getItemForTooltip();
if (item != null)
{
inventory.itemDisplay.transform.Find("itemImage").GetComponent<RawImage>().texture = item.image;
inventory.itemDisplay.transform.Find("itemImage").GetComponent<RawImage>().color = item.rarityColor;
inventory.itemDisplay.transform.Find("itemName").GetComponent<Text>().text = TextHandler.translate(item.getName());
inventory.itemDisplay.transform.Find("itemStats").GetComponent<Text>().text = item.getInformation();
inventory.itemDisplay.transform.localScale = new Vector3(1, 1, 1);
}
}
public Item getItemForTooltip()
{
Item item = null;
if (place == ItemPlace.BAG)
{
item = items[currentBag];
}
else
{
item = equip;
}
return item;
}
public void hideTooltip()
{
inventory.itemDisplay.transform.localScale = new Vector3(0,0,0);
}
public Equipment getEquip()
{
return equip;
}
public void setEquip(Equipment item)
{
equip = item;
}
public void removeEquip()
{
equip = null;
}
private void loadImages()
{
Texture image = null;
switch (place)
{
case ItemPlace.LEFTHAND:
image = Resources.Load<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<PlayerGameObject>().getClass().classname + "/Inv_LeftHand");
break;
case ItemPlace.RIGHTHAND:
image = Resources.Load<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<PlayerGameObject>().getClass().classname + "/Inv_RightHand");
break;
case ItemPlace.HELMET:
image = Resources.Load<Texture>("Equipment/Inv_Helmet");
break;
case ItemPlace.BOOTS:
image = Resources.Load<Texture>("Equipment/Inv_Boots");
break;
case ItemPlace.AMULET:
image = Resources.Load<Texture>("Equipment/Inv_Amulet");
break;
case ItemPlace.RING:
image = Resources.Load<Texture>("Equipment/Inv_Ring");
break;
case ItemPlace.ARMOR:
image = Resources.Load<Texture>("Equipment/Inv_Chest");
break;
}
if (image != null)
{
gameObject.transform.Find("slotItem").GetComponent<RawImage>().texture = image;
}
}
public string saveGame()
{
string result = "";
if (place == ItemPlace.BAG)
{
for (int i = 1; i <= items.Length;i++)
{
if (items[i-1] == null)
{
result = result + "\"bag" + i + "\": \"empty\"";
}
else
{
result = result + "\"bag" + i + "\": {\r\n";
result = result + items[i-1].saveGame();
result = result + "\r\n}";
}
if (i != 3)
{
result = result + ",\r\n";
}
}
}
else
{
if(equip == null){
return result;
}
result = result + equip.saveGame();
}
return result;
}
public void loadSlot(JToken json, int bag)
{
if (bag == -1)
{
equip = new Equipment(json);
}
else
{
if(json["place"] != null){
items[bag] = new Equipment(json);
}
else{
items[bag] = new Item(json);
}
}
}
public void showSlotOptions(){
GameObject current = EventSystem.current.currentSelectedGameObject;
GameObject.Find("Inventory").GetComponent<Inventory>().currentSlot = current;
GameObject.Find("btnEquip").transform.Find("Text").GetComponent<Text>().text = TextHandler.getText("equip");
GameObject.Find("btnEquip").GetComponent<Button>().interactable = true;
if(equip != null || items[currentBag] != null){
if(equip != null){
GameObject.Find("btnEquip").transform.Find("Text").GetComponent<Text>().text = TextHandler.getText("unequip");
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnEquip"));
}
if(items[currentBag] != null){
if(items[currentBag] is Equipment){
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnEquip"));
}
else{
GameObject.Find("btnEquip").GetComponent<Button>().interactable = false;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnTrash"));
}
}
GameObject.Find("pnlInventoryActions").transform.position = new Vector3(current.transform.position.x + 125, current.transform.position.y, 0);
GameObject.Find("pnlInventoryActions").transform.localScale = new Vector3(1,1,1);
}
}
}
}

View File

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

View File

@@ -1,40 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts
{
public class InventoryTrash : MonoBehaviour
{
public Texture close;
public Texture open;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void onMouseEnter()
{
gameObject.GetComponent<RawImage>().texture = open;
}
public void onMouseLeave()
{
gameObject.GetComponent<RawImage>().texture = close;
}
public void deleteItem()
{
}
}
}

View File

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

View File

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

View File

@@ -1,29 +0,0 @@
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts
{
public class Book : Item
{
public Book(int luck) : base(luck)
{
itemName = "The kings diary #1";
loadImage();
rarityColor = Color.white;
}
public Book(JToken json) : base(json)
{
}
override
protected void loadImage()
{
image = Resources.Load<Texture>("Items/Inv_Book");
}
}
}

View File

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

View File

@@ -1,340 +0,0 @@
using Assets.Scripts.Player;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts
{
public class Equipment : Item
{
ItemPlace place;
Dictionary<string, int> attributes;
public Equipment(int luck) : base(luck, true)
{
attributes = new Dictionary<string, int>();
int numberOfAttributes = 1;
if (rarity > ItemRarity.COMMON)
{
numberOfAttributes = 2;
}
if (rarity > ItemRarity.RARE)
{
numberOfAttributes = 3;
}
if (rarity == ItemRarity.LEGENDARY)
{
numberOfAttributes = 0;
}
calculateAttributes(luck, numberOfAttributes);
place = (ItemPlace)rand.Next(8);
editName();
loadImage();
}
public Equipment(JToken json) : base(json)
{
attributes = new Dictionary<string, int>();
place = (ItemPlace)Enum.Parse(typeof(ItemPlace), json["place"].ToString());
loadAttributes(json);
loadImage();
}
private void loadAttributes(JToken json)
{
if (json["MPR"] != null)
{
attributes.Add("MPR", int.Parse(json["MPR"].ToString()));
}
if (json["MP"] != null)
{
attributes.Add("MP", int.Parse(json["MP"].ToString()));
}
if (json["HP"] != null)
{
attributes.Add("HP", int.Parse(json["HP"].ToString()));
}
if (json["STR"] != null)
{
attributes.Add("STR", int.Parse(json["STR"].ToString()));
}
if (json["DEX"] != null)
{
attributes.Add("DEX", int.Parse(json["DEX"].ToString()));
}
if (json["INT"] != null)
{
attributes.Add("INT", int.Parse(json["INT"].ToString()));
}
if (json["LCK"] != null)
{
attributes.Add("LCK", int.Parse(json["LCK"].ToString()));
}
}
private void editName()
{
string replacement = "";
if (place == ItemPlace.LEFTHAND)
{
switch (GameObject.Find("Player").GetComponent<PlayerGameObject>().getClass().classname)
{
case "Warrior":
replacement = "Greatshield";
break;
case "Thief":
replacement = "Shield";
break;
case "Mage":
replacement = "Orb";
break;
case "Druid":
replacement = "Shield";
break;
}
}
else if (place == ItemPlace.RIGHTHAND)
{
switch (GameObject.Find("Player").GetComponent<PlayerGameObject>().getClass().classname)
{
case "Warrior":
replacement = "Sword";
break;
case "Thief":
replacement = "Dagger";
break;
case "Mage":
replacement = "Wand";
break;
case "Druid":
replacement = "Wand";
break;
}
}
if (itemName != null)
{
if (replacement.Length > 0)
{
itemName = replacement + " of " + itemName + " attribute (" + rarity.ToString() + ")";
}
else
{
itemName = place.ToString() + " of " + itemName + " attribute (" + rarity.ToString() + ")";
}
}
else
{
if (replacement.Length > 0)
{
itemName = replacement + " " + rarity.ToString();
}
else
{
itemName = place.ToString() + " " + rarity.ToString();
}
}
itemName = itemName.ToLower();
itemName = char.ToUpper(itemName[0]) + itemName.Substring(1);
}
private void calculateAttributes(int luck, int numberOfAttributes)
{
if (numberOfAttributes != 0)
{
int[] indexes = new int[numberOfAttributes];
int index;
for (int i = 0; i < numberOfAttributes; i++)
{
index = calculateIndex(indexes);
switch (index)
{
case 1:
if (i == 0)
{
itemName = "Luck";
}
attributes.Add("LCK", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1)));
break;
case 2:
if (i == 0)
{
itemName = "Intelligence";
}
attributes.Add("INT", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1)));
break;
case 3:
if (i == 0)
{
itemName = "Dexterity";
}
attributes.Add("DEX", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1)));
break;
case 4:
if (i == 0)
{
itemName = "Strength";
}
attributes.Add("STR", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1)));
break;
case 5:
if (i == 0)
{
itemName = "Health";
}
attributes.Add("HP", Mathf.RoundToInt((float)(10 - (2 * i) + rand.Next(luck) * 0.1)));
break;
case 6:
if (i == 0)
{
itemName = "mana";
}
attributes.Add("MP", Mathf.RoundToInt((float)(10 - (2 * i) + rand.Next(luck) * 0.1)));
break;
case 7:
if (i == 0)
{
itemName = "mana regeneration";
}
attributes.Add("MPR", Mathf.RoundToInt((float)(3 - (2 * i) + rand.Next(luck) * 0.1)));
break;
}
indexes[i] = index;
}
}
else
{
int bonus = rand.Next(luck);
attributes.Add("MPR", Mathf.RoundToInt((float)(3 + bonus * 0.1)));
attributes.Add("MP", Mathf.RoundToInt((float)(3 + bonus * 0.1)));
attributes.Add("HP", Mathf.RoundToInt((float)(3 + bonus * 0.1)));
attributes.Add("STR", Mathf.RoundToInt((float)(3 + bonus * 0.1)));
attributes.Add("DEX", Mathf.RoundToInt((float)(3 + bonus * 0.1)));
attributes.Add("INT", Mathf.RoundToInt((float)(3 + bonus * 0.1)));
attributes.Add("LCK", Mathf.RoundToInt((float)(3 + bonus * 0.1)));
}
}
private int calculateIndex(int[] indexes)
{
int counter = 0;
int index = 0;
while (true)
{
index = rand.Next(8);
counter = 0;
for (int j = 0; j < indexes.Length; j++)
{
if (indexes[j] == index)
{
counter++;
break;
}
}
if (counter == 0)
{
break;
}
}
return index;
}
public ItemPlace getPlace()
{
return place;
}
public string getDisplayText()
{
string displayText = "";
displayText = displayText + itemName + "\r\n";
if (rarity == ItemRarity.LEGENDARY)
{
displayText = displayText + "All attributes: +" + attributes["STR"];
}
else
{
foreach (string key in attributes.Keys)
{
displayText = displayText + key + ": +" + attributes[key] + "\r\n";
}
}
return displayText;
}
override
protected void loadImage()
{
switch (place)
{
case ItemPlace.LEFTHAND:
image = Resources.Load<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<PlayerGameObject>().getClass().classname + "/Inv_LeftHand");
break;
case ItemPlace.RIGHTHAND:
image = Resources.Load<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<PlayerGameObject>().getClass().classname + "/Inv_RightHand");
break;
case ItemPlace.HELMET:
image = Resources.Load<Texture>("Equipment/Inv_Helmet");
break;
case ItemPlace.BOOTS:
image = Resources.Load<Texture>("Equipment/Inv_Boots");
break;
case ItemPlace.AMULET:
image = Resources.Load<Texture>("Equipment/Inv_Amulet");
break;
case ItemPlace.RING:
image = Resources.Load<Texture>("Equipment/Inv_Ring");
break;
case ItemPlace.ARMOR:
image = Resources.Load<Texture>("Equipment/Inv_Chest");
break;
}
}
public Dictionary<string, int> getAttributes()
{
return attributes;
}
override
public string saveGame()
{
string result = "";
int counter = 0;
result = result + FileHandler.generateJSON("rarity", "\"" + rarity + "\"") + ",\r\n";
result = result + FileHandler.generateJSON("place", "\"" + place + "\"") + ",\r\n";
result = result + FileHandler.generateJSON("itemName", "\"" + itemName + "\"") + ",\r\n";
foreach (string key in attributes.Keys)
{
result = result + FileHandler.generateJSON(key, attributes[key]);
if (counter < attributes.Count - 1)
{
result = result + ",\r\n";
}
counter++;
}
return result;
}
override
public string getInformation()
{
string text = "Stats:\r\n";
if (rarity == ItemRarity.LEGENDARY)
{
text = "All stats: +" + attributes["STR"];
}
else
{
foreach (string key in attributes.Keys)
{
text = text + key + ": +" + attributes[key] + "\r\n";
}
}
return text;
}
}
}

View File

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

View File

@@ -1,196 +0,0 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts
{
public class Item
{
protected System.Random rand = new System.Random();
protected string itemName;
protected ItemRarity rarity;
public Texture image;
public Color32 rarityColor;
public Item(int luck, bool isEquipment)
{
if(isEquipment){
luck = luck + GameObject.Find("Inventory").GetComponent<Inventory>().getEquipmentBonus()["LCK"];
calculateRarity(luck);
setColor();
}
else{
chooseItem();
rarity = ItemRarity.COMMON;
rarityColor = Color.white;
loadImage();
}
}
public Item(string name)
{
rarity = ItemRarity.COMMON;
itemName = name;
rarityColor = Color.white;
loadImage();
}
public Item(JToken json)
{
rarity = (ItemRarity)Enum.Parse(typeof(ItemRarity), json["rarity"].ToString());
itemName = json["itemName"].ToString();
if(json["place"] != null){
setColor();
}
else{
rarityColor = Color.white;
}
loadImage();
}
private void calculateRarity(int luck)
{
int number = rand.Next(100);
if (number + luck < 70)
{
rarity = ItemRarity.COMMON;
}
else if (number + luck >= 70 && number + luck < 95)
{
rarity = ItemRarity.RARE;
}
else if (number + luck >= 95 && number + luck < 120)
{
rarity = ItemRarity.EPIC;
}
else if (number + luck >= 120)
{
rarity = ItemRarity.LEGENDARY;
}
}
private void setColor()
{
switch (rarity)
{
case ItemRarity.COMMON:
rarityColor = new Color32(0, 255, 20, 255);
break;
case ItemRarity.RARE:
rarityColor = new Color32(0, 100, 255, 255);
break;
case ItemRarity.EPIC:
rarityColor = new Color32(255, 0, 230, 255);
break;
case ItemRarity.LEGENDARY:
rarityColor = new Color32(255, 230, 0, 255);
break;
}
}
protected virtual void loadImage()
{
switch (itemName)
{
case "Slimeball":
image = Resources.Load<Texture>("Items/Inv_Slimeball");
break;
case "Wood":
image = Resources.Load<Texture>("Items/Inv_Wood");
break;
case "Rock":
image = Resources.Load<Texture>("Items/Inv_Stone");
break;
case "Iron ore":
image = Resources.Load<Texture>("Items/Inv_Iron");
break;
case "Gold ore":
image = Resources.Load<Texture>("Items/Inv_Gold");
break;
case "Copper ore":
image = Resources.Load<Texture>("Items/Inv_Copper");
break;
case "Tin ore":
image = Resources.Load<Texture>("Items/Inv_Tin");
break;
}
}
public virtual string saveGame()
{
string result = "";
result = result + FileHandler.generateJSON("rarity", "\"" + rarity + "\"") + ",\r\n";
result = result + FileHandler.generateJSON("itemName", "\"" + itemName + "\"") + ",\r\n";
return result;
}
public void setName(string name)
{
this.itemName = name;
}
public string getName()
{
return itemName;
}
public ItemRarity getRarity()
{
return rarity;
}
public virtual string getInformation()
{
string result = "";
switch (itemName)
{
case "Slimeball":
result = TextHandler.getText("slimeballInfo");//"";
break;
case "Wood":
result = TextHandler.getText("woodInfo");//"";
break;
case "Rock":
result = TextHandler.getText("rockInfo");//"";
break;
case "Iron ore":
result = TextHandler.getText("ironOreInfo");//"";
break;
case "Gold ore":
result = TextHandler.getText("goldOreInfo");//"";
break;
case "Copper ore":
result = TextHandler.getText("copperOreInfo");//"";
break;
case "Tin ore":
result = TextHandler.getText("tinOreInfo");//"";
break;
}
return result;
}
private void chooseItem()
{
int index = rand.Next(4);
switch (index)
{
case 0:
itemName = "Slimeball";
break;
case 1:
itemName = "Rock";
break;
case 2:
itemName = "Iron ore";
break;
case 3:
itemName = "Gold ore";
break;
}
}
}
}

View File

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

View File

@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts
{
public enum ItemPlace
{
HELMET,
RIGHTHAND,
LEFTHAND,
RING,
AMULET,
ARMOR,
BOOTS,
BAG
}
}

View File

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

View File

@@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts
{
public enum ItemRarity
{
COMMON,
RARE,
EPIC,
LEGENDARY
}
}

View File

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

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 648f691b06a71134d8ff2a5599a25c30
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,80 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts
{
class LogWriter : MonoBehaviour
{
GameObject img;
GameObject txt;
List<string> messages;
bool isDisplaying = false;
DateTime call;
void Start()
{
img = GameObject.Find("MessageImage").gameObject;
txt = GameObject.Find("MessageText").gameObject;
messages = new List<string>();
}
void Update()
{
if (messages.Count > 0)
{
if (!isDisplaying)
{
writeMessage();
}
else
{
hideMessage();
}
}
}
public void addMessage(string message)
{
messages.Add(message);
}
public void writeMessage()
{
switch (messages[0].Split(';')[0])
{
case "ERROR":
img.GetComponent<RawImage>().color = Color.red;
break;
case "INFORMATION":
img.GetComponent<RawImage>().color = Color.black;
break;
case "SUCCESS":
img.GetComponent<RawImage>().color = Color.green;
break;
case "WARNING":
img.GetComponent<RawImage>().color = Color.yellow;
break;
}
txt.GetComponent<Text>().text = messages[0].Split(';')[1];
gameObject.transform.localScale = new Vector3(1, 1, 1);
isDisplaying = true;
call = DateTime.Now;
}
private void hideMessage()
{
if (call.AddSeconds(2).CompareTo(DateTime.Now) <= 0)
{
gameObject.transform.localScale = new Vector3(0, 0, 0);
isDisplaying = false;
messages.Remove(messages[0]);
}
}
}
}

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -1,87 +0,0 @@
using Assets.Scripts;
using Assets.Scripts.Menu;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class ControlsMenu : MonoBehaviour
{
UIHandlerMenu uihandler;
MoveDirection direction;
PlayerInput playerInput;
void Start()
{
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandlerMenu>();
direction = MoveDirection.None;
playerInput = GetComponent<PlayerInput>();
}
// Update is called once per frame
void Update()
{
changeNameInput();
if(playerInput.currentControlScheme == "Controller"){
if(EventSystem.current.currentSelectedGameObject == null){
EventSystem.current.SetSelectedGameObject(FindFirstObjectByType<Button>().gameObject);
}
if(Cursor.lockState != CursorLockMode.Locked){
Cursor.lockState = CursorLockMode.Locked;
}
if(playerInput.currentActionMap.name != "Menu"){
playerInput.SwitchCurrentActionMap("Menu");
}
}
else{
if(Cursor.lockState != CursorLockMode.Confined){
Cursor.lockState = CursorLockMode.Confined;
}
}
}
public void FixedUpdate(){
if(direction != MoveDirection.None){
AxisEventData data = new AxisEventData(EventSystem.current);
data.moveDir = direction;
data.selectedObject = EventSystem.current.currentSelectedGameObject;
ExecuteEvents.Execute(data.selectedObject, data, ExecuteEvents.moveHandler);
}
}
public void OnMovement(InputValue value){
if(value.Get<Vector2>().x < 0){
direction = MoveDirection.Left;
}
else if(value.Get<Vector2>().x > 0){
direction = MoveDirection.Right;
}
else if(value.Get<Vector2>().y < 0){
direction = MoveDirection.Down;
}
else if(value.Get<Vector2>().y > 0){
direction = MoveDirection.Up;
}
}
public void OnBack(){
}
public void changeNameInput(){
if(uihandler.isCharacterCreation()){
if(playerInput.currentControlScheme == "Controller"){
if(EventSystem.current.currentSelectedGameObject == null || EventSystem.current.currentSelectedGameObject == GameObject.Find("inName")){
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnRandomName"));
}
GameObject.Find("inName").GetComponent<InputField>().interactable = false;
}
else{
GameObject.Find("inName").GetComponent<InputField>().interactable = true;
}
}
}
}

View File

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

View File

@@ -1,247 +0,0 @@
using Assets.Scripts.Classes;
using Assets.Scripts.Player;
using Assets.Scripts.Races;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;
namespace Assets.Scripts.Menu
{
public class UIHandlerMenu : MonoBehaviour
{
public GameObject mainMenu;
public GameObject options;
public GameObject characterCreation;
// Start is called before the first frame update
void Start()
{
FileHandler.loadOptions(false);
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(1,1,1);
SteamWorksHandler.getStandardAchievement("StartAchievement");
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
public void startGame(SceneHandler sceneHandler)
{
int cityAmount = 0;
switch (GameObject.Find("dropSize").GetComponent<Dropdown>().value)
{
case 0:
cityAmount = 5;
break;
case 1:
cityAmount = 10;
break;
case 2:
cityAmount = 20;
break;
case 3:
cityAmount = 40;
break;
}
PlayerPrefs.SetInt("cityAmount", cityAmount);
PlayerPrefs.SetInt("class", GameObject.Find("dropClass").GetComponent<Dropdown>().value);
PlayerPrefs.SetInt("race", GameObject.Find("dropRace").GetComponent<Dropdown>().value);
PlayerPrefs.SetString("playername", GameObject.Find("inName").GetComponent<InputField>().text);
PlayerPrefs.SetInt("difficulty", GameObject.Find("dropDifficulty").GetComponent<Dropdown>().value);
PlayerPrefs.SetInt("isLoad", 0);
SteamWorksHandler.getStandardAchievement("CharAchievement");
sceneHandler.openGameScene();
}
private void setPlayerInformation()
{
string name = GameObject.Find("inName").GetComponent<InputField>().text;
int role = GameObject.Find("dropClass").GetComponent<Dropdown>().value;
int race = GameObject.Find("dropRace").GetComponent<Dropdown>().value;
BasicRace playerRace = new BasicRace();
BasicClass playerClass = new BasicClass();
switch (role)
{
case 0:
playerClass = new WarriorClass();
break;
case 1:
playerClass = new MageClass();
break;
case 2:
playerClass = new ThiefClass();
break;
case 3:
playerClass = new DruidClass();
break;
}
switch (race)
{
case 0:
playerRace = new HumanRace();
break;
case 1:
playerRace = new ElvenRace();
break;
case 2:
playerRace = new DwarvenRace();
break;
case 3:
playerRace = new GoblinRace();
break;
case 4:
playerRace = new GiantRace();
break;
case 5:
playerRace = new NightelfRace();
break;
}
GameObject.Find("Player").GetComponent<PlayerGameObject>().generatePlayer(playerRace, playerClass, name, GameObject.Find("dropDifficulty").GetComponent<Dropdown>().value);
}
public void openCharacterCreation()
{
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(1,1,1);
mainMenu.transform.localScale = new Vector3(0,0,0);
EventSystem.current.SetSelectedGameObject(GameObject.Find("inName"));
}
public void closeCharacterCreation()
{
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(1,1,1);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
public void openOptions()
{
options.transform.localScale = new Vector3(1,1,1);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(0,0,0);
FileHandler.loadOptionDisplay();
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnAudio"));
showOptionView("audio");
}
public void closeOptions()
{
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(1,1,1);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
public string saveVideoSettings(){
GameObject resolution = GameObject.Find("dropResolution");
GameObject mode = GameObject.Find("dropMode");
string result = "";
switch (resolution.GetComponent<Dropdown>().value)
{
case 0:
Screen.SetResolution(800, 600, Screen.fullScreenMode);
break;
case 1:
Screen.SetResolution(1280, 800, Screen.fullScreenMode);
break;
case 2:
Screen.SetResolution(1920, 1080, Screen.fullScreenMode);
break;
}
switch (mode.GetComponent<Dropdown>().value)
{
case 0:
if (Screen.fullScreenMode != FullScreenMode.Windowed)
{
Screen.fullScreenMode = FullScreenMode.Windowed;
}
break;
case 1:
if (Screen.fullScreenMode != FullScreenMode.ExclusiveFullScreen)
{
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
}
break;
case 2:
if (Screen.fullScreenMode != FullScreenMode.FullScreenWindow)
{
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
}
break;
}
result = result + "Resolution:"+resolution.GetComponent<Dropdown>().value+"\r\n";
result = result + "Mode:"+mode.GetComponent<Dropdown>().value;
return result;
}
public string saveLanguage(){
GameObject language = GameObject.Find("dropLanguage");
string result = "";
switch (language.GetComponent<Dropdown>().value)
{
case 0:
result = "de";
break;
case 1:
result = "en";
break;
}
result = "Language:"+result;
return result;
}
public void updateCreationInformation()
{
setPlayerInformation();
// health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence, level, experience, maxExperience, points
PlayerGameObject player = GameObject.Find("Player").GetComponent<PlayerGameObject>();
GameObject.Find("txtStrength_Creation").GetComponent<Text>().text = TextHandler.getText("strength") + " " + player.getPlayerStat("Strength").getAmount();
GameObject.Find("txtDexterity_Creation").GetComponent<Text>().text = TextHandler.getText("dexterity") + " " + player.getPlayerStat("Dexterity").getAmount();
GameObject.Find("txtIntelligence_Creation").GetComponent<Text>().text = TextHandler.getText("intelligence") + " " + player.getPlayerStat("Intelligence").getAmount();
GameObject.Find("txtHealth_Creation").GetComponent<Text>().text = TextHandler.getText("health") + " " + player.getPlayerStat("MaxHealth").getAmount();
GameObject.Find("txtSecondary_Creation").GetComponent<Text>().text = "Mana: " + player.getPlayerStat("MaxSecondary").getAmount();
}
public void loadGame(SceneHandler sceneHandler)
{
PlayerPrefs.SetInt("isLoad", 1);
sceneHandler.openGameScene();
}
public bool isCharacterCreation(){
return characterCreation.activeSelf;
}
public void showOptionView(string key){
GameObject optionContent = GameObject.Find("pnlContent");
for(int i = 0; i < optionContent.transform.childCount; i++){
if(optionContent.transform.GetChild(i).name.ToLower().Contains(key)){
optionContent.transform.GetChild(i).transform.localScale = new Vector3(1,1,1);
}
else{
optionContent.transform.GetChild(i).transform.localScale = new Vector3(0,0,0);
}
}
}
public void switchLanguage(){
GameObject language = GameObject.Find("dropLanguage");
switch (language.GetComponent<Dropdown>().value)
{
case 0:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("de");
break;
case 1:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("en");
break;
}
}
}
}

View File

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

View File

@@ -1,309 +0,0 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Linq;
public class NoiseGenerator
{
System.Random rand = new System.Random();
public void applyNoise(GameObject tile, Dictionary<Vector3, GameObject> map, Vector3 index)
{
//resetMesh(tile);
Mesh mesh = tile.GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
float[] samples;
Color32[] colors;
Color32 low;
Color32 high;
List<TileType> availableTypes = checkAvailability(map, index);
TileType tiletype = TileType.NULL;
if (index == new Vector3(0, 0, 0))
{ //IS SPAWN
tiletype = (TileType)rand.Next(0, TileTypeMethods.getHighest() + 1);
}
else
{
if (availableTypes.Count == 0)
{
Debug.Log("NO MATCH FOUND");
}
else
{
if (availableTypes.Contains(TileType.CITY))
{
if (rand.Next(0, 101) < 10)
{
tiletype = TileType.CITY;
SteamWorksHandler.getStandardAchievement("CityAchievement");
}
else
{
availableTypes.Remove(TileType.CITY);
tiletype = availableTypes[rand.Next(0, availableTypes.Count)];
}
}
else
{
tiletype = availableTypes[rand.Next(0, availableTypes.Count)];
}
}
}
tile.name = tiletype.ToString() + "_" + map.Count;
low = TileTypeMethods.getLowestColor(tiletype);
high = TileTypeMethods.getHighestColor(tiletype);
samples = TileTypeMethods.generateSamples(tiletype, vertices, rand);
float lowestValue = 10;
float highestValue = 0;
for (int i = 0; i < samples.Length; i++)
{
if (lowestValue > samples[i])
{
lowestValue = samples[i];
}
if (highestValue < samples[i])
{
highestValue = samples[i];
}
}
float modifier = highestValue - lowestValue;
colors = new Color32[samples.Length];
for (int i = 0; i < samples.Length; i++)
{
colors[i] = Color32.Lerp(low, high, (1 / modifier) * (samples[i] - lowestValue));
}
//Connect samples to neighbours
samples = connectNeighbourSamples(samples, map, index);
colors = connectNeighbourColors(colors, map, index);
for (int i = 0; i < samples.Length; i++)
{
vertices[i].y = samples[i];
}
applyMesh(tile, mesh, vertices, colors);
}
private List<TileType> checkAvailability(Dictionary<Vector3, GameObject> tiles, Vector3 index)
{
List<List<TileType>> toCheck = new List<List<TileType>>();
List<TileType> result = new List<TileType>();
for (int i = 0; i < TileTypeMethods.getHighest() + 1; i++)
{
result.Add((TileType)i);
}
if (tiles.ContainsKey(index - new Vector3(1, 0, 0)))
{
toCheck.Add(tiles[index - new Vector3(1, 0, 0)].GetComponent<Tile>().getPossibleNeighbours());
}
if (tiles.ContainsKey(index - new Vector3(-1, 0, 0)))
{
toCheck.Add(tiles[index - new Vector3(-1, 0, 0)].GetComponent<Tile>().getPossibleNeighbours());
}
if (tiles.ContainsKey(index - new Vector3(0, 0, 1)))
{
toCheck.Add(tiles[index - new Vector3(0, 0, 1)].GetComponent<Tile>().getPossibleNeighbours());
}
if (tiles.ContainsKey(index - new Vector3(0, 0, -1)))
{
toCheck.Add(tiles[index - new Vector3(0, 0, -1)].GetComponent<Tile>().getPossibleNeighbours());
}
for (int i = 0; i < toCheck.Count; i++)
{
result = result.Intersect(toCheck[i]).ToList();
}
return result;
}
private float[] connectNeighbourSamples(float[] basis, Dictionary<Vector3, GameObject> tiles, Vector3 index)
{
float[] result = basis;
Mesh mesh;
Vector3[] vertices;
int sidelength = (int)Mathf.Sqrt(result.Length);
if (tiles.ContainsKey(index - new Vector3(1, 0, 0))) //Links
{
mesh = tiles[index - new Vector3(1, 0, 0)].GetComponent<MeshFilter>().mesh;
vertices = mesh.vertices;
for (int i = 0; i < sidelength; i++)
{
result[sidelength - 1 + i * sidelength] = vertices[0 + i * sidelength].y;
result[sidelength - 2 + i * sidelength] = (result[sidelength - 1 + i * sidelength] + result[sidelength - 3 + i * sidelength]) / 2;
}
}
if (tiles.ContainsKey(index - new Vector3(-1, 0, 0))) //Rechts
{
mesh = tiles[index - new Vector3(-1, 0, 0)].GetComponent<MeshFilter>().mesh;
vertices = mesh.vertices;
for (int i = 0; i < sidelength; i++)
{
result[0 + i * sidelength] = vertices[sidelength - 1 + i * sidelength].y;
result[1 + i * sidelength] = (result[0 + i * sidelength] + result[2 + i * sidelength]) / 2;
}
}
if (tiles.ContainsKey(index - new Vector3(0, 0, 1))) //Unten
{
mesh = tiles[index - new Vector3(0, 0, 1)].GetComponent<MeshFilter>().mesh;
vertices = mesh.vertices;
for (int i = 0; i < sidelength; i++)
{
result[sidelength * sidelength - (sidelength - i)] = vertices[i].y;
result[sidelength * (sidelength - 1) - (sidelength - i)] = (result[sidelength * sidelength - (sidelength - i)] + result[sidelength * (sidelength - 2) - (sidelength - i)]) / 2;
}
}
if (tiles.ContainsKey(index - new Vector3(0, 0, -1))) //Oben
{
mesh = tiles[index - new Vector3(0, 0, -1)].GetComponent<MeshFilter>().mesh;
vertices = mesh.vertices;
for (int i = 0; i < sidelength; i++)
{
result[i] = vertices[sidelength * sidelength - (sidelength - i)].y;
result[i + sidelength] = (result[i] + result[i + sidelength * 2]) / 2;
}
}
return result;
}
private Color32[] connectNeighbourColors(Color32[] basis, Dictionary<Vector3, GameObject> tiles, Vector3 index)
{
Color32[] result = basis;
Mesh mesh;
Color32[] colors;
int sidelength = (int)Mathf.Sqrt(result.Length);
if (tiles.ContainsKey(index - new Vector3(1, 0, 0))) //Links
{
mesh = tiles[index - new Vector3(1, 0, 0)].GetComponent<MeshFilter>().mesh;
colors = mesh.colors32;
for (int i = 0; i < sidelength; i++)
{
result[sidelength - 1 + i * sidelength] = colors[0 + i * sidelength];
result[sidelength - 2 + i * sidelength] = Color32.Lerp(result[sidelength - 1 + i * sidelength], result[sidelength - 3 + i * sidelength], 0.5f);
}
}
if (tiles.ContainsKey(index - new Vector3(-1, 0, 0))) //Rechts
{
mesh = tiles[index - new Vector3(-1, 0, 0)].GetComponent<MeshFilter>().mesh;
colors = mesh.colors32;
for (int i = 0; i < sidelength; i++)
{
result[0 + i * sidelength] = colors[sidelength - 1 + i * sidelength];
result[1 + i * sidelength] = Color32.Lerp(result[0 + i * sidelength], result[2 + i * sidelength], 0.5f);
}
}
if (tiles.ContainsKey(index - new Vector3(0, 0, 1))) //Unten
{
mesh = tiles[index - new Vector3(0, 0, 1)].GetComponent<MeshFilter>().mesh;
colors = mesh.colors32;
for (int i = 0; i < sidelength; i++)
{
result[sidelength * sidelength - (sidelength - i)] = colors[i];
result[sidelength * (sidelength - 1) - (sidelength - i)] = Color32.Lerp(result[sidelength * sidelength - (sidelength - i)], result[sidelength * (sidelength - 2) - (sidelength - i)], 0.5f);
}
}
if (tiles.ContainsKey(index - new Vector3(0, 0, -1))) //Oben
{
mesh = tiles[index - new Vector3(0, 0, -1)].GetComponent<MeshFilter>().mesh;
colors = mesh.colors32;
for (int i = 0; i < sidelength; i++)
{
result[i] = colors[sidelength * sidelength - (sidelength - i)];
result[i + sidelength] = Color32.Lerp(result[i], result[i + sidelength * 2], 0.5f);
}
}
return result;
}
private void resetMesh(GameObject tile)
{
Mesh mesh = tile.GetComponent<MeshCollider>().sharedMesh;
Vector3[] vertices = mesh.vertices;
for (int i = 0; i < vertices.Length; i++)
{
vertices[i].y = 0;
}
mesh.vertices = vertices;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
tile.GetComponent<MeshCollider>().sharedMesh = mesh;
}
public void applyMesh(GameObject tile, Mesh mesh, Vector3[] vertices, Color32[] colors)
{
mesh.vertices = vertices;
mesh.colors32 = colors;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
tile.GetComponent<MeshCollider>().sharedMesh = mesh;
tile.GetComponent<MeshFilter>().sharedMesh = mesh;
}
public void saveTile(GameObject tile, string path)
{
string result = "";
Vector3[] vertices = tile.GetComponent<MeshFilter>().mesh.vertices;
Color32[] colors = tile.GetComponent<MeshFilter>().mesh.colors32;
result = result + "\"vertices\": {\r\n";
for (int i = 0; i < vertices.Length; i++)
{
result = result + FileHandler.generateJSON("vertice" + i, "\"" + vertices[i].x + "/" + vertices[i].y + "/" + vertices[i].z + "\"");
if (i < vertices.Length - 1)
{
result = result + ",\r\n";
}
}
result = result + "\r\n},\"colors\": {\r\n";
for (int i = 0; i < colors.Length; i++)
{
result = result + FileHandler.generateJSON("color" + i, "\"" + colors[i].r + "/" + colors[i].g + "/" + colors[i].b + "/" + colors[i].a + "\"");
if (i < colors.Length - 1)
{
result = result + ",\r\n";
}
}
result = result + "\r\n}\r\n}";
FileHandler.saveNoise(result, path);
}
public void loadTile(GameObject tile, JToken jsonVertices, JToken jsonColors)
{
var jsonData = JObject.Parse(jsonColors.ToString()).Children();
List<JToken> colorTokens = jsonData.Children().ToList();
jsonData = JObject.Parse(jsonVertices.ToString()).Children();
List<JToken> verticeTokens = jsonData.Children().ToList();
Color32[] colors = new Color32[colorTokens.Count];
Vector3[] vertices = new Vector3[verticeTokens.Count];
JToken current;
string[] parts;
for (int i = 0; i < colorTokens.Count; i++)
{
current = colorTokens[i];
parts = current.Value<string>().Split('/');
colors[i] = new Color32(byte.Parse(parts[0]), byte.Parse(parts[1]), byte.Parse(parts[2]), byte.Parse(parts[3]));
}
for (int i = 0; i < verticeTokens.Count; i++)
{
current = verticeTokens[i];
parts = current.Value<string>().Split('/');
vertices[i] = new Vector3(float.Parse(parts[0]), float.Parse(parts[1]), float.Parse(parts[2]));
}
applyMesh(tile, tile.GetComponent<MeshFilter>().mesh, vertices, colors);
}
}

View File

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

View File

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

View File

@@ -1,143 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Assets.Scripts.InteractableObjects;
namespace Assets.Scripts.Player
{
public class PlayerCamera : MonoBehaviour
{
UIHandler uihandler;
GameObject interact;
// Start is called before the first frame update
void Start()
{
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
interact = GameObject.Find("pnlInteract");
interact.transform.localScale = new Vector3(0, 0, 0);
}
// Update is called once per frame
void Update()
{
}
private void FixedUpdate()
{
showInformation();
}
public GameObject interactWithObject()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit, 3))
{
if (hit.collider.gameObject.tag.ToLower().Contains("object"))
{
return hit.collider.gameObject;
}
}
return null;
}
public void lookAround(Vector2 view, Vector2 speed)
{
GameObject target = GameObject.Find("targetLooking");
target.transform.localPosition = target.transform.localPosition + new Vector3(0,view.y,0) * speed.x;// * Time.deltaTime;
if(target.transform.localPosition.y >= 2){
target.transform.localPosition = new Vector3(target.transform.localPosition.x,2f,target.transform.localPosition.z);
}
if(target.transform.localPosition.y <= -1){
target.transform.localPosition = new Vector3(target.transform.localPosition.x,-1f,target.transform.localPosition.z);
}
}
void showInformation()
{
RaycastHit hit;
interact.transform.localScale = new Vector3(0, 0, 0);
if (Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity))
{
if (hit.collider.gameObject.tag.ToLower().Contains("object"))
{
string obj = hit.collider.gameObject.tag.Split(':')[1];
if (hit.distance <= 10 && !obj.ToLower().Equals("house"))
{
if (!uihandler.isPlayerInFight())
{
interact.transform.localScale = new Vector3(1, 1, 1);
}
}
switch (obj.ToLower())
{
case "tree":
displayInformation(TextHandler.getText("tree"));
break;
case "stone":
displayInformation(TextHandler.getText("rock"));
break;
case "npc":
displayInformation("NPC");
break;
case "enemy":
displayInformation(TextHandler.translate(hit.collider.gameObject.GetComponent<Enemy>().getEnemyName()));
break;
case "house":
displayInformation(TextHandler.getText("house"));
break;
case "door":
displayInformation(TextHandler.getText("door"));
break;
case "chest":
displayInformation(TextHandler.getText("chest"));
break;
case "ore":
if (hit.collider.gameObject.name.ToLower().Contains("iron"))
{
displayInformation(TextHandler.translate("Iron ore"));
}
else if (hit.collider.gameObject.name.ToLower().Contains("gold"))
{
displayInformation(TextHandler.translate("Gold ore"));
}
else if (hit.collider.gameObject.name.ToLower().Contains("copper"))
{
displayInformation(TextHandler.translate("Copper ore"));
}
else if (hit.collider.gameObject.name.ToLower().Contains("tin"))
{
displayInformation(TextHandler.translate("Tin ore"));
}
break;
default:
uihandler.hideInformation();
break;
}
}
else
{
uihandler.hideInformation();
}
}
else
{
uihandler.hideInformation();
}
}
private void displayInformation(string information)
{
if (!uihandler.isPlayerInFight())
{
uihandler.displayInformation(information);
}
else
{
uihandler.hideInformation();
}
}
}
}

View File

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

View File

@@ -1,403 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using Assets.Scripts.Classes;
using Assets.Scripts.Races;
using Newtonsoft.Json.Linq;
using UnityEngine.InputSystem;
using Assets.Scripts.InteractableObjects;
using UnityEngine.UIElements;
using UnityEngine.Animations;
namespace Assets.Scripts.Player
{
public class PlayerGameObject : MonoBehaviour
{
public float speed = 5f;
public GameObject[] leftHands;
public GameObject[] rightHands;
UIHandler uihandler;
AudioHandler audioHandler;
WorldGenerator worldGenerator;
Inventory inventory;
int difficulty = 0;
bool finishedGame = false;
PlayerObject player;
DateTime now;
int jumpFrameCounter;
public bool isArmed;
bool canJump;
private void OnEnable()
{
#if UNITY_EDITOR
SceneHandler.switchGameToMenu();
#endif
}
void Start()
{
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
audioHandler = GameObject.Find("AudioHandler").GetComponent<AudioHandler>();
if (GameObject.Find("Inventory") != null)
{
inventory = GameObject.Find("Inventory").GetComponent<Inventory>();
}
if (GameObject.Find("WorldGenerator") != null)
{
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
}
isArmed = true;
jumpFrameCounter = 0;
canJump = false;
}
// Update is called once per frame
void Update()
{
if (player == null)
{
return;
}
if (player.getStat("Killcount").getAmount() == -1)
{
return;
}
if (uihandler.state == UIState.DEATH)
{
return;
}
getRotation();
regeneratePlayer();
uihandler.adjustInformation(this);
if (!finishedGame)
{
gameFinished();
}
if (player.isDead())
{
SteamWorksHandler.getStandardAchievement("DeathAchievement");
uihandler.showDeathScreen();
}
}
private void regeneratePlayer()
{
if (uihandler.state != UIState.FIGHT)
{
if (now == null)
{
now = DateTime.Now;
}
else
{
if (now.AddSeconds(10).CompareTo(DateTime.Now) <= 0)
{
now = DateTime.Now;
player.regainSecondary(inventory.getEquipmentBonus()["MPR"], inventory.getEquipmentBonus()["MP"]);
player.healPlayer(4 - difficulty * 2, inventory.getEquipmentBonus()["HP"]);
}
}
}
else
{
now = DateTime.Now;
}
}
public void generatePlayer()
{
BasicRace race = new BasicRace();
BasicClass role = new BasicClass();
switch (PlayerPrefs.GetInt("class"))
{
case 0:
role = new WarriorClass();
break;
case 1:
role = new MageClass();
break;
case 2:
role = new ThiefClass();
break;
case 3:
role = new DruidClass();
break;
}
switch (PlayerPrefs.GetInt("race"))
{
case 0:
race = new HumanRace();
break;
case 1:
race = new ElvenRace();
break;
case 2:
race = new DwarvenRace();
break;
case 3:
race = new GoblinRace();
break;
case 4:
race = new GiantRace();
break;
case 5:
race = new NightelfRace();
break;
}
string playername = PlayerPrefs.GetString("playername");
difficulty = PlayerPrefs.GetInt("difficulty");
player = new PlayerObject(playername, race, role, difficulty);
player.getClass().loadHandObjects();
GetComponent<Animator>().SetBool("isArmed", true);
}
//Generating player instance for stat preview during creation
public void generatePlayer(BasicRace playerRace, BasicClass playerClass, string name, int difficulty)
{
player = new PlayerObject(name, playerRace, playerClass, difficulty);
}
public void move(Vector3 input)
{
if(gameObject.GetComponent<Rigidbody>().velocity.y <= 0.1f && gameObject.GetComponent<Rigidbody>().velocity.y >= -0.1f){
jumpFrameCounter++;
}
if(jumpFrameCounter >= 10){
canJump = true;
jumpFrameCounter = 0;
}
if (input.y != 0)
{
if (canJump)
{
gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, 5, 0);
audioHandler.playJump();
canJump = false;
}
}
Vector3 movement = new Vector3(input.x, 0, input.z);
gameObject.transform.Translate(movement * speed * Time.deltaTime);
gameObject.GetComponent<Animator>().SetFloat("velocity", (movement * speed).z);
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1);
}
public void rotate(Vector2 input, Vector2 speed){
transform.Rotate(Vector3.up, input.x * speed.y);// * Time.deltaTime);
}
public void getRotation()
{
GameObject needle = GameObject.Find("imgNeedle");
float rotation = -gameObject.transform.rotation.eulerAngles.y;
if (rotation < 0)
{
rotation += 360;
}
if (rotation >= 360)
{
rotation -= 360;
}
needle.transform.eulerAngles = new Vector3(0, 0, rotation);
}
public void gameFinished()
{
if (worldGenerator.gameWon() && player.getStat("Level").getAmount() >= difficulty * 10 + 10)
{
finishedGame = true;
uihandler.showMessage("SUCCESS;" + TextHandler.getText("gameWon"));
switch (difficulty)
{
case 0:
SteamWorksHandler.getStandardAchievement("EasyAchievement");
break;
case 1:
SteamWorksHandler.getStandardAchievement("NormalAchievement");
break;
case 2:
SteamWorksHandler.getStandardAchievement("HardAchievement");
break;
}
}
}
void OnTriggerEnter(Collider col)
{
if (col.name.Contains("_"))
{
worldGenerator.changeCurrentTile(col.gameObject);
worldGenerator.createTile(new Vector3(-1, 0, 0));
worldGenerator.createTile(new Vector3(1, 0, 0));
worldGenerator.createTile(new Vector3(0, 0, 1));
worldGenerator.createTile(new Vector3(0, 0, -1));
worldGenerator.createTile(new Vector3(-1, 0, -1));
worldGenerator.createTile(new Vector3(1, 0, -1));
worldGenerator.createTile(new Vector3(-1, 0, 1));
worldGenerator.createTile(new Vector3(1, 0, 1));
}
if (col.name.Contains("House"))
{
if (!col.transform.Find("Door").GetComponent<Door>().hasInteracted)
{
transform.position = new Vector3(transform.position.x + 10, 10, transform.position.z);
}
}
}
public void displayAction(int index, GameObject image, GameObject desc)
{
player.getSkill(index).display(image, desc, player.getStat("Secondary").getAmount());
}
public void enemyKilled()
{
uihandler.showMessage("SUCCESS;" + TextHandler.getText("enemyKilled"));
player.getStat("Killcount").changeAmount(1);
SteamWorksHandler.getSlimeAchievement(player.getStat("Killcount").getAmount());
gameFinished();
}
public void gainExperience(int amount)
{
if (player.gainExperience(amount))
{
uihandler.showMessage("SUCCESS;" + TextHandler.getText("levelUp"));
audioHandler.playLevelUp();
}
}
public void updateName(Text nameUI)
{
nameUI.text = player.getPlayerName() + " (" + TextHandler.getText(player.getRace().racename) + "/" + TextHandler.getText(player.getClass().classname) + ", Lvl. " + player.getStat("Level").getAmount() + ")";
}
public void updateNameHUD(Text nameUI)
{
nameUI.text = player.getPlayerName() + "(Lvl. " + player.getStat("Level").getAmount() + ")";
}
public void upgradeStrength()
{
if (!player.upgradeStat("Strength", 1))
{
uihandler.showMessage("ERROR;" + TextHandler.getText("noPoints"));
}
}
public void upgradeDexterity()
{
if (!player.upgradeStat("Dexterity", 1))
{
uihandler.showMessage("ERROR;" + TextHandler.getText("noPoints"));
}
}
public void upgradeIntelligence()
{
if (!player.upgradeStat("Intelligence", 1))
{
uihandler.showMessage("ERROR;" + TextHandler.getText("noPoints"));
}
}
public void upgradeHealth()
{
if (!player.upgradeStat("MaxHealth", 5))
{
uihandler.showMessage("ERROR;" + TextHandler.getText("noPoints"));
}
}
public void upgradeSecondary()
{
if (!player.upgradeStat("MaxSecondary", 5))
{
uihandler.showMessage("ERROR;" + TextHandler.getText("noPoints"));
}
}
public PlayerStat getPlayerStat(string identifier)
{
return player.getStat(identifier);
}
public void loadPlayer(JToken json)
{
player = new PlayerObject();
player.loadPlayer(json);
player.getClass().loadHandObjects();
GetComponent<Animator>().SetBool("isArmed", true);
}
public PlayerObject getPlayer()
{
return player;
}
public string saveGame()
{
return player.saveGame();
}
public BasicClass getClass()
{
return player.getClass();
}
public BasicRace getRace()
{
return player.getRace();
}
public int calculateDamage()
{
return player.calculateDamage(inventory.getEquipmentBonus()["STR"], inventory.getEquipmentBonus()["DEX"]);
}
public bool takeDamage(int amount)
{
if (player != null)
{
if (player.takeDamage(amount, inventory.getEquipmentBonus()["DEX"], inventory.getEquipmentBonus()["INT"]))
{
audioHandler.playDamage();
return true;
}
}
return false;
}
public int castSkill(int skillnumber)
{
int damage = player.castSkill(skillnumber, inventory.getEquipmentBonus()["INT"], inventory.getEquipmentBonus()["STR"], inventory.getEquipmentBonus()["DEX"]);
if (damage > 0)
{
player.getSkill(skillnumber).playSound(audioHandler);
}
return damage;
}
public void reduceCooldown(int skillnumber)
{
player.reduceCooldown(skillnumber);
}
public void regainSecondary()
{
player.regainSecondary(inventory.getEquipmentBonus()["MPR"], inventory.getEquipmentBonus()["MP"]);
}
}
}

View File

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

View File

@@ -1,401 +0,0 @@
using System;
using System.Collections.Generic;
using Assets.Scripts.Classes;
using Assets.Scripts.Races;
using Newtonsoft.Json.Linq;
namespace Assets.Scripts.Player
{
public class PlayerObject
{
Random rand = new Random();
Dictionary<string, PlayerStat> stats;
string playername;
BasicRace race;
BasicClass role;
BasicSkill[] skills = new BasicSkill[3];
bool isDodging = false;
int difficulty;
public PlayerObject(string playername, BasicRace race, BasicClass role, int difficulty)
{
this.playername = playername;
this.race = race;
this.role = role;
this.difficulty = difficulty;
generateStats(false);
generateSkills();
EasterEggHandler.applyEasterEgg(playername);
}
public PlayerObject()
{
generateStats(true);
}
private void generateStats(bool isLoad)
{
stats = new Dictionary<string, PlayerStat>();
stats.Add("Health", new PlayerStat("Health", 100, "The current health of the player"));
stats.Add("MaxHealth", new PlayerStat("MaxHealth", 100, "The current max health of the player"));
stats.Add("Secondary", new PlayerStat("Secondary", 20, "The current secondary of the player"));
stats.Add("MaxSecondary", new PlayerStat("MaxSecondary", 20, "The current max secondary of the player"));
stats.Add("Strength", new PlayerStat("Strength", 5, "The current strength of the player"));
stats.Add("Dexterity", new PlayerStat("Dexterity", 5, "The current dexterity of the player"));
stats.Add("Intelligence", new PlayerStat("Intelligence", 5, "The current intelligence of the player"));
stats.Add("Experience", new PlayerStat("Experience", 0, "The current experience of the player"));
stats.Add("MaxExperience", new PlayerStat("MaxExperience", 10, "The current max experience of the player"));
stats.Add("SecondaryRegen", new PlayerStat("SecondaryRegen", 5, "The current secondary regen of the player"));
stats.Add("Level", new PlayerStat("Level", 0, "The current level of the player"));
stats.Add("Luck", new PlayerStat("Luck", 20 - (difficulty * 5), "The current luck of the player"));
stats.Add("Killcount", new PlayerStat("Killcount", -1, "The current killcount of the player"));
stats.Add("Points", new PlayerStat("Points", 0, "The current skillpoints of the player"));
stats.Add("TreeCount", new PlayerStat("TreeCount",0,"The amount of trees the player chopped"));
stats.Add("OreCount", new PlayerStat("OreCount",0,"The amount of ores the player mined"));
if (!isLoad)
{
race.applyBonus(this);
role.applyBonus(this);
}
}
private void generateSkills()
{
switch (role.classname)
{
case "Warrior":
skills[0] = new BasicSkill(20, 10, 2, "Slash", "Skills/Warrior/Slash", null);
skills[0].setDescription(TextHandler.getText("slashDesc"));
skills[1] = new BasicSkill(0, 5, 1, "Block", "Skills/Warrior/Block", null);
skills[1].setDescription(TextHandler.getText("blockDesc"));
skills[2] = new BasicSkill(35, 30, 4, "Execution", "Skills/Warrior/Execution", null);
skills[2].setDescription(TextHandler.getText("executionDesc"));
break;
case "Thief":
skills[0] = new BasicSkill(20, 10, 2, "Stab", "Skills/Thief/Stab", null);
skills[0].setDescription(TextHandler.getText("stabDesc"));
skills[1] = new BasicSkill(0, 5, 1, "SmokeScreen", "Skills/Thief/SmokeScreen", null);
skills[1].setDescription(TextHandler.getText("smokeScreenDesc"));
skills[2] = new BasicSkill(35, 30, 4, "Heartstop", "Skills/Thief/Heartstop", null);
skills[2].setDescription(TextHandler.getText("heartStopDesc"));
break;
case "Mage":
skills[0] = new BasicSkill(20, 10, 2, "Icicle", "Skills/Mage/Icicle", null);
skills[0].setDescription(TextHandler.getText("icicleDesc"));
skills[1] = new BasicSkill(0, 5, 1, "Teleport", "Skills/Mage/Teleport", null);
skills[1].setDescription(TextHandler.getText("teleportDesc"));
skills[2] = new BasicSkill(35, 30, 4, "Fireball", "Skills/Mage/Fireball", null);
skills[2].setDescription(TextHandler.getText("fireballDesc"));
break;
case "Druid":
skills[0] = new BasicSkill(20, 10, 2, "Stab", "Skills/Thief/Stab", null);
skills[0].setDescription(TextHandler.getText("stabDesc"));
skills[1] = new BasicSkill(0, 5, 1, "SmokeScreen", "Skills/Thief/SmokeScreen", null);
skills[1].setDescription(TextHandler.getText("smokeScreenDesc"));
skills[2] = new BasicSkill(35, 30, 4, "Heartstop", "Skills/Thief/Heartstop", null);
skills[2].setDescription(TextHandler.getText("heartStopDesc"));
break;
}
}
public void loadPlayer(JToken json)
{
playername = json["playername"].ToString();
stats["MaxHealth"].setAmount((int)json["maxHealth"]);
stats["MaxSecondary"].setAmount((int)json["maxSecondary"]);
stats["Secondary"].setAmount((int)json["secondary"]);
stats["Health"].setAmount((int)json["health"]);
stats["Strength"].setAmount((int)json["strength"]);
stats["Dexterity"].setAmount((int)json["dexterity"]);
stats["Intelligence"].setAmount((int)json["intelligence"]);
stats["Level"].setAmount((int)json["level"]);
stats["Experience"].setAmount((int)json["experience"]);
stats["MaxExperience"].setAmount((int)json["maxExperience"]);
stats["Points"].setAmount((int)json["points"]);
stats["Luck"].setAmount((int)json["luck"]);
stats["SecondaryRegen"].setAmount((int)json["secondaryRegen"]);
stats["Killcount"].setAmount((int)json["killcount"]);
stats["TreeCount"].setAmount((int)json["treecount"]);
stats["OreCount"].setAmount((int)json["orecount"]);
loadRole(json["role"].ToString());
loadRace(json["race"].ToString());
isDodging = bool.Parse(json["isDodging"].ToString());
difficulty = (int)json["difficulty"];
generateSkills();
}
private void loadRole(string name)
{
switch (name)
{
case "Warrior":
role = new WarriorClass();
break;
case "Mage":
role = new MageClass();
break;
case "Thief":
role = new ThiefClass();
break;
case "Driud":
role = new DruidClass();
break;
}
}
private void loadRace(string name)
{
switch (name)
{
case "Human":
race = new HumanRace();
break;
case "Dwarf":
race = new DwarvenRace();
break;
case "Elf":
race = new ElvenRace();
break;
case "Giant":
race = new GiantRace();
break;
case "Goblin":
race = new GoblinRace();
break;
case "Nightelf":
race = new NightelfRace();
break;
}
}
public void changeStats(int strength, int health, int dexterity, int intelligence, int secondary)
{
stats["MaxHealth"].changeAmount(health);
stats["Health"].changeAmount(stats["MaxHealth"].getAmount());
stats["MaxSecondary"].changeAmount(secondary);
stats["Secondary"].changeAmount(stats["MaxSecondary"].getAmount());
stats["Strength"].changeAmount(strength);
stats["Dexterity"].changeAmount(dexterity);
stats["Intelligence"].changeAmount(intelligence);
}
public void regainSecondary(int equipRegen, int equipStat)
{
stats["Secondary"].changeAmount(stats["SecondaryRegen"].getAmount() + equipRegen);
if (stats["Secondary"].getAmount() >= stats["MaxSecondary"].getAmount() + equipStat)
{
stats["Secondary"].setAmount(stats["MaxSecondary"].getAmount() + equipStat);
}
}
public void healPlayer(int regeneration, int equipStat)
{
stats["Health"].changeAmount(regeneration);
if (stats["Health"].getAmount() >= stats["MaxHealth"].getAmount() + equipStat)
{
stats["Health"].setAmount(stats["MaxHealth"].getAmount() + equipStat);
}
}
public Dictionary<string, PlayerStat> getStats()
{
return stats;
}
public void setStats(Dictionary<string, PlayerStat> stats)
{
this.stats = stats;
}
public PlayerStat getStat(string identifier)
{
return stats[identifier];
}
public BasicSkill getSkill(int index)
{
return skills[index];
}
public int calculateDamage(int equipStatStr, int equipStatDex)
{
int result;
int bonus = 0;
if (isCrit(equipStatDex))
{
bonus = (stats["Strength"].getAmount() + equipStatStr) * 2;
}
result = stats["Strength"].getAmount() + bonus + 5 + equipStatStr;
switch (difficulty)
{
case 0:
result = result * 2;
break;
case 1:
//Default difficulty
break;
case 2:
result = result / 2;
break;
}
return result;
}
public int castSkill(int index, int equipStatInt, int equipStatStr, int equipStatDex)
{
int damage = 0;
if (skills[index].canPlayerCast(stats["Secondary"].getAmount()))
{
if (index == 1)
{
isDodging = true;
}
stats["Secondary"].changeAmount(-skills[index].getSecondaryConsumption());
if (role.classname == "Wizard")
{
damage = skills[index].calculateDamage(stats["Intelligence"].getAmount() + equipStatInt, isCrit(equipStatDex));
}
else
{
damage = skills[index].calculateDamage(stats["Strength"].getAmount() + equipStatStr, isCrit(equipStatDex));
}
switch (difficulty)
{
case 0:
damage = damage * 2;
break;
case 1:
//Default difficulty
break;
case 2:
damage = damage / 2;
break;
}
}
return damage;
}
public void reduceCooldown(int index)
{
for (int i = 0; i < skills.Length; i++)
{
if (i != index)
{
skills[i].reduceCooldown();
}
}
}
public bool isCrit(int equipStat)
{
return rand.Next(1, 101) <= stats["Dexterity"].getAmount() + equipStat;
}
public bool takeDamage(int amount, int equipStatDex, int equipStatInt)
{
if (amount <= 0 || EasterEggHandler.isGodMode(this))
{
return isDead();
}
if (isDodging)
{
isDodging = false;
}
else
{
int dodgeChance = stats["Dexterity"].getAmount() + equipStatDex + ((stats["Intelligence"].getAmount() + equipStatInt) / 2);
if (rand.Next(1, 101) > dodgeChance)
{
stats["Health"].changeAmount(-amount);
}
}
return isDead();
}
public bool isDead(){
return stats["Health"].getAmount() <= 0;
}
public bool gainExperience(int amount)
{
bool result = false;
stats["Experience"].changeAmount(amount);
if (stats["Experience"].getAmount() >= stats["MaxExperience"].getAmount())
{
stats["Experience"].changeAmount(-stats["MaxExperience"].getAmount());
stats["MaxExperience"].changeAmount(stats["MaxExperience"].getAmount());
stats["Level"].changeAmount(1);
stats["Points"].changeAmount(3);
stats["Luck"].changeAmount(2);
result = true;
}
return result;
}
public bool upgradeStat(string identifier, int amount)
{
bool result = false;
if (stats["Points"].getAmount() > 0)
{
result = true;
stats[identifier].changeAmount(amount);
stats["Points"].changeAmount(-1);
}
return result;
}
public string getPlayerName()
{
return playername;
}
public int getDifficulty()
{
return difficulty;
}
public BasicRace getRace()
{
return race;
}
public BasicClass getClass()
{
return role;
}
public string saveGame()
{
string result = "";
result = result + FileHandler.generateJSON("playername", "\"" + playername + "\"") + ",\r\n";
result = result + FileHandler.generateJSON("maxHealth", stats["MaxHealth"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("maxSecondary", stats["MaxSecondary"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("secondary", stats["Secondary"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("health", stats["Health"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("strength", stats["Strength"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("dexterity", stats["Dexterity"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("intelligence", stats["Intelligence"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("level", stats["Level"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("experience", stats["Experience"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("maxExperience", stats["MaxExperience"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("race", "\"" + race.racename + "\"") + ",\r\n";
result = result + FileHandler.generateJSON("role", "\"" + role.classname + "\"") + ",\r\n";
result = result + FileHandler.generateJSON("points", stats["Points"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("secondaryRegen", stats["SecondaryRegen"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("isDodging", "\"" + isDodging + "\"") + ",\r\n";
result = result + FileHandler.generateJSON("killcount", stats["Killcount"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("treecount", stats["TreeCount"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("orecount", stats["OreCount"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("luck", stats["Luck"].getAmount()) + ",\r\n";
result = result + FileHandler.generateJSON("difficulty", difficulty);
return result;
}
}
}

View File

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

View File

@@ -1,48 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using Assets.Scripts.Classes;
using Assets.Scripts.Races;
using Newtonsoft.Json.Linq;
using UnityEngine.InputSystem;
namespace Assets.Scripts.Player
{
public class PlayerStat
{
string text;
int amount;
string tooltip;
public PlayerStat(string text, int amount, string tooltip){
this.text = text;
this.amount = amount;
this.tooltip = tooltip;
}
public string getTooltip(){
return this.tooltip;
}
public string getText(){
return this.text;
}
public int getAmount(){
return this.amount;
}
public void changeAmount(int change){
this.amount = this.amount + change;
}
public void setAmount(int amount){
this.amount = amount;
}
}
}

View File

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

View File

@@ -1,237 +0,0 @@
using Assets.Scripts.Player;
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts
{
public class QuestLog : MonoBehaviour
{
public Dictionary<string, List<Quest>> quests;
public GameObject content;
public Scrollbar scrollBar;
System.Random rand = new System.Random();
public GameObject quest;
public Texture finished;
public GameObject uiHandler;
// Start is called before the first frame update
void Start()
{
if (quests == null && PlayerPrefs.GetInt("isLoad") != 1)
{
quests = new Dictionary<string, List<Quest>>();
quests.Add("find", new List<Quest>());
FindQuest main = new FindQuest(createQuestDisplay());
main.generateCityQuest();
quests["find"].Add(main);
}
}
// Update is called once per frame
void Update()
{
}
public void updateQuests(string key, object obj, int amount)
{
if (quests.ContainsKey(key))
{
foreach (Quest quest in quests[key])
{
quest.update(obj, amount);
}
}
}
public void addQuest()
{
int index = rand.Next(4);
string type = "";
Quest questItem;
switch (index)
{
case 0:
type = "collect";
questItem = new CollectQuest(createQuestDisplay());
break;
case 1:
type = "kill";
questItem = new KillQuest(createQuestDisplay());
break;
case 2:
type = "find";
questItem = new FindQuest(createQuestDisplay());
break;
/*case 3:
type = "craft";
break;*/
case 3:
type = "explore";
questItem = new ExploreQuest(createQuestDisplay());
break;
default:
questItem = new Quest(createQuestDisplay());
break;
}
if (!quests.ContainsKey(type))
{
quests.Add(type, new List<Quest>());
}
quests[type].Add(questItem);
}
private GameObject createQuestDisplay()
{
GameObject newQuest = Instantiate(quest);
newQuest.transform.SetParent(content.transform, false);
return newQuest;
}
public void showQuests()
{
content.GetComponent<RectTransform>().sizeDelta = new Vector2(0, 10);
float y = -37.5f;
foreach (string key in quests.Keys)
{
foreach (Quest quest in quests[key])
{
quest.show(y);
y = y - 75;
content.GetComponent<RectTransform>().sizeDelta = new Vector2(0, content.GetComponent<RectTransform>().sizeDelta.y + 75);
}
}
scrollBar.value = 0;
content.transform.localPosition = new Vector3(0,0,0);
}
public void removeQuests()
{
Inventory inventory = GameObject.Find("Inventory").GetComponent<Inventory>();
int luck = GameObject.Find("Player").GetComponent<PlayerGameObject>().getPlayerStat("Luck").getAmount();
luck = luck + inventory.getEquipmentBonus()["LCK"];
Dictionary<string, List<Quest>> toDelete = new Dictionary<string, List<Quest>>();
foreach (string key in quests.Keys)
{
foreach (Quest quest in quests[key])
{
if (quest.isFinishedQuest())
{
if (!toDelete.ContainsKey(key))
{
toDelete.Add(key, new List<Quest>());
}
toDelete[key].Add(quest);
}
}
}
int rand = new System.Random().Next(100) + 1;
foreach (string key in toDelete.Keys)
{
foreach (Quest quest in toDelete[key])
{
rand = new System.Random().Next(4);
if (quest is CollectQuest)
{
((CollectQuest)quest).removeItems(inventory);
}
quest.delete();
quests[key].Remove(quest);
if(rand == 1){
inventory.addItem(new Equipment(luck));
}
else{
inventory.addItem(new Item(luck, false));
}
}
}
}
public string saveGame()
{
string result = "";
int counter = 0;
int count = 0;
foreach (string key in quests.Keys)
{
counter = 0;
result = result + "\""+key+"\": {\r\n";
foreach (Quest quest in quests[key])
{
result = result + "\"quest" + counter + "\": {\r\n";
result = result + quest.saveQuest();
result = result + "\r\n}";
if (counter < quests[key].Count - 1)
{
result = result + ",\r\n";
}
counter++;
}
result = result + "\r\n}";
if (count < quests.Keys.Count - 1)
{
result = result + ",\r\n";
}
count++;
}
return result;
}
private void clearQuestlog(){
int children = content.transform.childCount;
for(int i = 0; i < children; i++){
Destroy(content.transform.GetChild(i).gameObject);
}
}
public void loadQuests(JToken json)
{
var jsonData = JObject.Parse(json.ToString()).Children();
List<JToken> keywords = jsonData.Children().ToList();
List<JToken> quests;
string key = "";
Quest questItem;
this.quests = new Dictionary<string, List<Quest>>();
this.quests.Clear();
clearQuestlog();
foreach (JToken keyword in keywords)
{
jsonData = JObject.Parse(keyword.ToString()).Children();
quests = jsonData.Children().ToList();
foreach (JToken quest in quests)
{
key = quest["questname"].ToString().Split(' ')[0].ToLower();
if (!this.quests.ContainsKey(key))
{
this.quests.Add(key, new List<Quest>());
}
switch (key)
{
case "collect":
questItem = new CollectQuest(quest, createQuestDisplay());
break;
case "kill":
questItem = new KillQuest(quest, createQuestDisplay());
break;
case "find":
questItem = new FindQuest(quest, createQuestDisplay());
break;
case "explore":
questItem = new ExploreQuest(quest, createQuestDisplay());
break;
default:
questItem = new Quest(quest, createQuestDisplay());
break;
}
this.quests[key].Add(questItem);
}
}
}
}
}

View File

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

View File

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

View File

@@ -1,164 +0,0 @@
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts
{
public class CollectQuest : Quest
{
public CollectQuest(GameObject display) : base(display)
{
current = 0;
goal = getRandomNumber(10) + 1;
questname = "Collect " + goal + " ";
int index = getRandomNumber(11);
switch (index)
{
case 0:
questname = questname + "slimeball";
keyword = "Slimeball";
break;
case 1:
questname = questname + "rock";
keyword = "Rock";
break;
case 2:
questname = questname + "wood";
keyword = "Wood";
break;
case 3:
questname = questname + "common item";
keyword = "Common";
break;
case 4:
questname = questname + "rare item";
keyword = "Rare";
break;
case 5:
questname = questname + "epic item";
keyword = "Epic";
break;
case 6:
questname = questname + "legendary item";
keyword = "Legendary";
break;
case 7:
questname = questname + "Iron ore";
keyword = "Iron";
break;
case 8:
questname = questname + "Gold ore";
keyword = "Gold";
break;
case 9:
questname = questname + "Copper ore";
keyword = "Copper";
break;
case 10:
questname = questname + "Tin ore";
keyword = "Tin";
break;
}
}
public CollectQuest(JToken token, GameObject display) : base(token, display) { }
override
public void update(object obj, int amount)
{
Item item = (Item)obj;
if (checkItem(item))
{
current = current + amount;
}
if (current >= goal)
{
isFinished = true;
}
else
{
isFinished = false;
}
}
public void removeItems(Inventory inventory)
{
Item item;
int counter = 0;
for (int i = 0; i < 3; i++)
{
foreach (GameObject slot in inventory.slots)
{
item = slot.GetComponent<InventorySlot>().getItem(i);
if (item != null)
{
if (checkItem(item))
{
slot.GetComponent<InventorySlot>().removeItem(i);
counter++;
}
}
if (counter == goal)
{
break;
}
}
if (counter == goal)
{
break;
}
}
}
private bool checkItem(Item item)
{
bool result = false;
if (keyword == "Slimeball" && item.getName().ToLower().Contains("slimeball"))
{
return true;
}
if (keyword == "Rock" && item.getName().ToLower().Contains("rock"))
{
return true;
}
if (keyword == "Iron" && item.getName().ToLower().Contains("iron"))
{
return true;
}
if (keyword == "Gold" && item.getName().ToLower().Contains("gold"))
{
return true;
}
if (keyword == "Copper" && item.getName().ToLower().Contains("copper"))
{
return true;
}
if (keyword == "Tin" && item.getName().ToLower().Contains("tin"))
{
return true;
}
if (keyword == "Wood" && item.getName().ToLower().Contains("wood"))
{
return true;
}
if (keyword == "Common" && item.getName().ToLower().Contains("common"))
{
return true;
}
if (keyword == "Rare" && item.getName().ToLower().Contains("rare"))
{
return true;
}
if (keyword == "Epic" && item.getName().ToLower().Contains("epic"))
{
return true;
}
if (keyword == "Legendary" && item.getName().ToLower().Contains("legendary"))
{
return true;
}
return result;
}
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More