mirror of
https://github.com/ConjureETS/Labo_2_Equ_1_a15.git
synced 2026-03-24 01:50:58 +00:00
health added
This commit is contained in:
parent
d75a31ff14
commit
23424c7b2d
9
Assets/Prefabs.meta
Normal file
9
Assets/Prefabs.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1c776bc4dc6ca074ea07054b33c57706
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1447945458
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Prefabs/Heart.prefab
Normal file
BIN
Assets/Prefabs/Heart.prefab
Normal file
Binary file not shown.
8
Assets/Prefabs/Heart.prefab.meta
Normal file
8
Assets/Prefabs/Heart.prefab.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5c6327fc8da56da4e8a5949457d56e76
|
||||||
|
timeCreated: 1447945520
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
52
Assets/Scripts/Health.cs
Normal file
52
Assets/Scripts/Health.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class Health : MonoBehaviour
|
||||||
|
{
|
||||||
|
public int startingHealth;
|
||||||
|
public Image heartImage;
|
||||||
|
|
||||||
|
public int maxHeartsPerRow;
|
||||||
|
|
||||||
|
private ArrayList hearts = new ArrayList();
|
||||||
|
|
||||||
|
private float spaceX;
|
||||||
|
private float spaceY;
|
||||||
|
|
||||||
|
void Start ()
|
||||||
|
{
|
||||||
|
RectTransform r = heartImage.rectTransform;
|
||||||
|
spaceX = r.rect.width;
|
||||||
|
spaceY = r.rect.height;
|
||||||
|
Debug.Log("spaceX : " + spaceX);
|
||||||
|
Debug.Log("spaceY : " + spaceY);
|
||||||
|
AddHearts (startingHealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddHearts (int n)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
Transform heart = ((Image)Instantiate(heartImage)).transform;
|
||||||
|
heart.SetParent(GameObject.Find("HeartCanvas").transform, false);
|
||||||
|
|
||||||
|
int y = Mathf.FloorToInt(hearts.Count/maxHeartsPerRow);
|
||||||
|
int x = hearts.Count - y * maxHeartsPerRow;
|
||||||
|
|
||||||
|
Debug.Log("X : " + x);
|
||||||
|
Debug.Log("Y : " + y);
|
||||||
|
|
||||||
|
Vector2 pos = heart.position;
|
||||||
|
pos.x += x * spaceX;
|
||||||
|
pos.y += y * spaceY;
|
||||||
|
|
||||||
|
Debug.Log("posX : " + pos.x);
|
||||||
|
Debug.Log("posY : " + pos.y);
|
||||||
|
|
||||||
|
heart.position = pos;
|
||||||
|
|
||||||
|
hearts.Add(heart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Scripts/Health.cs.meta
Normal file
12
Assets/Scripts/Health.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 496d8c4c25eff1443b8789ad17b173c5
|
||||||
|
timeCreated: 1447945584
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Sprites/heart.png
Normal file
BIN
Assets/Sprites/heart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 115 KiB |
56
Assets/Sprites/heart.png.meta
Normal file
56
Assets/Sprites/heart.png.meta
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c9dfa90bc9f92e44086c62a9c1c32d47
|
||||||
|
timeCreated: 1447944457
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
linearTexture: 0
|
||||||
|
correctGamma: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: .25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 0
|
||||||
|
cubemapConvolution: 0
|
||||||
|
cubemapConvolutionSteps: 8
|
||||||
|
cubemapConvolutionExponent: 1.5
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: -1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
rGBM: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: .5, y: .5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
textureType: 8
|
||||||
|
buildTargetSettings: []
|
||||||
|
spriteSheet:
|
||||||
|
sprites: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user