Ejemplo n.º 1
0
 private void checkAttackInput()
 {
     if (!blockInput)
     {
         if (Input.GetButtonDown("Light") && Input.GetAxis("Vertical") < 0)
         {
             attackInput       = true;
             currentAttackType = attackType.kick;
         }
         else if (Input.GetButtonDown("Light") && Input.GetAxis("Vertical") > 0)
         {
             attackInput       = true;
             currentAttackType = attackType.MoveLightSlash;
         }
         else if (Input.GetButton("Light"))
         {
             attackInput       = true;
             currentAttackType = attackType.standingSlashRight;
         }
         else if (Input.GetButtonDown("Heavy"))
         {
             attackInput       = true;
             currentAttackType = attackType.standingHeavy;
         }
         else if (Input.GetButtonDown("Heavy") && Input.GetAxis("Vertical") > 0)
         {
             attackInput       = true;
             currentAttackType = attackType.MoveHeavySlash;
         }
         else
         {
             attackInput = false;
         }
     }
 }
Ejemplo n.º 2
0
 public void letMeAttack(attackType aT)
 {
     if (aT != attackType.kick)
     {
         currentDamage = (weaponDamage + plStats.strenght / 2) * getAttackBonus(aT);
     }
     else
     {
         currentDamage = (plStats.dexterity + plStats.strenght) * getAttackBonus(aT);
     }
 }
Ejemplo n.º 3
0
    public void randomChange()
    {
        int num = Random.Range(0, 10);

        if (num >= 5)
        {
            attack = attackType.bullet;
        }
        else
        {
            attack = attackType.missile;
        }
    }
Ejemplo n.º 4
0
    void setCD(attackType a, float cd)
    {
        switch (a)
        {
        case attackType.abil1:
            abil1CD = cd;
            break;

        case attackType.abil2:
            abil2CD = cd;
            break;
        }
    }
Ejemplo n.º 5
0
    private void Update()
    {
        changeAttackCounte -= Time.deltaTime;
        if (changeAttackCounte <= 0)
        {
            changeAttackCounte = chageAttackTimer;
            switch (Type)
            {
            case attackType.bullet: Type = attackType.missile; break;

            case attackType.missile: Type = attackType.bullet; break;
            }
        }
        fireCounter -= Time.deltaTime;
        if (fireCounter <= 0)
        {
            fireCounter = fireRate;
            if (Type == attackType.bullet)
            {
                for (int i = 0; i < cannons.Length; i++)
                {
                    if (cannons[bulletCount] != null)
                    {
                        cannons[bulletCount].fire();
                        bulletCount++;
                        if (bulletCount >= cannons.Length)
                        {
                            bulletCount = 0;
                        }
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            else
            {
                Instantiate(missiles, missileSpawnPoints[missileCount].position, missileSpawnPoints[missileCount].rotation);
                missileCount++;
                if (missileCount >= missileSpawnPoints.Length)
                {
                    missileCount = 0;
                }
            }
        }
    }
Ejemplo n.º 6
0
    IEnumerator InitiateAttack(attackType type)
    {
        yield return(new WaitForEndOfFrame());

        anim.SetBool("Attack", true);
        anim.SetInteger("AttackType", (int)type);
        if (type != attackType.kick)
        {
            plControl.stopMoveAnim();
            doDamage.letMeAttack(type);
        }
        else
        {
            plControl.stopMoveAnim();
            kickDamage.letMeKick();
        }
    }
Ejemplo n.º 7
0
        public override int attack()
        {
            attackType at = getRandomAttackType();

            int damage = 0;

            switch (at)
            {
            case attackType.ground:
                damage = base.attack();
                break;

            case attackType.fire:
                damage = magicAttack();
                break;
            }

            return(damage);
        }
Ejemplo n.º 8
0
    public void postBufferAttackEffect(int amount, attackType type, statusEffects effects, attackLocation location, GameObject source)
    {
        int healthBeforeDamage = HP;

        //CALLS THE METHODS FOR EACH ATTACK TYPE AND STATUS EFFECT.
        //IMMUNITY AND SPECIAL EFFECTS TO DIFFERENT TYPES CAN BE MADE BY OVERRIDING THE VIRTUAL METHODS.
        if (type == attackType.Normal)
        {
            NormalDamage(amount, source);
        }
        if (type == attackType.Fire)
        {
            FireDamage(amount, source);
        }
        if (type == attackType.Heal)
        {
            Heal(amount, source);
        }
        if (type == attackType.LifeSteal)
        {
            LifeStealDamage(amount, source);
        }
        //----------------------------------------------------------------------------------------------

        //CHECK IF DEAD---------------------------
        if (HP <= 0)
        {
            death();
            return;
        }

        foreach (LowHealthTriggerInfo lowHealthTrigger in LowHealthTriggers)
        {
            if (HP <= lowHealthTrigger.TriggerValue && lowHealthTrigger.TriggerValue < healthBeforeDamage)
            {
                if (CombatExecutor.CutsceneDataManager.TriggerATrigger(lowHealthTrigger.Label))
                {
                    GameDataTracker.combatExecutor.AddCutsceneToQueue(Resources.Load <DialogueContainer>(lowHealthTrigger.CutscenePath), name, gameObject);
                }
            }
        }
    }
Ejemplo n.º 9
0
    GameObject lookup(attackType a)
    {
        switch (a)
        {
        case attackType.basic:
            return(attackPre1);

        case attackType.heavy:
            return(attackPre2);

        case attackType.abil1:
            return(abilPre1);

        case attackType.abil2:
            return(abilPre2);

        default:
            return(attackPre1);
        }
    }
Ejemplo n.º 10
0
    void CmdAtk(attackType a, Vector3 groundTarget)
    {
        //Debug.Log(atkPre);
        vis.RpcColorNose(true);
        GameObject atkPre = lookup(a);

        attack = Instantiate(atkPre, transform);
        Attack atk = attack.GetComponent <Attack>();

        atk.setOwner(netId, team);
        setCD(a, atk.cooldown);
        if (attack.GetComponent <AttackM>())
        {
            attack.GetComponent <AttackM>().setColliders(false);
            attackTurn = attack.GetComponent <AttackM>().turnDeg;
        }
        else if (attack.GetComponent <AttackS>())
        {
            AttackS spwn = attack.GetComponent <AttackS>();
            Vector3 tar  = groundTarget;
            tar.y = 0;
            Vector3 loc = transform.position;
            loc.y = 0;
            if ((tar - loc).magnitude > spwn.range)
            {
                tar = (tar - loc).normalized * spwn.range + loc;
            }
            tar.y       = groundTarget.y;
            spwn.target = tar;
            attackTurn  = 0;
        }
        else
        {
            attackTurn = 360;
        }

        NetworkServer.Spawn(attack);
    }
Ejemplo n.º 11
0
 float getAttackBonus(attackType aT)
 {
     if (aT == attackType.standingSlashRight)
     {
         return(0.90f);
     }
     if (aT == attackType.standingSlashLeft)
     {
         return(0.90f);
     }
     if (aT == attackType.MoveHeavySlash)
     {
         return(1.2f);
     }
     if (aT == attackType.standingHeavy)
     {
         return(1.15f);
     }
     if (aT == attackType.kick)
     {
         return(0.9f);
     }
     return(0);
 }
Ejemplo n.º 12
0
    /// <summary> Plays a specified Attack Animation. </summary>
    /// <param name="attackType"> Which Attack to be used. </param>
    public void attack(attackType attackType)
    {
        int attack = (int)attackType;

        switch (attack)
        {
        case 0:
            animator.SetTrigger("SideSlash");
            break;

        case 1:
            animator.SetTrigger("DownSlash");
            break;

        case 2:
            animator.SetTrigger("SpinSlash");
            break;

        default:
            animator.SetTrigger("SideSlash");
            Debug.Log("ERROR");
            break;
        }
    }
Ejemplo n.º 13
0
    public void PlayerTurnOnCLick(int a)
    {
        if (!turnTaken)
        {
            attackType attack = (attackType)a;

            if (state == combatState.PLAYER)
            {
                switch (attack)
                {
                case attackType.MELEE:
                    if (player.Consume(2, 15))
                    {
                        dialogue.text = "You perform a melee attack.";
                        StartCoroutine(PlayerAttack(attack));
                    }
                    else
                    {
                        dialogue.text = "You don't have enough stamina to perform a melee attack.";
                    }
                    break;

                case attackType.MAGIC:
                    if (player.Consume(1, 15))
                    {
                        dialogue.text = "You perform a magic attack.";
                        StartCoroutine(PlayerAttack(attack));
                    }
                    else
                    {
                        dialogue.text = "You don't have enough magic to perform a magic attack.";
                    }
                    break;

                case attackType.HEAL:
                    if (player.Consume(1, 15))
                    {
                        dialogue.text = "You use magic to heal yourself.";
                        StartCoroutine(PlayerAttack(attack));
                    }
                    else
                    {
                        dialogue.text = "You don't have enough magic to cast heal.";
                    }
                    break;

                case attackType.POTION:
                    if (player.gameObject.GetComponent <Inventory>().potionsCount > 0)
                    {
                        dialogue.text = "You consume a potion to restore yourself.";
                        StartCoroutine(PlayerAttack(attack));
                    }
                    else
                    {
                        dialogue.text = "You don't have enough potions to perform this action.";
                    }

                    break;

                case attackType.BLOCK:
                    if (player.Consume(2, 5))
                    {
                        dialogue.text = "You attempt to block your opponents next attack, you feel renewed.";
                        StartCoroutine(PlayerAttack(attack));
                    }
                    else
                    {
                        dialogue.text = "You don't have enough stamina to block.";
                    }
                    break;

                case attackType.COWER:
                    StartCoroutine(PlayerAttack(attack));
                    break;

                default:
                    Debug.LogError("Invalid attack type");
                    break;
                }
            }
            else
            {
                Debug.LogError("Player attack buttons should not be visible when not on the players turn.");
            }
        }
    }
        public bool rangedAttack(Player1 attacker, attackType attackType)
        {
            //Aim in the direction player is facing
            direction = attacker.flipModifier;

            //Fire shot type
            attacker.myModelManager.AddShot(attacker.getPosition(), new Vector3(direction, 0, 0), attacker, attackType);
            return true;
        }
Ejemplo n.º 15
0
    IEnumerator EnemyTurn()
    {
        bool playerDead = false;

        if (state == combatState.ENEMY)
        {
            //Can be modified to include a priority system here so more likely to heal when low on health etc.
            attackType attack = (attackType)Random.Range(0, 6);

            switch (attack)
            {
            case attackType.MELEE:
                if (currentEnemy.Consume(2, 15))
                {
                    playerDead    = player.TakeDamage(currentEnemy.damage);
                    dialogue.text = currentEnemy.characterName + " performs a melee attack at you.";
                }
                else
                {
                    dialogue.text = currentEnemy.characterName + " cowers.";
                }
                break;

            case attackType.MAGIC:
                if (currentEnemy.Consume(1, 15))
                {
                    playerDead    = player.TakeDamage(currentEnemy.damage);
                    dialogue.text = currentEnemy.characterName + " performs a magic attack at you.";
                }
                break;

            case attackType.HEAL:
                if (currentEnemy.Consume(1, 15 + (5 * (3 - HealCount))))
                {
                    currentEnemy.Restore(0, 5 * HealCount);
                    dialogue.text = currentEnemy.characterName + " casts healing on themself.";
                    HealCount--;
                }
                break;

            case attackType.POTION:
                currentEnemy.Restore(1, 25);
                currentEnemy.Restore(2, 25);
                dialogue.text = currentEnemy.characterName + " restores their abilities.";
                break;

            case attackType.BLOCK:
                if (currentEnemy.Consume(2, 5))
                {
                    currentEnemy.Restore(0, 5);
                    dialogue.text = currentEnemy.characterName + " prepares to block your next attack.";
                }
                break;

            case attackType.COWER:
                dialogue.text = currentEnemy.characterName + " cowers.";
                break;
            }
        }

        UpdateHUD();

        yield return(new WaitForSeconds(2));

        if (playerDead)
        {
            state = combatState.LOSE;
            StopAllCoroutines();
        }
        else
        {
            dialogue.text = "You prepare your next move...";
            state         = combatState.PLAYER;
            PlayerAttacks.SetActive(true);
        }
        turnTaken = false;
    }
Ejemplo n.º 16
0
    IEnumerator PlayerAttack(attackType attack)
    {
        turnTaken = true;
        bool enemyDead = false;

        switch (attack)
        {
        case attackType.MELEE:
            enemyDead = currentEnemy.TakeDamage(player.damage);
            break;

        case attackType.MAGIC:
            enemyDead = currentEnemy.TakeDamage(player.damage);
            break;

        case attackType.HEAL:
            player.Restore(0, 25);
            break;

        case attackType.POTION:
            player.Restore(0, 50);
            player.Restore(1, 25);
            player.Restore(2, 25);
            break;

        case attackType.BLOCK:
            player.Restore(0, 5);
            break;

        case attackType.COWER:
            int successChance = Random.Range(0, 4);
            if (successChance == 3)
            {
                dialogue.text = "You cower successfully and the gods take pity on you. You find your resolve for battle is fortified.";
                int stat = Random.Range(0, 3);
                player.Restore(stat, 50);
            }
            else
            {
                dialogue.text = "You cower unsuccessfully, the gods have forsaken you. You find your resolve for battle falters.";
                int stat = Random.Range(0, 3);
                player.Restore(stat, 5);
            }
            break;
        }

        UpdateHUD();

        yield return(new WaitForSeconds(2));

        //Check if enemy is dead
        if (enemyDead)
        {
            state = combatState.WIN;
            StopAllCoroutines();
            StartCoroutine(PlayerWin());
        }
        else
        {
            PlayerAttacks.SetActive(false);
            dialogue.text = "Your oponent prepares to attack...";
            state         = combatState.ENEMY;
            yield return(new WaitForSeconds(1));

            StartCoroutine(EnemyTurn());
        }
    }
Ejemplo n.º 17
0
 private void Awake()
 {
     instance = this;
     Type     = attackType.bullet;
 }
Ejemplo n.º 18
0
 //攻撃タイプを変更する
 public void changeFase(attackType type)
 {
     attack = type;
 }
Ejemplo n.º 19
0
 public Weapon(attackType type)
 {
     this.type = type;
 }
        //processRangedAttack is only called by modelManager when targets collide
        //returns true if the bullet collided and should disappear
        public bool processRangedAttack(Bullet bullet, Player1 target, attackType attackType)
        {
            if (target.isAlive == false)
                return false;

            //Blocked by shielding
            if (target.isShielding)
            {
                shieldBlock(target);
                return true;
            }

            //Dodged by rolling
            if (target.rolling)
            {
                return false;
            }

            //Do ranged attack
            switch (attackType)
            {
                case attackType.BULLET:
                    damageModifier = 1;
                    knockbackModifier = 0;
                    attackKnockbackCap = 0;
                    stunValue = 0;
                    target.myModelManager.playSound(ModelManager.sound.SHOCKHIT);
                    break;

                case attackType.SMASHBULLET:
                    damageModifier = 10;
                    knockbackModifier = 40f;
                    attackKnockbackCap = -1;
                    stunValue = .9f;
                    target.myModelManager.playSound(ModelManager.sound.SHOCKSMASHHIT);
                    break;
            }

            //Recognize the values from the switch
            damageTotal = damageDealt * damageModifier;
            knockbackTotal = knockbackDealt * knockbackModifier;

            //Stun target
            target.stunTimer = stunValue;

            //Calculate and set damage
            if (target.currPercentage + damageTotal > target.maxPercentage)
                target.currPercentage = target.maxPercentage;
            else
                target.currPercentage += damageTotal;

            //Calculate and set knockback
            //
            knockbackDirection = (target.getPosition().X - bullet.getPosition().X);
            //Assess whether facing left or right
            if (knockbackDirection > 0)
                direction = 1;
            else direction = -1;

            //Calculate Distance
            knockbackDirection = knockbackDirection / Math.Abs(knockbackDirection);
            knockbackDistance = target.currPercentage / knockbackTotal * knockbackDirection;

            //Cap knockback and knockback as appropriate
            if (attackKnockbackCap > 0 &&
                Math.Abs(knockbackDistance) > Math.Abs(attackKnockbackCap))
                target.knockback(attackKnockbackCap * direction);
            else if (knockbackTotal != 0 && knockbackDirection != 0)
                target.knockback(knockbackDistance);

            return true;
        }
Ejemplo n.º 21
0
 public void ActivateFire()
 {
     canUseSpecificAttack [(int)attackType.Fire] = true;
     actualType = attackType.Fire;
 }
Ejemplo n.º 22
0
 public void UseFire()
 {
     actualType = attackType.Fire;
 }
        //Does melee attacks and reads ranged attack inputs
        public bool attack(Player1 attacker, attackType attackType)
        {
            if (p1.isAlive == false || p2.isAlive == false)
                return false;
            Player1 target;
            if (attacker == p1)
                target = p2;
            else
                target = p1;

            //Blocked by shielding
            if (target.isShielding && attackType != InteractionMediator.attackType.RANGE)
            {
                shieldBlock(target);
                return false;
            }

            //Dodged by rolling
            if (target.rolling && attackType != InteractionMediator.attackType.RANGE)
            {
                return false;
            }

            //Do melee attacks
            if (attacker.CollidesWith(target.model, target.GetWorld()))//If colliding
            {
                target.stunTimer = 0.2f;
                // Up attack
                if (Keyboard.GetState().IsKeyDown(attacker.upKey) || GamePad.GetState(attacker.myPlayerIndex).IsButtonDown(attacker.upButton) || GamePad.GetState(attacker.myPlayerIndex).IsButtonDown(attacker.smashUp))
                {
                    damageModifier = 3;
                    knockbackModifier = 0.04f;
                    target.currPercentage += damageModifier;
                    target.jumpMomentum = knockbackModifier * target.currPercentage;
                    target.jumping = true;
                }
                else
                {
                    switch (attackType)
                    {
                        case attackType.BASIC:
                            damageModifier = 3;
                            knockbackModifier = 40f;
                            attackKnockbackCap = 1;
                            break;

                        case attackType.SMASH:
                            damageModifier = 5;
                            knockbackModifier = 20f;
                            attackKnockbackCap = -1;
                            break;
                    }

                    //Recognize the values from the switch
                    damageTotal = damageDealt * damageModifier;
                    knockbackTotal = knockbackDealt * knockbackModifier;

                    //Calculate and set damage
                    if (target.currPercentage + damageTotal > target.maxPercentage)
                        target.currPercentage = target.maxPercentage;
                    else
                        target.currPercentage += damageTotal;

                    //Calculate and set knockback
                    //
                    knockbackDirection = (target.getPosition().X - attacker.getPosition().X);
                    //Assess whether facing left or right
                    if (knockbackDirection > 0)
                        direction = 1;
                    else direction = -1;

                    if (knockbackDirection == 0)
                        knockbackDirection = .000000001f;
                    knockbackDirection = knockbackDirection / Math.Abs(knockbackDirection);

                    knockbackDistance = target.currPercentage / 1.2f / knockbackTotal * knockbackDirection;

                    //Cap knockback
                    if (attackKnockbackCap > 0 &&
                        Math.Abs(knockbackDistance) > Math.Abs(attackKnockbackCap))
                        target.knockback(attackKnockbackCap * direction);
                    else target.knockback(knockbackDistance);
                }
                return true;
            }

            return false;
        }