Minion throw health cost and reload time
This commit is contained in:
parent
62bdfa65ab
commit
310c4ce85f
@ -30,6 +30,7 @@ RectTransform:
|
||||
m_Children:
|
||||
- {fileID: 1979632679258755679}
|
||||
- {fileID: 1979632679604795358}
|
||||
- {fileID: 4713540475464922574}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -51,6 +52,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
icon: {fileID: 1979632679604795359}
|
||||
reloadSlider: {fileID: 5455234342035423124}
|
||||
indexInMinionList: 0
|
||||
selectedColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
unSelectedColor: {r: 0.6792453, g: 0.6792453, b: 0.6792453, a: 1}
|
||||
@ -204,3 +206,166 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &2680926411192010905
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4713540475464922574}
|
||||
- component: {fileID: 5455234342035423124}
|
||||
m_Layer: 5
|
||||
m_Name: Slider
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &4713540475464922574
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2680926411192010905}
|
||||
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_Children:
|
||||
- {fileID: 358338754108010580}
|
||||
m_Father: {fileID: 1979632678310270258}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &5455234342035423124
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2680926411192010905}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 0
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 0}
|
||||
m_FillRect: {fileID: 358338754108010580}
|
||||
m_HandleRect: {fileID: 0}
|
||||
m_Direction: 2
|
||||
m_MinValue: 0
|
||||
m_MaxValue: 1
|
||||
m_WholeNumbers: 0
|
||||
m_Value: 0.5
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &6604576339594320426
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 358338754108010580}
|
||||
- component: {fileID: 6464480435457661666}
|
||||
- component: {fileID: 6973380708449632018}
|
||||
m_Layer: 5
|
||||
m_Name: Reload Fill
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &358338754108010580
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6604576339594320426}
|
||||
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_Children: []
|
||||
m_Father: {fileID: 4713540475464922574}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6464480435457661666
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6604576339594320426}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &6973380708449632018
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6604576339594320426}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.5188679, g: 0.5188679, b: 0.5188679, a: 0.4745098}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
|
||||
@ -11,8 +11,12 @@ public class MinionThrower : MonoBehaviour {
|
||||
bool isInThrowMode;
|
||||
Vector2 throwDirection = Vector2.right;
|
||||
MinionBar minionBar;
|
||||
VampireEntity vampireEntity;
|
||||
float currentCooldownTimer;
|
||||
float currentInitialCooldown;
|
||||
|
||||
void Awake() {
|
||||
vampireEntity = GetComponent<VampireEntity>();
|
||||
minionBar = FindObjectOfType<MinionBar>();
|
||||
aimArrow.SetActive(false);
|
||||
}
|
||||
@ -23,6 +27,13 @@ public class MinionThrower : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
if(currentCooldownTimer > 0f) {
|
||||
currentCooldownTimer -= Time.fixedDeltaTime;
|
||||
minionBar.UpdateReload(currentCooldownTimer / currentInitialCooldown);
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleThrowMode(InputAction.CallbackContext context) {
|
||||
if (context.performed) {
|
||||
isInThrowMode = true;
|
||||
@ -40,9 +51,20 @@ public class MinionThrower : MonoBehaviour {
|
||||
}
|
||||
|
||||
void PerformThrow() {
|
||||
if (!isInThrowMode) {
|
||||
if (!isInThrowMode || currentCooldownTimer > 0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
float minionHealthCost = 10f; // TODO
|
||||
// if(minionHealthCost >= vampireEntity.Health) {
|
||||
// return;
|
||||
// }
|
||||
vampireEntity.TakeDamage(minionHealthCost);
|
||||
|
||||
currentInitialCooldown = 2f; // TODO
|
||||
currentCooldownTimer = currentInitialCooldown;
|
||||
minionBar.UpdateReload(currentCooldownTimer / currentInitialCooldown);
|
||||
|
||||
GameObject newMinion = Instantiate(minionBar.GetCurrentMinion(), transform.position + new Vector3(throwDirection.x, throwDirection.y, 0f) * 1f, Quaternion.identity);
|
||||
// Apply throw force
|
||||
}
|
||||
|
||||
@ -5,9 +5,9 @@ using UnityEngine.InputSystem;
|
||||
|
||||
public class MinionBar : MonoBehaviour {
|
||||
|
||||
List<GameObject> minionTypes;
|
||||
public GameObject minionIconPrefab;
|
||||
|
||||
List<GameObject> minionTypes;
|
||||
List<MinionIcon> minionIcons;
|
||||
int currentIndex;
|
||||
|
||||
@ -16,17 +16,9 @@ public class MinionBar : MonoBehaviour {
|
||||
minionIcons = new List<MinionIcon>();
|
||||
}
|
||||
|
||||
// public void Start() {
|
||||
// minionIcons = new List<MinionIcon>();
|
||||
// for (int i=0; i<minionTypes.Count; ++i) {
|
||||
// GameObject newIconObj = Instantiate(minionIconPrefab, transform);
|
||||
// minionIcons.Add(newIconObj.GetComponent<MinionIcon>());
|
||||
// // minionIcons[i].icon = minionTypes.icon; // TODO
|
||||
// minionIcons[i].indexInMinionList = i;
|
||||
// minionIcons[i].UnSelect();
|
||||
// }
|
||||
// minionIcons[currentIndex].Select();
|
||||
// }
|
||||
void Start() {
|
||||
UpdateReload(0f);
|
||||
}
|
||||
|
||||
public void ChangeSelectedIcon(InputAction.CallbackContext context) {
|
||||
|
||||
@ -64,6 +56,19 @@ public class MinionBar : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateReload(float reloadFraction) {
|
||||
float reloadFractionCorrected = reloadFraction;
|
||||
if (reloadFractionCorrected < 0f) {
|
||||
reloadFractionCorrected = 0f;
|
||||
} else if (reloadFractionCorrected > 1f) {
|
||||
reloadFractionCorrected = 1f;
|
||||
}
|
||||
|
||||
foreach (MinionIcon icon in minionIcons) {
|
||||
icon.reloadSlider.value = reloadFractionCorrected;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject GetCurrentMinion() {
|
||||
return minionTypes[currentIndex];
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using UnityEngine.UI;
|
||||
public class MinionIcon : MonoBehaviour {
|
||||
|
||||
public Image icon;
|
||||
public Slider reloadSlider;
|
||||
[HideInInspector] public int indexInMinionList;
|
||||
public Color selectedColor;
|
||||
public Color unSelectedColor;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user