Esempio n. 1
0
 public static void SetDestination(float time, BaseGameplayRule gameplayRule, MonsterCharacterEntity monsterCharacterEntity, NavMeshAgent navMeshAgent, Vector3 targetPosition)
 {
     monsterCharacterEntity.setDestinationTime = time;
     monsterCharacterEntity.isWandering        = false;
     navMeshAgent.speed = gameplayRule.GetMoveSpeed(monsterCharacterEntity);
     navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.MedQualityObstacleAvoidance;
     navMeshAgent.SetDestination(targetPosition);
     navMeshAgent.isStopped = false;
     monsterCharacterEntity.oldDestination = targetPosition;
 }
Esempio n. 2
0
 public static void SetWanderDestination(float time, BaseGameplayRule gameplayRule, MonsterCharacterEntity monsterCharacterEntity, NavMeshAgent navMeshAgent, Vector3 destination)
 {
     monsterCharacterEntity.setDestinationTime = time;
     monsterCharacterEntity.isWandering        = true;
     monsterCharacterEntity.wanderDestination  = destination;
     navMeshAgent.speed = gameplayRule.GetMoveSpeed(monsterCharacterEntity);
     navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;
     navMeshAgent.SetDestination(monsterCharacterEntity.wanderDestination.Value);
     navMeshAgent.isStopped = false;
 }
    protected static void UpdateAnimation(float deltaTime, BaseGameplayRule gameplayRule, CharacterAnimationComponent animationData, BaseCharacterEntity characterEntity, Transform transform)
    {
        if (characterEntity.isRecaching)
        {
            return;
        }

        // Update current velocity
        animationData.velocityCalculationDeltaTime += deltaTime;
        if (animationData.velocityCalculationDeltaTime >= UPDATE_VELOCITY_DURATION)
        {
            if (!animationData.previousPosition.HasValue)
            {
                animationData.previousPosition = transform.position;
            }
            var currentMoveDistance = transform.position - animationData.previousPosition.Value;
            animationData.currentVelocity              = currentMoveDistance / animationData.velocityCalculationDeltaTime;
            animationData.previousPosition             = transform.position;
            animationData.velocityCalculationDeltaTime = 0f;
        }

        var model = characterEntity.Model;

        if (model != null)
        {
            model.UpdateAnimation(characterEntity.CurrentHp <= 0, animationData.currentVelocity, gameplayRule.GetMoveSpeed(characterEntity) / characterEntity.CacheBaseMoveSpeed);
        }
    }