Added tree particles, added particle rotation

This commit is contained in:
TAASONI3
2023-12-26 21:04:40 +01:00
parent a8c4cdcf3c
commit 9737362dd5
5 changed files with 5623 additions and 940 deletions

View File

@@ -14,7 +14,6 @@ public class Controls : MonoBehaviour
GameObject worldGen;
GameObject playerCam;
UIHandler uihandler;
GameObject currentHouse;
Vector3 input;
Vector2 view;
PlayerInput playerInput;
@@ -37,36 +36,44 @@ public class Controls : MonoBehaviour
// Update is called once per frame
void Update()
{
if(playerInput.currentControlScheme == "Controller"){
if(Cursor.lockState != CursorLockMode.Locked){
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()){
else
{
if (uihandler.canPlayerRotate())
{
Cursor.lockState = CursorLockMode.Locked;
}
else{
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]");
}
if(uihandler.state == UIState.GAME && playerInput.currentActionMap.name != "MainGame"){
if (uihandler.state == UIState.GAME && playerInput.currentActionMap.name != "MainGame")
{
playerInput.SwitchCurrentActionMap("MainGame");
}
if(uihandler.state != UIState.GAME && playerInput.currentActionMap.name != "Menu"){
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 (uihandler.canPlayerRotate())
{
playerCam.GetComponent<PlayerCamera>().lookAround(view, playerInput.currentControlScheme == "Controller");
}
if (uihandler.canPlayerMove())
@@ -77,8 +84,10 @@ public class Controls : MonoBehaviour
}
}
public void FixedUpdate(){
if(direction != MoveDirection.None){
public void FixedUpdate()
{
if (direction != MoveDirection.None)
{
AxisEventData data = new AxisEventData(EventSystem.current);
data.moveDir = direction;
data.selectedObject = EventSystem.current.currentSelectedGameObject;
@@ -86,31 +95,41 @@ public class Controls : MonoBehaviour
}
}
public void OnLooking(InputValue value){
public void OnLooking(InputValue value)
{
view = value.Get<Vector2>();
}
public void OnMovement(InputValue value){
try{
public void OnMovement(InputValue value)
{
try
{
input = value.Get<Vector3>();
}catch{
if(value.Get<Vector2>().x < 0){
}
catch
{
if (value.Get<Vector2>().x < 0)
{
direction = MoveDirection.Left;
}
else if(value.Get<Vector2>().x > 0){
else if (value.Get<Vector2>().x > 0)
{
direction = MoveDirection.Right;
}
else if(value.Get<Vector2>().y < 0){
else if (value.Get<Vector2>().y < 0)
{
direction = MoveDirection.Down;
}
else if(value.Get<Vector2>().y > 0){
else if (value.Get<Vector2>().y > 0)
{
direction = MoveDirection.Up;
}
}
}
public void OnInteraction(){
public void OnInteraction()
{
if (uihandler.canPlayerMove())
{
GameObject target = playerCam.GetComponent<PlayerCamera>().interactWithObject();
@@ -122,8 +141,9 @@ public class Controls : MonoBehaviour
fight.GetComponent<Fight>().startFight(worldGen.GetComponent<WorldGenerator>().getCurrentTile(), target, player);
break;
case "Tree":
playParticle(target);
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Wood"));
Destroy(target);
//Destroy(target);
break;
case "Stone":
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Rock"));
@@ -139,16 +159,20 @@ public class Controls : MonoBehaviour
target.GetComponent<Chest>().interact();
break;
case "Ore":
if(target.name.ToLower().Contains("iron")){
if (target.name.ToLower().Contains("iron"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Iron ore"));
}
else if(target.name.ToLower().Contains("gold")){
else if (target.name.ToLower().Contains("gold"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Gold ore"));
}
else if(target.name.ToLower().Contains("copper")){
else if (target.name.ToLower().Contains("copper"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Copper ore"));
}
else if(target.name.ToLower().Contains("tin")){
else if (target.name.ToLower().Contains("tin"))
{
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Tin ore"));
}
Destroy(target);
@@ -158,50 +182,76 @@ public class Controls : MonoBehaviour
}
}
public void OnInventory(){
public void playParticle(GameObject target)
{
Vector3 playerPos = player.transform.position;
playerPos.y = target.transform.position.y;
Quaternion newRotation = Quaternion.LookRotation(playerPos - target.transform.position, target.transform.TransformDirection(Vector3.up));
ParticleSystem particleSystem = target.GetComponent<ParticleSystem>();
ParticleSystem.ShapeModule shape = particleSystem.shape;
shape.rotation = newRotation.eulerAngles;
particleSystem.Play();
}
public void OnInventory()
{
uihandler.switchInventory();
}
public void OnQuestlog(){
public void OnQuestlog()
{
uihandler.switchQuestLog();
}
public void OnPause(){
public void OnPause()
{
uihandler.switchPauseMenu();
}
public void OnSkillOne(){
if(uihandler.isPlayerInFight()){
public void OnSkillOne()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(1);
}
}
public void OnSkillTwo(){
if(uihandler.isPlayerInFight()){
public void OnSkillTwo()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(2);
}
}
public void OnSkillThree(){
if(uihandler.isPlayerInFight()){
public void OnSkillThree()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(3);
}
}
public void OnSkillFour(){
if(uihandler.isPlayerInFight()){
public void OnSkillFour()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(4);
}
}
public void OnSkillFive(){
if(uihandler.isPlayerInFight()){
public void OnSkillFive()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(5);
}
}
public void OnSkillSix(){
if(uihandler.isPlayerInFight()){
public void OnSkillSix()
{
if (uihandler.isPlayerInFight())
{
fight.GetComponent<Fight>().playerAction(6);
}
}