Base Scene

This commit is contained in:
2020-02-03 00:21:00 +00:00
parent 446510acc4
commit 739f87a1e4
142 changed files with 20574 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1dfaa9dc673323b4abca9435d6818674
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,56 @@
using Exsersewo.Nydaliv.Extensions;
using System.Collections;
using UnityEngine;
namespace Exsersewo.UI.Canvas
{
public class CanvasFader : MonoBehaviour
{
public MenuType MenuType;
public bool Visible => GetComponent<CanvasGroup>().alpha > 0.9f;
IEnumerator ChangeVisibility(bool lerp, bool show, float TimeToLerp)
{
float timeLerped = 0;
var group = GetComponent<CanvasGroup>();
group.interactable = group.blocksRaycasts = show;
if (lerp)
{
while (timeLerped < TimeToLerp)
{
var lerped = Mathf.Lerp(0, 1, timeLerped / TimeToLerp);
if (lerped > 0.9)
lerped = 1;
else if (lerped < 0.1)
lerped = 0;
group.alpha = show ? lerped : 1 - lerped;
timeLerped += Time.unscaledDeltaTime;
yield return null;
}
}
else
{
group.alpha = show ? 1 : 0;
}
yield return null;
}
public void HidePanel(bool lerp, float TimeToLerp)
{
StartCoroutine(ChangeVisibility(lerp, false, TimeToLerp));
}
public void ShowPanel(bool lerp, float TimeToLerp)
{
StartCoroutine(ChangeVisibility(lerp, true, TimeToLerp));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c58fff238daa16943b4b0f160a89238d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using System.Linq;
using UnityEngine;
namespace Exsersewo.UI.Canvas
{
[RequireComponent(typeof(CanvasGroup))]
public class CanvasManager : MonoBehaviour
{
public CanvasFader[] Canvases;
public float TimeToLerp;
void ChangeCanvas(MenuType menu, bool lerp)
{
var toZero = Canvases.Where(x => x.MenuType != menu).ToList();
var toOne = Canvases.FirstOrDefault(x => x.MenuType == menu);
toZero.ForEach(x =>
{
var fader = x.GetComponent<CanvasFader>();
if (fader.Visible)
{
fader.HidePanel(lerp, TimeToLerp);
}
});
toOne.GetComponent<CanvasFader>().ShowPanel(lerp, TimeToLerp);
}
public void ChangeToCanvas(CanvasFader menu)
=> ChangeToCanvas(menu.MenuType);
public void ChangeToCanvas(MenuType menu)
=> ChangeCanvas(menu, false);
public void LerpToCanvas(CanvasFader menu)
=> LerpToCanvas(menu.MenuType);
public void LerpToCanvas(MenuType menu)
=> ChangeCanvas(menu, true);
}
[System.Serializable]
public enum MenuType
{
Game = 0,
Stats = 1,
Codex = 2
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cfcae502041575f409e1334fcaa80eb1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CanvasManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b5538a37db28f6e43be610d4a558e14b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
using TMPro;
using UnityEngine;
public class LabelValueHolder : MonoBehaviour
{
public TextMeshProUGUI Label;
public TextMeshProUGUI Value;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d7b346e9805f6045a50f2ae0bfe237b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using Exsersewo.UI.ProgressBar;
using TMPro;
using UnityEngine;
public class PlayerCanvasManager : MonoBehaviour
{
[SerializeField]
TextMeshProUGUI Name;
[SerializeField]
LabelValueHolder Level;
[SerializeField]
ProgressBar HealthBar;
[SerializeField]
ProgressBar ExperienceBar;
public void SetNameText(string text)
=> Name.SetText(text);
public void SetLevelValue(string text)
=> Level.Value.SetText(text);
public void SetHealthValue(ulong value, ulong maxValue)
=> HealthBar.SetValue(value, maxValue);
public void SetExperienceBar(ulong value, ulong maxValue)
=> ExperienceBar.SetValue(value, maxValue);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 63f77217a8360b54f826577066ca7221
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2184427b38146c7449edec6ce6a815f5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
using Exsersewo.Nydaliv.Extensions;
using System.Collections;
using UnityEngine;
namespace Exsersewo.UI.ProgressBar
{
public class ProgressBar : MonoBehaviour
{
[SerializeField]
RectTransform ValueSlider;
public ProgressBarType FillType;
[Tooltip("X=Left Y=Right")]
public Vector2 Padding;
[SerializeField]
ProgressTransitionType Transition;
[SerializeField]
float TransitionTime = .5f;
[SerializeField]
float previousValue;
RectTransform RectTransform;
void Start()
{
RectTransform = GetComponent<RectTransform>();
previousValue = ValueSlider.rect.width;
}
IEnumerator SetWidth(ulong value, ulong maxValue)
{
float hori = RectTransform.rect.width;
var width = ((float)value).Remap(0, maxValue, 0, hori-(Padding.x+Padding.y));
switch (Transition)
{
case ProgressTransitionType.Lerp:
case ProgressTransitionType.SmoothStep:
{
float TimeLerped = 0f;
while (TimeLerped <= TransitionTime)
{
float lerpVal = 0;
switch (Transition)
{
case ProgressTransitionType.SmoothStep:
lerpVal = Mathf.SmoothStep(previousValue, width, TimeLerped / TransitionTime);
break;
case ProgressTransitionType.Lerp:
lerpVal = Mathf.Lerp(previousValue, width, TimeLerped / TransitionTime);
break;
}
SetSliderPosition(lerpVal);
TimeLerped += Time.deltaTime;
yield return null;
}
}
break;
case ProgressTransitionType.Instant:
default:
{
SetSliderPosition(width);
}
break;
}
previousValue = width;
}
void SetSliderPosition(float val)
{
switch (FillType)
{
case ProgressBarType.FillFromCenter:
ValueSlider.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, val);
break;
case ProgressBarType.FillFromLeft:
ValueSlider.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, val);
ValueSlider.SetLeft(Padding.x);
break;
case ProgressBarType.FillFromRight:
ValueSlider.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, val);
ValueSlider.SetRight(Padding.y);
break;
}
}
public void SetValue(ulong value, ulong maxValue)
{
StartCoroutine(SetWidth(value, maxValue));
}
}
public enum ProgressBarType
{
FillFromCenter,
FillFromLeft,
FillFromRight
}
public enum ProgressTransitionType
{
Instant,
Lerp,
SmoothStep
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4fc4cfeb1a520344817bf879a651682
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,6 @@
namespace Exsersewo.UI.ProgressBar
{
public class ProgressBarWithLabel : ProgressBar
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e0785dbea1b3654298637a11a0fff80
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class SplitSectionInHalf : MonoBehaviour
{
[Tooltip("X=Left Y=Right")]
public Vector2 Padding;
public TextMeshProUGUI left;
public TextMeshProUGUI right;
IEnumerator SetWidth()
{
yield return new WaitForFixedUpdate();
float hori = GetComponent<RectTransform>().rect.width;
left.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, hori / 2);
right.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, hori / 2);
left.rectTransform.SetRight(-(hori / 2) + Padding.x);
right.rectTransform.SetLeft(-(hori / 2) + Padding.y);
}
void FixedUpdate()
{
StartCoroutine(SetWidth());
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de0ae8ac97fba1c4e908b209cef516b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: