Charles

abilities adjustments and fine tuning

......@@ -373,7 +373,7 @@ RectTransform:
- {fileID: 980683940}
- {fileID: 198342459}
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
......@@ -535,7 +535,7 @@ Transform:
m_LocalScale: {x: 0.31989, y: 0.31989, z: 0.31989}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &362990467
MonoBehaviour:
......@@ -566,6 +566,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 378f6c0d9b7ffb74ea3ea82e8967d09f, type: 3}
m_Name:
m_EditorClassIdentifier:
moveTarget: {fileID: 1978195363}
--- !u!114 &362990469
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -631,6 +632,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
attackSpeed: 1
abilityCooldowns: []
--- !u!224 &433719336 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 854438021669437656, guid: a0430c94576a6804fbaf7e382da24739,
......@@ -1123,6 +1125,11 @@ PrefabInstance:
propertyPath: m_Name
value: Ability Slot (1)
objectReference: {fileID: 0}
- target: {fileID: 854438021669437659, guid: a0430c94576a6804fbaf7e382da24739,
type: 3}
propertyPath: activationKey
value: 119
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a0430c94576a6804fbaf7e382da24739, type: 3}
--- !u!1 &532100813
......@@ -1426,7 +1433,7 @@ Transform:
m_LocalScale: {x: 0.07821647, y: 0.46760535, z: 0.10786247}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 88.915, y: 0, z: 0}
--- !u!1001 &632878256
PrefabInstance:
......@@ -1942,7 +1949,7 @@ Transform:
m_Children:
- {fileID: 2044208974}
m_Father: {fileID: 0}
m_RootOrder: 12
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &909129332
MonoBehaviour:
......@@ -2007,6 +2014,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
attackSpeed: 1
abilityCooldowns: []
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
......@@ -2658,7 +2666,7 @@ Transform:
m_LocalScale: {x: 0.3187, y: 0.3187, z: 0.3187}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1174587269
MonoBehaviour:
......@@ -3077,7 +3085,7 @@ Transform:
m_LocalScale: {x: 0.27777064, y: 0.42203593, z: 0.09600017}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &1599470761 stripped
RectTransform:
......@@ -3284,6 +3292,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 378f6c0d9b7ffb74ea3ea82e8967d09f, type: 3}
m_Name:
m_EditorClassIdentifier:
moveTarget: {fileID: 0}
--- !u!114 &1727982935
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -3297,6 +3306,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
attackSpeed: 1
abilityCooldowns: []
--- !u!114 &1727982936
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -3425,7 +3435,7 @@ Transform:
m_LocalScale: {x: 0.31989, y: 0.31989, z: 0.31989}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1731946980
PrefabInstance:
......@@ -3667,6 +3677,11 @@ PrefabInstance:
propertyPath: m_Name
value: Ability Slot (2)
objectReference: {fileID: 0}
- target: {fileID: 854438021669437659, guid: a0430c94576a6804fbaf7e382da24739,
type: 3}
propertyPath: activationKey
value: 101
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a0430c94576a6804fbaf7e382da24739, type: 3}
--- !u!224 &1828672981 stripped
......@@ -3675,6 +3690,36 @@ RectTransform:
type: 3}
m_PrefabInstance: {fileID: 5887957687710896209}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1978195363
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1978195364}
m_Layer: 0
m_Name: MoveToTarget
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1978195364
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1978195363}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 3.57, y: -0.03, z: -13.4}
m_LocalScale: {x: 0.31989, y: 0.31989, z: 0.31989}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2042006732
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -3906,7 +3951,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2044208973
GameObject:
......@@ -4053,7 +4098,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2119262570
GameObject:
......@@ -4378,5 +4423,10 @@ PrefabInstance:
propertyPath: m_Name
value: Ability Slot
objectReference: {fileID: 0}
- target: {fileID: 854438021669437659, guid: a0430c94576a6804fbaf7e382da24739,
type: 3}
propertyPath: activationKey
value: 113
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a0430c94576a6804fbaf7e382da24739, type: 3}
......
......@@ -20,7 +20,13 @@ public class Ability : ScriptableObject
protected float abilityValue;
public float duration;
public float cooldown;
[SerializeField]
protected float cooldown;
//[HideInInspector]
public float cooldownTimer = 0;
protected Camera cam;
......
......@@ -8,6 +8,8 @@ public class AbilitySlot : MonoBehaviour
public Player_Controller playerController;
public KeyCode activationKey;
Ability ability;
......@@ -18,6 +20,9 @@ public class AbilitySlot : MonoBehaviour
icon.sprite = ability.icon;
icon.enabled = true;
description.text = newAbility.description;
}
//clears inventory slot
......@@ -27,6 +32,7 @@ public class AbilitySlot : MonoBehaviour
icon.sprite = null;
icon.enabled = false;
description.text = "";
}
//uses item in inventory slot
......
......@@ -49,8 +49,8 @@ public class AbilityUI : MonoBehaviour
//FIX PLEASE FUTURE CHARLES
void UpdateUI()
{
characterStats = playerManager.player1.GetComponent<Player_Stats>();
playerController = playerManager.player1.GetComponent<Player_Controller>();
characterStats = playerManager.activePerson.GetComponent<Player_Stats>();
playerController = playerManager.activePerson.GetComponent<Player_Controller>();
for (int i = 0; i < slots.Length; i++)
{
......
......@@ -13,11 +13,11 @@ public class Aoe_Ability : Ability
[SerializeField]
private TargetType targetType;
public float endPoint;
//public float endPoint;
public Vector3 origin;
private bool selfOrigin = false;
public bool selfOrigin = false;
[SerializeField]
private List<CharacterCombat> targets = new List<CharacterCombat>();
......@@ -26,6 +26,13 @@ public class Aoe_Ability : Ability
{
base.Use(user);
if (cooldownTimer >= 0)
{
Debug.Log("Ability on cooldown");
return;
}
cooldownTimer = cooldown;
if (selfOrigin) origin = user.transform.position;
else
{
......@@ -40,84 +47,106 @@ public class Aoe_Ability : Ability
if ( origin != null)
{
Collider[] colliderArray;
if (aoeType != AOEType.Cone)
if (aoeType == AOEType.Cube || aoeType == AOEType.Sphere)
CheckArea();
else
else if (aoeType == AOEType.Cone)
CheckCone();
else if (aoeType == AOEType.Line)
CheckLine();
foreach (var target in targets)
{
target.AbilityHit(user.GetComponent<Character_Stats>());
Debug.Log(target + " was hit at coordinates: " + origin);
user.GetComponent<CharacterCombat>().AbilityHit(target.GetMyStats());
}
targets.Clear();
}
targets.Clear();
}
private void CheckCone()
{
Collider[] colliderArray = Physics.OverlapSphere(origin, areaSize);
foreach (var collider in colliderArray)
if (colliderArray != null)
{
Vector3 directionTowardT = collider.transform.position - origin;
float angleFromConeCenter = Vector3.Angle(directionTowardT, Vector3.forward);
foreach (var collider in colliderArray)
{
Vector3 directionTowardT = collider.transform.position - origin;
float angleFromConeCenter = Vector3.Angle(directionTowardT, Vector3.forward);
CharacterCombat colliderCombat = collider.gameObject.GetComponent<CharacterCombat>();
CharacterCombat colliderCombat = collider.gameObject.GetComponent<CharacterCombat>();
if (colliderCombat != null && angleFromConeCenter <= 45)
{
switch (targetType)
if (colliderCombat != null && angleFromConeCenter <= 45)
{
case TargetType.Ally:
if (colliderCombat.tag == "Ally") targets.Add(colliderCombat);
break;
switch (targetType)
{
case TargetType.Ally:
if (colliderCombat.tag == "Ally") targets.Add(colliderCombat);
break;
case TargetType.Enemy:
if (colliderCombat.tag == "Enemy") targets.Add(colliderCombat);
break;
case TargetType.Enemy:
if (colliderCombat.tag == "Enemy") targets.Add(colliderCombat);
break;
case TargetType.Any:
targets.Add(colliderCombat);
break;
case TargetType.Any:
targets.Add(colliderCombat);
break;
default:
targets.Add(colliderCombat);
break;
default:
targets.Add(colliderCombat);
break;
}
}
}
}
}
private void CheckLine()
{
Ray aoeLineRay = new Ray(user.transform.position, user.transform.TransformDirection(Vector3.forward) * 2);
RaycastHit[] collidersHit = Physics.RaycastAll(aoeLineRay, areaSize);
if (collidersHit != null)
{
foreach (var rayHit in collidersHit)
{
CharacterCombat colliderCombat = rayHit.collider.gameObject.GetComponent<CharacterCombat>();
if (colliderCombat != null)
{
switch (targetType)
{
case TargetType.Ally:
if (colliderCombat.tag == "Ally") targets.Add(colliderCombat);
break;
case TargetType.Enemy:
if (colliderCombat.tag == "Enemy") targets.Add(colliderCombat);
break;
case TargetType.Any:
targets.Add(colliderCombat);
break;
}
}
}
}
}
private void CheckArea ()
{
Collider[] collidersNear = null;
if (aoeType == AOEType.Cube)
if (aoeType == AOEType.Cube)
collidersNear = Physics.OverlapBox(origin, new Vector3(areaSize, areaSize, areaSize));
else if (aoeType == AOEType.Sphere)
else if (aoeType == AOEType.Sphere)
collidersNear = Physics.OverlapSphere(origin, areaSize);
if (aoeType == AOEType.Line)
{
Ray aoeLineRay = new Ray(user.transform.position, Vector3.forward);
RaycastHit[] collidersHit = Physics.RaycastAll(aoeLineRay);
for (int i = 0; i < collidersHit.Length; i++)
{
collidersNear[i] = collidersHit[i].collider;
}
}
if (collidersNear != null)
{
foreach (var collider in collidersNear)
......@@ -139,22 +168,11 @@ public class Aoe_Ability : Ability
case TargetType.Any:
targets.Add(colliderCombat);
break;
default:
targets.Add(colliderCombat);
break;
}
}
}
}
}
private void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawSphere(origin, areaSize);
}
}
public enum AOEType { Sphere, Cube, Cone, Line }
......
......@@ -11,16 +11,25 @@ public class CharacterCombat : MonoBehaviour
public float attackSpeed = 1f;
private float attackCooldown = 0f;
public List<float> abilityCooldowns = new List<float>();
private void Start()
{
myStats = GetComponent<Character_Stats>();
attackSpeed = myStats.attackSpeed.GetValue();
foreach (Ability ability in myStats.abilities)
{
ability.cooldownTimer = 0;
}
}
private void Update()
{
attackCooldown -= Time.deltaTime;
foreach(Ability ability in myStats.abilities)
{
ability.cooldownTimer -= Time.deltaTime;
}
}
//method for attackng another character
......@@ -38,10 +47,15 @@ public class CharacterCombat : MonoBehaviour
}
}
public Character_Stats GetMyStats(){ return myStats; }
public void AbilityHit(Character_Stats targetStats)
{
//Debug.Log(targetStats + " was hit by an ability");
//tells attack target's stats that they take damage
targetStats.TakeDam(myStats.damage.GetValue());
}
public float GetAttackCooldown() { return attackCooldown; }
......
......@@ -22,9 +22,6 @@ public class Character_Stats : MonoBehaviour
{
ability.SetCam(Camera.main);
}
curHP = maxHP.GetValue();
}
......
......@@ -23,6 +23,8 @@ public class PlayerManager : MonoBehaviour
public Player_Controller activePerson;
void Start()
{
activePerson = player1.GetComponent<Player_Controller>();
......@@ -32,6 +34,9 @@ public class PlayerManager : MonoBehaviour
void Update()
{
//abilityCooldown -= Time.deltaTime;
//press 1 on keyboard to switch to character 1
if (Input.GetKeyDown(KeyCode.Alpha1))
{
......@@ -57,5 +62,19 @@ public class PlayerManager : MonoBehaviour
onCharacterChangeCallback.Invoke();
}
}
if (Input.GetKeyDown(KeyCode.Q))
{
activePerson.GetComponent<Player_Stats>().abilities[0].Use(activePerson.gameObject);
}
if (Input.GetKeyDown(KeyCode.W))
{
activePerson.GetComponent<Player_Stats>().abilities[1].Use(activePerson.gameObject);
}
if (Input.GetKeyDown(KeyCode.E))
{
activePerson.GetComponent<Player_Stats>().abilities[2].Use(activePerson.gameObject);
}
}
}
......
......@@ -44,12 +44,14 @@ public class Player_Controller : MonoBehaviour
if (Physics.Raycast(ray, out hit, 100))
{
//Debug.Log("We hit: " + hit.collider.name + " " + hit.point);
//Left mouse button click move
movement.MovetoPoint(hit.point);
movement.moveTarget.transform.position = hit.point;
RemoveFocus();
movement.FollowTarget(movement.moveTarget.gameObject);
}
}
......@@ -70,9 +72,6 @@ public class Player_Controller : MonoBehaviour
}
}
}
}
//Sets the player's focus
......@@ -92,7 +91,6 @@ public class Player_Controller : MonoBehaviour
//Tells interactable that they are being focused by the player
newFocus.OnFocused(transform);
}
//removes the player's current focus
......
......@@ -6,7 +6,9 @@ using UnityEngine.AI;
//[RequireComponent(typeof(NavMeshAgent))]
public class Player_Movement : MonoBehaviour
{
Transform target;
Transform target;
public GameObject moveTarget;
NavMeshAgent agent;
......@@ -25,9 +27,10 @@ public class Player_Movement : MonoBehaviour
}
}
public void MovetoPoint(Vector3 point)
public void MovetoPoint(Vector3 newPoint)
{
agent.SetDestination(point);
moveTarget.transform.position = newPoint;
FollowTarget(moveTarget);
}
public void FollowTarget(Interactable newTarget)
......@@ -42,6 +45,7 @@ public class Player_Movement : MonoBehaviour
agent.stoppingDistance = 3 * 0.8f;
agent.updateRotation = false;
target = newTarget.transform;
//Debug.Log("Target is: " + target);
}
public void StopFollowTarget()
......
......@@ -10,8 +10,12 @@ public class Player_Stats : Character_Stats
void Start()
{
equipManager = GetComponent<EquipmentManager>();
equipManager.onEquipmentChanged += OnEquipmentChanged;
equipManager.onEquipmentChanged += OnEquipmentChanged;
foreach (Ability ability in abilities)
{
ability.SetCam(Camera.main);
}
}
void OnEquipmentChanged (Equipment newItem, Equipment oldItem)
......
......@@ -12,20 +12,20 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9a40401784437aa48bf06c3387427385, type: 3}
m_Name: Test AOE Ability
m_EditorClassIdentifier:
name: New Ability
description: ability does thing
icon: {fileID: 0}
name: Test AOE ability 1
description: Explodes in a sphere
icon: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
buffList:
debuffList:
doesDamage: 0
doesDamage: 1
doesHealing: 0
abilityValue: 0
abilityValue: 5
duration: 0
cooldown: 0
areaSize: 0
aoeType: 0
targetType: 0
endPoint: 0
damageMod: 0
origin: {fileID: 0}
cooldown: 10
cooldownTimer: -242.27454
areaSize: 10
aoeType: 2
targetType: 2
origin: {x: 2.2270322, y: -0.44, z: -19.48202}
selfOrigin: 0
targets: []
......