Exemple #1
0
 public override void onInterrupt(float stunTime, bool successfulHit, hitbox hb)
 {
     if (rapidRecovery)
     {
         GetComponent <Fighter>().recoveryTime = GetComponent <Fighter>().recoveryTime * 0.5f;
     }
 }
Exemple #2
0
    public override void onInterrupt(float stunTime, bool successfulHit, hitbox hb)
    {
//		Debug.Log ("on Interrupt");
        if (counterAttack && !successfulHit && timeSinceStart > startUpTime && timeSinceStart < (startUpTime + resistanceTime))
        {
            fighter.endAttack();
            fighter.tryAttack(counterAttackType);
        }
    }
Exemple #3
0
    public string takeHit(hitbox hb)
    {
        if (hb.mAttr != null)
        {
            foreach (string k in resistences.Keys)
            {
                if (hb.mAttr.BinarySearch(k) != null)
                {
                    if (GetComponent <Fighter> ())
                    {
                        Debug.Log("registering stun");
                        GetComponent <Fighter> ().registerStun(hb.stun, false, hb);
                    }
                    if (k == "shot")
                    {
                        return("reflect");
                    }
                    return("block");
                }
            }
        }

        damageObj(hb.damage);
        if (mHitSound != "None")
        {
//			FindObjectOfType<GameManager> ().soundfx.gameObject.transform.Find (mHitSound).GetComponent<AudioSource> ().Play ();
        }
        AudioSource.PlayClipAtPoint(Hit, gameObject.transform.position);
        if (gameObject.GetComponent <Movement> ())
        {
            if (hb.fixedKnockback)
            {
                addToVelocity(hb.knockback);
            }
            else
            {
                Vector3 otherPos  = hb.gameObject.transform.position;
                float   angle     = Mathf.Atan2(transform.position.y - otherPos.y, transform.position.x - otherPos.x);            //*180.0f / Mathf.PI;
                float   magnitude = hb.knockback.magnitude;
                float   forceX    = Mathf.Cos(angle) * magnitude;
                float   forceY    = Mathf.Sin(angle) * magnitude;
                Vector2 force     = new Vector2(forceX, forceY);
                float   counterF  = (gameObject.GetComponent <Movement> ().velocity.y *(1 / Time.deltaTime));
                if (counterF < 0)
                {
                    force.y = force.y - counterF;
                }
                addToVelocity(force);
            }
        }
        if (hb.stun > 0 && GetComponent <Fighter> ())
        {
            GetComponent <Fighter> ().registerStun(hb.stun, true, hb);
        }
        return("hit");
    }
Exemple #4
0
 public void registerStun(float st, bool defaultStun, hitbox hb)
 {
     if (defaultStun)
     {
         //Debug.Log ("stunning?");
         startHitState(st);
     }
     if (currentAttack != null)
     {
         currentAttack.onInterrupt(stunTime, defaultStun, hb);
     }
 }
    public static float sKick(string color, hitbox h)
    {
        if (h == hitbox.rf && color == "Red")
        {
            return(15f);
        }

        if (h == hitbox.lf && color == "Blue")
        {
            return(15f);
        }

        return(0f);
    }
    public static float sPunch(string color, hitbox h)
    {
        if (h == hitbox.rh && color == "Red")
        {
            return(20f);
        }

        if (h == hitbox.lh && color == "Blue")
        {
            return(20f);
        }

        return(0f);
    }
Exemple #7
0
    public Projectile fire(Vector2 offset, bool facingLeft, string faction)
    {
        Vector3    newPos = new Vector3(transform.position.x + offset.x, transform.position.y + offset.y, 0);
        GameObject go     = Instantiate(projectile, newPos, Quaternion.identity) as GameObject;
        Projectile proj   = go.GetComponent <Projectile> ();
        hitbox     newBox = go.GetComponent <hitbox> ();

        newBox.setFaction(faction);
        if (facingLeft)
        {
            SpriteRenderer sprite = go.GetComponent <SpriteRenderer> ();
            sprite.flipX         = true;
            proj.projectileSpeed = new Vector3(-proj.projectileSpeed.x, proj.projectileSpeed.y, 0f);
        }
        return(proj);
    }
Exemple #8
0
    public hitbox createHitbox(Vector2 hitboxScale, Vector2 offset, float damage, float hitboxDuration, Vector2 knockback, bool fixedKnockback, string faction, bool followObj)
    {
        Vector3    newPos = new Vector3(transform.position.x + offset.x, transform.position.y + offset.y, 0);
        GameObject go     = Instantiate(hitboxClass, newPos, Quaternion.identity) as GameObject;
        hitbox     newBox = go.GetComponent <hitbox> ();

        newBox.setScale(hitboxScale);
        newBox.setDamage(damage);
        newBox.setHitboxDuration(hitboxDuration);
        newBox.setKnockback(knockback);
        newBox.setFixedKnockback(fixedKnockback);
        newBox.setFaction(faction);
        if (followObj)
        {
            newBox.setFollow(gameObject, offset);
        }
        return(newBox);
    }
Exemple #9
0
    public Projectile fire(Vector2 offset, bool facingLeft, string faction, GameObject shotPrefab)
    {
        Vector3    newPos = new Vector3(transform.position.x + offset.x, transform.position.y + offset.y, 0);
        GameObject go     = Instantiate(shotPrefab, newPos, Quaternion.identity) as GameObject;
        Projectile proj   = go.GetComponent <Projectile> ();

        if (ShotSound != null)
        {
            AudioSource.PlayClipAtPoint(ShotSound, gameObject.transform.position);
        }
        hitbox newBox = go.GetComponentInChildren <hitbox> ();

        newBox.creator = gameObject;
        newBox.setFaction(faction);
        if (facingLeft)
        {
            proj.projectileSpeed = new Vector3(-proj.projectileSpeed.x, proj.projectileSpeed.y, 0f);
        }
        proj.facingLeft = facingLeft;
        return(proj);
    }
Exemple #10
0
 internal void OnTriggerEnter2D(Collider2D other)
 {
     if (!GetComponentInChildren <hitbox> ())
     {
         Debug.Log("Projectile destroyed due to no hitbox");
         Destroy(gameObject);
     }
     else if (other.gameObject.GetComponent <Attackable> () && other.gameObject.GetComponent <Attackable> ().faction == GetComponentInChildren <hitbox> ().faction ||
              penetrating)
     {
     }
     else if (other.gameObject.GetComponent <hitbox> ())
     {
     }
     else
     {
         hitbox hb = GetComponentInChildren <hitbox> ();
         hb.OnTriggerEnter2D(other);
         Destroy(gameObject);
     }
 }
    public static float use(move m, string color, hitbox h)
    {
        if (m == move.wP)
        {
            return(wPunch(color, h));
        }
        if (m == move.sP)
        {
            return(sPunch(color, h));
        }
        if (m == move.wK)
        {
            return(wKick(color, h));
        }
        if (m == move.sK)
        {
            return(sKick(color, h));
        }

        return(0.0f);
    }
Exemple #12
0
    // gets the hitbox based on what direction the player is looking
    private hitbox GetHitbox()
    {
        Direction direction = playerCont.GetDirection();
        hitbox    hitbox    = null;

        switch (direction)
        {
        case Direction.LEFT: hitbox = lefthitbox; break;

        case Direction.RIGHT: hitbox = righthitbox; break;

        case Direction.UP: hitbox = tophitbox; break;

        case Direction.DOWN: hitbox = bottomhitbox; break;

        default:
            Debug.LogError("Invalid direction, I don't know which hitbox to pick help me");
            break;
        }

        return(hitbox);
    }
Exemple #13
0
    public override void onHitConfirm(GameObject other)
    {
        if (other.GetComponent <Projectile> ())
        {
            Projectile p = other.GetComponent <Projectile> ();
            p.projectileSpeed.x = p.projectileSpeed.x * -1f;
            p.projectileSpeed.y = p.projectileSpeed.y * -1f;
            if (ReflectSound != null)
            {
                AudioSource.PlayClipAtPoint(ReflectSound, gameObject.transform.position);
            }
            hitbox hb = other.GetComponentInChildren <hitbox> ();
            hb.creator = gameObject;

            hb.faction        = GetComponent <Attackable> ().faction;
            hb.collidedObjs   = new List <Attackable> ();
            hb.hitboxDuration = Mathf.Min(Mathf.Max(0.5f, hb.hitboxDuration), 2.0f) * 4.0f;
            p.duration        = hb.hitboxDuration;
        }
        if (rapidRecovery)
        {
            GetComponent <Fighter>().recoveryTime = GetComponent <Fighter>().recoveryTime * 0.5f;
        }
    }
Exemple #14
0
 public virtual void onInterrupt(float stunTime, bool successfulHit, hitbox hb)
 {
 }
Exemple #15
0
    // Update is called once per frame
    void Update()
    {
        // figure out which hitbox we should use if we attack

        if (Input.GetButton("Fire1") && !attacking && cd == 0 && PlayerRoll.rolling == false)
        {
            fastAttack = true;
            attacking  = true;
            anim.SetBool("attacking", attacking);
            anim.SetBool("fastAtt", fastAttack);
            attackTimer = attackAnimCd;
            cd          = coolDown;

            enabledHitbox = GetHitbox();
            enabledHitbox.ActivateHitbox(fastAttackDamgae);
        }
        if (Input.GetButton("Fire3") && !attacking && cd == 0 && PlayerRoll.rolling == false)
        {
            heavyAttack = true;
            attacking   = true;
            anim.SetBool("attacking", attacking);
            anim.SetBool("heavyAtt", heavyAttack);
            attackTimer = hAnimCd;
            cd          = hcoolDown;

            enabledHitbox = GetHitbox();
            enabledHitbox.ActivateHitbox(heavyAttackDamage);
        }

        if (fastAttack)
        {
            if (attacking)
            {
                if (attackTimer > 0)
                {
                    attackTimer -= Time.deltaTime;
                }
                else
                {
                    attackTimer = 0;
                    attacking   = false;
                    anim.SetBool("attacking", attacking);
                    enabledHitbox.DeactivateHitbox();
                    enabledHitbox = null;
                    //  attackTrigger.enabled = false;
                }
            }
            if (cd > 0)
            {
                cd -= Time.deltaTime;
            }
            else
            {
                cd         = 0;
                fastAttack = false;
                anim.SetBool("fastAtt", fastAttack);
            }
        }
        if (heavyAttack)
        {
            if (attacking)
            {
                if (attackTimer > 0)
                {
                    attackTimer -= Time.deltaTime;
                }
                else
                {
                    attackTimer = 0;
                    attacking   = false;
                    anim.SetBool("attacking", attacking);
                    enabledHitbox.DeactivateHitbox();
                    enabledHitbox = null;
                    //  attackTrigger.enabled = false;
                }
            }
            if (cd > 0)
            {
                cd -= Time.deltaTime;
            }
            else
            {
                cd          = 0;
                heavyAttack = false;
                anim.SetBool("heavyAtt", heavyAttack);
            }
        }
    }