added auto attack. Fixed superjump bug(setting new state before jump ends)

This commit is contained in:
AlexMamontow 2021-09-09 16:02:24 +03:00
parent 45b9a1e9c6
commit 19b891a495
11 changed files with 96 additions and 629 deletions

View File

@ -295,49 +295,49 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: BackToIdle - m_Name: BackToIdle
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Build - m_Name: Build
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: TreeAttack - m_Name: TreeAttack
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Move - m_Name: Move
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: SuperJump - m_Name: SuperJump
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Frozen - m_Name: Frozen
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: isMoving - m_Name: isMoving
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer

View File

@ -19,3 +19,4 @@ MonoBehaviour:
type: 3} type: 3}
standartAttackGroundImpact: {fileID: 8619867339336636724, guid: fb745cfc34702fc4daee97f8f3273f09, standartAttackGroundImpact: {fileID: 8619867339336636724, guid: fb745cfc34702fc4daee97f8f3273f09,
type: 3} type: 3}
throw_SFX: {fileID: 8300000, guid: 9ea918c6c23577f4e885a8490d2f2046, type: 3}

View File

@ -12,6 +12,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0169a7715dc4850439785448a35ff4a3, type: 3} m_Script: {fileID: 11500000, guid: 0169a7715dc4850439785448a35ff4a3, type: 3}
m_Name: SuperJump m_Name: SuperJump
m_EditorClassIdentifier: m_EditorClassIdentifier:
duration: 3 duration: 2.8
distance: 1 distance: 1
actionType: 4 actionType: 4

View File

@ -76,10 +76,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
owner: 0 owner: 0
velocity: 10 velocity: 20
damage: 100 damage: 100
throwSFX: {fileID: 8300000, guid: 9ea918c6c23577f4e885a8490d2f2046, type: 3}
ac: {fileID: 0}
--- !u!1001 &8121987183007887425 --- !u!1001 &8121987183007887425
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -14416,7 +14416,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102420987} m_GameObject: {fileID: 1102420987}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 485a40104d8db9e4fbbbe12d1ff14e39, type: 3} m_Script: {fileID: 11500000, guid: 485a40104d8db9e4fbbbe12d1ff14e39, type: 3}
m_Name: m_Name:
@ -20265,6 +20265,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 47d48585e7d7ec5499adf21e4333cb9b, type: 3} m_Script: {fileID: 11500000, guid: 47d48585e7d7ec5499adf21e4333cb9b, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
autoattackDistance: 3
--- !u!114 &1503763730 --- !u!114 &1503763730
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -20384,7 +20385,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 754e9bf36b6ab0b40a8b71c58aa34b04, type: 3} m_Script: {fileID: 11500000, guid: 754e9bf36b6ab0b40a8b71c58aa34b04, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
isAIActive: 0 isAIActive: 1
botState: 0 botState: 0
leftInput: {x: 0, y: 0} leftInput: {x: 0, y: 0}
rightInput: {x: 0, y: 0} rightInput: {x: 0, y: 0}
@ -24902,6 +24903,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 47d48585e7d7ec5499adf21e4333cb9b, type: 3} m_Script: {fileID: 11500000, guid: 47d48585e7d7ec5499adf21e4333cb9b, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
autoattackDistance: 3
--- !u!136 &1801060032 --- !u!136 &1801060032
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -26994,7 +26996,8 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1923264931} 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_LocalPosition: {x: 0, y: 0.87083435, z: -14.50833}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
@ -27680,7 +27683,7 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1946816075} 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_LocalPosition: {x: 0, y: 13, z: -6.5}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:

View File

@ -43,6 +43,7 @@ public class ActionTargetingSystem : MonoBehaviour
} }
} }
private IEnumerator Targeting() private IEnumerator Targeting()
{ {

View File

@ -5,6 +5,8 @@ using UnityEngine;
public class ActionTriggerSystem : MonoBehaviour public class ActionTriggerSystem : MonoBehaviour
{ {
public int autoattackDistance = 3;
private PlayerState _playerState; private PlayerState _playerState;
public Action OnActionEnd; public Action OnActionEnd;
@ -17,10 +19,52 @@ public class ActionTriggerSystem : MonoBehaviour
if (_playerState.controlType == ControlType.Player) 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() private void TryToTriggerCurrentAction()
{ {

View File

@ -47,6 +47,18 @@ public class SuperJump : PlayerAction
var capController = currentPlayer.GetComponent<CaptureController>(); 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) foreach (TileInfo tile in _capTiles)
{ {
if (tile == null) if (tile == null)

View File

@ -57,6 +57,8 @@ public class CaptureController : MonoBehaviour
if (tile.easyCaptureFor.Contains(_playerState.ownerIndex) || tile.easyCaptureForAll) if (tile.easyCaptureFor.Contains(_playerState.ownerIndex) || tile.easyCaptureForAll)
{ {
CaptureTile(tile); CaptureTile(tile);
_playerState.SetNewState(CharacterState.Idle);
} }
else else
{ {
@ -66,6 +68,8 @@ public class CaptureController : MonoBehaviour
StartCoroutine(_currentCoroutine);*/ StartCoroutine(_currentCoroutine);*/
CaptureTile(tile); CaptureTile(tile);
_playerState.SetNewState(CharacterState.Idle);
} }
else else
{ {
@ -88,6 +92,7 @@ public class CaptureController : MonoBehaviour
if (_playerState.currentTile.tileOwnerIndex != _playerState.ownerIndex) if (_playerState.currentTile.tileOwnerIndex != _playerState.ownerIndex)
{ {
CaptureTile(_playerState.currentTile); CaptureTile(_playerState.currentTile);
_playerState.SetNewState(CharacterState.Idle);
} }
} }
@ -105,7 +110,7 @@ public class CaptureController : MonoBehaviour
public void CaptureTile(TileInfo tile) public void CaptureTile(TileInfo tile)
{ {
TileManagment.ChangeTileOwner(tile, _playerState); TileManagment.ChangeTileOwner(tile, _playerState);
_playerState.SetNewState(CharacterState.Idle); //_playerState.SetNewState(CharacterState.Idle);
if (capVFX != null) if (capVFX != null)
{ {
Instantiate(capVFX, tile.tilePosition + capVFX.transform.position, capVFX.transform.rotation); Instantiate(capVFX, tile.tilePosition + capVFX.transform.position, capVFX.transform.rotation);
@ -129,6 +134,7 @@ public class CaptureController : MonoBehaviour
//OnCaptureEnd?.Invoke(tile, captureTime); //OnCaptureEnd?.Invoke(tile, captureTime);
CaptureTile(tile); CaptureTile(tile);
_playerState.SetNewState(CharacterState.Idle);
StopCapturingTile(); StopCapturingTile();
//StopCoroutine(_currentCoroutine); //StopCoroutine(_currentCoroutine);
} }

File diff suppressed because one or more lines are too long

View File

@ -127,7 +127,7 @@ PlayerSettings:
16:10: 1 16:10: 1
16:9: 1 16:9: 1
Others: 1 Others: 1
bundleVersion: 0.24 bundleVersion: 0.25
preloadedAssets: [] preloadedAssets: []
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0