void Update() { float hAxis = Input.GetAxis("Horizontal"); _tdBaseEntity.SendMessageToBrain(tdMessageType.Move, hAxis); _tdBaseEntity.OnGround = Physics.Raycast(transform.position + _tdBaseEntity.ColliderOffset, Vector2.down, _tdBaseEntity.GroundLength, tdData.GroundLayer); if (Input.GetKeyDown(KeyCode.Space)) { _tdBaseEntity.JumpTimer = Time.time + _tdBaseEntity.JumpDelay; } _currentComboInput = null; if (Input.GetKeyUp(HeavyKey)) { _currentComboInput = new tdComboInput(tdAttackType.Heavy); } if (Input.GetKeyUp(LightKey)) { _currentComboInput = new tdComboInput(tdAttackType.Light); } if (Input.GetKeyUp(MagicKey)) { _currentComboInput = new tdComboInput(tdAttackType.Magic); } //temp left mouse click if (Input.GetKeyDown(LeftMouseClick)) { _currentComboInput = new tdComboInput(tdAttackType.Light); } }
public bool ContinueCombo(tdComboInput input) { if (Inputs[_curInputIdx].IsSameAs(input)) { _curInputIdx++; //Debug.Log(_curInputIdx); if (_curInputIdx >= Inputs.Count) { DoComboAtk = true; OnInputted.Invoke(); _curInputIdx = 0; } return(true); } else { _curInputIdx = 0; return(false); } }
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)); } }
public bool IsSameAs(tdComboInput comboInput) { return(Type == comboInput.Type); }