protected virtual void OnAbilityActivation(float rotation, byte startFrame, byte activationFrame) { if (currentAbilityActivation != null) { DIContainer.Logger.Warn("Received Ability activation while already having an ability active"); return; } currentAbilityActivation = new AbilityActivationData(rotation, (byte)MathHelper.Modulo(startFrame + FrameDelay, byte.MaxValue), (byte)MathHelper.Modulo(activationFrame + FrameDelay, byte.MaxValue)); }
protected override void OnAbilityActivation(float rotation, byte startFrame, byte activationFrame) { if (currentAbilityActivation != null) { return; } currentAbilityActivation = new AbilityActivationData(rotation, startFrame, activationFrame); telegraphRoot.transform.rotation = Quaternion.Euler(0f, rotation, 0f); modelRoot.transform.rotation = Quaternion.Euler(0f, rotation, 0f); telegraphRoot.gameObject.SetActive(true); telegraphFillRoot.gameObject.SetActive(true); animator.SetTrigger("Attack"); }
private static void activateAbility(CharacterObject characterObject, int turnNumber, AbilityActivationData abilityActivationData) { List <Ability> abilties = characterObject.GetAbilities(); if (abilties.Count > abilityActivationData.abilityIndex && abilties[abilityActivationData.abilityIndex].isEnabled()) { bool success = abilties[abilityActivationData.abilityIndex].run(characterObject, turnNumber, abilityActivationData.attackPoint, abilityActivationData.direction); if (success) { PushEvent(new PlayerActivateAbilityEvent(characterObject.playerId, abilityActivationData.abilityIndex)); } else { //TODO send back forced client update } } else { //TODO send back forced client update } }
protected virtual void UpdateToNextState(byte currentFrame) { int speedPartToModify = 390 / 6; float queueCount = interpolationQueue.Count; float frameDelay = FrameDelay; // quick decrease, slow increase float maxSpeedThisFrame = Mathf.Min(1f, lastMovementSpeedModifier + 0.05f); float minSpeedThisFrame = Mathf.Max(0f, lastMovementSpeedModifier - 0.3f); float movementSpeedModifier = Mathf.Clamp01(Mathf.Clamp(queueCount / frameDelay, minSpeedThisFrame, maxSpeedThisFrame)); int movementSpeedForFrame = (int)(390 - speedPartToModify + (speedPartToModify * movementSpeedModifier)); float movevementDistanceAvailable = UnitValueConverter.ToUnityPosition(movementSpeedForFrame); lastMovementSpeedModifier = movementSpeedModifier; /*DIContainer.Logger.Debug(string.Format("Movement speed for frame: {0} Modifier: {1} QueueCount: {2} Delay: {3}", * movementSpeedForFrame, movementSpeedModifier, interpolationQueue.Count, PositionFrameDelay));*/ if (CurrentStateToLerpTo != null) { AdvanceLerpToPositionState(CurrentStateToLerpTo, ref movevementDistanceAvailable); if (CurrentStateToLerpTo == null) { // to ensure next lerp is started so wait frame that results in a stutter is generated. StartLerpingIfValid(currentFrame, ref movevementDistanceAvailable); } } else if (!StartLerpingIfValid(currentFrame, ref movevementDistanceAvailable)) { /*StringBuilder stringBuilder = new StringBuilder(); * InterpolationState[] stateArray = interpolationQueue.ToArray(); * for (int i = 0; i < stateArray.Length; i++) * { * stringBuilder.Append(stateArray[i].TargetFrame); * stringBuilder.Append(" "); * } * * DIContainer.Logger.Warn(string.Format("No state to update to at frame: {0} existing frames: {1}", currentFrame, stringBuilder));*/ movementChangedCounter++; if (movementChangedCounter > 2 && animator != null) { animator.SetBool("Running", false); } } if (currentAbilityActivation != null && (MatchSimulationUnit.IsFrameInFuture(currentFrame, currentAbilityActivation.StartFrame) || currentFrame == currentAbilityActivation.StartFrame)) { modelRoot.transform.rotation = Quaternion.Euler(0f, currentAbilityActivation.Rotation, 0f); telegraphRoot.transform.rotation = Quaternion.Euler(0f, currentAbilityActivation.Rotation, 0f); if (!currentAbilityActivation.Started) { telegraphRoot.gameObject.SetActive(true); telegraphFillRoot.gameObject.SetActive(true); if (animator != null) { animator.SetTrigger("Attack"); } currentAbilityActivation.Started = true; } if (MatchSimulationUnit.IsFrameInFuture(currentFrame, currentAbilityActivation.ActivationFrame) || currentFrame == currentAbilityActivation.ActivationFrame) { currentAbilityActivation = null; telegraphRoot.gameObject.SetActive(false); telegraphFillRoot.gameObject.SetActive(true); telegraphFillRoot.transform.localScale = new Vector3(0f, 1f, 0f); } else { UpdateTelegraphFillState(currentFrame); } } }