added auto attack. Fixed superjump bug(setting new state before jump ends)
This commit is contained in:
parent
45b9a1e9c6
commit
19b891a495
@ -295,49 +295,49 @@ AnimatorController:
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: BackToIdle
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Build
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: TreeAttack
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Move
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: SuperJump
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Frozen
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: isMoving
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
|
@ -19,3 +19,4 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
standartAttackGroundImpact: {fileID: 8619867339336636724, guid: fb745cfc34702fc4daee97f8f3273f09,
|
||||
type: 3}
|
||||
throw_SFX: {fileID: 8300000, guid: 9ea918c6c23577f4e885a8490d2f2046, type: 3}
|
||||
|
@ -12,6 +12,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 0169a7715dc4850439785448a35ff4a3, type: 3}
|
||||
m_Name: SuperJump
|
||||
m_EditorClassIdentifier:
|
||||
duration: 3
|
||||
duration: 2.8
|
||||
distance: 1
|
||||
actionType: 4
|
||||
|
@ -76,10 +76,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
owner: 0
|
||||
velocity: 10
|
||||
velocity: 20
|
||||
damage: 100
|
||||
throwSFX: {fileID: 8300000, guid: 9ea918c6c23577f4e885a8490d2f2046, type: 3}
|
||||
ac: {fileID: 0}
|
||||
--- !u!1001 &8121987183007887425
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -14416,7 +14416,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1102420987}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 485a40104d8db9e4fbbbe12d1ff14e39, type: 3}
|
||||
m_Name:
|
||||
@ -20265,6 +20265,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 47d48585e7d7ec5499adf21e4333cb9b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
autoattackDistance: 3
|
||||
--- !u!114 &1503763730
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -20384,7 +20385,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 754e9bf36b6ab0b40a8b71c58aa34b04, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
isAIActive: 0
|
||||
isAIActive: 1
|
||||
botState: 0
|
||||
leftInput: {x: 0, y: 0}
|
||||
rightInput: {x: 0, y: 0}
|
||||
@ -24902,6 +24903,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 47d48585e7d7ec5499adf21e4333cb9b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
autoattackDistance: 3
|
||||
--- !u!136 &1801060032
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -26994,7 +26996,8 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1923264931}
|
||||
m_LocalRotation: {x: 0.029971035, y: 0.000000004076362, z: -0.000000007576159, w: 0.9995508}
|
||||
m_LocalRotation: {x: 0.029971035, y: -0.000000004076362, z: 0.0000000075761575,
|
||||
w: 0.9995508}
|
||||
m_LocalPosition: {x: 0, y: 0.87083435, z: -14.50833}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
@ -27680,7 +27683,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1946816075}
|
||||
m_LocalRotation: {x: 0.5257311, y: 0.0000000073183117, z: -0.0000000045229647, w: 0.85065085}
|
||||
m_LocalRotation: {x: 0.5257311, y: -0.000000007318311, z: 0.000000004522964, w: 0.85065085}
|
||||
m_LocalPosition: {x: 0, y: 13, z: -6.5}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
|
@ -42,6 +42,7 @@ public class ActionTargetingSystem : MonoBehaviour
|
||||
StartCoroutine(Targeting());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator Targeting()
|
||||
{
|
||||
|
@ -5,6 +5,8 @@ using UnityEngine;
|
||||
|
||||
public class ActionTriggerSystem : MonoBehaviour
|
||||
{
|
||||
public int autoattackDistance = 3;
|
||||
|
||||
private PlayerState _playerState;
|
||||
|
||||
public Action OnActionEnd;
|
||||
@ -16,10 +18,52 @@ public class ActionTriggerSystem : MonoBehaviour
|
||||
|
||||
if (_playerState.controlType == ControlType.Player)
|
||||
{
|
||||
CustomInput.OnTouchUp += TryToTriggerCurrentAction;
|
||||
CustomInput.OnTouchUp += TryToTriggerCurrentAction;
|
||||
CustomInput.OnTouchUp += TryToAutoAttack;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void TryToAutoAttack()
|
||||
{
|
||||
PlayerState targetPlayer = null;
|
||||
Debug.Log("auto ");
|
||||
foreach(var enemy in _playerState.enemies)
|
||||
{
|
||||
if (!enemy.gameObject.activeSelf)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Vector3.Distance(_playerState.currentTile.tilePosition, enemy.transform.position) <= 1.1f*autoattackDistance*TileManagment.tileOffset)
|
||||
{
|
||||
targetPlayer = enemy;
|
||||
Debug.Log("I see " + enemy.gameObject.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_playerState.IsAnyActionsAllowed() && _playerState.currentAction.actionType==ActionType.Attack && targetPlayer!=null)
|
||||
{
|
||||
if (!GetComponent<AttackEnergyController>().IsReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
StopAllCoroutines();
|
||||
List<TileInfo> adjacentTiles = TileManagment.GetAllAdjacentTiles(_playerState.currentTile);
|
||||
TileInfo closestTile = adjacentTiles[0];
|
||||
foreach (TileInfo tile in adjacentTiles)
|
||||
{
|
||||
float oldDist = Vector3.Distance(targetPlayer.transform.position, closestTile.tilePosition);
|
||||
float newDist = Vector3.Distance(targetPlayer.transform.position, tile.tilePosition);
|
||||
if (newDist < oldDist)
|
||||
{
|
||||
closestTile = tile;
|
||||
}
|
||||
}
|
||||
_playerState.currentActionTarget = closestTile;
|
||||
DoAction(_playerState.currentAction);
|
||||
}
|
||||
}
|
||||
|
||||
private void TryToTriggerCurrentAction()
|
||||
{
|
||||
|
@ -47,6 +47,18 @@ public class SuperJump : PlayerAction
|
||||
|
||||
var capController = currentPlayer.GetComponent<CaptureController>();
|
||||
|
||||
foreach (var enemy in currentPlayer.enemies)
|
||||
{
|
||||
if (!enemy.gameObject.activeSelf)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (_capTiles.Contains(enemy.currentTile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (TileInfo tile in _capTiles)
|
||||
{
|
||||
if (tile == null)
|
||||
|
@ -57,6 +57,8 @@ public class CaptureController : MonoBehaviour
|
||||
if (tile.easyCaptureFor.Contains(_playerState.ownerIndex) || tile.easyCaptureForAll)
|
||||
{
|
||||
CaptureTile(tile);
|
||||
_playerState.SetNewState(CharacterState.Idle);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -66,6 +68,8 @@ public class CaptureController : MonoBehaviour
|
||||
StartCoroutine(_currentCoroutine);*/
|
||||
|
||||
CaptureTile(tile);
|
||||
_playerState.SetNewState(CharacterState.Idle);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -88,7 +92,8 @@ public class CaptureController : MonoBehaviour
|
||||
if (_playerState.currentTile.tileOwnerIndex != _playerState.ownerIndex)
|
||||
{
|
||||
CaptureTile(_playerState.currentTile);
|
||||
}
|
||||
_playerState.SetNewState(CharacterState.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
private void StopCapturingTile()
|
||||
@ -105,7 +110,7 @@ public class CaptureController : MonoBehaviour
|
||||
public void CaptureTile(TileInfo tile)
|
||||
{
|
||||
TileManagment.ChangeTileOwner(tile, _playerState);
|
||||
_playerState.SetNewState(CharacterState.Idle);
|
||||
//_playerState.SetNewState(CharacterState.Idle);
|
||||
if (capVFX != null)
|
||||
{
|
||||
Instantiate(capVFX, tile.tilePosition + capVFX.transform.position, capVFX.transform.rotation);
|
||||
@ -129,6 +134,7 @@ public class CaptureController : MonoBehaviour
|
||||
|
||||
//OnCaptureEnd?.Invoke(tile, captureTime);
|
||||
CaptureTile(tile);
|
||||
_playerState.SetNewState(CharacterState.Idle);
|
||||
StopCapturingTile();
|
||||
//StopCoroutine(_currentCoroutine);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -127,7 +127,7 @@ PlayerSettings:
|
||||
16:10: 1
|
||||
16:9: 1
|
||||
Others: 1
|
||||
bundleVersion: 0.24
|
||||
bundleVersion: 0.25
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user