Example #1
0
    private void ChangeLinkState(LinkState _newState)
    {
        if (linkState == _newState)
        {
            return;
        }

        switch (_newState)
        {
        case LinkState.Broken:
            FeedbackManager.SendFeedback("event.LinkBroken", firstPawn, firstPawn.GetCenterPosition(), firstPawn.GetCenterPosition() - transform.position, firstPawn.GetCenterPosition() - transform.position);
            FeedbackManager.SendFeedback("event.LinkBroken", secondPawn, secondPawn.GetCenterPosition(), secondPawn.GetCenterPosition() - transform.position, secondPawn.GetCenterPosition() - transform.position);
            WarningPanel.OpenPanel();
            break;

        case LinkState.Rebuilt:
            FeedbackManager.SendFeedback("event.LinkRebuilt", firstPawn, firstPawn.GetCenterPosition(), firstPawn.GetCenterPosition() - transform.position, firstPawn.GetCenterPosition() - transform.position);
            FeedbackManager.SendFeedback("event.LinkRebuilt", secondPawn, secondPawn.GetCenterPosition(), secondPawn.GetCenterPosition() - transform.position, secondPawn.GetCenterPosition() - transform.position);
            WarningPanel.ClosePanel();
            break;

        case LinkState.Showing:
            break;

        case LinkState.Slowing:
            break;

        case LinkState.Hidden:
            break;
        }

        linkState = _newState;
    }
Example #2
0
    public void Dash(Vector3 _direction)
    {
        if (!CanDash())
        {
            return;
        }
        if (playerUI != null)
        {
            playerUI.DisplayDashes();
        }
        Analytics.CustomEvent("PlayerDash", new Dictionary <string, object> {
            { "Zone", GameManager.GetCurrentZoneName() },
        });
        _direction = _direction.normalized;
        Vector3 i_startPosition = transform.position;
        Vector3 i_endPosition   = transform.position + _direction * distance;
        //Check for min distance & maxDistance
        RaycastHit hit;

        if (Physics.Raycast(linkedPawn.GetCenterPosition(), _direction, out hit, distance))
        {
            if (Vector3.Distance(linkedPawn.GetCenterPosition(), hit.point) <= minDistance)
            {
                return;                 //Cancel dash
            }
            else if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Environment"))
            {
                i_endPosition = hit.point - (_direction * 0.5f);
            }
        }
        i_endPosition.y = i_startPosition.y;

        linkedPawn.ChangePawnState("Dashing", Dash_C(i_startPosition, i_endPosition), StopDash_C());
    }
Example #3
0
    void UpdateState()
    {
        switch (enemyState)
        {
        case EnemyState.Hidden:
            CheckDistanceAndAdaptFocus();
            if (CheckIfMustDeploy())
            {
                ChangeState(EnemyState.Deploying);
            }
            break;

        case EnemyState.Idle:
            timeBetweenCheck -= Time.deltaTime;
            if (timeBetweenCheck <= 0)
            {
                CheckDistanceAndAdaptFocus();
                timeBetweenCheck = focusValues.maxTimeBetweenCheck;
            }
            if (focusedPawnController != null)
            {
                ChangeState(EnemyState.Following);
            }
            break;

        case EnemyState.Following:
            timeBetweenCheck -= Time.deltaTime;
            if (timeBetweenCheck <= 0)
            {
                CheckDistanceAndAdaptFocus();
                timeBetweenCheck = focusValues.maxTimeBetweenCheck;
            }

            if (navMeshAgent != null && navMeshAgent.isActiveAndEnabled)
            {
                if (distanceWithFocusedPlayer < focusValues.closestDistanceToplayer)
                {
                    navMeshAgent.isStopped = true;
                }
                else
                {
                    navMeshAgent.isStopped = false;
                    if (focusedPawnController != null)
                    {
                        // Rotate to face the focused player
                        Quaternion i_targetRotation = Quaternion.LookRotation(focusedPawnController.GetCenterPosition() - transform.position);
                        i_targetRotation.eulerAngles = new Vector3(0, i_targetRotation.eulerAngles.y, 0);
                        transform.rotation           = Quaternion.Lerp(transform.rotation, i_targetRotation, attackValues.rotationSpeedPreparingAttack);

                        if (closestSurroundPoint != null)
                        {
                            if (navMeshAgent != null && navMeshAgent.isActiveAndEnabled && GetNavMesh().enabled)
                            {
                                navMeshAgent.SetDestination(UpdateNewDestinationAlongBezierCurve(closestSurroundPoint.position));
                            }
                        }
                        else
                        {
                            if (navMeshAgent != null && navMeshAgent.isActiveAndEnabled && GetNavMesh().enabled)
                            {
                                navMeshAgent.SetDestination(focusedPawnController.transform.position);
                            }
                        }
                    }
                }
            }
            cooldownDuration -= Time.deltaTime;
            if (distanceWithFocusedPlayer <= attackValues.distanceToAttack && cooldownDuration < 0)
            {
                ChangeState(EnemyState.PreparingAttack);
            }
            break;

        case EnemyState.ChangingFocus:
            break;

        case EnemyState.PreparingAttack:
            PreparingAttackState();
            break;

        case EnemyState.Attacking:
            AttackingState();
            break;

        case EnemyState.PauseAfterAttack:
            currentTimePausedAfterAttack -= Time.deltaTime;
            if (currentTimePausedAfterAttack <= 0)
            {
                ChangeState(EnemyState.Idle);
            }
            break;

        case EnemyState.Dying:
            currentDeathWaitTime -= Time.deltaTime;
            if (currentDeathWaitTime < 0)
            {
                Kill();
            }
            break;

        case EnemyState.Deploying:
            currentSpawningAnimDuration -= Time.deltaTime;
            if (currentSpawningAnimDuration < 0)
            {
                ChangeState(EnemyState.Idle);
            }
            break;
        }
    }
Example #4
0
 private void UpdateDunkReadyPanel()
 {
     if (CanDunk() && currentDunkReadyPanel != null)
     {
         if (!currentDunkReadyPanel.activeSelf)
         {
             if (enableDunkReadyPanel)
             {
                 currentDunkReadyPanel.SetActive(true);
             }
         }
         if (currentDunkReadyFX == null)
         {
             currentDunkReadyFX = FeedbackManager.SendFeedback("event.DunkReady", this, pawnController.GetCenterPosition(), Vector3.up, Vector3.up, !isPlayer).GetVFX();
         }
         currentDunkReadyPanel.transform.position = GameManager.mainCamera.WorldToScreenPoint(pawnController.GetHeadPosition());
     }
     else
     {
         if (currentDunkReadyFX != null)
         {
             Destroy(currentDunkReadyFX);
         }
         if (currentDunkReadyPanel.activeSelf)
         {
             currentDunkReadyPanel.SetActive(false);
         }
     }
 }