Merge branch 'main' of ssh://gitfrieds.nackenbox.xyz:3011/MeigoFried/GameVsJam
This commit is contained in:
@ -1,7 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using Interaction;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
using Utility;
|
||||
|
||||
public class Character : MonoBehaviour
|
||||
{
|
||||
@ -33,7 +38,20 @@ public class Character : MonoBehaviour
|
||||
|
||||
[Header("Hold item")]
|
||||
[SerializeField] private Transform _hand;
|
||||
[SerializeField] private GameObject _carriedItem;
|
||||
[FormerlySerializedAs("_carriedItem")] [SerializeField] private GameObject _carriedItemModel;
|
||||
[SerializeField] private PickupInteractible _carriedInteractible;
|
||||
[FormerlySerializedAs("_throwAsideForce")] [SerializeField, Tooltip("Die Kraft mit der der Gegenstand fallen gelassen wird.")]
|
||||
private float _dropItemForce = 3.0f;
|
||||
|
||||
[SerializeField]
|
||||
private GottfriedData _data;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _audioSource;
|
||||
|
||||
public bool CarriesItem => _carriedInteractible;
|
||||
|
||||
public PickupInteractible CarriedItem => _carriedInteractible;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@ -62,25 +80,24 @@ public class Character : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
public void PickupItem(Pickupable itemToPickup)
|
||||
public void PickupItem(PickupInteractible itemToPickup)
|
||||
{
|
||||
if (_carriedItem)
|
||||
if (_carriedInteractible)
|
||||
{
|
||||
Pickupable pickupable = _carriedItem.GetComponentInChildren<Pickupable>(true);
|
||||
|
||||
pickupable.gameObject.SetActive(true);
|
||||
pickupable.transform.parent = null;
|
||||
_carriedInteractible.gameObject.SetActive(true);
|
||||
_carriedInteractible.transform.parent = null;
|
||||
|
||||
pickupable.transform.position = _carriedItem.transform.position;
|
||||
pickupable.transform.rotation = _carriedItem.transform.rotation;
|
||||
_carriedInteractible.transform.position = _carriedItemModel.transform.position;
|
||||
_carriedInteractible.transform.rotation = _carriedItemModel.transform.rotation;
|
||||
|
||||
Rigidbody rigidbody = pickupable.GetComponent<Rigidbody>();
|
||||
Rigidbody rigidbody = _carriedInteractible.GetComponent<Rigidbody>();
|
||||
|
||||
rigidbody.AddForce(Random.insideUnitSphere * 2.0f, ForceMode.Impulse);
|
||||
rigidbody.AddForce(Random.insideUnitSphere * _dropItemForce, ForceMode.Impulse);
|
||||
|
||||
Destroy(_carriedItem);
|
||||
Destroy(_carriedItemModel);
|
||||
|
||||
_carriedItem = null;
|
||||
_carriedItemModel = null;
|
||||
_carriedInteractible = null;
|
||||
}
|
||||
|
||||
if (itemToPickup)
|
||||
@ -90,7 +107,8 @@ public class Character : MonoBehaviour
|
||||
itemToPickup.transform.parent = model.transform;
|
||||
itemToPickup.gameObject.SetActive(false);
|
||||
|
||||
_carriedItem = model;
|
||||
_carriedItemModel = model;
|
||||
_carriedInteractible = itemToPickup;
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,6 +136,10 @@ public class Character : MonoBehaviour
|
||||
Invoke(nameof(ResetJump), jumpCooldown);
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.G))
|
||||
{
|
||||
PickupItem(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void MovePlayer()
|
||||
@ -149,4 +171,16 @@ public class Character : MonoBehaviour
|
||||
{
|
||||
readyToJump = true;
|
||||
}
|
||||
|
||||
public void GiveItemTo(Developer developer)
|
||||
{
|
||||
Debug.Log($"Gebe {_carriedInteractible.Name} an {developer.Name}");
|
||||
|
||||
PickupItem(null);
|
||||
}
|
||||
|
||||
public void SayItsImpossible()
|
||||
{
|
||||
_audioSource.PlayOneShot(_data.VoiceSayItsImpossible.GetRandomElement());
|
||||
}
|
||||
}
|
||||
|
||||
3
3d Prototyp/Assets/Scripts/Data.meta
Normal file
3
3d Prototyp/Assets/Scripts/Data.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c773f750690456bbc885176d7935367
|
||||
timeCreated: 1712430313
|
||||
11
3d Prototyp/Assets/Scripts/Data/GottfriedData.cs
Normal file
11
3d Prototyp/Assets/Scripts/Data/GottfriedData.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
[CreateAssetMenu(fileName = "GottfriedData", menuName = "DataObjects/GottfriedData", order = 0)]
|
||||
public class GottfriedData : ScriptableObject
|
||||
{
|
||||
[FormerlySerializedAs("Say_Impossible")] public AudioClip[] VoiceSayItsImpossible;
|
||||
}
|
||||
}
|
||||
3
3d Prototyp/Assets/Scripts/Data/GottfriedData.cs.meta
Normal file
3
3d Prototyp/Assets/Scripts/Data/GottfriedData.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62867debe01c41d89e01687ef2722fcd
|
||||
timeCreated: 1712430327
|
||||
@ -41,11 +41,17 @@ public struct DeveloperStats
|
||||
|
||||
public class Developer : MonoBehaviour
|
||||
{
|
||||
[Header("Basis Informationen")]
|
||||
[SerializeField]
|
||||
private string _name;
|
||||
|
||||
[SerializeField]
|
||||
private DeveloperStats _baseStats = DeveloperStats.Default;
|
||||
|
||||
[SerializeField]
|
||||
private float _talkRange = 2.0f;
|
||||
|
||||
[Header("Aktuelle Informationen")]
|
||||
[SerializeField, ShowOnly]
|
||||
private double _currentEfficiency = 1.0;
|
||||
|
||||
@ -76,9 +82,6 @@ public class Developer : MonoBehaviour
|
||||
[SerializeField]
|
||||
private DeveloperNeeds _developerNeeds;
|
||||
|
||||
[SerializeField]
|
||||
private float _talkRange = 2.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die Grunddaten des Entwicklers zurück.
|
||||
/// </summary>
|
||||
|
||||
@ -14,7 +14,7 @@ public partial class GameManager : MonoBehaviourSingleton<GameManager>
|
||||
public GameObject NeedFullfilledParticleEffect;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject _player;
|
||||
private Character _player;
|
||||
|
||||
[SerializeField]
|
||||
private double _totalGameDurationSeconds;
|
||||
@ -52,6 +52,8 @@ public partial class GameManager : MonoBehaviourSingleton<GameManager>
|
||||
|
||||
public double NeedNotificationThreshold => _needNotificationThreshold;
|
||||
|
||||
public Character Player => _player;
|
||||
|
||||
/// <summary>
|
||||
/// Die Transform des Spielers.
|
||||
/// </summary>
|
||||
|
||||
3
3d Prototyp/Assets/Scripts/Interaction.meta
Normal file
3
3d Prototyp/Assets/Scripts/Interaction.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 088e8b34c7ef472e9cea312c5f180215
|
||||
timeCreated: 1712426151
|
||||
12
3d Prototyp/Assets/Scripts/Interaction/Copier.cs
Normal file
12
3d Prototyp/Assets/Scripts/Interaction/Copier.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Interaction
|
||||
{
|
||||
public class Copier : MonoBehaviour
|
||||
{
|
||||
public void Copy()
|
||||
{
|
||||
Debug.Log("Kopierer erfolgreich benutzt!");
|
||||
}
|
||||
}
|
||||
}
|
||||
3
3d Prototyp/Assets/Scripts/Interaction/Copier.cs.meta
Normal file
3
3d Prototyp/Assets/Scripts/Interaction/Copier.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc147cbb4aa44e209ac96e08e57cab11
|
||||
timeCreated: 1712427562
|
||||
@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Interaction
|
||||
{
|
||||
public class GiveItemInteractible : Interactible
|
||||
{
|
||||
[SerializeField] private Developer _developer;
|
||||
|
||||
/// <summary>
|
||||
/// Der Entwickler an den das Item übergeben wird.
|
||||
/// </summary>
|
||||
public Developer Developer => _developer;
|
||||
|
||||
public override bool IsBlocked() => !GameManager.Instance.Player.CarriesItem;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c62dfbaefa34afca6b4a8378b9c9083
|
||||
timeCreated: 1712427286
|
||||
50
3d Prototyp/Assets/Scripts/Interaction/Interactible.cs
Normal file
50
3d Prototyp/Assets/Scripts/Interaction/Interactible.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Utility;
|
||||
|
||||
namespace Interaction
|
||||
{
|
||||
public enum InteractibleType
|
||||
{
|
||||
Pickup,
|
||||
Use,
|
||||
Give
|
||||
}
|
||||
|
||||
public abstract class Interactible : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Outline _outline;
|
||||
|
||||
[SerializeField]
|
||||
private Color _selectedColor = Color.white;
|
||||
[SerializeField]
|
||||
private Color _highlightColor = Color.yellow;
|
||||
|
||||
public void Highlight(bool hightlight)
|
||||
{
|
||||
_outline.enabled = hightlight;
|
||||
_outline.OutlineColor = _highlightColor;
|
||||
_outline.OutlineWidth = 2;
|
||||
}
|
||||
|
||||
public void SetSelected(bool isSelected)
|
||||
{
|
||||
Highlight(true);
|
||||
if (isSelected)
|
||||
{
|
||||
_outline.OutlineColor = _selectedColor;
|
||||
_outline.OutlineWidth = 4;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsBlocked()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
3d Prototyp/Assets/Scripts/Interaction/Interactible.cs.meta
Normal file
11
3d Prototyp/Assets/Scripts/Interaction/Interactible.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36d05f0291670f94c9430f1f5e2604a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
3d Prototyp/Assets/Scripts/Interaction/PickupInteractible.cs
Normal file
18
3d Prototyp/Assets/Scripts/Interaction/PickupInteractible.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Interaction
|
||||
{
|
||||
public class PickupInteractible : Interactible
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject _model;
|
||||
|
||||
[SerializeField]
|
||||
private string _name;
|
||||
|
||||
public GameObject Model => _model;
|
||||
|
||||
public string Name => _name;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cae243dedd2499e8326b9ed6de6e32e
|
||||
timeCreated: 1712426173
|
||||
12
3d Prototyp/Assets/Scripts/Interaction/UseInteractible.cs
Normal file
12
3d Prototyp/Assets/Scripts/Interaction/UseInteractible.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Interaction
|
||||
{
|
||||
public class UseInteractible : Interactible
|
||||
{
|
||||
[FormerlySerializedAs("Text")] public string UseText;
|
||||
|
||||
public UnityEvent OnUse;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18452aa2b74a4b10aaed4635c1080c90
|
||||
timeCreated: 1712426953
|
||||
@ -1,15 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Interaction;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UiController : MonoBehaviour
|
||||
{
|
||||
[FormerlySerializedAs("_pickupper")]
|
||||
[Header("Objects")]
|
||||
[SerializeField]
|
||||
private Pickupper _pickupper;
|
||||
private InteractionHandler interactionHandler;
|
||||
|
||||
[Header("UI Elements")]
|
||||
[SerializeField]
|
||||
@ -28,16 +31,36 @@ public class UiController : MonoBehaviour
|
||||
|
||||
private void UpdateActionDisplay()
|
||||
{
|
||||
bool show = _pickupper.PickupablesInRange.Count > 0;
|
||||
bool show = interactionHandler.InteractionsInRange.Count > 0;
|
||||
|
||||
_actionDisplay.SetActive(show);
|
||||
|
||||
if (!show)
|
||||
return;
|
||||
|
||||
_actionText.text = $"{_pickupper.Selected.Name}";
|
||||
switch (interactionHandler.SelectedAction)
|
||||
{
|
||||
case PickupInteractible pickup:
|
||||
_actionText.text = $"Hebe {pickup.Name} auf";
|
||||
break;
|
||||
case UseInteractible usable:
|
||||
_actionText.text = usable.UseText;
|
||||
break;
|
||||
case GiveItemInteractible giveItem:
|
||||
_actionText.text = $"Gebe {GameManager.Instance.Player.CarriedItem?.Name ?? "keinen Gegenstand"} an {giveItem.Developer.Name}";
|
||||
break;
|
||||
default:
|
||||
_actionText.text = $"Unbekannte Aktion";
|
||||
break;
|
||||
// case InteractibleType.Use:
|
||||
// _actionText.text = $"{_pickupper.Selected.Name} benutzen";
|
||||
// break;
|
||||
// case InteractibleType.Give:
|
||||
// _actionText.text = $"An {_pickupper.Selected.Name} geben";
|
||||
// break;
|
||||
}
|
||||
|
||||
_prevActionButton.interactable = _pickupper.CanSelectPrevious;
|
||||
_nextActionButton.interactable = _pickupper.CanSelectNext;
|
||||
//_prevActionButton.interactable = _pickupper.CanSelectPrevious;
|
||||
//_nextActionButton.interactable = _pickupper.CanSelectNext;
|
||||
}
|
||||
}
|
||||
|
||||
13
3d Prototyp/Assets/Scripts/Utility/IReadonlyListExtension.cs
Normal file
13
3d Prototyp/Assets/Scripts/Utility/IReadonlyListExtension.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utility
|
||||
{
|
||||
public static class IReadonlyListExtension
|
||||
{
|
||||
public static T GetRandomElement<T>(this IReadOnlyList<T> list)
|
||||
{
|
||||
return list[Random.Range(0, list.Count)];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a37950394de44b8db5d8de3e9fd574a6
|
||||
timeCreated: 1712430620
|
||||
Reference in New Issue
Block a user