added animation, pickaxe, fixed lookaround

This commit is contained in:
TAASONI3
2023-12-27 10:54:16 +01:00
parent 4626722b94
commit 0865eee42f
20 changed files with 1450 additions and 550 deletions

View File

@@ -8,19 +8,12 @@ namespace Assets.Scripts.Player
public class PlayerCamera : MonoBehaviour
{
UIHandler uihandler;
GameObject player;
Vector2 rotation = Vector2.zero;
public float mouseSpeed = 100; //the sensibility
public float controllerSpeed = 0.01f; //the sensibility
float xMaxLimit = 50.0f;
float xMinLimit = -50.0f;
GameObject interact;
// Start is called before the first frame update
void Start()
{
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
player = gameObject.transform.parent.gameObject;
interact = GameObject.Find("pnlInteract");
interact.transform.localScale = new Vector3(0, 0, 0);
}
@@ -29,7 +22,6 @@ namespace Assets.Scripts.Player
void Update()
{
transform.position = new Vector3(transform.parent.transform.position.x, transform.position.y, transform.parent.transform.position.z);
}
private void FixedUpdate()
@@ -37,22 +29,6 @@ namespace Assets.Scripts.Player
showInformation();
}
public void lookAround(Vector2 view, bool isController)
{
rotation.y += view.x;
rotation.x += -view.y;
//rotation.x = Mathf.Clamp(rotation.x, xMinLimit, xMaxLimit);
if (isController)
{
transform.eulerAngles = rotation * (controllerSpeed * Time.deltaTime);
}
else
{
transform.eulerAngles = rotation * mouseSpeed;
//TODO: Look at camera movement -> Not rly smooth. Weird drag
}
}
public GameObject interactWithObject()
{
RaycastHit hit;

View File

@@ -25,6 +25,11 @@ namespace Assets.Scripts.Player
DateTime jumpTimer;
DateTime now;
int bobbingDirection = -1;
public float mouseSpeed = 100; //the sensibility
public float controllerSpeed = 0.01f; //the sensibility
float xMaxLimit = 45.0f;
float xMinLimit = -45.0f;
Vector2 rotation = Vector2.zero;
private void OnEnable()
{
@@ -157,8 +162,6 @@ namespace Assets.Scripts.Player
}
Vector3 movement = new Vector3(input.x, 0, input.z);
movement = camera.transform.TransformDirection(movement);
movement.y = 0;
gameObject.transform.Translate(movement * speed * Time.deltaTime);
if (input.z != 0)
@@ -180,7 +183,7 @@ namespace Assets.Scripts.Player
public void getRotation()
{
GameObject needle = GameObject.Find("imgNeedle");
float rotation = GameObject.Find("Main Camera").transform.rotation.eulerAngles.y;
float rotation = gameObject.transform.rotation.eulerAngles.y;
if (rotation < 0)
{
rotation += 360;
@@ -218,19 +221,21 @@ namespace Assets.Scripts.Player
{
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, 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));
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){
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);
}
}
@@ -349,7 +354,8 @@ namespace Assets.Scripts.Player
{
if (player != null)
{
if(player.takeDamage(amount, inventory.getEquipmentBonus()["DEX"], inventory.getEquipmentBonus()["INT"])){
if (player.takeDamage(amount, inventory.getEquipmentBonus()["DEX"], inventory.getEquipmentBonus()["INT"]))
{
audioHandler.playDamage();
return true;
}
@@ -360,7 +366,8 @@ namespace Assets.Scripts.Player
public int castSkill(int skillnumber)
{
int damage = player.castSkill(skillnumber, inventory.getEquipmentBonus()["INT"], inventory.getEquipmentBonus()["STR"], inventory.getEquipmentBonus()["DEX"]);
if(damage > 0){
if (damage > 0)
{
player.getSkill(skillnumber).playSound(audioHandler);
}
return damage;
@@ -375,5 +382,21 @@ namespace Assets.Scripts.Player
{
player.regainSecondary(inventory.getEquipmentBonus()["MPR"], inventory.getEquipmentBonus()["MP"]);
}
public void lookAround(Vector2 view, bool isController)
{
rotation.y += view.x;
rotation.x += -view.y;
rotation.x = Mathf.Clamp(rotation.x, xMinLimit, xMaxLimit);
if (isController)
{
transform.eulerAngles = rotation * (controllerSpeed * Time.deltaTime);
}
else
{
transform.eulerAngles = rotation * mouseSpeed;
//TODO: Look at camera movement -> Not rly smooth. Weird drag
}
}
}
}