示例#1
0
    public void UpdateGauge()
    {
        float i_currentValue = EnergyManager.GetEnergy();

        gaugeFillLerped.fillAmount = Mathf.Lerp(gaugeFillLerped.fillAmount, EnergyManager.GetDisplayedEnergy(), Time.deltaTime * 8);
        gaugeFillRay.fillAmount    = gaugeFillLerped.fillAmount;

        if (Mathf.Abs(i_currentValue - previousValue) >= 0.1f)
        {
            transform.DOShakeScale(0.1f, 0.1f).OnComplete(ResetScale);
        }
        previousValue = i_currentValue;

        if (EnergyManager.GetEnergy() >= 0.99f)
        {
            textAnimator.SetBool("dunkReady", true);
            gaugeFillLerped.color = new Color(fullGaugeColor.r, fullGaugeColor.g, fullGaugeColor.b, gaugeFillLerped.color.a);
            gaugeFillRay.color    = new Color(fullGaugeColor.r, fullGaugeColor.g, fullGaugeColor.b, gaugeFillLerped.color.a);
        }
        else
        {
            gaugeFillLerped.color = new Color(defaultGaugeColor.r, defaultGaugeColor.g, defaultGaugeColor.b, gaugeFillLerped.color.a);
            gaugeFillRay.color    = new Color(defaultGaugeColor.r, defaultGaugeColor.g, defaultGaugeColor.b, gaugeFillLerped.color.a);
            textAnimator.SetBool("dunkReady", false);
        }
    }
示例#2
0
 public bool CanDunk()
 {
     if (isPlayer)
     {
         if (EnergyManager.GetEnergy() < energyCost || dunkState != DunkState.None || passController.GetBall() != null || GameManager.deadPlayers.Count > 0 || currentCD > 0 || playerController.GetOtherPlayer().passController.GetBall() == null)
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
     return(true);
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        bool playable = false;

        // almost certainly dont need to do every frame, only certain events will change this, but for now...
        if (_gamePhaseManager.GamePhase == GamePhase.PlayerTurn)
        {
            if (_card.GetCost() <= _energyManager.GetEnergy())
            {
                playable = true;
            }
        }

        if (playable)
        {
            SetPlayable();
        }
        else
        {
            SetUnplayable();
        }
    }
示例#4
0
    private void UpdateLink()
    {
        if (linkGameObject != null)
        {
            if (firstPawn.moveState == MoveState.Dead || secondPawn.moveState == MoveState.Dead)
            {
                lineRenderer.positionCount = 0; WarningPanel.ClosePanelInstantly(); linkIsBroke = false; return;
            }
            float i_linkLength = Vector3.Distance(firstPawn.transform.position, secondPawn.transform.position);
            if (!linkIsBroke)
            {
                linkMaterial.SetFloat("_CurrentEnergyAmout", EnergyManager.GetEnergy());
                if (i_linkLength < maxDistanceBeforeBreaking)
                {
                    //Hide link
                    lineRenderer.positionCount = 2;
                    lineRenderer.SetPosition(0, firstPawn.GetCenterPosition());
                    lineRenderer.SetPosition(1, secondPawn.GetCenterPosition());
                    linkMaterial.SetFloat("_BreakingLinkProgression", 0);
                    ChangeLinkState(LinkState.Hidden);
                }
                if (i_linkLength >= maxDistanceBeforeShowing && i_linkLength < maxDistanceBeforeSlowing)
                {
                    //Show link
                    lineRenderer.positionCount = 2;
                    lineRenderer.SetPosition(0, firstPawn.GetCenterPosition());
                    lineRenderer.SetPosition(1, secondPawn.GetCenterPosition());
                    float lerpValue = (maxDistanceBeforeSlowing - i_linkLength) / (maxDistanceBeforeSlowing - maxDistanceBeforeShowing);
                    lerpValue = 1f - slowCoefCurve.Evaluate(lerpValue);
                    linkMaterial.SetFloat("_BreakingLinkProgression", 0);
                    ChangeLinkState(LinkState.Showing);
                }
                if (i_linkLength >= maxDistanceBeforeSlowing && i_linkLength < maxDistanceBeforeBreaking)
                {
                    lineRenderer.positionCount = 2;
                    lineRenderer.SetPosition(0, firstPawn.GetCenterPosition());
                    lineRenderer.SetPosition(1, secondPawn.GetCenterPosition());
                    float lerpValue = (maxDistanceBeforeBreaking - i_linkLength) / (maxDistanceBeforeBreaking - maxDistanceBeforeSlowing);
                    lerpValue = 1f - slowCoefCurve.Evaluate(lerpValue);
                    linkMaterial.SetFloat("_BreakingLinkProgression", lerpValue);

                    float slowValue = Mathf.Lerp(1f, maxSlowCoef, lerpValue);

                    //Slow player 1
                    float FcDirectionAngle = Vector3.Angle(firstPawn.transform.forward, secondPawn.transform.position - firstPawn.transform.position);
                    float FcSlowValue      = Mathf.Lerp(1f, slowValue, FcDirectionAngle / 180f);
                    firstPawn.AddSpeedModifier(new SpeedCoef(FcSlowValue, Time.deltaTime, SpeedMultiplierReason.Link, false));

                    //Slow player 2
                    float FsDirectionAngle = Vector3.Angle(secondPawn.transform.forward, firstPawn.transform.position - secondPawn.transform.position);
                    float FsSlowValue      = Mathf.Lerp(1f, slowValue, FsDirectionAngle / 180f);
                    secondPawn.AddSpeedModifier(new SpeedCoef(FsSlowValue, Time.deltaTime, SpeedMultiplierReason.Link, false));
                    ChangeLinkState(LinkState.Slowing);
                }
                if (i_linkLength >= maxDistanceBeforeBreaking)
                {
                    //Break link
                    lineRenderer.positionCount = 0;
                    linkIsBroke = true;
                    ChangeLinkState(LinkState.Broken);
                }
            }
            else
            {
                if (i_linkLength <= distanceBeforeRebuilding)
                {
                    //Rebuild link
                    linkIsBroke = false;
                    ChangeLinkState(LinkState.Rebuilt);
                }
                else
                {
                    damageCount += damagesPerSecWithoutLink * Time.deltaTime;
                    if (damageCount >= 1)
                    {
                        firstPawn.Damage(Mathf.RoundToInt(damageCount));
                        secondPawn.Damage(Mathf.RoundToInt(damageCount));
                        damageCount = 0;
                    }
                }
            }
        }
    }