예제 #1
0
    //Enact effects method
    public void enactEffects(Collider2D enemy)
    {
        PKMNEntity enemyFighter = enemy.GetComponent <PKMNEntity>();

        //Bounds shotgunBounds = shotgunBlast.GetComponent<Collider2D>().bounds;
        int   pwr;
        float offense;
        float defense;

        pwr     = SHOTGUN_PWR;
        offense = basis.accessStat(BaseStat.SPECIAL_ATTACK);
        defense = enemyFighter.accessStat(BaseStat.SPECIAL_DEFENSE);

        int damage = Battle.damageCalc(basis.level, pwr, offense, defense);

        enemyFighter.StartCoroutine(enemyFighter.receiveDamage(damage, basis));

        StatEffect effects = new StatEffect(STAT_DURATION, REDUCTION_FACTOR, BaseStat.SPECIAL_DEFENSE);

        effects.applyEffect(enemyFighter);

        //THIS SENSING METHOD DOES NOT WORK

        /*if(enemy.bounds.Intersects(shotgunBounds)) {
         *  pwr = SHOTGUN_PWR;
         *  offense = basis.accessStat(BaseStat.SPECIAL_ATTACK);
         *  defense = enemyFighter.accessStat(BaseStat.SPECIAL_DEFENSE);
         *  StatEffect effects = new StatEffect(STAT_DURATION, REDUCTION_FACTOR, BaseStat.SPECIAL_DEFENSE);
         *  effects.applyEffect(enemyFighter);
         * }else{
         *  pwr = DASH_PWR;
         *  offense = basis.accessStat(BaseStat.ATTACK);
         *  defense = enemyFighter.accessStat(BaseStat.DEFENSE);
         * }*/
    }
예제 #2
0
    public void enactEffects(Collider2D tgt)
    {
        PKMNEntity enemy  = tgt.GetComponent <PKMNEntity>();
        int        damage = Battle.damageCalc(basis.level, PWR, basis.accessStat(BaseStat.ATTACK), basis.accessStat(BaseStat.DEFENSE));

        enemy.StartCoroutine(enemy.receiveDamage(damage, basis));
        enemy.StartCoroutine(grabKnockback(enemy.transform));
    }
예제 #3
0
    //enableEffects method
    public void enactEffects(Collider2D enemy)
    {
        //Calculates damage
        PKMNEntity enemyFighter = enemy.GetComponent <PKMNEntity>();
        int        damage       = Battle.damageCalc(basis.level, PWR, basis.accessStat(BaseStat.SPECIAL_ATTACK), enemyFighter.accessStat(BaseStat.SPECIAL_DEFENSE));

        enemyFighter.StartCoroutine(enemyFighter.receiveDamage(damage, basis));
    }
예제 #4
0
    //Offensive setup
    public void offensiveSetup(PKMNEntity source)
    {
        this.source    = source;
        offenseStat    = source.accessStat(BaseStat.SPECIAL_ATTACK);
        enemyTag       = (source.tag == "Player" || source.tag == "PlayerRecovery") ? "Enemy" : "Player";
        enemyAttackTag = (source.tag == "Player" || source.tag == "PlayerRecovery") ? "EnemyAttack" : "PlayerAttack";

        GetComponent <SpriteRenderer>().color = (source.tag == "Player" || source.tag == "PlayerRecovery") ? new Color(0.65f, 0.31f, 0.95f, 0.5f) : new Color(0.39f, 0.26f, 0.51f, 0.5f);
    }
예제 #5
0
    //Method that applies effect to enemies if hit
    public void enactEffects(Collider2D threat)
    {
        PKMNEntity enemy = threat.GetComponent <PKMNEntity>();
        Vector2    kVect = Battle.dirKnockbackCalc(basis.transform.position, enemy.transform.position, KNOCKBACK_VAL);

        threat.GetComponent <Rigidbody2D>().AddForce(kVect);
        int damage = Battle.damageCalc(basis.level, PWR, basis.accessStat(BaseStat.ATTACK), basis.accessStat(BaseStat.DEFENSE));

        enemy.StartCoroutine(enemy.receiveDamage(damage, basis));
    }
예제 #6
0
    //Upon collision on enemy, enact effects
    public void enactEffects(Collider2D enemy)
    {
        Vector2 knockbackVector = Battle.dirKnockbackCalc(basis.transform.position, enemy.transform.position, KNOCKBACK_VAL);

        enemy.GetComponent <Rigidbody2D>().AddForce(knockbackVector);

        //Calculates damage
        PKMNEntity enemyFighter = enemy.GetComponent <PKMNEntity>();
        int        damage       = Battle.damageCalc(basis.level, PWR, basis.accessStat(BaseStat.ATTACK), enemyFighter.accessStat(BaseStat.DEFENSE));

        enemyFighter.StartCoroutine(enemyFighter.receiveDamage(damage, basis));
    }
예제 #7
0
    //Applies effects to enemy hit
    public void enactEffects(Collider2D tgt)
    {
        PKMNEntity enemy  = tgt.GetComponent <PKMNEntity>();
        int        damage = Battle.damageCalc(basis.level, INITIAL_PWR, basis.accessStat(BaseStat.SPECIAL_ATTACK), basis.accessStat(BaseStat.SPECIAL_DEFENSE));

        enemy.StartCoroutine(enemy.receiveDamage(damage, basis));

        //Add debuff
        StatEffect debuff = new StatEffect(DEBUFF_DURATION, DEBUFF_FACTOR, DEBUFF_TYPE);

        debuff.applyEffect(enemy.GetComponent <PKMNEntity>());
    }
예제 #8
0
    //AssistExecute for Player
    public IEnumerator assistExecute()
    {
        //Set up move
        Battle.updatePlayerAOrientation(basis.transform);
        ProjectileBehavior hitBehavior = hitbox.GetComponent <ProjectileBehavior>();

        hitBehavior.setMouseDirection(basis.transform);

        offCD = false;
        anim.SetBool("SpAttacking", true);
        int   shotsFired = 0;
        float curHealth  = basis.accessStat(BaseStat.HEALTH);

        //Bullet system. Player can fire a barrage of 5 bullets by holding button, but must stay still during it (CHANGE THIS KEYCODE)
        while (curHealth <= basis.accessStat(BaseStat.HEALTH) && shotsFired < MAX_SHOTS && curAmmo > 0)
        {
            curAmmo--;                                                         //Decrement ammo by 1
            shotsFired++;                                                      //Increment shots fired by 1

            Transform curBullet = Object.Instantiate(hitbox, basis.transform); //Instantiates hitbox with basis as the parent
            curBullet.GetComponent <ProjectileBehavior>().currentMove = this;

            //Bullet sound effect
            basis.soundFXs.Stop();
            basis.soundFXs.clip = Resources.Load <AudioClip>("Audio/AttackSounds/MachineGun");
            basis.soundFXs.Play();

            yield return(new WaitForSeconds(FIRE_RATE));
        }

        curCooldown = shotsFired * (MAX_COOLDOWN / MAX_SHOTS); //Reduces cooldown depending on the amount of shots fired

        //Upon release, enable cooldown timers and movement
        anim.SetBool("SpAttacking", false);
        basis.getController().SendMessage("assistExecuted");
        yield return(0);
    }
예제 #9
0
    //If someone enters, add them to data structure
    void OnTriggerEnter2D(Collider2D collider)
    {
        PKMNEntity enemy = collider.GetComponent <PKMNEntity>();

        if (collider.tag == enemyTag || (collider.tag == enemyAttackTag && enemy != null))
        {
            int damage = Battle.damageCalc(source.level, POISON_PWR, offenseStat, enemy.accessStat(BaseStat.SPECIAL_DEFENSE));
            enemy.StartCoroutine(enemy.receiveDoT(damage, source));
            hit.Add(enemy);

            if (enemyTag == "Player")
            {
                enemy.getController().SendMessage("setIsolation", true);
            }
        }
    }
예제 #10
0
    //Sends damage if enemy is within hitbox of transform
    //  Does damage to an area in front
    public void enactEffects(Collider2D enemy)
    {
        if (!hit.Contains(enemy))
        {
            hit.Add(enemy); //Add enemy to hashset to avoid double dipping

            //Calculates knockback
            Vector2 knockback = Battle.sourceKnockbackCalc(animator, KNOCKBACK_VAL);

            //Calculates damage
            PKMNEntity enemyFighter = enemy.GetComponent <PKMNEntity>();
            int        damage       = Battle.damageCalc(basis.level, PWR, basis.accessStat(BaseStat.ATTACK), enemyFighter.accessStat(BaseStat.DEFENSE));

            enemy.GetComponent <Rigidbody2D>().AddForce(knockback);      //Applies knockback
            enemyFighter.StartCoroutine(enemyFighter.receiveDamage(damage, basis));
        }
    }
예제 #11
0
    //Displays ALL fighter information and sets menu up
    public void displayFighterInfo(int newIndex)
    {
        //Get Fighter
        int prevIndex = fighterIndex;

        fighterIndex = newIndex;
        PKMNEntity fighter = fighters[fighterIndex];

        //Update ALL Info
        health.fillAmount = fighter.healthBar.fillAmount;
        float curHealth = fighter.accessStat(BaseStat.HEALTH);

        curHealth       = (curHealth <= 0) ? 0 : (curHealth < 1) ? 1 : curHealth;
        healthText.text = (int)curHealth + "/" + fighter.accessBaseStat(BaseStat.HEALTH);

        armor.fillAmount = fighter.armorBar.fillAmount;
        armorText.text   = fighter.armorToString();

        levelDisplay.text   = "Level: " + fighter.level;
        exp.fillAmount      = fighter.getPercentToLvL();
        availableUpgrades   = fighter.getNumStatBoosts();
        openBoostsText.text = "" + availableUpgrades;

        numOpenBoosts.color = (availableUpgrades > 0) ? upgradeReady : noUpgrade;

        //Update base stats
        foreach (SingleBaseStat baseStat in baseStatDisplays)
        {
            baseStat.displayFighterInfo(fighter);

            if (availableUpgrades > 0)
            {
                baseStat.displayPotentialUpgrade();
            }
            else
            {
                baseStat.disablePotentialUpgrade();
            }
        }

        //Update buttons
        fighterButtons[fighterIndex].interactable = false;
        fighterButtons[prevIndex].interactable    = true;
    }
예제 #12
0
    private IEnumerator automatedAssistDuration(float assistHealth, bool moveRan)
    {
        assistFighter.setAssist(true);      //Set assist status to true
        assistTimerUI.updateProgress(1f);

        //If a move was running, wait until move is done
        if (moveRan)
        {
            yield return(new WaitUntil(checkAssistExecutedStatus));
        }

        //Reset to down idle animation
        Animator anim = assistFighter.GetComponent <Animator>();

        anim.SetFloat("speed", 0.0f);
        assistMoveExecuted = false;

        //Upon move finishing, wait for the designated wait period
        float timer     = 0.0f;
        float curHealth = assistHealth;

        //If the enemy hit during wait period, timer automatically resets
        while (timer < REST_DURATION && curHealth > 0)
        {
            yield return(new WaitForEndOfFrame());

            timer    += Time.deltaTime;
            curHealth = assistFighter.accessStat(BaseStat.HEALTH);

            if (curHealth < assistHealth || assistFighter.isStunned())
            {
                timer       -= HIT_DELAY;
                timer        = (timer < 0) ? 0 : timer;
                assistHealth = curHealth;
            }

            assistHealth = curHealth;
            assistTimerUI.updateProgress((REST_DURATION - timer) / REST_DURATION);
        }
    }
예제 #13
0
    //Execute method upon user input FOR PLAYER for charging a self-buff
    public IEnumerator execute()
    {
        Controller entityController = anim.GetComponent <PKMNEntity>().getController();

        charging = true;                                                                //Set boolean locking variable to true to avoid decay while charging
        anim.SetFloat("speed", 0);                                                      //Set Animation
        anim.SetBool("Charging", true);
        entityController.canMove = false;                                               //Disable movement
        float curHealth = unit.accessStat(BaseStat.HEALTH);                             //Get current health for checking

        progress.gameObject.SetActive(true);                                            //Set progressbar to true

        unit.soundFXs.clip = Resources.Load <AudioClip>("Audio/AttackSounds/Charging"); //Establish sound clip
        float soundTimer = CHARGE_SOUND_INTERVAL;                                       //Set sound to play immediately

        //While player holds key, update chargeProgress
        while (Input.GetMouseButton(1) && chargeProgress < CHARGE_REQ && unit.accessStat(BaseStat.HEALTH) >= curHealth)
        {
            chargeProgress += Time.deltaTime;
            soundTimer     += Time.deltaTime;

            curHealth = unit.accessStat(BaseStat.HEALTH);
            progress.updateProgress(chargeProgress / CHARGE_REQ);

            if (soundTimer >= CHARGE_SOUND_INTERVAL)
            {
                soundTimer = 0.0f;
                unit.soundFXs.Stop();
                unit.soundFXs.Play();
            }

            yield return(new WaitForFixedUpdate());
        }

        anim.SetBool("Charging", false);

        //If charge is successful, update animator and apply StatEffect to self
        if (chargeProgress >= CHARGE_REQ)
        {
            progress.gameObject.SetActive(false);
            chargeProgress = 0.0f;
            offCD          = false;
            enactEffects(unit.GetComponent <Collider2D>());

            //Sound effects
            unit.soundFXs.Stop();
            unit.soundFXs.clip = Resources.Load <AudioClip>("Audio/AttackSounds/Beep");
            unit.soundFXs.Play();

            anim.SetBool("FinishedCharge", true);
            float animLength = anim.GetCurrentAnimatorStateInfo(0).length;
            yield return(new WaitForSeconds(animLength));

            anim.SetBool("FinishedCharge", false);
        }

        charging = false;

        if (!unit.isStunned() && unit.isAlive())
        {
            entityController.canMove = true;
        }
    }
예제 #14
0
    //Execute assist move method
    //  Pre: Pressed C or V, fighterIndex < numPartners
    //  Post: Do tactical slow down sequence to select move
    IEnumerator assistMoveExecute(int assistIndex, Vector3 mainPosition)
    {
        int        mainIndex   = (partyIndex > assistIndex) ? partyIndex - 1 : partyIndex; //Store new main index to go back to player after attack
        PKMNEntity mainFighter = selectedFighter;

        assistFighter = transform.GetChild(assistIndex).GetComponent <PKMNEntity>();     //Get new assist fighter
        Transform assist       = assistFighter.transform;
        float     assistHealth = assistFighter.accessStat(BaseStat.HEALTH);              //Get health statuses
        float     mainHealth   = selectedFighter.accessStat(BaseStat.HEALTH);

        numPartners--;

        //Enable and detach
        partyIndex = assistIndex;
        swapMainCharUI(true);
        //assist.position = transform.position;

        //Commence slow down sequence
        assistSeqOn = true;
        assistFighter.transform.parent = null;
        assistTimerUI.gameObject.SetActive(true);
        Time.timeScale = SLOWED_TIME_SCALE;
        float curTime = 0.0f;
        bool  moveRan = false;
        bool  notHit  = assistHealth <= assistFighter.accessStat(BaseStat.HEALTH) && mainHealth <= mainFighter.accessStat(BaseStat.HEALTH);

        //Slow down sequence
        while ((Input.GetKey("c") || Input.GetKey("v")) && !moveRan && curTime < MAX_ASSIST_SEQUENCE_DURATION && notHit)
        {
            assistTimerUI.updateProgress((MAX_ASSIST_SEQUENCE_DURATION - curTime) / MAX_ASSIST_SEQUENCE_DURATION);

            yield return(new WaitForSecondsRealtime(0.01f));

            curTime += Time.deltaTime;

            if (Input.GetMouseButton(1))
            {
                moveRan = moveRan || selectedFighter.executeAssistMove(secMoveIndex);
            }

            float curAssistHealth = assistFighter.accessStat(BaseStat.HEALTH);
            float curMainHealth   = mainFighter.accessStat(BaseStat.HEALTH);

            notHit       = assistHealth <= curAssistHealth && mainHealth <= curMainHealth; //Checks if main character OR assist character was hit
            assistHealth = curAssistHealth;
            mainHealth   = curMainHealth;
        }

        //Set main character back as the selected fighter while keeping enemy detached
        partyIndex = mainIndex;
        goBackToMain(mainPosition);
        Time.timeScale = 1f;
        assistSeqOn    = false;
        bool allowDuration = moveRan || !notHit;

        canMove = false;
        yield return(new WaitForSeconds(0.18f));

        if (!selectedFighter.isStunned())
        {
            canMove = true;
        }

        if (allowDuration)
        {
            yield return(StartCoroutine(automatedAssistDuration(assistHealth, moveRan)));
        }

        assistTimerUI.gameObject.SetActive(false);

        if (assistFighter.isAlive())                     //If assist fighter is alive, re implement him back in. If not alive, don't reimplement
        {
            revertAssist(assistIndex, allowDuration);
        }
        else
        {
            abilityUIMap[assistFighter].updateStatus();
        }

        assistFighter = null;   //Turn assist fighter equal to null to indicate that no assist fighter is present
    }