Esempio n. 1
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);
    }
Esempio n. 2
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);
    }
Esempio n. 3
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);
    }
Esempio n. 4
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);
    }
Esempio n. 5
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();
    }