Implemented forced fight, updated attack range to be closer to player.
This commit is contained in:
@@ -1364,6 +1364,10 @@ MonoBehaviour:
|
||||
m_Key: pine
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 344147329127993344
|
||||
m_Key: escapeFailForced
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_KeyGenerator:
|
||||
|
||||
@@ -1375,6 +1375,10 @@ MonoBehaviour:
|
||||
m_Localized: Tanne
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 344147329127993344
|
||||
m_Localized: Du kannst diesem Kampf nicht entkommen.
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
|
||||
@@ -1416,6 +1416,10 @@ MonoBehaviour:
|
||||
m_Localized: Pine tree
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 344147329127993344
|
||||
m_Localized: You cannot escape this fight.
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
references:
|
||||
version: 2
|
||||
RefIds: []
|
||||
|
||||
@@ -1,258 +1,5 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1755437404601407390
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1490485691279698368}
|
||||
- component: {fileID: 2823500805711375321}
|
||||
- component: {fileID: 2095238798181559198}
|
||||
m_Layer: 5
|
||||
m_Name: pnlHealth
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1490485691279698368
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1755437404601407390}
|
||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 8692566566668546467}
|
||||
m_Father: {fileID: 8927601208402363686}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 180, 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!222 &2823500805711375321
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1755437404601407390}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2095238798181559198
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1755437404601407390}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
|
||||
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_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
|
||||
--- !u!1 &1873279497245847383
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8927601208402363686}
|
||||
- component: {fileID: 4898475509121882234}
|
||||
- component: {fileID: 7219702916767965912}
|
||||
- component: {fileID: 985266517551115690}
|
||||
m_Layer: 5
|
||||
m_Name: Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8927601208402363686
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1873279497245847383}
|
||||
m_LocalRotation: {x: -0, y: 0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 10, y: 10, z: 10}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1490485691279698368}
|
||||
m_Father: {fileID: 4016379320889883386}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0.75}
|
||||
m_SizeDelta: {x: 0.2, y: 0.05}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!223 &4898475509121882234
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1873279497245847383}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 2
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &7219702916767965912
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1873279497245847383}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.CanvasScaler
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 1
|
||||
--- !u!114 &985266517551115690
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1873279497245847383}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.GraphicRaycaster
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!1 &2454216620873436980
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8692566566668546467}
|
||||
- component: {fileID: 7163846638090094393}
|
||||
- component: {fileID: 2408993422533026150}
|
||||
m_Layer: 5
|
||||
m_Name: pnlFill
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8692566566668546467
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2454216620873436980}
|
||||
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: 1490485691279698368}
|
||||
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!222 &7163846638090094393
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2454216620873436980}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2408993422533026150
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2454216620873436980}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 0, b: 0, 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_Sprite: {fileID: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &4493055063801180089
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -357,7 +104,7 @@ SphereCollider:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 10
|
||||
m_Radius: 2
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &9177574821772890452
|
||||
GameObject:
|
||||
@@ -492,9 +239,6 @@ PrefabInstance:
|
||||
- targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: 07d4f52b1d00e531cb997ce759ba7528, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1643418974084022053}
|
||||
- targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: 07d4f52b1d00e531cb997ce759ba7528, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 8927601208402363686}
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 07d4f52b1d00e531cb997ce759ba7528, type: 3}
|
||||
insertIndex: -1
|
||||
|
||||
@@ -157,7 +157,7 @@ SphereCollider:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 10
|
||||
m_Radius: 3
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &6930797397305739564
|
||||
PrefabInstance:
|
||||
|
||||
@@ -104,7 +104,7 @@ SphereCollider:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 10
|
||||
m_Radius: 3
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &9175929318179943571
|
||||
GameObject:
|
||||
|
||||
@@ -157,7 +157,7 @@ SphereCollider:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 10
|
||||
m_Radius: 3
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &7814914561341846133
|
||||
PrefabInstance:
|
||||
|
||||
@@ -104,7 +104,7 @@ SphereCollider:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 10
|
||||
m_Radius: 3
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &6532252744912899084
|
||||
GameObject:
|
||||
|
||||
@@ -51,7 +51,7 @@ SphereCollider:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 10
|
||||
m_Radius: 4
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &5449467032391326534
|
||||
GameObject:
|
||||
|
||||
@@ -145,7 +145,7 @@ public class Controls : MonoBehaviour
|
||||
switch (target.tag.Split(':')[1])
|
||||
{
|
||||
case "Enemy":
|
||||
fight.GetComponent<Fight>().startFight(worldGen.GetComponent<WorldGenerator>().getCurrentTile(), target, player);
|
||||
fight.GetComponent<Fight>().startFight(worldGen.GetComponent<WorldGenerator>().getCurrentTile(), target, player, true);
|
||||
break;
|
||||
case "Tree":
|
||||
player.GetComponent<PlayerGameObject>().getPlayer().getStat("TreeCount").changeAmount(1);
|
||||
|
||||
@@ -14,12 +14,16 @@ public class Fight : MonoBehaviour
|
||||
GameObject player;
|
||||
System.Random rand = new System.Random();
|
||||
UIHandler uihandler;
|
||||
bool isFleeable = true;
|
||||
public bool isFightActive = false;
|
||||
|
||||
public void startFight(GameObject tile, GameObject enemy, GameObject player)
|
||||
public void startFight(GameObject tile, GameObject enemy, GameObject player, bool isFleeable)
|
||||
{
|
||||
isFightActive = true;
|
||||
this.tile = tile;
|
||||
this.enemy = enemy;
|
||||
this.player = player;
|
||||
this.isFleeable = isFleeable;
|
||||
enemy.GetComponent<Enemy>().scaleEnemy(player.GetComponent<PlayerGameObject>());
|
||||
enemy.transform.rotation = Quaternion.Euler(0, GameObject.Find("Main Camera").transform.rotation.y, 0);
|
||||
|
||||
@@ -31,6 +35,7 @@ public class Fight : MonoBehaviour
|
||||
|
||||
private void endFight()
|
||||
{
|
||||
isFightActive = false;
|
||||
uihandler.closeFight();
|
||||
}
|
||||
|
||||
@@ -42,7 +47,7 @@ public class Fight : MonoBehaviour
|
||||
switch (index)
|
||||
{
|
||||
case 1:
|
||||
if (rand.Next(1, 11) <= 3)
|
||||
if (rand.Next(1, 11) <= 3 && isFleeable)
|
||||
{
|
||||
escapedSuccesfully = true;
|
||||
endFight();
|
||||
@@ -50,7 +55,14 @@ public class Fight : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
uihandler.showMessage("ERROR;" + TextHandler.getText("escapeFail"));
|
||||
if (isFleeable)
|
||||
{
|
||||
uihandler.showMessage("ERROR;" + TextHandler.getText("escapeFail"));
|
||||
}
|
||||
else
|
||||
{
|
||||
uihandler.showMessage("ERROR;" + TextHandler.getText("escapeFailForced"));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
||||
@@ -19,9 +19,7 @@ namespace Assets.Scripts.InteractableObjects
|
||||
bool isJumping;
|
||||
Stopwatch jumpTimer;
|
||||
bool followsPlayer;
|
||||
bool isAttacking;
|
||||
bool isAttackOnCooldown;
|
||||
Stopwatch attackTimer;
|
||||
Fight fight;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -30,33 +28,14 @@ namespace Assets.Scripts.InteractableObjects
|
||||
jumpTimer = new Stopwatch();
|
||||
jumpTimer.Start();
|
||||
followsPlayer = false;
|
||||
isAttacking = false;
|
||||
isAttackOnCooldown = false;
|
||||
attackTimer = new Stopwatch();
|
||||
fight = GameObject.Find("Fight").GetComponent<Fight>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(fight.isFightActive) return;
|
||||
Jump();
|
||||
if (isAttacking)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
}
|
||||
|
||||
void Attack()
|
||||
{
|
||||
if (!isAttackOnCooldown)
|
||||
{
|
||||
attackTimer.Start();
|
||||
isAttackOnCooldown = true;
|
||||
}
|
||||
if (attackTimer.ElapsedMilliseconds >= 2000)
|
||||
{
|
||||
attackTimer.Reset();
|
||||
isAttackOnCooldown = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Jump()
|
||||
@@ -95,16 +74,12 @@ namespace Assets.Scripts.InteractableObjects
|
||||
|
||||
public void HandleAttack()
|
||||
{
|
||||
isAttacking = true;
|
||||
//Create attack logic here
|
||||
//TODO: Force Fight start
|
||||
}
|
||||
|
||||
public void handleFollow(bool isFollowing)
|
||||
{
|
||||
followsPlayer = isFollowing;
|
||||
isAttacking = false;
|
||||
attackTimer.Reset();
|
||||
isAttackOnCooldown = false;
|
||||
}
|
||||
|
||||
public void HandleDetection()
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace Assets.Scripts.Player
|
||||
switch (col.name)
|
||||
{
|
||||
case "AttackRange":
|
||||
enemy.HandleAttack();
|
||||
GameObject.Find("Fight").GetComponent<Fight>().startFight(worldGenerator.GetComponent<WorldGenerator>().getCurrentTile(), col.gameObject.transform.parent.gameObject, gameObject, false);
|
||||
break;
|
||||
case "DetectionRange":
|
||||
enemy.HandleDetection();
|
||||
|
||||
Reference in New Issue
Block a user