Skip to content
Snippets Groups Projects
Commit 05f67524 authored by MuhamadAjiW's avatar MuhamadAjiW
Browse files

refactor: layer and damage modifier

parent bb55926b
1 merge request!2Base arch
Showing
with 81 additions and 35 deletions
...@@ -30,7 +30,7 @@ Transform: ...@@ -30,7 +30,7 @@ Transform:
m_GameObject: {fileID: 125248941348886635} m_GameObject: {fileID: 125248941348886635}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.75, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.4, y: 1.5, z: 0.4} m_LocalScale: {x: 0.4, y: 1.5, z: 0.4}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
......
...@@ -30,7 +30,7 @@ Transform: ...@@ -30,7 +30,7 @@ Transform:
m_GameObject: {fileID: 3596266059315004415} m_GameObject: {fileID: 3596266059315004415}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.75, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 2, y: 1.5, z: 2} m_LocalScale: {x: 2, y: 1.5, z: 2}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
...@@ -143,4 +143,6 @@ MonoBehaviour: ...@@ -143,4 +143,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dc4d5359067cdfb47a45684d6cc1482a, type: 3} m_Script: {fileID: 11500000, guid: dc4d5359067cdfb47a45684d6cc1482a, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
WeaponLocation: {x: 0, y: 0, z: 0} staticWeaponPivot: {x: 0.5, y: 0, z: 0.375}
renderer: {fileID: 0}
bottomOffset: 0
...@@ -14,7 +14,7 @@ GameObject: ...@@ -14,7 +14,7 @@ GameObject:
- component: {fileID: 1523314302102385116} - component: {fileID: 1523314302102385116}
- component: {fileID: 138729632845352590} - component: {fileID: 138729632845352590}
m_Layer: 0 m_Layer: 0
m_Name: Basic3 m_Name: Basic3Model
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
......
...@@ -30,7 +30,7 @@ Transform: ...@@ -30,7 +30,7 @@ Transform:
m_GameObject: {fileID: 5071667469683539556} m_GameObject: {fileID: 5071667469683539556}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
...@@ -143,4 +143,6 @@ MonoBehaviour: ...@@ -143,4 +143,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dc4d5359067cdfb47a45684d6cc1482a, type: 3} m_Script: {fileID: 11500000, guid: dc4d5359067cdfb47a45684d6cc1482a, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
WeaponLocation: {x: 0, y: 0, z: 0} staticWeaponPivot: {x: 0, y: 0, z: 0}
renderer: {fileID: 0}
bottomOffset: 0
...@@ -31,7 +31,7 @@ Transform: ...@@ -31,7 +31,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 6312057550851766622} - {fileID: 5263704032773805873}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &344713511152250207 --- !u!114 &344713511152250207
...@@ -67,7 +67,7 @@ BoxCollider: ...@@ -67,7 +67,7 @@ BoxCollider:
serializedVersion: 3 serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1} m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: -1, y: 0.5, z: 0} m_Center: {x: -1, y: 0.5, z: 0}
--- !u!1001 &7576994708712382837 --- !u!1001 &8625066742953119514
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
...@@ -81,7 +81,7 @@ PrefabInstance: ...@@ -81,7 +81,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4521062537676429355, guid: ec549132bf117594e81e95cc4ae15b07, type: 3} - target: {fileID: 4521062537676429355, guid: ec549132bf117594e81e95cc4ae15b07, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 0.5 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4521062537676429355, guid: ec549132bf117594e81e95cc4ae15b07, type: 3} - target: {fileID: 4521062537676429355, guid: ec549132bf117594e81e95cc4ae15b07, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
...@@ -117,15 +117,15 @@ PrefabInstance: ...@@ -117,15 +117,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5071667469683539556, guid: ec549132bf117594e81e95cc4ae15b07, type: 3} - target: {fileID: 5071667469683539556, guid: ec549132bf117594e81e95cc4ae15b07, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: Model value: TestInteractableModel
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ec549132bf117594e81e95cc4ae15b07, type: 3} m_SourcePrefab: {fileID: 100100000, guid: ec549132bf117594e81e95cc4ae15b07, type: 3}
--- !u!4 &6312057550851766622 stripped --- !u!4 &5263704032773805873 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 4521062537676429355, guid: ec549132bf117594e81e95cc4ae15b07, type: 3} m_CorrespondingSourceObject: {fileID: 4521062537676429355, guid: ec549132bf117594e81e95cc4ae15b07, type: 3}
m_PrefabInstance: {fileID: 7576994708712382837} m_PrefabInstance: {fileID: 8625066742953119514}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
...@@ -53,7 +53,7 @@ BoxCollider: ...@@ -53,7 +53,7 @@ BoxCollider:
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_Size: {x: 2, y: 1.5, z: 2} m_Size: {x: 2, y: 1.5, z: 2}
m_Center: {x: 0, y: 0.75, z: 0} m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &7768068847418568192 --- !u!114 &7768068847418568192
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -31,7 +31,7 @@ Transform: ...@@ -31,7 +31,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2941944313554370296} - {fileID: 1239839213894966083}
- {fileID: 8287830469197447668} - {fileID: 8287830469197447668}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -84,10 +84,10 @@ MonoBehaviour: ...@@ -84,10 +84,10 @@ MonoBehaviour:
maxHealth: 100000 maxHealth: 100000
health: 100000 health: 100000
damagedDelay: 0.5 damagedDelay: 0.5
baseDamage: 0
weaponList: weaponList:
- {fileID: 2798277747015640978, guid: 967e1612f343be242bd63968a7374248, type: 3} - {fileID: 2798277747015640978, guid: 967e1612f343be242bd63968a7374248, type: 3}
baseDamage: 0 --- !u!1001 &2330325376918371153
--- !u!1001 &1851493345103208170
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
...@@ -101,7 +101,7 @@ PrefabInstance: ...@@ -101,7 +101,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3558461250457509906, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3} - target: {fileID: 3558461250457509906, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 0.75 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3558461250457509906, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3} - target: {fileID: 3558461250457509906, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
...@@ -137,17 +137,17 @@ PrefabInstance: ...@@ -137,17 +137,17 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3596266059315004415, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3} - target: {fileID: 3596266059315004415, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: Model value: Basic2Model
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3}
--- !u!4 &2941944313554370296 stripped --- !u!4 &1239839213894966083 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 3558461250457509906, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3} m_CorrespondingSourceObject: {fileID: 3558461250457509906, guid: 12a4aadfaedb1df42bbe4222406bb2ad, type: 3}
m_PrefabInstance: {fileID: 1851493345103208170} m_PrefabInstance: {fileID: 2330325376918371153}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1001 &4258106615694226828 --- !u!1001 &4258106615694226828
PrefabInstance: PrefabInstance:
......
using UnityEngine;
public abstract class EnemyEntity : CombatantEntity public abstract class EnemyEntity : CombatantEntity
{ {
// Set-Getters
public new string AttackLayerCode => EnvironmentConfig.LAYER_ENEMY_ATTACK;
public new float AttackMultiplier => GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.Instance.difficulty].enemyDamageMultiplier;
// Functions // Functions
new protected void Start() new protected void Start()
{ {
base.Start(); base.Start();
SetLayer(EnvironmentConfig.LAYER_ENEMY);
SetAttackLayer(EnvironmentConfig.LAYER_ENEMY_ATTACK);
Health *= GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.Instance.difficulty].enemyHealthMultiplier; Health *= GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.Instance.difficulty].enemyHealthMultiplier;
BaseDamage *= GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.Instance.difficulty].enemyDamageMultiplier;
tag = EnvironmentConfig.TAG_ENEMY; tag = EnvironmentConfig.TAG_ENEMY;
} }
} }
...@@ -11,7 +11,7 @@ public class GameController : MonoBehaviour ...@@ -11,7 +11,7 @@ public class GameController : MonoBehaviour
public GameCameraController mainCamera; public GameCameraController mainCamera;
public GameStateController stateController; public GameStateController stateController;
// Set-getters // Set-Getters
public bool IsPaused => Time.timeScale == 0; public bool IsPaused => Time.timeScale == 0;
// Constructor // Constructor
......
...@@ -15,6 +15,8 @@ public abstract class Collectible : WorldObject ...@@ -15,6 +15,8 @@ public abstract class Collectible : WorldObject
protected new void Start() protected new void Start()
{ {
base.Start(); base.Start();
SetLayer(EnvironmentConfig.LAYER_COLLECTIBLE);
OnCollectEvent += OnCollect; OnCollectEvent += OnCollect;
OnCollectEvent += OnCollectEnd; OnCollectEvent += OnCollectEnd;
OnTimeoutEvent += OnTimeout; OnTimeoutEvent += OnTimeout;
......
...@@ -15,10 +15,6 @@ public class Player : PlayerEntity ...@@ -15,10 +15,6 @@ public class Player : PlayerEntity
public PlayerStateController stateController; public PlayerStateController stateController;
public PlayerStats stats; public PlayerStats stats;
// Set-Getters
public new string AttackLayerCode => EnvironmentConfig.LAYER_PLAYER;
public new float AttackMultiplier => GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.Instance.difficulty].playerDamageMultiplier;
// Constructor // Constructor
new void Start() new void Start()
{ {
...@@ -30,6 +26,8 @@ public class Player : PlayerEntity ...@@ -30,6 +26,8 @@ public class Player : PlayerEntity
inputController = new PlayerInputController(this); inputController = new PlayerInputController(this);
movementController = new PlayerMovementController(this); movementController = new PlayerMovementController(this);
animationController = new PlayerAnimationController(this); animationController = new PlayerAnimationController(this);
SetLayer(EnvironmentConfig.LAYER_PLAYER);
SetAttackLayer(EnvironmentConfig.LAYER_PLAYER_ATTACK);
GameController.Instance.player = this; GameController.Instance.player = this;
......
...@@ -11,14 +11,24 @@ public class CombatantEntity : DamageableEntity, IArmed ...@@ -11,14 +11,24 @@ public class CombatantEntity : DamageableEntity, IArmed
public List<WeaponObject> weaponList = new(); public List<WeaponObject> weaponList = new();
private int weaponIndex; private int weaponIndex;
private WeaponObject weapon; private WeaponObject weapon;
private float attackMultiplier = 1f;
private string attackLayerCode = EnvironmentConfig.LAYER_ENVIRONMENT_ATTACK;
// Set-Getters // Set-Getters
public List<WeaponObject> WeaponList => weaponList; public List<WeaponObject> WeaponList => weaponList;
public WeaponObject Weapon => weapon; public WeaponObject Weapon => weapon;
public Transform Orientation => transform; public Transform Orientation => transform;
public Vector3 WeaponLocation => model.WeaponPivot; public Vector3 WeaponLocation => model.WeaponPivot;
public string AttackLayerCode => EnvironmentConfig.LAYER_ENVIRONMENT_ATTACK; public float AttackMultiplier
public float AttackMultiplier => 1f; {
get => attackMultiplier;
set => attackMultiplier = value;
}
public string AttackLayerCode
{
get => attackLayerCode;
set => attackLayerCode = value;
}
public float BaseDamage public float BaseDamage
{ {
get => baseDamage; get => baseDamage;
...@@ -51,6 +61,17 @@ public class CombatantEntity : DamageableEntity, IArmed ...@@ -51,6 +61,17 @@ public class CombatantEntity : DamageableEntity, IArmed
// Functions // Functions
public void SetAttackLayer(string attackLayerCode)
{
AttackLayerCode = attackLayerCode;
AttackMultiplier = attackLayerCode switch
{
EnvironmentConfig.LAYER_ENEMY_ATTACK => GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.Instance.difficulty].enemyDamageMultiplier,
EnvironmentConfig.LAYER_PLAYER_ATTACK => GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.Instance.difficulty].playerDamageMultiplier,
_ => 1f
};
}
public void EquipWeapon(int index) public void EquipWeapon(int index)
{ {
if(weaponList.Count == 0) if(weaponList.Count == 0)
......
...@@ -52,9 +52,16 @@ public class WorldEntity : WorldObject, IRigid ...@@ -52,9 +52,16 @@ public class WorldEntity : WorldObject, IRigid
groundDetectionSize = new Vector3(0.05f, 0.05f, 0.05f); groundDetectionSize = new Vector3(0.05f, 0.05f, 0.05f);
groundLayers = LayerMask.GetMask(EnvironmentConfig.LAYER_DEFAULT); groundLayers = LayerMask.GetMask(EnvironmentConfig.LAYER_DEFAULT);
model.gameObject.layer = LayerMask.NameToLayer(LayerCode);
} }
// Functions // Functions
public new void SetLayer(string layerCode)
{
base.SetLayer(layerCode);
model.gameObject.layer = LayerMask.NameToLayer(LayerCode);
}
protected void Refresh() protected void Refresh()
{ {
Rigidbody.AddForce(Vector2.zero); Rigidbody.AddForce(Vector2.zero);
......
...@@ -3,14 +3,20 @@ using UnityEngine; ...@@ -3,14 +3,20 @@ using UnityEngine;
public class WorldObject : MonoBehaviour public class WorldObject : MonoBehaviour
{ {
// Attributes // Attributes
public string id;
private static int autoIncrement = 0; private static int autoIncrement = 0;
private int numberId; private int numberId;
private string prefix; private string prefix;
public string id; private string layerCode = EnvironmentConfig.LAYER_DEFAULT;
// Set-Getters // Set-Getters
public Vector3 Front => transform.rotation * Vector3.forward; public Vector3 Front => transform.rotation * Vector3.forward;
public Quaternion Rotation => transform.rotation; public Quaternion Rotation => transform.rotation;
public string LayerCode
{
get => layerCode;
set => layerCode = value;
}
// Constructor // Constructor
protected void Start() protected void Start()
...@@ -29,8 +35,17 @@ public class WorldObject : MonoBehaviour ...@@ -29,8 +35,17 @@ public class WorldObject : MonoBehaviour
numberId = autoIncrement; numberId = autoIncrement;
id = numberId.ToString(); id = numberId.ToString();
autoIncrement++; autoIncrement++;
gameObject.layer = LayerMask.NameToLayer(LayerCode);
} }
public void SetLayer(string layerCode)
{
LayerCode = layerCode;
gameObject.layer = LayerMask.NameToLayer(LayerCode);
}
// Functions // Functions
protected void SetIdPrefix(string prefix) protected void SetIdPrefix(string prefix)
{ {
......
...@@ -5,8 +5,8 @@ public interface IArmed ...@@ -5,8 +5,8 @@ public interface IArmed
{ {
// Set-Getters // Set-Getters
public float BaseDamage { get; set; } public float BaseDamage { get; set; }
public string AttackLayerCode { get; } public string AttackLayerCode { get; set; }
public float AttackMultiplier { get; } public float AttackMultiplier { get; set; }
public Vector3 WeaponLocation { get; } public Vector3 WeaponLocation { get; }
public WeaponObject Weapon { get; } public WeaponObject Weapon { get; }
public Transform Orientation { get; } public Transform Orientation { get; }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment