Skip to content

Commit

Permalink
0.3a RC6 bugfixes and comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelday008 committed Oct 9, 2019
1 parent d96d608 commit 332a3b7
Show file tree
Hide file tree
Showing 60 changed files with 308 additions and 326 deletions.
6 changes: 3 additions & 3 deletions Abilities/Ability/BaseAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public bool CanCast() {

public void Use() {
//Debug.Log("BaseAbility.Use()");
// testing - warp in canCast to prevent casting any ability without the proper weapon affinity
// prevent casting any ability without the proper weapon affinity
if (CanCast()) {
PlayerManager.MyInstance.MyCharacter.MyCharacterAbilityManager.BeginAbility(this);
}
Expand Down Expand Up @@ -322,16 +322,16 @@ public virtual void StartCasting(BaseCharacter source) {
if (castingAnimationClip != null) {
source.MyCharacterUnit.MyCharacterAnimator.HandleCastingAbility(castingAnimationClip, this);
}
// TESTING GRAVITY FREEZE FOR CASTING
// GRAVITY FREEZE FOR CASTING
// DISABLING SINCE IT IS CAUSING INSTANT CASTS TO STOP CHARACTER WHILE MOVING. MAYBE CHECK IF CAST TIMER AND THEN DO IT?
// NEXT LINE NO LONGER NEEDED SINCE WE NOW ACTUALLY CHECK THE REAL DISTANCE MOVED BY THE CHARACTER AND DON'T CANCEL CAST UNTIL DISTANCE IS > 0.1F
//source.MyRigidBody.constraints = RigidbodyConstraints.FreezeAll;

if (abilityCastingPrefab != null) {
if (abilityCastingPrefabRef == null) {
Vector3 spawnLocation = new Vector3(source.MyCharacterUnit.transform.position.x + prefabOffset.x, source.MyCharacterUnit.transform.position.y + prefabOffset.y, source.MyCharacterUnit.transform.position.z + prefabOffset.z);
//Debug.Log("BaseAbility.OnCastStart(): Instantiating spell casting prefab at " + source.transform.position + "; spawnLocation is : " + spawnLocation);
//abilityCastingPrefabRef = Instantiate(abilityCastingPrefab, spawnLocation, source.MyCharacterUnit.transform.rotation * Quaternion.Euler(source.MyCharacterUnit.transform.TransformDirection(prefabRotation)), source.transform);
//TESTING GET PROPER ROTATION ON CASTING PREFABS
abilityCastingPrefabRef = Instantiate(abilityCastingPrefab, spawnLocation, Quaternion.LookRotation(source.MyCharacterUnit.transform.forward) * Quaternion.Euler(prefabRotation), source.MyCharacterUnit.transform);
}
}
Expand Down
16 changes: 11 additions & 5 deletions Abilities/Effect/AOEEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,29 @@ public override void CastComplete(BaseCharacter source, GameObject target, Abili
TargetAOEComplete(source, target, abilityAffectInput);
}

private void TargetAOEHit(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput) {
private float TargetAOEHit(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput) {
//Debug.Log(MyName + "AOEEffect.TargetAOEHit(" + (source == null ? "null" : source.name) + ", " + (target == null ? "null" : target.name) + ")");
List<GameObject> validTargets = GetValidTargets(source, target, abilityEffectInput, hitAbilityEffectList);
foreach (GameObject validTarget in validTargets) {
PerformAOEHit(source, validTarget, 1f / validTargets.Count, abilityEffectInput);
}
return validTargets.Count;
}

private void TargetAOETick(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput) {
private float TargetAOETick(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput) {
List<GameObject> validTargets = GetValidTargets(source, target, abilityEffectInput, tickAbilityEffectList);
foreach (GameObject validTarget in validTargets) {
PerformAOETick(source, validTarget, 1f / validTargets.Count, abilityEffectInput);
}
return validTargets.Count;
}

private void TargetAOEComplete(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput) {
private float TargetAOEComplete(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput) {
List<GameObject> validTargets = GetValidTargets(source, target, abilityEffectInput, completeAbilityEffectList);
foreach (GameObject validTarget in validTargets) {
PerformAOEComplete(source, validTarget, 1f / validTargets.Count, abilityEffectInput);
}
return validTargets.Count;
}

private List<GameObject> GetValidTargets(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput, List<AbilityEffect> abilityEffectList) {
Expand All @@ -89,11 +92,14 @@ private List<GameObject> GetValidTargets(BaseCharacter source, GameObject target
}
aoeSpawnCenter += source.MyCharacterUnit.transform.TransformDirection(aoeCenter);
Collider[] colliders = new Collider[0];
int playerMask = 1 << LayerMask.NameToLayer("Player");
int characterMask = 1 << LayerMask.NameToLayer("CharacterUnit");
int validMask = (playerMask | characterMask);
if (useRadius) {
colliders = Physics.OverlapSphere(aoeSpawnCenter, aoeRadius);
colliders = Physics.OverlapSphere(aoeSpawnCenter, aoeRadius, validMask);
}
if (useExtents) {
colliders = Physics.OverlapBox(aoeSpawnCenter, aoeExtents / 2f, source.MyCharacterUnit.transform.rotation);
colliders = Physics.OverlapBox(aoeSpawnCenter, aoeExtents / 2f, source.MyCharacterUnit.transform.rotation, validMask);
}
//Debug.Log("AOEEffect.Cast(): Casting OverlapSphere with radius: " + aoeRadius);
List<GameObject> validTargets = new List<GameObject>();
Expand Down
16 changes: 11 additions & 5 deletions Abilities/Effect/AbilityEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,23 @@ void PerformMaterialChange(BaseCharacter source, GameObject target) {
return;
}
if (target == null) {
Debug.Log("target is null. returning");
//Debug.Log("target is null. returning");
return;
}

Renderer[] meshRenderer = target.GetComponentsInChildren<MeshRenderer>();

if (meshRenderer == null || meshRenderer.Length == 0) {
Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Unable to find mesh renderer in target.");
//Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Unable to find mesh renderer in target.");
meshRenderer = target.GetComponentsInChildren<SkinnedMeshRenderer>();
if (meshRenderer == null || meshRenderer.Length == 0) {
Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Unable to find skinned mesh renderer in target.");
//Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Unable to find skinned mesh renderer in target.");
return;
} else {
Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Found " + meshRenderer.Length + " Skinned Mesh Renderers");
//Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Found " + meshRenderer.Length + " Skinned Mesh Renderers");
}
} else {
Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Found " + meshRenderer.Length + " Mesh Renderers");
//Debug.Log(resourceName + ".AbilityEffect.PerformmaterialChange(): Found " + meshRenderer.Length + " Mesh Renderers");
}


Expand All @@ -282,4 +282,10 @@ void PerformMaterialChange(BaseCharacter source, GameObject target) {
}
}

public AbilityEffectOutput ApplyInputMultiplier(AbilityEffectOutput abilityEffectInput) {
abilityEffectInput.healthAmount = (int)(abilityEffectInput.healthAmount * inputMultiplier);
abilityEffectInput.manaAmount = (int)(abilityEffectInput.manaAmount * inputMultiplier);
return abilityEffectInput;
}

}
1 change: 0 additions & 1 deletion Abilities/Effect/LengthEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public override void Cast(BaseCharacter source, GameObject target, GameObject or
}
base.Cast(source, target, originalTarget, abilityEffectInput);
if (abilityEffectPrefab != null && prefabSpawnLocation != PrefabSpawnLocation.None && (target != null || prefabSpawnLocation == PrefabSpawnLocation.Point || requiresTarget == false)) {
// FIX THIS. ITS ADDING TOO MUCH TOGETHER - FIXED :) - BUT NOW GROUND TARGET IS BROKEN :(
//float finalX = (prefabParent == null ? prefabOffset.x : prefabParent.TransformPoint(prefabOffset).x);
//float finalY = (prefabParent == null ? prefabOffset.y : prefabParent.TransformPoint(prefabOffset).x);
//float finalZ = (prefabParent == null ? prefabOffset.z : prefabParent.TransformPoint(prefabOffset).z);
Expand Down
18 changes: 9 additions & 9 deletions Abilities/Effect/MaterialChangeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ public void Initialize(float changeDuration, Material temporaryMaterial) {
meshRenderers = GetComponentsInChildren<MeshRenderer>();

if (meshRenderers == null || meshRenderers.Length == 0) {
Debug.Log("MaterialChangeController.Initialize(): Unable to find mesh renderer in target.");
//Debug.Log("MaterialChangeController.Initialize(): Unable to find mesh renderer in target.");
meshRenderers = GetComponentsInChildren<SkinnedMeshRenderer>();
if (meshRenderers == null || meshRenderers.Length == 0) {
Debug.Log("MaterialChangeController.Initialize(): Unable to find skinned mesh renderer in target.");
//Debug.Log("MaterialChangeController.Initialize(): Unable to find skinned mesh renderer in target.");
return;
} else {
Debug.Log("MaterialChangeController.Initialize(): Found " + meshRenderers.Length + " Skinned Mesh Renderers");
//Debug.Log("MaterialChangeController.Initialize(): Found " + meshRenderers.Length + " Skinned Mesh Renderers");
}
} else {
Debug.Log("MaterialChangeController.Initialize(): Found " + meshRenderers.Length + " Mesh Renderers");
//Debug.Log("MaterialChangeController.Initialize(): Found " + meshRenderers.Length + " Mesh Renderers");
}

PerformMaterialChange();
}

public void PerformMaterialChange() {
Debug.Log("MaterialChangeController.PerformMaterialChange()");
//Debug.Log("MaterialChangeController.PerformMaterialChange()");

if (meshRenderers == null) {
Debug.Log("MaterialChangeController.PerformMaterialChange(): meshRender is null. This shouldn't happen because we checked before instantiating this!");
//Debug.Log("MaterialChangeController.PerformMaterialChange(): meshRender is null. This shouldn't happen because we checked before instantiating this!");
return;
}
foreach (Renderer renderer in meshRenderers) {
originalMaterials.Add(renderer, renderer.materials);
Debug.Log("MaterialChangeController.PerformMaterialChange(): material length: " + originalMaterials[renderer].Length);
//Debug.Log("MaterialChangeController.PerformMaterialChange(): material length: " + originalMaterials[renderer].Length);
temporaryMaterials = new Material[originalMaterials[renderer].Length];
Debug.Log("MaterialChangeController.PerformMaterialChange(): temporary materials length: " + temporaryMaterials.Length);
//Debug.Log("MaterialChangeController.PerformMaterialChange(): temporary materials length: " + temporaryMaterials.Length);
for (int i = 0; i < originalMaterials[renderer].Length; i++) {
//temporaryMaterials[i] = originalMaterials[renderer][i];
temporaryMaterials[i] = temporaryMaterial;
Expand All @@ -61,7 +61,7 @@ public void PerformMaterialChange() {
public void RevertMaterialChange () {

if (meshRenderers == null) {
Debug.Log("meshRender is null. This shouldn't happen because we checked before instantiating this!");
//Debug.Log("meshRender is null. This shouldn't happen because we checked before instantiating this!");
return;
}

Expand Down
3 changes: 2 additions & 1 deletion Abilities/Effect/ProjectileEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ public class ProjectileEffect : DirectEffect {
public float projectileSpeed = 0;

public override void Cast(BaseCharacter source, GameObject target, GameObject originalTarget, AbilityEffectOutput abilityEffectInput) {
//Debug.Log(abilityEffectName + ".ProjectileAttackEffect.Cast(" + source.name + ", " + target.name + ")");
//Debug.Log(MyName + ".ProjectileAttackEffect.Cast(" + source.name + ", " + target.name + ")");
base.Cast(source, target, originalTarget, abilityEffectInput);
ProjectileScript projectileScript = abilityEffectObject.GetComponent<ProjectileScript>();
if (projectileScript != null) {
abilityEffectInput = ApplyInputMultiplier(abilityEffectInput);
projectileScript.Initialize(projectileSpeed, source, target, new Vector3(0, 1, 0), abilityEffectInput);
projectileScript.OnCollission += HandleCollission;
}
Expand Down
5 changes: 1 addition & 4 deletions Camera/AnyRPGCharacterPreviewCameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ private void LateUpdate() {
cameraPan = false;
cameraZoom = false;

// TESTING MOVE TO BELOW SO ITS UPDATED BASED ON MIDDLE MOUSE PAN
//SetTargetPosition();

// handleZoom
if (!mouseOutsideWindow && InputManager.MyInstance.mouseScrolled) {
//Debug.Log("Mouse Scrollwheel: " + Input.GetAxis("Mouse ScrollWheel"));
Expand Down Expand Up @@ -203,7 +200,7 @@ private void LateUpdate() {
cameraPan = true;
}

// TESTING MOVE TO BELOW SO ITS UPDATED BASED ON MIDDLE MOUSE PAN
// THIS MUST BE DOWN HERE SO ITS UPDATED BASED ON MIDDLE MOUSE PAN
SetTargetPosition();

// follow the player
Expand Down
5 changes: 3 additions & 2 deletions Characters/AI/AICombat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ public override void ClearAggro(GameObject target) {
}
*/

public override void TakeDamage(int damage, Vector3 sourcePosition, BaseCharacter source, CombatType combatType, CombatMagnitude combatMagnitude, string abilityName) {
public override bool TakeDamage(int damage, Vector3 sourcePosition, BaseCharacter source, CombatType combatType, CombatMagnitude combatMagnitude, string abilityName) {
//Debug.Log("AICombat.TakeDamage(" + damage + ", " + sourcePosition + ", " + source + ")");
if (!((baseCharacter.MyCharacterController as AIController).MyCurrentState is EvadeState) && !((baseCharacter.MyCharacterController as AIController).MyCurrentState is DeathState)) {
// order is important here. we want to set target before taking damage because taking damage could kill us, and we don't want to re-trigger and agro on someone after we are dead

// this should happen automatically inside the update loop of idle state
//baseCharacter.MyCharacterController.SetTarget(source);
base.TakeDamage(damage, sourcePosition, source, combatType, combatMagnitude, abilityName);
return base.TakeDamage(damage, sourcePosition, source, combatType, combatMagnitude, abilityName);
}
return false;
}
/*
public override void TakeAbilityDamage(int damage, GameObject source) {
Expand Down
10 changes: 2 additions & 8 deletions Characters/AI/AIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ protected override void Awake() {
baseCharacter = GetComponent<AICharacter>() as ICharacter;
aiPatrol = GetComponent<AIPatrol>();

// just in case this character is spawning not directly on a navmesh (inaccurate editor placement etc) get the closest valid navmesh position
// if one cannot be found, just use the current position anyway
// this will hopefully prevent a character from trying to return to a spawn point that is out of reach, and never exiting return state because the spawn point is never near enough to get inside the hitbox
//Debug.Log(gameObject.name + ".AIController.Awake(): MyStartPosition: " + MyStartPosition);
MyAggroRange = initialAggroRange;
}

Expand All @@ -70,7 +66,7 @@ protected override void Start() {
}
MyStartPosition = (correctedPosition != Vector3.zero ? correctedPosition : transform.position);

// testing this was after the idlestate but that doesn't make sense. hopefully this doesn't break anything
// ensure base.Start is run before change to IdleState
base.Start();

ChangeState(new IdleState());
Expand All @@ -94,7 +90,7 @@ public void ApplyControlEffects(BaseCharacter source) {
masterUnit.MyCharacterCombat.OnDropCombat += OnMasterDropCombat;
(masterUnit.MyCharacterController as PlayerController).OnManualMovement += OnMasterMovement;

// TESTING, DIDN'T CLEAR AGRO TABLE OR NOTIFY REPUTATION CHANGE
// CLEAR AGRO TABLE OR NOTIFY REPUTATION CHANGE - THIS SHOULD PREVENT ATTACKING SOMETHING THAT SUDDENLY IS UNDER CONTROL AND NOW YOUR FACTION WHILE YOU ARE INCOMBAT WITH IT
MyBaseCharacter.MyCharacterCombat.MyAggroTable.ClearTable();
SystemEventManager.MyInstance.NotifyOnReputationChange();
SetMasterRelativeDestination();
Expand Down Expand Up @@ -176,8 +172,6 @@ public void UpdateTarget() {
}
AggroNode topNode;
if (underControl) {
// TESTING FOR MASTER CONTROL
//return;
topNode = masterUnit.MyCharacterCombat.MyAggroTable.MyTopAgroNode;
} else {
topNode = baseCharacter.MyCharacterCombat.MyAggroTable.MyTopAgroNode;
Expand Down
2 changes: 1 addition & 1 deletion Characters/AI/UnitSpawnNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void SpawnWithDelay() {
if ((spawnReferences.Count < GetMaxUnits() || GetMaxUnits() == -1) && MyPrerequisitesMet) {
if (countDownRoutine == null) {
countDownRoutine = StartCoroutine(StartSpawnCountdown(spawnTimer));
// TESTING TO AVOID MULTIPLE SPAWNS DUE TO TRIGGER BY PREREQUISITES ON A NODE WITH A ZERO DELAY TIME -- MOVED INSIDE OUTER ROUTINE CHECK
// AVOID MULTIPLE SPAWNS DUE TO TRIGGER BY PREREQUISITES ON A NODE WITH A ZERO DELAY TIME -- MOVED INSIDE OUTER ROUTINE CHECK
if (delayRoutine == null) {
delayRoutine = StartCoroutine(StartSpawnDelayCountDown());
}
Expand Down
Loading

0 comments on commit 332a3b7

Please sign in to comment.