Skip to content
Snippets Groups Projects
Commit 164f9a54 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Merge branch 'main' into 'master'

Updating master branch.

See merge request !33
parents 1c08bddf 16860b71
No related branches found
No related tags found
2 merge requests!34Dodge,!33Updating master branch.
......@@ -16,10 +16,7 @@ namespace BigSock {
public class PlayerController : Character
{
public HPBar hpBar;
public XpBar xpBar;
public XpBar manaBar;
public XpBar staminaBar;
public UtilBar utilBar;
public float collisionOffset = 0.05f;
......@@ -50,13 +47,15 @@ namespace BigSock {
{
base.Start();
xpBar?.SetMaxXp(maxXp);
xpBar?.SetXp(xp);
utilBar?.WithXP((int)xp, (int)maxXp)
?.WithHealth(Convert.ToInt32(HP), Convert.ToInt32(MaxHP));
animator = GetComponent<Animator>();
spriteRenderer = GetComponent<SpriteRenderer>();
hpBar?.SetMaxHealth(Convert.ToInt32(MaxHP));
hpBar?.SetHealth(Convert.ToInt32(HP));
//!! DEBUG: Add item to player at start to test if it works.
TryPickUpItem(ItemService.SINGLETON.Get(201));
......@@ -139,8 +138,9 @@ namespace BigSock {
*/
public override void UpdateModifiers(ICharacterStats modifiers = null) {
base.UpdateModifiers(modifiers);
manaBar?.SetMaxXp(Stats.MaxMana);
staminaBar?.SetMaxXp(Stats.MaxStamina);
utilBar?.WithMana(maxValue: (int)Stats.MaxMana)
?.WithStamina(maxValue: (int)Stats.MaxStamina);
}
......@@ -149,8 +149,8 @@ namespace BigSock {
*/
protected override void Regenerate() {
base.Regenerate();
manaBar?.SetXp(Mana);
staminaBar?.SetXp(Stamina);
utilBar?.WithMana(value: (int)Mana)
?.WithStamina(value: (int)Stamina);
}
private bool TryMove_OLD(Vector2 direction) {
......@@ -194,13 +194,13 @@ namespace BigSock {
*/
protected override void AfterDamage(IAttackStats attack) {
base.AfterDamage(attack);
hpBar?.SetHealth(Convert.ToInt32(HP));
utilBar?.WithHealth(Convert.ToInt32(HP));
}
public void GainXp(float xp){
GiveXp(xp);
CheckXp();
xpBar?.SetXp(this.xp);
utilBar?.WithXP((int)this.xp);
}
private void CheckXp(){
......@@ -208,7 +208,8 @@ namespace BigSock {
level += 1;
xp -= maxXp;
maxXp = (level + 1) * 100;
xpBar?.SetMaxXp(maxXp);
utilBar?.WithXP(maxValue: (int)maxXp);
}
}
......
fileFormatVersion: 2
guid: 8002570591600194cbfd5196aedccbee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace BigSock.UI{
public class UtilBar : MonoBehaviour
{
public Slider hpSlider;
public Slider manaSlider;
public Slider staminaSlider;
public Slider xpSlider;
public Gradient gradient;
public Image hpFill;
public UtilBar WithHealth(int? value = null, int? maxValue = null){
if(value != null) hpSlider.value = value.Value;
if(maxValue != null) hpSlider.maxValue = maxValue.Value;
hpFill.color = gradient.Evaluate(hpSlider.normalizedValue);
return this;
}
public UtilBar WithMana(int? value = null, int? maxValue = null){
if(value != null) manaSlider.value = value.Value;
if(maxValue != null) manaSlider.maxValue = maxValue.Value;
return this;
}
public UtilBar WithStamina(int? value = null, int? maxValue = null){
if(value != null) staminaSlider.value = value.Value;
if(maxValue != null) staminaSlider.maxValue = maxValue.Value;
return this;
}
public UtilBar WithXP(int? value = null, int? maxValue = null){
if(value != null) xpSlider.value = value.Value;
if(maxValue != null) xpSlider.maxValue = maxValue.Value;
return this;
}
}
}
fileFormatVersion: 2
guid: 2d7f19087286e834f816cbf2da1d1aba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
This diff is collapsed.
MrBigsock/Assets/UI/Sprites/hpBARx16.png

14.8 KiB

fileFormatVersion: 2
guid: c69fcc4ae8b7e814aa45e6fc8303a1d5
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment