public override void OnStateEnter(object[] args) { if (args != null) { tdAttack currentAtk = (tdAttack)args[0]; Entity.AnimCtrl.SetInteger("anim_state", (int)currentAtk.AnimState); } }
void FinalAttack(tdAttack atk) { IsOnCombo = true; _currentAttack = atk; _attackTimer = atk.LengthDuration; Debug.Log(_currentAttack.Name + " ");// + _currentAttack.LengthDuration); _entity.SendMessageToBrain(tdMessageType.Attack, atk); Invoke(nameof(IsOnComboReset), _attackTimer); }
public override void OnReceiveMessage(tdMessageType msgType, object[] args) { switch (msgType) { //TODO continuous combo case tdMessageType.Attack: tdAttack currentAtk = (tdAttack)args[0]; Entity.AnimCtrl.SetInteger("anim_state", (int)currentAtk.AnimState); break; case tdMessageType.Flinch: break; } }
void ComboLogic() { //when final atk is happenning if (_currentAttack != null) { if (_attackTimer > 0) { _attackTimer -= Time.deltaTime; } else { _currentAttack = null; } return; } //check if player is beyond leeway time if (_currentCombos.Count > 0) { _leeway += Time.deltaTime; if (_leeway >= ComboLeeway) { if (_lastInput != null) { // FinalAttack(GetAttackFromType(_lastInput.Type)); _lastInput = null; } ResetCombos(); } } else { _leeway = 0; } //inputs.. TODO separate the one on player and AI tdComboInput input = null; if (_playerController != null) { input = _playerController.GetCurrentInput(); Debug.Log(input); } if (input == null) { return; } _lastInput = input; //continue combo reference List <int> removeCombo = new List <int>(); for (int i = 0; i < _currentCombos.Count; i++) { tdCombo c = Combos[_currentCombos[i]]; if (c.ContinueCombo(input) && !c.DoComboAtk) { //TODO send message to brain ChainAttack(GetAttackFromType(_lastInput.Type)); _leeway = 0; } else { removeCombo.Add(i); } } if (_skip) { _skip = false; return; } //checking combo list for (int i = 0; i < Combos.Count; i++) { if (_currentCombos.Contains(i)) { continue; } if (Combos[i].ContinueCombo(input)) { //TODO send message to entity brain ChainAttack(GetAttackFromType(_lastInput.Type)); _currentCombos.Add(i); _leeway = 0; } } //this will cause bugs later... foreach (int i in removeCombo) { _currentCombos.RemoveAt(i); } //get the combo if (_currentCombos.Count <= 0) { //TODO send message to brain FinalAttack(GetAttackFromType(input.Type)); } }
//do something regards to this haha void ChainAttack(tdAttack chainAtk) { IsOnCombo = true; //Debug.Log(chainAtk.Name); _entity.SendMessageToBrain(tdMessageType.Attack, chainAtk); }