void PrimeCombos() { for (int i = 0; i < Combos.Count; i++) { tdCombo c = Combos[i]; c.OnInputted = () => { _skip = true; FinalAttack(c.ComboAttack); Invoke(nameof(ResetCombos), c.ComboAttack.LengthDuration); }; } }
void ResetCombos() { _leeway = 0; for (int i = 0; i < _currentCombos.Count; i++) { tdCombo c = Combos[_currentCombos[i]]; c.ResetCombo(); } _currentCombos.Clear(); _anim.SetInteger("anim_state", 0); IsOnComboReset(); }
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)); } }