Exemplo n.º 1
0
    //Called when the player is hit by an attack.
    public void TakeHit(Vector2 angle, float magnitude, RPS_Result result)
    {
        hit = true;
        anim.SetTrigger("init_Hit");
        actionable = false;
        Vector2 knockback = angle * magnitude;

        //Changes the character orientation so that their always facing towards the thing that hit them.
        if (knockback.x <= 0)
        {
            if (directionMod < 0)
            {
                transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
            }
        }
        else
        {
            if (directionMod > 0)
            {
                transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
            }
        }
        rb.velocity     = knockback;
        rb.gravityScale = (normalGrav / 2);
        if (result == RPS_Result.Loss)
        {
            Camera.main.GetComponent <ScreenShaker>().shake(20);
        }
        else
        {
            Camera.main.GetComponent <ScreenShaker>().shake(10);
        }
        hitStun = magnitude * 0.05f;
        rb.drag = 3;
    }
Exemplo n.º 2
0
    public static RPS_Result determineWinner(RPS_State hero, RPS_State villian)
    {
        RPS_Result result = RPS_Result.Tie;

        if (hero == RPS_State.Basic && villian != RPS_State.Basic)
        {
            result = RPS_Result.Loss;
        }
        if (hero != RPS_State.Basic && villian == RPS_State.Basic)
        {
            result = RPS_Result.Win;
        }
        if (hero == villian)
        {
            result = RPS_Result.Tie;
        }
        if (hero == RPS_State.Rock)
        {
            if (villian == RPS_State.Paper)
            {
                result = RPS_Result.Loss;
            }

            if (villian == RPS_State.Scissors)
            {
                result = RPS_Result.Win;
            }
        }

        if (hero == RPS_State.Paper)
        {
            if (villian == RPS_State.Rock)
            {
                result = RPS_Result.Win;
            }
            if (villian == RPS_State.Scissors)
            {
                result = RPS_Result.Loss;
            }
        }
        if (hero == RPS_State.Scissors)
        {
            if (villian == RPS_State.Rock)
            {
                result = RPS_Result.Loss;
            }

            if (villian == RPS_State.Paper)
            {
                result = RPS_Result.Win;
            }
        }

        return(result);
    }
Exemplo n.º 3
0
    void CheckForPlayers()
    {
        List <Player> toJunk = new List <Player>();

        foreach (Player p in killablePlayers)
        {
            if (!p.Dizzy())
            {
                toJunk.Add(p);
            }
            else
            {
                RPS_Result result = RPSX.determineWinner(MyState, p.currentState);
                if (result != RPS_Result.Win)
                {
                    toJunk.Add(p);
                }
            }
        }
        if (toJunk.Count != 0)
        {
            for (int i = 0; i < toJunk.Count; i++)
            {
                Player p = toJunk[i];
                killablePlayers.Remove(p);
            }
        }
        for (int i = 0; i < PlayerManager.numberOfPlayers; i++)
        {
            Player p = PlayerManager.players[i];
            if (p.Dizzy())
            {
                RPS_Result result = RPSX.determineWinner(MyState, p.currentState);
                if (result == RPS_Result.Win)
                {
                    killablePlayers.Add(p);
                }
            }
        }
        foreach (Player p in players)
        {
            RPS_Result result = RPSX.determineWinner(MyState, p.currentState);
            if (result == RPS_Result.Win)
            {
                if (p.Dizzy() && canKill())
                {
                    p.KillCharacter(bright);
                }
            }
        }
    }
Exemplo n.º 4
0
    public virtual void hitPlayer(Player player)
    {
        if (!player.Invincible())
        {
            float      effectiveKB  = baseKnockback;
            RPS_Result result       = RPSX.determineWinner(myState, player.currentState);
            float      knockbackX   = (baseKnockbackAngle.x + (stickInputX * KBInfluenceX)) * directionMod;
            float      knockbackY   = baseKnockbackAngle.y + (stickInputY * KBInfluenceY);
            Vector2    effectiveKBA = new Vector2(knockbackX, knockbackY);
            AudioClip  clipToPlay   = null;
            switch (result)
            {
            case RPS_Result.Tie:
                effectiveKB = baseKnockback;
                clipToPlay  = normalHitSound;
                break;

            case RPS_Result.Win:
                effectiveKB = baseKnockback * winKnockbackGrownth;
                clipToPlay  = superHitSound;
                if (PlayerManager.dizzyTotals[player.playerNum - 1] - dizzyDamage <= 0 && !player.Dizzy())
                {
                    SoundManager sm = GameObject.Find("Manager").GetComponent <SoundManager>();
                    player.impactAudio.PlayOneShot(sm.KOSound);
                    player.loopingAudio.clip = sm.DizzySound;
                    player.loopingAudio.Play();
                }
                PlayerManager.TakeDizzy(dizzyDamage, player.playerNum);
                break;
            }
            if (result != RPS_Result.Loss)
            {
                player.TakeHit(effectiveKBA, effectiveKB, result);
                player.impactAudio.PlayOneShot(clipToPlay);
            }
            else
            {
                GameObject parrySpark = Instantiate(Resources.Load("Prefabs/ParrySpark")) as GameObject;
                parrySpark.transform.position = player.gameObject.transform.position;
                parrySpark.GetComponent <SpriteRenderer>().color = RPSX.StateColor(player.currentState);
                if (!player.Dizzy())
                {
                    player.Parry(effectiveKBA);
                    PlayerManager.RecoverDizzy(dizzyDamage, player.playerNum);
                }
                owner.Stagger(effectiveKBA * -1, baseKnockback * 0.5f);
            }
        }
    }
Exemplo n.º 5
0
    void ArrowPoint()
    {
        RPS_Result result = RPSX.determineWinner(players[0].currentState, players[1].currentState);

        if (result == RPS_Result.Win)
        {
            arrow.transform.localScale = new Vector3(1, arrow.transform.localScale.y, arrow.transform.localScale.z);
            arrow.color = lerpingColors[0];
        }
        else if (result == RPS_Result.Loss)
        {
            arrow.transform.localScale = new Vector3(-1, arrow.transform.localScale.y, arrow.transform.localScale.z);
            arrow.color = lerpingColors[1];
        }
        else
        {
            arrow.color = Color.clear;
        }
    }
Exemplo n.º 6
0
    void FindPlayers()
    {
        RPS_Result result = RPSX.determineWinner(PlayerManager.players[0].currentState, PlayerManager.players[1].currentState);

        if (result == RPS_Result.Win)
        {
            owner    = PlayerManager.players[0].transform;
            opponent = PlayerManager.players[1].transform;
            sr.color = RPSX.StateColor(PlayerManager.players[0].currentState);
        }
        else if (result == RPS_Result.Loss)
        {
            owner    = PlayerManager.players[1].transform;
            opponent = PlayerManager.players[0].transform;
            sr.color = RPSX.StateColor(PlayerManager.players[1].currentState);
        }
        else
        {
            owner = GreenRoom;
        }
    }
Exemplo n.º 7
0
    void KeepTrackOfStates(int playerNum)
    {
        Player     player     = players[playerNum];
        Player     opponent   = null;
        RPS_Result result     = RPS_Result.Tie;
        Image      emblem     = emblemDisplays[playerNum];
        Image      stateTimer = stateTimers[playerNum];
        Image      stateBG    = StateBG[playerNum];
        Image      portrait   = portraits[playerNum];
        Image      heart      = hearts[playerNum];
        Image      dizzyMeter = dizzyMeters[playerNum];

        if (playerNum == 0)
        {
            if (numberOfPlayers > 1)
            {
                opponent = players[1];
            }
        }
        else
        {
            opponent = players[0];
        }

        result = RPSX.determineWinner(player.currentState, opponent.currentState);

        if (player.currentState == RPS_State.Rock)
        {
            emblem.sprite     = emblems[1];
            normal[playerNum] = RPSX.rockColor;
            bright[playerNum] = Color.blue;
            dark[playerNum]   = RPSX.rockColorDark;
            faded[playerNum]  = RPSX.rockColorFaded;
        }
        else if (player.currentState == RPS_State.Paper)
        {
            emblem.sprite     = emblems[2];
            normal[playerNum] = RPSX.paperColor;
            bright[playerNum] = Color.green;
            dark[playerNum]   = RPSX.paperColorDark;
            faded[playerNum]  = RPSX.paperColorFaded;
        }
        else if (player.currentState == RPS_State.Scissors)
        {
            emblem.sprite     = emblems[3];
            normal[playerNum] = RPSX.scissorsColor;
            bright[playerNum] = Color.red;
            dark[playerNum]   = RPSX.scissorsColorDark;
            faded[playerNum]  = RPSX.scissorsColorFaded;
        }
        else
        {
            emblem.sprite     = emblems[0];
            normal[playerNum] = Color.white;
            bright[playerNum] = Color.white;
            dark[playerNum]   = Color.white;
            faded[playerNum]  = Color.white;
        }

        lerpingColors[playerNum] = Color.Lerp(bright[playerNum], dark[playerNum], Mathf.PingPong(Time.time * UIFlashSpeed, 1));

        if (result == RPS_Result.Win)
        {
            emblem.color     = lerpingColors[playerNum];
            stateTimer.color = lerpingColors[playerNum];
        }
        else
        {
            emblem.color     = bright[playerNum];
            stateTimer.color = bright[playerNum];
        }
        stateBG.color = faded[playerNum];
        portraitBG[playerNum].color = faded[playerNum];
        stateTimer.color            = bright[playerNum];
        portrait.color   = normal[playerNum];
        heart.color      = normal[playerNum];
        dizzyMeter.color = bright[playerNum];

        healthDisplays[playerNum].text = PlayerManager.healthTotals[playerNum].ToString();
        float currentFillAmount = PlayerManager.maxStateTime - player.timeInState;

        stateTimer.fillAmount = RPSX.fillAmount(currentFillAmount, PlayerManager.maxStateTime);
        if (players[playerNum].Dizzy())
        {
            dizzyMeters[playerNum].fillAmount = PlayerManager.dizzyTimers[playerNum] / PlayerManager.maxDizzyTime;
        }
        else
        {
            dizzyMeters[playerNum].fillAmount = RPSX.fillAmount(PlayerManager.dizzyTotals[playerNum], players[playerNum].maxDizzyHits);
        }

        if (player.Dizzy())
        {
            faces[playerNum].index = 2;
        }
        else if (player.hit)
        {
            faces[playerNum].index = 1;
        }
        else
        {
            faces[playerNum].index = 0;
        }

        if (PlayerManager.dizzyTotals[playerNum] > 6)
        {
            screenCracks[playerNum].index = 0;
        }
        else if (PlayerManager.dizzyTotals[playerNum] <= 6 && PlayerManager.dizzyTotals[playerNum] > 4)
        {
            screenCracks[playerNum].index = 1;
        }
        else if (PlayerManager.dizzyTotals[playerNum] <= 4 && PlayerManager.dizzyTotals[playerNum] > 2)
        {
            screenCracks[playerNum].index = 2;
        }
        else if (PlayerManager.dizzyTotals[playerNum] <= 2 && PlayerManager.dizzyTotals[playerNum] > 0)
        {
            screenCracks[playerNum].index = 3;
        }
        else
        {
            screenCracks[playerNum].index = 4;
        }
    }