evershade/Assets/Data/ScriptableObjects/GamePlayerSo.cs

130 lines
3.4 KiB
C#

using System;
using System.Collections.Generic;
using Types;
using Types.UI;
using UnityEngine;
// Example: PlayerData.cs
namespace Data.ScriptableObjects
{
[CreateAssetMenu(fileName = "Player", menuName = "Game Data/Player")]
public class GamePlayerSo : ScriptableObject
{
private static GamePlayerSo _instance;
// public Display<int, Slot>; boxSlots;
public string playerName;
public int level;
public int health;
public int maxHealth;
public int inventorySize;
public int toolbarSize;
public int experience;
public int gold;
public int attack;
public int defense;
public int speed;
public int luck;
public int magic;
public int sanity;
public int maxSanity;
// Movement
public float moveSpeed;
public bool movingRight;
public bool movingLeft;
public bool movingDown;
public bool movingUp;
public int playerDirection;
public bool attacking;
public float attackCoolDownTime;
public bool justAttacked;
public bool hurting;
public float hurtingCoolDownTime;
public bool justHurt;
public int weaponInUse;
public string currentMap;
public Vector3 currentPosition;
public bool isKnockedBack;
public Vector2 knockbackDirection;
public Vector2 moveInput;
public int playerNumber;
public readonly Dictionary<int, GameSlot> EquipmentSlots = new();
// player inventory slots data
public readonly Dictionary<int, GameSlot> InventorySlots = new();
public readonly Dictionary<int, GameSlot> ToolbarSlots = new();
public Guid ID;
// clone as new Player
// set defaults when creating new player
public GamePlayerSo()
{
Initialize();
}
private void Initialize()
{
ID = Guid.NewGuid();
playerName = "Player";
level = 1;
health = 100;
maxHealth = 100;
inventorySize = 20;
toolbarSize = 10;
experience = 0;
gold = 0;
attack = 10;
defense = 10;
// set the default inventory slots
for (var i = 0; i < inventorySize; i++)
{
var slot = new GameSlot();
slot.Position = i;
slot.SlotType = SlotType.Inventory;
slot.Item = null;
InventorySlots.Add(slot.GetId(), slot);
}
// set the default toolbar slots
for (var i = 0; i < toolbarSize; i++)
{
var slot = new GameSlot();
slot.Position = i;
slot.SlotType = SlotType.Toolbar;
slot.Item = null;
ToolbarSlots.Add(slot.GetId(), slot);
}
// set the default equipment slots
for (var i = 0; i < 5; i++)
{
var slot = new GameSlot();
slot.Position = i;
slot.SlotType = SlotType.Equipment;
slot.Item = null;
EquipmentSlots.Add(slot.GetId(), slot);
}
}
public GamePlayer Clone()
{
return new GamePlayer(this);
}
}
}