mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 16:43:12 +02:00
added hp display and improved main scene
This commit is contained in:
parent
94a32459ea
commit
de67d01f08
@ -33,6 +33,7 @@ Transform:
|
|||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 8125631373578802561}
|
- {fileID: 8125631373578802561}
|
||||||
- {fileID: 5390027776247701102}
|
- {fileID: 5390027776247701102}
|
||||||
|
- {fileID: 8020832172312775243}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
@ -80,12 +81,14 @@ MonoBehaviour:
|
|||||||
target: {fileID: 0}
|
target: {fileID: 0}
|
||||||
enemyType: 0
|
enemyType: 0
|
||||||
ourType: 0
|
ourType: 0
|
||||||
|
maxHealthPoints: 100
|
||||||
healthPoints: 100
|
healthPoints: 100
|
||||||
rangeAttack: 3
|
rangeAttack: 3
|
||||||
rangeView: 1
|
rangeView: 1
|
||||||
damageAttack: 1
|
damageAttack: 1
|
||||||
speedAttack: 1
|
speedAttack: 1
|
||||||
nameText: {fileID: 6838251604148675782}
|
nameText: {fileID: 6838251604148675782}
|
||||||
|
healthPointsText: {fileID: 8012357605284019061}
|
||||||
--- !u!1 &2026481257847620386
|
--- !u!1 &2026481257847620386
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -121,7 +124,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: 0, y: -0.85}
|
m_AnchoredPosition: {x: 0, y: -0.35}
|
||||||
m_SizeDelta: {x: 20, y: 5}
|
m_SizeDelta: {x: 20, y: 5}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!23 &1498494949006888735
|
--- !u!23 &1498494949006888735
|
||||||
@ -186,7 +189,7 @@ MonoBehaviour:
|
|||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text:
|
m_text: name
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
@ -258,6 +261,178 @@ MonoBehaviour:
|
|||||||
m_hasFontAssetChanged: 0
|
m_hasFontAssetChanged: 0
|
||||||
m_renderer: {fileID: 1498494949006888735}
|
m_renderer: {fileID: 1498494949006888735}
|
||||||
m_maskType: 0
|
m_maskType: 0
|
||||||
|
--- !u!1 &2062275012809416088
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 8020832172312775243}
|
||||||
|
- component: {fileID: 4083783489867894370}
|
||||||
|
- component: {fileID: 8012357605284019061}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: HP
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &8020832172312775243
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2062275012809416088}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 430939372503899243}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -0.85}
|
||||||
|
m_SizeDelta: {x: 20, y: 5}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!23 &4083783489867894370
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2062275012809416088}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!114 &8012357605284019061
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2062275012809416088}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_text: 100/100
|
||||||
|
m_isRightToLeft: 0
|
||||||
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_fontSharedMaterials: []
|
||||||
|
m_fontMaterial: {fileID: 0}
|
||||||
|
m_fontMaterials: []
|
||||||
|
m_fontColor32:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_enableVertexGradient: 0
|
||||||
|
m_colorMode: 3
|
||||||
|
m_fontColorGradient:
|
||||||
|
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_fontColorGradientPreset: {fileID: 0}
|
||||||
|
m_spriteAsset: {fileID: 0}
|
||||||
|
m_tintAllSprites: 0
|
||||||
|
m_StyleSheet: {fileID: 0}
|
||||||
|
m_TextStyleHashCode: -1183493901
|
||||||
|
m_overrideHtmlColors: 0
|
||||||
|
m_faceColor:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontSize: 5
|
||||||
|
m_fontSizeBase: 5
|
||||||
|
m_fontWeight: 400
|
||||||
|
m_enableAutoSizing: 0
|
||||||
|
m_fontSizeMin: 18
|
||||||
|
m_fontSizeMax: 72
|
||||||
|
m_fontStyle: 0
|
||||||
|
m_HorizontalAlignment: 2
|
||||||
|
m_VerticalAlignment: 256
|
||||||
|
m_textAlignment: 65535
|
||||||
|
m_characterSpacing: 0
|
||||||
|
m_wordSpacing: 0
|
||||||
|
m_lineSpacing: 0
|
||||||
|
m_lineSpacingMax: 0
|
||||||
|
m_paragraphSpacing: 0
|
||||||
|
m_charWidthMaxAdj: 0
|
||||||
|
m_enableWordWrapping: 1
|
||||||
|
m_wordWrappingRatios: 0.4
|
||||||
|
m_overflowMode: 0
|
||||||
|
m_linkedTextComponent: {fileID: 0}
|
||||||
|
parentLinkedComponent: {fileID: 0}
|
||||||
|
m_enableKerning: 1
|
||||||
|
m_enableExtraPadding: 0
|
||||||
|
checkPaddingRequired: 0
|
||||||
|
m_isRichText: 1
|
||||||
|
m_parseCtrlCharacters: 1
|
||||||
|
m_isOrthographic: 0
|
||||||
|
m_isCullingEnabled: 0
|
||||||
|
m_horizontalMapping: 0
|
||||||
|
m_verticalMapping: 0
|
||||||
|
m_uvLineOffset: 0
|
||||||
|
m_geometrySortingOrder: 0
|
||||||
|
m_IsTextObjectScaleStatic: 0
|
||||||
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
|
m_useMaxVisibleDescender: 1
|
||||||
|
m_pageToDisplay: 1
|
||||||
|
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
|
m_isVolumetricText: 0
|
||||||
|
_SortingLayer: 0
|
||||||
|
_SortingLayerID: 0
|
||||||
|
_SortingOrder: 0
|
||||||
|
m_hasFontAssetChanged: 0
|
||||||
|
m_renderer: {fileID: 4083783489867894370}
|
||||||
|
m_maskType: 0
|
||||||
--- !u!1 &2353457452513625490
|
--- !u!1 &2353457452513625490
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -156,9 +156,9 @@ MonoBehaviour:
|
|||||||
WORLD_SPACE_OFFSET: {x: 0.5, y: 1, z: 0.5}
|
WORLD_SPACE_OFFSET: {x: 0.5, y: 1, z: 0.5}
|
||||||
soldierStartingPositions:
|
soldierStartingPositions:
|
||||||
- {x: 0, y: 0}
|
- {x: 0, y: 0}
|
||||||
- {x: 0, y: 5}
|
- {x: 1, y: 2}
|
||||||
enemyStartingPositions:
|
enemyStartingPositions:
|
||||||
- {x: 1, y: 0}
|
- {x: 2, y: 0}
|
||||||
- {x: 9, y: 5}
|
- {x: 9, y: 5}
|
||||||
tilemap: {fileID: 1853262998}
|
tilemap: {fileID: 1853262998}
|
||||||
soldierPrefab: {fileID: 403095692180922766, guid: a87b1aa46b0ed3e0fba621e11dd4f1e2,
|
soldierPrefab: {fileID: 403095692180922766, guid: a87b1aa46b0ed3e0fba621e11dd4f1e2,
|
||||||
|
|||||||
@ -13,6 +13,7 @@ public class Soldier : MonoBehaviour
|
|||||||
[SerializeField] private Soldier target;
|
[SerializeField] private Soldier target;
|
||||||
[SerializeField] private SoldierType enemyType;
|
[SerializeField] private SoldierType enemyType;
|
||||||
[SerializeField] private SoldierType ourType;
|
[SerializeField] private SoldierType ourType;
|
||||||
|
[SerializeField] private float maxHealthPoints = 10;
|
||||||
[SerializeField] private float healthPoints = 1;
|
[SerializeField] private float healthPoints = 1;
|
||||||
[SerializeField] private float rangeAttack = 100;
|
[SerializeField] private float rangeAttack = 100;
|
||||||
[SerializeField] private float rangeView = 1;
|
[SerializeField] private float rangeView = 1;
|
||||||
@ -20,8 +21,11 @@ public class Soldier : MonoBehaviour
|
|||||||
[SerializeField] private float speedAttack = 1;
|
[SerializeField] private float speedAttack = 1;
|
||||||
|
|
||||||
[SerializeField] private TMP_Text nameText = null;
|
[SerializeField] private TMP_Text nameText = null;
|
||||||
|
[SerializeField] private TMP_Text healthPointsText = null;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start(){
|
void Start(){
|
||||||
|
healthPoints = maxHealthPoints; // initialize health
|
||||||
|
UpdateHPDisplay();
|
||||||
setEnemyTag();
|
setEnemyTag();
|
||||||
|
|
||||||
Debug.Log("Soldier: " + ourType.ToString() + " has appeared", gameObject);
|
Debug.Log("Soldier: " + ourType.ToString() + " has appeared", gameObject);
|
||||||
@ -134,6 +138,12 @@ public class Soldier : MonoBehaviour
|
|||||||
if (healthPoints <= 0)
|
if (healthPoints <= 0)
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
|
|
||||||
|
UpdateHPDisplay();
|
||||||
Debug.Log("I took damage, oh my HP is now: " + healthPoints + " noooo!!!!", gameObject);
|
Debug.Log("I took damage, oh my HP is now: " + healthPoints + " noooo!!!!", gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateHPDisplay()
|
||||||
|
{
|
||||||
|
healthPointsText.text = healthPoints.ToString() + "/" + maxHealthPoints.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user