Skill Logic
Implemented basic UI for skills to player
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
@@ -9,12 +10,26 @@ public class PlayerMovement : MonoBehaviour
|
||||
|
||||
private CharacterController controller;
|
||||
private Vector3 velocity;
|
||||
private PlayerSkillTree PlayerSkills;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PlayerSkills = PlayerSkillTree.Instance;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
controller = GetComponent<CharacterController>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
HandleDash();
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
HandleMovement();
|
||||
@@ -38,6 +53,19 @@ public class PlayerMovement : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void HandleDash()
|
||||
{
|
||||
if (PlayerSkills.IsSkillUnlocked(PlayerSkillTree.Skills.Dash))
|
||||
{
|
||||
// Implement dash logic
|
||||
Debug.Log("Dashing!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Dash skill is not unlocked.");
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyGravity()
|
||||
{
|
||||
if (IsGrounded() && velocity.y < 0) velocity.y = -2f;
|
||||
@@ -50,4 +78,9 @@ public class PlayerMovement : MonoBehaviour
|
||||
float groundDistance = 0.2f;
|
||||
return Physics.Raycast(transform.position, Vector3.down, groundDistance);
|
||||
}
|
||||
|
||||
public List<PlayerSkillTree.Skills> GetPlayerSkills()
|
||||
{
|
||||
return PlayerSkills.GetPlayerSkills();
|
||||
}
|
||||
}
|
||||
51
3D blobici/Assets/Scripts/Player/PlayerSkillTree.cs
Normal file
51
3D blobici/Assets/Scripts/Player/PlayerSkillTree.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class PlayerSkillTree
|
||||
{
|
||||
|
||||
private static PlayerSkillTree _instance;
|
||||
|
||||
public static PlayerSkillTree Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new PlayerSkillTree();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum Skills
|
||||
{
|
||||
Dash,
|
||||
Rush,
|
||||
Kek,
|
||||
LMAO
|
||||
}
|
||||
|
||||
private List<Skills> playerSkills;
|
||||
|
||||
public PlayerSkillTree()
|
||||
{
|
||||
playerSkills = new List<Skills>();
|
||||
}
|
||||
|
||||
public void UnlockSkill(Skills skill)
|
||||
{
|
||||
playerSkills.Add(skill);
|
||||
}
|
||||
|
||||
public bool IsSkillUnlocked(Skills skill)
|
||||
{
|
||||
return playerSkills.Contains(skill);
|
||||
}
|
||||
|
||||
public List<Skills> GetPlayerSkills() { return playerSkills; }
|
||||
|
||||
|
||||
}
|
||||
2
3D blobici/Assets/Scripts/Player/PlayerSkillTree.cs.meta
Normal file
2
3D blobici/Assets/Scripts/Player/PlayerSkillTree.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ee023dad7da1b5498077a6744499037
|
||||
Reference in New Issue
Block a user