Example #1
0
    public virtual void Defeated(PunchInfo punchInfo)
    {
        string trigger = "Defeated";

        if (punchInfo.PunchRawLocal.x == -1)
        {
            trigger += "Left";
        }
        else if (punchInfo.PunchRawLocal.x == 1)
        {
            trigger += "Right";
        }
        else
        {
            print("Error in X input of PunchInfo");
        }

        anim.SetTrigger(trigger);
        CurrentKnockouts++;
        if (CurrentKnockouts < 3)
        {
            KnockedOut = true;
            anim.SetBool("Recovered", true);
        }
    }
Example #2
0
 public void ProcessHit(PunchInfo info, float damage)
 {
     photonView.RPC("DamagePlayer", PhotonTargets.Others, damage, index);
     healthPoints.runTimeValue -= damage;
     audioSource.PlayOneShot(grunts.GetRandom());
     PlayRandomHitAnimation();
 }
Example #3
0
 public void Hit(PunchInfo info)
 {
     if (onHit != null)
     {
         onHit.Invoke(info, CalculateDamage(info.velocity, damageMultiplier.runTimeValue, info.charge));
     }
 }
Example #4
0
    public virtual void Damaged(PunchInfo punchInfo)
    {
        CurrentHealth -= punchInfo.Damage;
        string Trigger = "Recieve";

        if (punchInfo.Hard)
        {
            Trigger += "Hard";
        }

        if (punchInfo.PunchRawLocal.y == -1)
        {
            Trigger += "Bottom";
        }
        else if (punchInfo.PunchRawLocal.y == 1)
        {
            Trigger += "Up";
        }
        else
        {
            print("Error in Y input of PunchInfo");
        }

        if (punchInfo.PunchRawLocal.x == -1)
        {
            Trigger += "Left";
        }
        else if (punchInfo.PunchRawLocal.x == 1)
        {
            Trigger += "Right";
        }
        else
        {
            print("Error in X input of PunchInfo");
        }

        if (!punchInfo.Hard)
        {
            cam.CamShake(0.06f, 0.1f);
        }
        else
        {
            cam.CamShake(0.2f, 0.3f);
        }

        if (CurrentHealth <= 0)
        {
            Defeated(punchInfo);
            return;
        }

        anim.SetTrigger(Trigger);

        if (stateinfo.Punching || stateinfo.HardPunching)
        {
            print("i get punch whlie i punch");
            StartCoroutine(FailedRecuperation(punchInfo));
        }
    }
Example #5
0
 public void ProcessHit(PunchInfo info, float damage)
 {
     healthPoints -= damage;
     Debug.Log("damage: " + damage);
     if (healthPoints <= 0)
     {
         KnockOut();
     }
 }
Example #6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.transform.tag == "Receptor")
     {
         Recieve = true;
         Charctr.PunchRecieved = true;
         PunchInfo info = collision.transform.GetComponent <ReceptorScript>().Info;
         if (gameObject.transform.parent.name.Contains("Blocking"))
         {
             Charctr.Blocked(info);
             return;
         }
         Charctr.Damaged(info);
     }
 }
Example #7
0
    IEnumerator FailedRecuperation(PunchInfo punchInfo)
    {
        anim.SetBool("PunchFailed", true);
        PunchFailed = true;
        float rectime = PFailedRecuperationTime;

        if (punchInfo.Hard)
        {
            rectime = rectime * 1.5f;
        }


        yield return(new WaitForSeconds(rectime));

        anim.SetBool("PunchFailed", false);
        PunchFailed = false;
    }
Example #8
0
 public virtual void Damaged(PunchInfo punchInfo)
 {
     CurrentHealth -= punchInfo.Damage;
     if (!punchInfo.Hard)
     {
         if (punchInfo.PunchRawLocal.y == -1)
         {
             if (punchInfo.PunchRawLocal.x == -1)
             {
             }
         }
     }
     if (CurrentHealth <= 0)
     {
         Defeated();
         return;
     }
 }
Example #9
0
 public virtual void Blocked(PunchInfo info)
 {
     anim.SetTrigger("Blocked");
 }
Example #10
0
    // Update is called once per frame
    public override void UpdateThis()
    {
        base.UpdateThis();

        actualtime = Time.time;

        AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);



        if (Player.Punch && stateInfo.IsName("BlockV"))
        {
            Player.Punch = false;
            float     rand2block = Random.Range(0f, 100f);
            float     rand2Dodge = Random.Range(0f, 100f);
            PunchInfo inf        = Player.info;
            if (!inf.Hard)
            {
                float AuxProbDodge = PDodge / 2;
                if (inf.PunchRawLocal.y == -1f)
                {
                    bool IsBlock = rand2block < PbottomBlock;
                    bool IsDodge = rand2Dodge < AuxProbDodge;
                    if (IsBlock)
                    {
                        BlockDir = -1;
                        Blocking = true;
                    }
                    else if (IsDodge)
                    {
                        if (inf.PunchRawLocal.x == -1)
                        {
                            anim.SetTrigger("DodgeLeft");
                        }
                        else
                        {
                            anim.SetTrigger("DodgeRight");
                        }
                    }
                }
                else if (inf.PunchRawLocal.y == 1f)
                {
                    bool IsBlock = rand2block < PupBlock;
                    bool IsDodge = rand2Dodge < AuxProbDodge;
                    if (IsBlock)
                    {
                        BlockDir = 1;
                        Blocking = true;
                    }
                    else if (IsDodge)
                    {
                        if (inf.PunchRawLocal.x == -1)
                        {
                            anim.SetTrigger("DodgeLeft");
                        }
                        else
                        {
                            anim.SetTrigger("DodgeRight");
                        }
                    }
                }
            }
            else
            {
                if (inf.PunchRawLocal.y == -1f)
                {
                    bool IsBlock = rand2block < PbottomBlock;
                    bool IsDodge = rand2Dodge < 1.5f * PDodge;
                    if (IsDodge)
                    {
                        if (inf.PunchRawLocal.x == -1)
                        {
                            anim.SetTrigger("DodgeLeft");
                        }
                        else
                        {
                            anim.SetTrigger("DodgeRight");
                        }
                    }
                    if (IsBlock)
                    {
                        BlockDir = -1;
                        Blocking = true;
                    }
                }
                else if (inf.PunchRawLocal.y == 1f)
                {
                    bool IsBlock = rand2block < PupBlock;
                    bool IsDodge = rand2Dodge < 2 * PDodge;

                    if (IsDodge)
                    {
                        if (inf.PunchRawLocal.x == -1)
                        {
                            anim.SetTrigger("DodgeLeft");
                        }
                        else
                        {
                            anim.SetTrigger("DodgeRight");
                        }
                    }
                    else if (IsBlock)
                    {
                        BlockDir = 1;
                        Blocking = true;
                    }
                }
            }
        }
        float time = Time.time;

        if (PunchRecieved)
        {
            Blocking      = false;
            PunchRecieved = false;
        }
        if (BlockUp.Recieve)
        {
            print("Blocked UP");
        }

        if (!Blocking)
        {
            BlockDir = 0;
        }

        anim.SetFloat("Blockv", BlockDir);

        bool Trigg = Time.time - StartTime > time2NextCombo;

        if (Trigg)
        {
            StartTime      = Time.time;
            time2NextCombo = Random.Range(ClampedTimeA, ClampedTimeB);
            float B      = Random.Range(1f, 2f) - 1;
            int   WCombo = B < 0.5 ? 1 : 2;
            print(B + " is " + WCombo);
            if (stateInfo.IsName("BlockV"))
            {
                anim.SetTrigger("Combo" + WCombo);
            }
        }

        Player.Punch = false;
    }