Example #1
0
 public override void OtherEffect(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
     if (attackInfo.damage >= enemyInfo.CurrHealth)
     {
         lifeStoneManager.FillLifeStone(1, LifeStoneType.Normal);
     }
 }
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        cc_Rb.rotation = Quaternion.Euler(0, m_CameraTransform.eulerAngles.y, 0);
        cr_Anim.SetTrigger(attack.TriggerName);

        // change color from default to the attack color
        IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);

        StartCoroutine(toColor);

        // wait for windup time to be over
        yield return(new WaitForSeconds(attack.WindUpTime));

        Vector3 offset = transform.forward * attack.Offset.z +
                         transform.right * attack.Offset.x + transform.up * attack.Offset.y;
        GameObject go = Instantiate(attack.AbilityGO, transform.position + offset, cc_Rb.rotation);

        go.GetComponent <Ability>().Use(transform.position + offset);

        // change color back to default after the attack is over
        StopCoroutine(toColor);
        StartCoroutine(ChangeColor(p_DefaultColor, 50));

        yield return(new WaitForSeconds(attack.Cooldown));

        attack.ResetCooldown();
    }
    private void Update()
    {
        if (p_FrozenTimer > 0)
        {
            p_Velocity     = Vector2.zero;
            p_FrozenTimer -= Time.deltaTime;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }

        //Ability use
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];
            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    p_FrozenTimer = attack.FrozenTime;
                    DecreaseHealth(attack.HealthCost);
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }
        //set how hard the palyer is pressing movement buttons
        float forward = Input.GetAxis("Vertical");
        float right   = Input.GetAxis("Horizontal");

        //Updating the animation
        cr_Anim.SetFloat("Speed", Mathf.Clamp01(Mathf.Abs(forward) + Mathf.Abs(right)));

        //Updateing velocity
        float moveThreshold = 0.3f;

        if (forward > 0 && forward < moveThreshold)
        {
            forward = 0;
        }
        else if (forward < 0 && forward > -moveThreshold)
        {
            forward = 0;
        }
        if (right > 0 && right < moveThreshold)
        {
            right = 0;
        }
        if (right < 0 && right > -moveThreshold)
        {
            right = 0;
        }
        p_Velocity.Set(right, forward);
    }
    private void Awake()
    {
        p_Velocity = Vector2.zero;
        cc_Rb      = GetComponent <Rigidbody>();

        cr_Anim = GetComponent <Animator>();

        cr_Renderer    = GetComponentInChildren <Renderer>();
        p_DefaultColor = cr_Renderer.material.color;



        p_FrozenTimer = 0;
        p_CurHealth   = m_MaxHealth;
        p_CurPower    = 0;
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];
            attack.Cooldown = 0;

            if (attack.WindUpTime > attack.FrozenTime)
            {
                Debug.LogError(attack.AttackName + "wind up time longer than frozen time");
            }
        }
    }
Example #5
0
    private void Awake()
    {
        m_KillCountDown.text = "";
        p_KillTime           = 0;
        p_Velocity           = Vector2.zero;
        cc_Rb          = GetComponent <Rigidbody>();
        cr_Anim        = GetComponent <Animator>();
        cr_Renderer    = GetComponentInChildren <Renderer>();
        p_DefaultColor = cr_Renderer.material.color;
        p_CurHealth    = m_MaxHealth;

        p_FrozenTimer = 0;

        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];
            attack.Cooldown = 0;

            if (attack.WindUpTime > attack.FrozenTime)
            {
                Debug.LogError(attack.AttackName + " has a wind up time that is larger than amount of time player is frozen for");
            }
        }
        p_CurScore = 0;
    }
Example #6
0
    private void Awake()
    {
        p_Velocity     = Vector2.zero;
        cc_Rb          = GetComponent <Rigidbody>();
        cr_anim        = GetComponent <Animator>();
        cr_Renderer    = GetComponentInChildren <Renderer>();
        p_DefaultColor = cr_Renderer.material.color;
        p_elaspedtime  = 0;
        p_CurrHealth   = m_Health;
        p_CurrMana     = m_Mana;
        p_ManaRegen    = m_ManaGain;
        p_ManaTimer    = m_TimeToRegen;
        p_FrozenTimer  = 0;

        for (int i = 0; i < m_attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_attacks[i];
            attack.Cooldown = 0;

            if (attack.WindUpTime > attack.FrozenTime)
            {
                Debug.LogError(attack.Name + " has a wind up time larger than the time the player is frozen for");
            }
        }
    }
Example #7
0
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        //cc_Rb.rotation = Quaternion.Euler(0, m_CameraTransform.eulerAngles.y, 0);
        //Quaternion new_Rotation = cc_Rb.rotation;
        //cr_Anim.SetTrigger(attack.TriggerName);
        //IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);
        //StartCoroutine(toColor);
        //yield return new WaitForSeconds(attack.WindUpTime);

        //Vector3 offset = transform.forward * attack.Offset.z + transform.right * attack.Offset.x + transform.up * attack.Offset.y;
        Vector3 spawnPos = transform.position;// + offset;

        /*if (attack.Bomb)
         * {
         *  spawnPos = new Vector3(transform.position.x, 40, transform.position.z);
         *  Quaternion current_Rotation = attack.AbilityGO.transform.rotation;
         *  new_Rotation = new Quaternion(-current_Rotation.x, current_Rotation.y, current_Rotation.z, current_Rotation.w);
         *
         * }*/
        GameObject go = Instantiate(attack.AbilityGO, spawnPos, transform.rotation);

        go.GetComponent <Ability>().Use(spawnPos);

        //StopCoroutine(toColor);
        //StartCoroutine(ChangeColor(p_DefaultColor, 50));
        yield return(new WaitForSeconds(attack.Cooldown));

        attack.ResetCooldown();
    }
Example #8
0
 public override void OtherEffect(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
     if (combo.Equals(this.combo[0]) && hit)
     {
         hit = false;
         comboCurrentCool[1]++;
     }
 }
Example #9
0
 public override void OtherEffect(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
     damageStack += attackInfo.damage;
     if (damageStack >= 500)
     {
         MapManager.Instance.UpgradeRoom(RoomType.Item);
         damageStack = 0;
     }
 }
Example #10
0
 private void Awake()
 {
     rewiredPlayer      = ReInput.players.GetPlayer(rewiredPlayerId);
     controller         = GetComponent <Controller2D>();
     movementController = GetComponent <MovementController>();
     jumpController     = GetComponent <JumpController>();
     standardAttack     = GetComponentInChildren <PlayerAttackInfo>();
     teleportAttack     = GetComponentInChildren <PlayerTeleportAttack>();
     animatorController = GetComponent <AnimatorController>();
 }
Example #11
0
    public virtual float[] DebuffFinalAdder(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
    {
        float[] varArray = new float[(int)EnemyDebuffCase.END_POINTER];
        for (int i = 0; i < (int)EnemyDebuffCase.END_POINTER; i++)
        {
            varArray[i] = 0f;
        }

        return(varArray);
    }
Example #12
0
 public override float DamageMultiplier(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
     if (!GameManager.Instance.player.GetComponent <PlayerController>().IsGrounded())
     {
         return(1.75f);
     }
     else
     {
         return(1f);
     }
 }
Example #13
0
 public override float DamageMultiplier(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
     if (attackInfo.damage < 3)
     {
         return(2f);
     }
     else
     {
         return(1f);
     }
 }
Example #14
0
    public override float[] DebuffAdder(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
    {
        float[] varArray = new float[(int)EnemyDebuffCase.END_POINTER];
        for (int i = 0; i < (int)EnemyDebuffCase.END_POINTER; i++)
        {
            varArray[i] = 0f;
        }

        varArray[(int)EnemyDebuffCase.Fire] = 2f;

        return(varArray);
    }
Example #15
0
    public override float DamageMultiplier(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
    {
        int aNum = 0;

        for (int i = 0; i < combo.Length; i++)
        {
            if (combo[i] == 'B')
            {
                aNum++;
            }
        }

        return(1f + aNum * 0.5f);
    }
Example #16
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Bounds tmpBounds = new Bounds();

        if ((enemyLayer == (enemyLayer | 1 << collision.gameObject.layer)) && !collision.transform.GetChild(0).GetComponent <Enemy>().Invisible)
        {
            PlayerAttackInfo curAttack = new PlayerAttackInfo(damage, knockBackMultiplier, debuffTime);
            Enemy            enemyInfo = collision.transform.GetChild(0).GetComponent <Enemy>();

            foreach (Item tmpItem in inventoryManager.itemList)
            {
                for (int i = 0; i < tmpItem.skillNum; i++)
                {
                    if (tmpItem.combo[i].Equals(attackCombo))
                    {
                        tmpItem.AttackCalculation(curAttack, enemyInfo, attackCombo);
                        break;
                    }
                }
            }

            collision.transform.GetChild(0).GetComponent <Enemy>().GetHit(curAttack);

            //make effect
            foreach (Collider2D col in GetComponents <Collider2D>())
            {
                if (col.isActiveAndEnabled)
                {
                    tmpBounds = col.bounds;
                }
            }

            if (!tmpBounds.Equals(new Bounds()))
            {
                effectManager.StartEffect(0, tmpBounds, collision.bounds);
                effectManager.StartNumber(attackCombo[attackCombo.Length - 1] - 'A', tmpBounds, collision.bounds, curAttack.damage);
            }
        }
        if (projectileType == 1 && (vanishLayer == (vanishLayer | 1 << collision.gameObject.layer)))
        {
            Destroy(gameObject);
        }
        if (projectileType == 1 && (stopLayer == (stopLayer | 1 << collision.gameObject.layer)))
        {
            GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            GetComponent <Collider2D>().enabled   = false;

            StartCoroutine(WaitVanish(10f));
        }
    }
Example #17
0
    public override float DamageFinalAdder(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
    {
        LifeStoneManager lifeStoneManager = LifeStoneManager.Instance;

        if (Random.Range(0, 2) == 0)
        {
            lifeStoneManager.DestroyStone(2);
            return(0);
        }
        else
        {
            return(enemyInfo.CurrHealth * 0.25f);
        }
    }
Example #18
0
    // Update is called once per frame
    void Update()
    {
        //if already attacking do nothing else this frame
        if (Attacking)
        {
            return;
        }

        //access input values
        x_input = Input.GetAxisRaw("Horizontal");
        y_input = Input.GetAxisRaw("Vertical");
        Move();

        //check for attack executed
        bool punch_pressed = Input.GetKeyDown(KeyCode.Z);

        if (punch_pressed && punch_timer <= 0)
        {
            Punch();
        }

        //decrement all attack timers
        punch_timer -= Time.deltaTime;


        //Use Magic Attacks
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];

            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    //p_FrozenTimer = attack.FrozenTime;
                    //DecreaseHealth(attack.HealthCost);
                    StartCoroutine(UseAttack(attack));
                    //UseAttacks(attack);
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }
    }
Example #19
0
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        cr_Anim.SetTrigger(attack.TriggerName);
        IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);

        StartCoroutine(toColor);
        yield return(new WaitForSeconds(attack.WindupTime));

        Vector3    hitpoint = transform.forward * attack.AbilityGO.GetComponent <Ability>().Range;
        GameObject go       = Instantiate(attack.AbilityGO, transform.position + transform.forward * 0.2f, transform.rotation);

        go.GetComponent <Ability>().Use(transform.position, hitpoint);
        StopCoroutine(toColor);
        StartCoroutine(ChangeColor(p_DefaultColor, 50));
        yield return(new WaitForSeconds(attack.FrozenTime - attack.WindupTime));

        attack.ResetCooldown();
    }
Example #20
0
    IEnumerator Emit()
    {
        yield return(new WaitForSeconds(0.75f));

        Enemy[] enemyArray = MapManager.currentRoom.GetComponentsInChildren <Enemy>();

        foreach (Enemy enemy in enemyArray)
        {
            if (Vector3.Distance(enemy.gameObject.transform.position, player.transform.position) <= 6f)
            {
                PlayerAttackInfo attack = new PlayerAttackInfo(30f, 0f, new float[(int)EnemyDebuffCase.END_POINTER] {
                    0, 0, 2, 0, 0
                });
                AttackCalculation(attack, enemy, combo[1]);
                enemy.GetHit(attack);
                EffectManager.Instance.StartEffect(0, enemy.gameObject.transform.position);
                EffectManager.Instance.StartNumber(1, enemy.gameObject.transform.position, attack.damage);
            }
        }
    }
Example #21
0
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        cc_Rb.rotation = Quaternion.Euler(0, m_CameraTransform.eulerAngles.y, 0);
        cr_Anim.SetTrigger(attack.TriggerName);
        IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);

        StartCoroutine(toColor);
        yield return(new WaitForSeconds(attack.Windup));

        Vector3    offset = transform.forward * attack.Offset.z + transform.right * attack.Offset.x + transform.up * attack.Offset.y;
        GameObject go     = Instantiate(attack.AbilityGO, transform.position + offset, cc_Rb.rotation);

        go.GetComponent <Ability>().Use(transform.position + offset);
        DecreaseHealth(attack.HealthCost);

        StopCoroutine(toColor);
        StartCoroutine(ChangeColor(p_DefaultColor, 50));
        yield return(new WaitForSeconds(attack.Cooldown));

        attack.ResetCooldown();
    }
Example #22
0
    private void Awake()
    {
        p_CurHealth        = m_MaxHealth;
        p_AnimForwardSpeed = 0;
        p_Velocity         = Vector2.zero;
        p_isJumping        = false;
        p_rotationAmount   = 0;
        p_FrozenTimer      = 0;
        cc_Rb     = GetComponent <Rigidbody>();
        cc_Spring = GetComponent <ConfigurableJoint>();

        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];
            attack.Cooldown = 0;
            if (attack.WindupTime > attack.FrozenTime)
            {
                Debug.LogError(attack.AttackName + " has a channel time that is longer than its frozen time");
            }
        }
    }
Example #23
0
    // When damaged

    // - Calculate value & Arrange information
    public virtual void GetHit(PlayerAttackInfo attack)
    {
        TakeDamage(attack.damage);

        float knockbackDist = attack.damage * attack.knockBackMultiplier / weight;
        float knockbackTime = (knockbackDist >= 0.5f) ? 0.5f : knockbackDist;

        if (movementLock == EnemyMovementLock.Rigid) // 넉백이 진행 중
        {
            StopCoroutine("Knockback");
        }

        if (movementLock < EnemyMovementLock.Debuffed)
        {
            movementLock = EnemyMovementLock.Rigid;
            StartCoroutine(Knockback(knockbackDist, knockbackTime));
        }

        DebuffApply(attack.debuffTime);

        animator.SetTrigger("TrackTrigger");
    }
Example #24
0
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        //pause character during attack
        Attacking         = true;
        playerRB.velocity = Vector2.zero;
        //update animator
        anim.SetBool("Attacking", Attacking);



        GameObject go = Instantiate(attack.AbilityGO, playerRB.position + curr_dir, Quaternion.identity);

        go.GetComponent <Ability>().Use(playerRB.position + curr_dir, curr_dir);


        yield return(new WaitForSeconds(0.3f));

        //reenable movement
        Attacking = false;
        //update animator
        anim.SetBool("Attacking", Attacking);
    }
Example #25
0
    private void Awake()
    {
        p_Velocity     = Vector2.zero;
        cc_Rb          = GetComponent <Rigidbody>();
        cr_Anim        = GetComponent <Animator>();
        cr_Renderer    = GetComponentInChildren <Renderer>();
        p_DefaultColor = cr_Renderer.material.color;

        p_FrozenTimer = 0;
        p_CurHealth   = m_MaxHealth;

        //sound management
        p_StepSound             = gameObject.AddComponent <AudioSource>();
        p_StepSound.playOnAwake = false;
        p_StepSound.volume      = .4f;
        p_StepSound.clip        = stepClip;

        p_HealthPillSound             = gameObject.AddComponent <AudioSource>();
        p_HealthPillSound.playOnAwake = false;
        p_HealthPillSound.volume      = .2f;
        p_HealthPillSound.clip        = healthPillClip;

        p_MagicSound             = gameObject.AddComponent <AudioSource>();
        p_MagicSound.playOnAwake = false;
        p_MagicSound.volume      = .5f;
        p_MagicSound.clip        = magicClip;

        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];
            attack.Cooldown = 0;

            if (attack.WindUpTime > attack.FrozenTime)
            {
                Debug.LogError(attack.AttackName + " has a wind up time that is larger than the amount of time that the player is frozen for");
            }
        }
    }
Example #26
0
    public bool scarecrow_or_statue; // true: scarecrow

    public override void GetHit(PlayerAttackInfo attack)
    {
        if (Invisible)
        {
            return;
        }
        CurrHealth -= attack.damage;

        if (CurrHealth <= 0)
        {
            if (scarecrow_or_statue)
            {
                CurrHealth = maxHealth;
            }
            else
            {
                Invisible = true;
                animator.SetTrigger("DeadTrigger");
                return;
            }
        }

        animator.SetTrigger("DamagedTrigger");
    }
Example #27
0
    private void Update()
    {
        if (p_KillTime > 0)
        {
            p_KillTime          -= Time.deltaTime;
            m_KillCountDown.text = "Killer Mode Activated! Time Left = " + p_KillTime;
        }
        else
        {
            m_KillCountDown.text = "";
        }

        if (p_FrozenTimer > 0)
        {
            p_Velocity     = Vector2.zero;
            p_FrozenTimer -= Time.deltaTime;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }
        //Ability use -- see if ready
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];

            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    p_FrozenTimer = attack.FrozenTime;
                    DecreaseHealth(attack.HealthCost);
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }


        // see how hard player is pressomg movement buttons
        // up and down (+ and -)
        float forward = Input.GetAxis("Vertical");

        //right and left(+ and -)
        float right = Input.GetAxis("Horizontal");

        //updating the animation
        cr_Anim.SetFloat("Speed", Mathf.Clamp01(Mathf.Abs(forward) + Mathf.Abs(right)));

        // velocity
        float moveThreshold = 0.3f;

        if (forward > 0 && forward < moveThreshold)
        {
            forward = 0;
        }
        else if (forward < 0 && forward > -moveThreshold)
        {
            forward = 0;
        }

        if (right > 0 && right < moveThreshold)
        {
            right = 0;
        }
        else if (right < 0 && right > -moveThreshold)
        {
            right = 0;
        }
        p_Velocity.Set(right, forward);
    }
Example #28
0
 public override float DamageMultiplier(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
     return(1.55f);
 }
Example #29
0
 public virtual void OtherEffect(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
 }
Example #30
0
 public virtual float KnockBackFinalAdder(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
 {
     return(0f);
 }