Exemplo n.º 1
0
    public GameObject GetTeleportationExchangeObject(TeleportationTarget teleportationTarget)
    {
        DiscsOrder order = (teleportationTarget == TeleportationTarget.NewestDisc ? DiscsOrder.FromNewestToOldest :
                            teleportationTarget == TeleportationTarget.OldestDisc ? DiscsOrder.FromOldestToNewest : DiscsOrder.FromNewestToOldest);
        List <DiscScript> discs = DiscListingFactory.GetSortedInRangeDiscs(1, order, true, DiscManager.Instance.GetAllThrowedDiscs, DiscManager.Instance.GetInRangeDiscs);

        if (discs.Count == 0)
        {
            return(null);
        }

        return(discs[0].gameObject);
    }
Exemplo n.º 2
0
    public ActionSelectionResult TrySelectAction(int totalActionPoints, ActionType compType)
    {
        ActionSelectionResult trySelectResult = HasEnoughActionPoints(totalActionPoints, compType);

        if (trySelectResult == ActionSelectionResult.EnoughActionPoints)
        {
            if (compType == ActionType.Throw)
            {
                if (DiscManager.Instance.GetPossessedDiscsCount == 0)
                {
                    trySelectResult = ActionSelectionResult.NotEnoughDiscs;
                }
            }
            else if (compType == ActionType.Recall)
            {
                List <DiscScript> inRange    = DiscManager.Instance.GetInRangeDiscs;
                List <DiscScript> throwed    = DiscManager.Instance.GetAllThrowedDiscs;
                List <DiscScript> recallable = DiscListingFactory.GetSortedRecallableDiscs(recallCompetence, throwed, inRange);
                if (recallable.Count == 0)
                {
                    trySelectResult = ActionSelectionResult.NoNearbyDisc;
                }
            }
            else if (compType == ActionType.Special)
            {
                bool usable = GetSpecialCompetenceUsable(totalActionPoints);
                if (!usable)
                {
                    trySelectResult = ActionSelectionResult.NoNearbyDisc;
                }
            }
            currentActionPoints = totalActionPoints;
        }

        switch (trySelectResult)
        {
        case ActionSelectionResult.EnoughActionPoints:
            ChangeUsabilityState(UsabilityState.Preparing, compType);
            UIManager.Instance.GetActionBar.UpdatePreConsommationPointBar(totalActionPoints, GetCurrentCompetenceCost());
            UIManager.Instance.ShowActionPointsCostText();
            UIManager.Instance.UpdateActionPointCostText(GetCurrentCompetenceCost(), totalActionPoints);
            SoundManager.Instance.PlaySound(Sound.SelectCompetence, Camera.main.transform.position);
            break;

        default:
            SoundManager.Instance.PlaySound(Sound.NotEnoughActionPoint, Camera.main.transform.position);
            break;
        }

        return(trySelectResult);
    }
Exemplo n.º 3
0
    public void UpdateRecallPreparation()
    {
        Vector3 playerPos = _player.transform.position;
        Dictionary <DiscScript, DiscTrajectoryParameters> recallTrajectoryParameters = new Dictionary <DiscScript, DiscTrajectoryParameters>();

        List <DiscScript> recallableDiscs = DiscListingFactory.GetSortedRecallableDiscs(recallCompetence, DiscManager.Instance.GetAllThrowedDiscs, DiscManager.Instance.GetInRangeDiscs);

        foreach (DiscScript discInRange in recallableDiscs)
        {
            DiscTrajectoryParameters newParams =
                DiscTrajectoryFactory.GetTrajectory(recallCompetence, discInRange.transform.position, playerPos,
                                                    DiscManager.Instance.GetAllThrowedDiscs, DiscManager.Instance.GetInRangeDiscs, discInRange);
            recallTrajectoryParameters.Add(discInRange, newParams);
        }

        PreviewCompetencesManager.Instance.UpdateRecallPreview(recallTrajectoryParameters, playerPos);
    }
Exemplo n.º 4
0
    public static Dictionary <DiscScript, DiscTrajectoryParameters> GetDiscInRangeTrajectory(Vector3 targetPosition, CompetenceRecall recallCompetence)
    {
        List <DiscScript> recallableFromPosition =
            DiscListingFactory.GetSortedRecallableDiscs(recallCompetence,
                                                        DiscManager.Instance.GetAllThrowedDiscs, DiscManager.Instance.GetAllInRangeDiscsFromPosition(targetPosition));

        Dictionary <DiscScript, DiscTrajectoryParameters> allTrajParams = new Dictionary <DiscScript, DiscTrajectoryParameters>();

        foreach (DiscScript disc in recallableFromPosition)
        {
            DiscTrajectoryParameters newTrajParams =
                DiscTrajectoryFactory.GetTrajectory(recallCompetence, disc.transform.position, targetPosition,
                                                    DiscManager.Instance.GetAllThrowedDiscs, DiscManager.Instance.GetInRangeDiscs, disc);

            allTrajParams.Add(disc, newTrajParams);
        }
        return(allTrajParams);
    }
Exemplo n.º 5
0
    public bool GetRecallCompetenceUsable(int currentActionPoints)
    {
        bool usable = true;

        List <DiscScript> inRange    = DiscManager.Instance.GetInRangeDiscs;
        List <DiscScript> throwed    = DiscManager.Instance.GetAllThrowedDiscs;
        List <DiscScript> recallable = DiscListingFactory.GetSortedRecallableDiscs(recallCompetence, throwed, inRange);

        if (recallCompetence.GetActionPointsCost > currentActionPoints)
        {
            return(false);
        }
        else if (recallable.Count == 0)
        {
            return(false);
        }

        return(usable);
    }
Exemplo n.º 6
0
    public void LaunchRecallCompetenceForReal()
    {
        currentlyInUseDiscs = new List <DiscScript>();
        List <DiscScript> discsToRecall = DiscListingFactory.GetSortedRecallableDiscs(recallCompetence, DiscManager.Instance.GetAllThrowedDiscs, DiscManager.Instance.GetInRangeDiscs);

        foreach (DiscScript discToRecall in discsToRecall)
        {
            StartRecallDisc(discToRecall);
        }

        if (discsToRecall.Count > 0)
        {
            ChangeUsabilityState(UsabilityState.Using, ActionType.Recall);
        }
        else
        {
            ResetUsabilityState();
        }
        CameraManager.instance.GetPlayerCamera.ResetPlayerCamera();
    }
    public void StartMovementPreview(List <float> distances, List <Vector3> trajectory, CompetenceRecall currentRecallComp, int completelyUsedActionPoints, bool reachMax)
    {
        hitByDiscTrajectories = new Dictionary <DiscScript, Dictionary <GameObject, EnemyBase> >();

        movementGhostPreview.GetRenderer.material = baseGhostMaterial;

        Vector3 startPosition  = trajectory[0];
        Vector3 targetPosition = trajectory[trajectory.Count - 1];

        #region Circles
        if (showMovementCircles)
        {
            int newNumber = distances.Count;
            if (newNumber > movementCirclePreviews.Count)
            {
                for (int i = movementCirclePreviews.Count; i < newNumber; i++)
                {
                    MovementCirclePreview newMovementCirclePreview = Instantiate(movementCirclePreviewPrefab, movementPreviewsParent);
                    newMovementCirclePreview.ShowPreview();
                    movementCirclePreviews.Add(newMovementCirclePreview);
                }
            }

            Vector3 circlePos = new Vector3(startPosition.x, 0.01f, startPosition.z);
            for (int i = 0; i < newNumber; i++)
            {
                movementCirclePreviews[i].ShowPreview();
                movementCirclePreviews[i].ChangeRadius(distances[i]);
                movementCirclePreviews[i].transform.position = circlePos;
            }

            for (int i = newNumber; i < movementCirclePreviews.Count; i++)
            {
                movementCirclePreviews[i].HidePreview();
            }
        }
        #endregion

        currentMovementDistances = distances;

        movementLinePreview.ShowPreview();
        movementLinePreview.UpdateLine(trajectory, currentMovementDistances, completelyUsedActionPoints, reachMax);

        movementGhostPreview.ShowPreview();
        movementGhostPreview.transform.position = trajectory[trajectory.Count - 1];

        Dictionary <DiscScript, DiscTrajectoryParameters> discsInNewPositionRangeParameters = DiscListingFactory.GetDiscInRangeTrajectory(targetPosition, currentRecallComp);
        StartRecallPreview(discsInNewPositionRangeParameters, targetPosition);

        justStartedMovementPreview = true;
        UpdateMovementPreview(trajectory, currentRecallComp, completelyUsedActionPoints, reachMax);

        foreach (EnemyBase enemy in EnemiesManager.Instance.GetAllInGameEnemiesOrdered)
        {
            enemy.DisplayAndActualisePreviewAttack(movementGhostPreview.transform);
        }
    }
    public void UpdateTeleportationPreview(Vector3 position, bool canTeleport, CompetenceRecall currentRecallComp)
    {
        movementGhostPreview.GetRenderer.material = canTeleport ? baseGhostMaterial : cantMoveThereMaterial;
        movementGhostPreview.transform.position   = position;

        Dictionary <DiscScript, DiscTrajectoryParameters> discsInNewPositionRangeParameters = DiscListingFactory.GetDiscInRangeTrajectory(position, currentRecallComp);

        UpdateRecallPreview(discsInNewPositionRangeParameters, position);
    }
    public void StartTeleportationPreview(Vector3 startPos, Vector3 targetPos, bool canTeleport, CompetenceRecall currentRecallComp)
    {
        hitByDiscTrajectories = new Dictionary <DiscScript, Dictionary <GameObject, EnemyBase> >();

        movementGhostPreview.GetRenderer.material = canTeleport ? baseGhostMaterial : cantMoveThereMaterial;
        discEffectZonePreview.gameObject.SetActive(true);
        discEffectZonePreview.transform.localScale = Vector3.one * DiscManager.Instance.recallRange;
        discEffectZonePreview.transform.position   = startPos + Vector3.up * 0.01f;

        movementGhostPreview.gameObject.SetActive(true);
        movementGhostPreview.transform.position = targetPos;

        Dictionary <DiscScript, DiscTrajectoryParameters> discsInNewPositionRangeParameters = DiscListingFactory.GetDiscInRangeTrajectory(targetPos, currentRecallComp);

        StartRecallPreview(discsInNewPositionRangeParameters, targetPos);

        foreach (EnemyBase enemy in EnemiesManager.Instance.GetAllInGameEnemiesOrdered)
        {
            enemy.DisplayAndActualisePreviewAttack(movementGhostPreview.transform);
        }
    }
    public void UpdateMovementPreview(List <Vector3> trajectory, CompetenceRecall currentRecallComp, int completelyUsedActionPoints, bool reachMax)
    {
        Vector3 startPosition  = trajectory[0];
        Vector3 targetPosition = trajectory[trajectory.Count - 1];

        movementLinePreview.UpdateLine(trajectory, currentMovementDistances, completelyUsedActionPoints, reachMax);
        movementGhostPreview.transform.position = targetPosition;

        if (!justStartedMovementPreview)
        {
            Dictionary <DiscScript, DiscTrajectoryParameters> discsInNewPositionRangeParameters = DiscListingFactory.GetDiscInRangeTrajectory(targetPosition, currentRecallComp);
            UpdateRecallPreview(discsInNewPositionRangeParameters, targetPosition);
        }
        else
        {
            justStartedMovementPreview = false;
        }
    }