Skip to content

Commit

Permalink
feat: Moveset changing.
Browse files Browse the repository at this point in the history
Added method to change the current moveset of a entity, along with an event that fires when it happens.
  • Loading branch information
christides11 committed Aug 17, 2020
1 parent 1538651 commit 60c2440
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,14 @@ protected virtual void BoxesMenuNavigationBar()

if (GUILayout.Button("Add", GUILayout.Width(50)))
{
Undo.RecordObject(attack, "Added Box Group");
AddBoxGroup();
}
if (GUILayout.Button("Remove", GUILayout.Width(60)))
{
Undo.RecordObject(attack, "Removed Box Group");
attack.boxGroups.RemoveAt(currentHitboxGroupIndex);
currentHitboxGroupIndex--;
currentHitboxGroupIndex--;
}
}

Expand Down
13 changes: 13 additions & 0 deletions Assets/CAF/Entities/Managers/EntityCombatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class EntityCombatManager : MonoBehaviour, IHurtable
{
public delegate void EntityEmptyAction(EntityManager self);
public delegate void EntityHealthChangedAction(EntityManager initializer, EntityManager self, HitInfoBase hitInfo);
public delegate void EntityMovesetChangedAction(EntityManager self, MovesetDefinition lastMoveset);
public event EntityHealthChangedAction OnHit;
public event EntityHealthChangedAction OnHealed;
public event EntityEmptyAction OnEnterHitStop;
Expand All @@ -18,6 +19,7 @@ public class EntityCombatManager : MonoBehaviour, IHurtable
public event EntityEmptyAction OnHitStunAdded;
public event EntityEmptyAction OnExitHitStop;
public event EntityEmptyAction OnExitHitStun;
public event EntityMovesetChangedAction OnMovesetChanged;

public int Team { get; set; } = 0;
public int HitStun { get; protected set; } = 0;
Expand Down Expand Up @@ -73,6 +75,10 @@ public virtual void SetAttack(MovesetAttackNode attackNode)

public virtual MovesetAttackNode TryAttack()
{
if(CurrentMoveset == null)
{
return null;
}
if(CurrentAttack == null)
{
return CheckStartingNodes();
Expand Down Expand Up @@ -278,6 +284,13 @@ public virtual void AddHitStun(int value)
OnHitStunAdded?.Invoke(controller);
}

public virtual void SetMoveset(MovesetDefinition moveset)
{
MovesetDefinition oldMoveset = CurrentMoveset;
CurrentMoveset = moveset;
OnMovesetChanged?.Invoke(controller, oldMoveset);
}

public virtual HitReaction Hurt(Vector3 center, Vector3 forward, Vector3 right, HitInfoBase hitInfo)
{
HitReaction hr = new HitReaction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ MonoBehaviour:
entityPrefab: {fileID: 8147816337253296054, guid: 566a2b9082a19f54d9a11fabf7eb2be8,
type: 3}
entityStats: {fileID: 11400000, guid: 8146d0caba1679d42a9e707c89dba1cb, type: 2}
movesets:
- {fileID: 11400000, guid: d767c8566af37be4fb1c760ebd85d96f, type: 2}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b727ab7513f07da4ab8ca7d2f6d52cc9, type: 3}
m_Name: Ground_A
m_EditorClassIdentifier:
attackName:
attackName: Ground A
description:
stateOverride: -1
length: 1
length: 45
heightRestriction: 0
gravityScaleAdded: 0
animationGround: {fileID: 0}
Expand All @@ -25,43 +25,39 @@ MonoBehaviour:
enemyStepWindows: []
landCancelWindows: []
commandAttackCancelWindows: []
chargeWindows:
- id: 0
chargeWindows: []
boxGroups:
- id: 1
- id: 0
events: []
references:
version: 1
00000000:
type: {class: ChargeDefinition, ns: CAF.Combat, asm: CAF}
data:
frame: 1
releaseOnCompletion: 1
chargeLevels:
- maxChargeFrames: 30
- maxChargeFrames: 30
- maxChargeFrames: 30
00000001:
type: {class: BoxGroup, ns: CAF.Combat, asm: CAF}
data:
ID: 0
activeFramesStart: 0
activeFramesEnd: 0
activeFramesStart: 5
activeFramesEnd: 8
hitGroupType: 0
boxes: []
attachToEntity: 1
styleGain: 1
hitboxHitInfo:
id: 2
00000002:
type: {class: HitInfo, ns: TDAction.Combat, asm: TDAction}
id: 1
00000001:
type: {class: HitInfo, ns: CAF.Combat, asm: CAF}
data:
forceType: 0
forceRelation: 0
airOnly: 0
groundOnly: 0
hitKills: 1
continuousHit: 0
spaceBetweenHits: 0
opponentResetXForce: 1
opponentResetYForce: 1
attackerHitstop: 0
hitstop: 0
hitstun: 0
forceType: 0
forceRelation: 0
breakArmor: 0
unblockable: 0
knockdown: 0
Expand All @@ -71,12 +67,6 @@ MonoBehaviour:
wallBounceForce: 0
damageOnHit: 0
damageOnBlock: 0
hitKills: 1
attackerHitstop: 0
hitstop: 0
hitstun: 0
opponentResetXForce: 1
opponentResetYForce: 1
causesTumble: 0
opponentForceMagnitude: 1
opponentForceDir: {x: 0, y: 0, z: 1}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
using System.Collections;
using CAF.Input;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TDAction.Entities.Characters.Boxer
{
public class BoxerManager : CharacterManager
{
public override void Initialize(InputControlType controlType)
{
base.Initialize(controlType);
CombatManager.SetMoveset(entityDefinition.movesets[0]);
}

protected override void SetupStates()
{
Expand Down
11 changes: 0 additions & 11 deletions Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs.meta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class EntityDefinition : ScriptableObject
{
[SerializeField] protected EntityManager entityPrefab;
[SerializeField] protected EntityStats entityStats;
[SerializeField] protected List<MovesetDefinition> movesets = new List<MovesetDefinition>();
[SerializeField] public List<MovesetDefinition> movesets = new List<MovesetDefinition>();

public virtual EntityStats GetEntityStats()
{
Expand Down
1 change: 0 additions & 1 deletion TDAction_CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<Compile Include="Assets\CAF\Samples\TDAction\Characters\Shared\States\CWalk.cs" />
<Compile Include="Assets\CAF\Samples\TDAction\Scripts\Camera\CameraHandler.cs" />
<Compile Include="Assets\CAF\Samples\TDAction\Scripts\Combat\Attack\AttackDefinition.cs" />
<Compile Include="Assets\CAF\Samples\TDAction\Scripts\Combat\HitInfo.cs" />
<Compile Include="Assets\CAF\Samples\TDAction\Scripts\Combat\Moveset\MovesetDefinition.cs" />
<Compile Include="Assets\CAF\Samples\TDAction\Scripts\Entities\CharacterController2D.cs" />
<Compile Include="Assets\CAF\Samples\TDAction\Scripts\Entities\EntityDefinition.cs" />
Expand Down

0 comments on commit 60c2440

Please sign in to comment.