mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-30 04:57:09 +01:00
first commit
This commit is contained in:
9
Assets/Scripts/Crop.cs
Normal file
9
Assets/Scripts/Crop.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "Crop", menuName = "Harvestdale/Crops", order = 0)]
|
||||
public class Crop : ScriptableObject
|
||||
{
|
||||
public string cropName;
|
||||
public int daysToGrow;
|
||||
public bool isHarvestable;
|
||||
}
|
||||
11
Assets/Scripts/Crop.cs.meta
Normal file
11
Assets/Scripts/Crop.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e283aa008f05f1e46b99a7987202ec09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Scripts/Field.cs
Normal file
17
Assets/Scripts/Field.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
public class Field : MonoBehaviour
|
||||
{
|
||||
public Crop crop;
|
||||
public int daysSincePlanted;
|
||||
public bool isWatered;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TimeManager.OnMinuteChanged += logTime;
|
||||
TimeManager.OnHourChanged += logTime;
|
||||
}
|
||||
public void logTime()
|
||||
{
|
||||
Debug.Log($"{TimeManager.Hour:00}:{TimeManager.Minute:00}");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Field.cs.meta
Normal file
11
Assets/Scripts/Field.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d700e4905ee3fd2408f52a4e3ecb48e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/Scripts/PlayerMovement.cs
Normal file
34
Assets/Scripts/PlayerMovement.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public float moveSpeed = 5f;
|
||||
private Rigidbody2D rb;
|
||||
private Animator animator;
|
||||
private Vector2 movement;
|
||||
|
||||
void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
movement.x = Input.GetAxisRaw("Horizontal");
|
||||
movement.y = Input.GetAxisRaw("Vertical");
|
||||
|
||||
animator.SetFloat("Horizontal", movement.x);
|
||||
animator.SetFloat("Vertical", movement.y);
|
||||
animator.SetFloat("Speed", movement.sqrMagnitude);
|
||||
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
movement.Normalize();
|
||||
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/PlayerMovement.cs.meta
Normal file
11
Assets/Scripts/PlayerMovement.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3dc19f09577ba440891c03b861220f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Scripts/TimeManager.cs
Normal file
51
Assets/Scripts/TimeManager.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
public class TimeManager : MonoBehaviour
|
||||
{
|
||||
public static Action OnMinuteChanged;
|
||||
public static Action OnHourChanged;
|
||||
public static Action OnDayChanged;
|
||||
|
||||
public static int Minute { get; private set; }
|
||||
public static int Hour { get; private set; }
|
||||
public static int Day { get; private set; }
|
||||
|
||||
private float minuteToRealTime = .5f;
|
||||
private float timer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Minute = 0;
|
||||
Hour = 10;
|
||||
Day = 1;
|
||||
timer = minuteToRealTime;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
|
||||
if (timer <= 0)
|
||||
{
|
||||
Minute++;
|
||||
OnMinuteChanged?.Invoke();
|
||||
if (Minute >= 60)
|
||||
{
|
||||
Hour++;
|
||||
Minute = 0;
|
||||
if (Hour >= 24)
|
||||
{
|
||||
Day++;
|
||||
Hour = 0;
|
||||
OnDayChanged();
|
||||
}
|
||||
|
||||
OnHourChanged();
|
||||
}
|
||||
|
||||
timer = minuteToRealTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TimeManager.cs.meta
Normal file
11
Assets/Scripts/TimeManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efc6be5d380533e4bb0a0179bec47c77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user