Example #1
0
    public override void OnExit()
    {
        float rotationAngle = Vector2.Angle(Vector2.right, input);
        float scaleX        = distanceTraveled / 3.0f;

        if (scaleX == 0.0f)
        {
            scaleX = dodgeDistance / 2.8f;
        }

        Debug.Log("ScaleX " + scaleX + " Rotation " + rotationAngle);

        if (input.y < -0.001)
        {
            rotationAngle = -rotationAngle;
        }


        TempSpriteManager.GetInstance().PlayAnimation("Dodge_Blur_Back", startPos, new Vector2(scaleX, 0.8f), Vector2.zero, rotationAngle, "Foreground2", 0, 0.0f, _player.color);
        TempSpriteManager.GetInstance().PlayAnimation("Dodge_Blur_Color", startPos, new Vector2(scaleX, 0.8f), Vector2.zero, rotationAngle, "Foreground2", 1, 0.0f, _player.color2);



        base.OnExit();
    }
Example #2
0
    public override void Jump()
    {
        audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("Jump");
        audioSource.Play();
        //Set state to airborne
        playerState = PlayerState.AIRBORNE;
        //Change the animation state to jumping
        animator.ChangeAnimation((int)PlayerAnimState.JUMP);
        //Que dust to play under the players feet
        //float dustDelay = 0.25f;
        //if(Mathf.Abs(_rbody.velocity.x) < 0.1f) {
        //    TempSpriteManager.GetInstance().PlayAnimation("Dust_Small", (Vector2)transform.position + new Vector2(1.5f,-1.5f), new Vector2(3,3), 0, "Foreground", 0, dustDelay);
        //    TempSpriteManager.GetInstance().PlayAnimation("Dust_Small", (Vector2)transform.position + new Vector2(-1.5f,-1.5f), new Vector2(-3,3), 0, "Foreground", 0, dustDelay);
        //}
        //else if(facingRight) {
        //    TempSpriteManager.GetInstance().PlayAnimation("Dust_Small", (Vector2)transform.position + new Vector2(1.5f,-1.5f), new Vector2(3,3), 0, "Foreground", 0, dustDelay);
        //    TempSpriteManager.GetInstance().PlayAnimation("Dust_Mid", (Vector2)transform.position + new Vector2(-1.5f,-1.5f), new Vector2(3,3), 0, "Foreground", 0, dustDelay);
        //}
        //else {
        //    TempSpriteManager.GetInstance().PlayAnimation("Dust_Small", (Vector2)transform.position + new Vector2(-1.5f,-1.5f), new Vector2(-3,3), 0, "Foreground", 0, dustDelay);
        //    TempSpriteManager.GetInstance().PlayAnimation("Dust_Mid", (Vector2)transform.position + new Vector2(1.5f,-1.5f), new Vector2(-3,3), 0, "Foreground", 0, dustDelay);
        //}

        Invoke("InvokeBaseClassJump", 0.05f);
        TempSpriteManager.GetInstance().PlayAnimation("Jump_Dust", (Vector2)transform.position + new Vector2(0, 0.5f), new Vector2(2 * Mathf.Sign(transform.localScale.x), 2), "Background2", -1);

        TempSpriteManager.GetInstance().PlayAnimation("Dust_Trail_Left2", (Vector2)transform.position + new Vector2(-0.1f, -0.25f), new Vector2(0.5f, 0.5f), new Vector2(-0.02f, 0), 0.0f, "Background2", 1, 0.3f);
        TempSpriteManager.GetInstance().PlayAnimation("Dust_Trail_Right2", (Vector2)transform.position + new Vector2(0.1f, -0.25f), new Vector2(0.5f, 0.5f), new Vector2(0.02f, 0), 0.0f, "Background2", 1, 0.3f);
    }
Example #3
0
    public void CreateDustCloud(Vector2 position, float rotationAngle)
    {
        TempSpriteManager spriteManager = TempSpriteManager.GetInstance();

        Vector2 dustTrailSpeed = new Vector2(0.015f, 0.0f);
        Vector2 smallDustSpeed = new Vector2(0.005f, 0.0f);

        float cs = Mathf.Cos(Mathf.Deg2Rad * rotationAngle);
        float sn = Mathf.Sin(Mathf.Deg2Rad * rotationAngle);

        Vector2 offset1 = new Vector2(0.0f, 1.0f);

        offset1 = new Vector2(offset1.x * cs - offset1.y * sn, offset1.x * sn + offset1.y * cs);

        Vector2 offset2 = new Vector2(0.7f, 0.0f);

        offset2 = new Vector2(offset2.x * cs - offset2.y * sn, offset2.x * sn + offset2.y * cs);
        Vector2 offset3 = new Vector2(-0.7f, 0.0f);

        offset3 = new Vector2(offset3.x * cs - offset3.y * sn, offset3.x * sn + offset3.y * cs);

        spriteManager.PlayAnimation("Large_Hit_02", position, new Vector2(1.5f, 1.5f), rotationAngle, "Foreground2", 0);
        spriteManager.PlayAnimation("Large_Dust_01", position + offset1, new Vector2(1, 1), rotationAngle, "Ground", 0, 0.1f);
        spriteManager.PlayAnimation("Dust_Trail_Left", position, new Vector2(1, 1), new Vector2(-dustTrailSpeed.x * cs - dustTrailSpeed.y * sn, -dustTrailSpeed.x * sn + dustTrailSpeed.y * cs), rotationAngle, "Ground", 0, 0.2f);
        spriteManager.PlayAnimation("Dust_Trail_Right", position, new Vector2(1, 1), new Vector2(dustTrailSpeed.x * cs - dustTrailSpeed.y * sn, dustTrailSpeed.x * sn + dustTrailSpeed.y * cs), rotationAngle, "Ground", 0, 0.2f);
        spriteManager.PlayAnimation("Small_Dust_01", position + offset2, new Vector2(1, 1), new Vector2(smallDustSpeed.x * cs - smallDustSpeed.y * sn, smallDustSpeed.x * sn + smallDustSpeed.y * cs), rotationAngle, "Ground", 0, 0.3f);
        spriteManager.PlayAnimation("Small_Dust_01", position + offset3, new Vector2(-1, 1), new Vector2(-smallDustSpeed.x * cs - smallDustSpeed.y * sn, -smallDustSpeed.x * sn + smallDustSpeed.y * cs), rotationAngle, "Ground", 0, 0.3f);
    }
Example #4
0
    void LoadAnimations()
    {
        //Load aniamtions
        foreach (NamedSprite animatedSprite in animations)
        {
            Animation2D anim = new Animation2D(animatedSprite.sprite, animatedSprite.priority, animatedSprite.name, false, animatedSprite.loop, animatedSprite.fadeOut);
            _resourceManager.GetAnimationManager().AddAnimation(anim);
        }
        //Load animation Sets
        foreach (NamedSpriteSet animatedSpriteSet in animationSets)
        {
            List <Animation2D> animList = new List <Animation2D>();
            foreach (NamedSprite animatedSprite in animatedSpriteSet.spriteList)
            {
                Animation2D anim = new Animation2D(animatedSprite.sprite, animatedSprite.priority, animatedSprite.name, false, animatedSprite.loop, animatedSprite.fadeOut);
                animList.Add(anim);
            }
            AnimationSet2D animSet = new AnimationSet2D(animatedSpriteSet.name, animList);
            _resourceManager.GetAnimationManager().AddAnimationSet(animSet);
        }

        //Load Temporary Sprites in the same fasion
        foreach (NamedSprite tempSprite in temporarySprites)
        {
            Animation2D anim = new Animation2D(tempSprite.sprite, tempSprite.priority, tempSprite.name, true, tempSprite.loop, tempSprite.fadeOut);
            TempSpriteManager.GetInstance().AddAnimation(anim);
        }
    }
Example #5
0
    public void BeginDodge(Vector2 inputDir)
    {
        if (canExecute)
        {
            _player.dodging  = true;
            _player.canDodge = false;
            Invoke("PlayerDodgeCooldown", actionCD);
            input = inputDir;
            _player.animator.ForceAnimationChange((int)PlayableEntity.PlayerAnimState.DODGE_ENTER);

            Color color  = new Color(_player.color.r, _player.color.g, _player.color.b, 0.75f);
            Color color2 = new Color(_player.color2.r, _player.color2.g, _player.color2.b, 0.75f);

            TempSpriteManager.GetInstance().PlayAnimation("Dodge_Gleem_Back", (Vector2)_player.transform.position, new Vector2(1, 1), Vector2.zero, 0.0f, "Foreground2", 0, 0.0f, color);
            TempSpriteManager.GetInstance().PlayAnimation("Dodge_Gleem_Color", (Vector2)_player.transform.position, new Vector2(1, 1), Vector2.zero, 0.0f, "Foreground2", 1, 0.0f, color2);

            _rbody.isKinematic = true;
            _player.GetComponent <CircleCollider2D>().enabled = false;
            _rbody.velocity = Vector2.zero;

            prevVel            = _rbody.velocity;
            _player.invincible = true;

            startPos = (Vector2)_player.transform.position;
            base.OnEnter();
        }
    }
 //Get instance method
 public static TempSpriteManager GetInstance()
 {
     if (_instance == null)
     {
         _instance = new TempSpriteManager();
     }
     return(_instance);
 }
Example #7
0
    private void InvokeWallJump()
    {
        //Jump away from the wall.
        float hForce = jumpForce / 3.0f;

        //If player is facing the left, inverse the forward force of the jump.
        if (!facingRight)
        {
            hForce *= -1;
        }
        //Add force to the player's rigidbody
        _rbody.AddForce(new Vector2(hForce, jumpForce));
        TempSpriteManager.GetInstance().PlayAnimation("Jump_Dust", (Vector2)transform.position + new Vector2(0.5f * Mathf.Sign(transform.localScale.x), 0), new Vector2(2, -2 * Mathf.Sign(hForce)), 90.0f, "Background2", -1);
    }
Example #8
0
    public void DoubleJump()
    {
        //Tell the animator to trigger the jump animation
        animator.ChangeAnimation((int)PlayerAnimState.JUMP);
        //Consume the double jump
        doubleJump = false;
        //Add a vertical force to the player.
        _rbody.velocity = new Vector3(_rbody.velocity.x, 0.0f, _rbody.velocity.y);
        Invoke("InvokeDoubleJump", 0.1f);

        TempSpriteManager.GetInstance().PlayAnimation("Jump_Dust", (Vector2)transform.position + new Vector2(0, -1.5f), new Vector2(-2 * Mathf.Sign(transform.localScale.x), -2), "Background2", -1);

        TempSpriteManager.GetInstance().PlayAnimation("Dust_Trail_Left2", (Vector2)transform.position + new Vector2(-0.1f, -0.25f), new Vector2(0.3f, 0.3f), new Vector2(-0.02f, 0), 0.0f, "Background2", -1, 0.3f);
        TempSpriteManager.GetInstance().PlayAnimation("Dust_Trail_Right2", (Vector2)transform.position + new Vector2(0.1f, -0.25f), new Vector2(0.3f, 0.3f), new Vector2(0.02f, 0), 0.0f, "Background2", -1, 0.3f);
    }
    public override void OnHit(Collider2D other)
    {
        BaseGameEntity otherObj = other.gameObject.GetComponent <BaseGameEntity>();

        if (!_audioSource.isPlaying)
        {
            _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumKick");
            _audioSource.Play();
            TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(0.7f * Mathf.Sign(player.transform.localScale.x), 0.7f), "Foreground2", 6);
        }
        otherObj.DealTempDamage(damage * damageMod);
        if (Mathf.Sign(transform.localScale.x) == 1.0f)
        {
            otherObj.Knockback(new Vector2(2.0f, 1.0f).normalized, force, 0.2f);
        }
        else
        {
            otherObj.Knockback(new Vector2(-2.0f, 1.0f).normalized, force, 0.2f);
        }
    }
Example #10
0
    public override void OnHit(Collider2D other)
    {
        BaseGameEntity otherObj = other.gameObject.GetComponent <BaseGameEntity>();

        if (!_audioSource.isPlaying)
        {
            _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("WeakKick");
            _audioSource.Play();
            int    i        = Random.Range(1, 4);
            string smallHit = "Small_Hit_0";
            smallHit = smallHit.Insert(smallHit.Length, i.ToString());
            TempSpriteManager.GetInstance().PlayAnimation(smallHit, other.transform.position + new Vector3(1 * Mathf.Sign(player.transform.localScale.x), 0, 0), new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), "Foreground2", 6);
        }
        otherObj.DealTempDamage(damage * damageMod);
        Vector3 direction = Vector3.right;

        if (Mathf.Sign(transform.localScale.x) == -1)
        {
            direction = Vector3.left;
        }
        otherObj.Knockback(direction * 2 + Vector3.up, force, 0.1f);
    }
Example #11
0
    public override void Finish()
    {
        Color color  = new Color(_player.color.r, _player.color.g, _player.color.b, 0.75f);
        Color color2 = new Color(_player.color2.r, _player.color2.g, _player.color2.b, 0.75f);

        TempSpriteManager.GetInstance().PlayAnimation("Dodge_Gleem_Back", (Vector2)_player.transform.position, new Vector2(1, 1), Vector2.zero, 0.0f, "Foreground2", 0, 0.0f, color);
        TempSpriteManager.GetInstance().PlayAnimation("Dodge_Gleem_Color", (Vector2)_player.transform.position, new Vector2(1, 1), Vector2.zero, 0.0f, "Foreground2", 1, 0.0f, color2);

        _player.dodging    = false;
        _player.invincible = false;


        float inX = Input.GetAxis(_player.horizontalAxis);
        float inY = Input.GetAxis(_player.verticalAxis);

        if (_player.vanishCounter)
        {
            _player.vanishCounter = false;
            if (_player.facingRight && inX < 0)
            {
                _player.FlipX();
            }
            else if (!_player.facingRight && inX > 0)
            {
                _player.FlipX();
            }
            input = new Vector2(inX, -inY).normalized;
            _player.Attack(inX, inY);
        }
        else
        {
            //_rbody.velocity = prevVel;
            _rbody.velocity = Vector2.zero;
        }
        base.Finish();
    }
Example #12
0
    public override void OnHit(Collider2D other)
    {
        BaseGameEntity otherObj        = other.gameObject.GetComponent <BaseGameEntity>();
        Vector2        directionVector = (otherObj.transform.position - transform.position).normalized + Vector3.up;

        float angle = Mathf.Rad2Deg * Mathf.Acos(Vector2.Dot(directionVector.normalized, Vector2.right));

        switch (_animator.currAnim.currFrame)
        {
        case (0):
            //Crit Frame
            if (Mathf.Abs(((Vector2)(transform.position) - (Vector2)(other.transform.position)).magnitude) <= critRange)
            {
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("StrongPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Large_Hit_02", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), angle, "Foreground2", 6);
                }
                otherObj.DealTempDamage(damage * damageMod * 2.0f);
                otherObj.LinearKnockback(directionVector, 0.4f);
            }
            else
            {
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), angle, "Foreground2", 6);
                }
                otherObj.DealTempDamage(damage * damageMod);
                otherObj.Knockback(directionVector, force, 0.2f);
            }
            break;

        case (1):
            if (!_audioSource.isPlaying)
            {
                _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                _audioSource.Play();
                TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), angle, "Foreground2", 6);
            }
            otherObj.DealTempDamage(damage * damageMod * 0.9f);
            otherObj.Knockback(directionVector, force, 0.15f);
            break;

        case (2):
            if (!_audioSource.isPlaying)
            {
                _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                _audioSource.Play();
                TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), angle, "Foreground2", 6);
            }
            otherObj.DealTempDamage(damage * damageMod * 0.8f);
            otherObj.Knockback(directionVector, force - 1000, 0.10f);
            break;

        case (3):
            if (!_audioSource.isPlaying)
            {
                _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                _audioSource.Play();
                TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), angle, "Foreground2", 6);
            }
            otherObj.DealTempDamage(damage * damageMod * 0.7f);
            otherObj.Knockback(directionVector, force - 2000, 0.05f);
            break;
        }
    }
Example #13
0
 public override void Enter()
 {
     _player.animator.ChangeAnimation((int)PlayableEntity.PlayerAnimState.BLOCK);
     TempSpriteManager.GetInstance().PlayAnimation("Pow", _player.transform.position, new Vector2(4.5f, 4.5f), "Foreground", 0);
     _player.blocking = true;
 }
Example #14
0
 private void FootStep()
 {
     //helper function just to play a small foot step sprite which can be called with invoke
     TempSpriteManager.GetInstance().PlayAnimation("Jump_Dust", (Vector2)transform.position, new Vector2(Mathf.Sign(transform.localScale.x), 1), "Background2", -1);
 }
Example #15
0
    // Update is called once per frame
    protected override void Update()
    {
        if (health <= 0)
        {
            Kill();
        }

        //Regen HP
        if (timeGotHit > 0.0f)
        {
            if (Time.time - timeGotHit >= regenCD)
            {
                if (tempHealth < health)
                {
                    tempHealth += (regenRate * Time.deltaTime);
                }
                if (tempHealth > health)
                {
                    timeGotHit = 0.0f;
                    tempHealth = health;
                }
            }
        }

        //Jessica is Sexy! (.)(.) <3

        //Determine the updates on the player depending on player state
        //The player contorller handles user input based on these states.
        //We must do all the rigidbody movement from outside forces, animations and soundeffects which belong to the character.  Temporary sprites involving player interaction will be handled outside this class
        playerAnimState = PlayerAnimState.NONE;  //making a temporary enum here so we dont call change animation a dozen times
        switch (playerState)
        {
        case (PlayerState.GROUNDED):
            SetGravity(1.0f);
            //set drag for ground
            if (!knockedback)
            {
                _rbody.drag = dragGround;
            }
            else
            {
                _rbody.drag = dragSliding;
            }

            transform.rotation = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
            if (playerAnimState == PlayerAnimState.FALL)
            {
                playerAnimState = PlayerAnimState.CROUCH;
                break;
            }
            //We are grounded so check for movement to determine if idle or running
            //If the x velocity is greater then 0.1 or less then -0.1 we are moving
            if (_rbody.velocity.x > 0.1 || _rbody.velocity.x < -0.1)
            {
                float h = Input.GetAxis(horizontalAxis);
                if ((h > 0.01f && _rbody.velocity.x > 0.1f) || (h < -0.01f && _rbody.velocity.x < -0.1f))
                {
                    playerAnimState = PlayerAnimState.RUN;
                    kickedUpDust    = false;
                }
                else
                {
                    if (!kickedUpDust && playerAnimState != PlayerAnimState.SLIDE)
                    {
                        kickedUpDust = true;
                        TempSpriteManager.GetInstance().PlayAnimation("Small_Dust_02", (Vector2)transform.position + new Vector2(Mathf.Sign(transform.localScale.x) * 1, 0), new Vector2(0.5f * Mathf.Sign(transform.localScale.x), 0.5f), new Vector2(0.02f * Mathf.Sign(transform.localScale.x), 0), 0.0f, "Background2", -1, 0.3f);
                    }
                    playerAnimState = PlayerAnimState.SLIDE;
                }
            }
            //We dont have to set idle because we did at the beginning.  If the player isnt running and is in this state nothing else will be called because of the break.
            //Jittering in the transition from idle and run can be solved using the horizontal axis, however the playercontroller class will have to be altered slightly
            else
            {
                playerAnimState = PlayerAnimState.IDLE;
            }
            break;

        case (PlayerState.AIRBORNE):
            if (!knockedback)
            {
                SetGravity(1.0f);
            }
            //PROBABLY WANNA CHANGE THIS AT SOME POINT TO BETTER CODE.... WAY TO LAZY RIGHT NOW
            if (attacking)
            {
                _rbody.drag = dragGround;
            }
            else
            {
                _rbody.drag = dragAir;
            }
            //playerAnimState = PlayerAnimState.FALL;

            if (Mathf.Abs(_rbody.velocity.y) <= 5.5f)
            {
                playerAnimState = PlayerAnimState.APEX;
            }
            else if (_rbody.velocity.y > 0.1f)
            {
                playerAnimState = PlayerAnimState.JUMP;
            }
            else
            {
                playerAnimState = PlayerAnimState.FALL;
            }

            break;

        case (PlayerState.CLIMBING):
            _rbody.drag = dragClimbing;
            //If we are climbing then set the animation to climbing.  In this player state there isnt any other animation that could occur.
            transform.rotation = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
            SetGravity(0.33f);
            playerAnimState = PlayerAnimState.CLIMB;
            break;

        case (PlayerState.HANGING):
            //If we are hanging then set the animation to hang. In this player state there isnt any other animation that could occur.
            playerAnimState = PlayerAnimState.HANG;
            SetGravity(0.0f);
            _rbody.velocity = Vector2.zero;
            break;

        case (PlayerState.DEAD):
            timeSinceDied += Time.deltaTime;
            if (timeSinceDied >= respawnCD)
            {
                timeSinceDied = 0.0f;
                Respawn(GameObject.Find("Main Camera").transform.position);
            }
            break;
        }
        //Crouching?
        if (crouching)
        {
            playerAnimState = PlayerAnimState.CROUCH;
        }

        //If we have changed animations update the animator
        if (animator.animState != (int)playerAnimState)
        {
            animator.ChangeAnimation((int)playerAnimState);
        }

        //animator is updated in the base class
        base.Update();
        if (playerState != PlayerState.DEAD)
        {
            controller.Update();
        }
    }
Example #16
0
    public override void OnHit(Collider2D other)
    {
        BaseGameEntity otherObj        = other.gameObject.GetComponent <BaseGameEntity>();
        Vector2        directionVector = Vector2.right;

        if (Mathf.Sign(transform.localScale.x) == -1)
        {
            directionVector = Vector2.left;
        }

        float cs = Mathf.Cos(transform.rotation.eulerAngles.z);
        float sn = Mathf.Sin(transform.rotation.eulerAngles.z);

        directionVector = new Vector2(directionVector.x * cs - directionVector.y * sn, directionVector.x * sn + directionVector.y * cs);


        switch (_animator.currAnim.currFrame)
        {
        case (0):
            //Crit Frame
            if (Mathf.Abs(((Vector2)(transform.position) - (Vector2)(other.transform.position)).magnitude) <= critRange)
            {
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("StrongPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Large_Hit_02", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), "Foreground2", 6);
                }
                otherObj.DealTempDamage(damage * damageMod * 2.0f);
                otherObj.LinearKnockback(directionVector, 0.4f);
            }
            else
            {
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), "Foreground2", 6);
                }
                otherObj.DealTempDamage(damage * damageMod);
                otherObj.Knockback(directionVector, force, 0.2f);
            }
            break;

        case (1):
            if (!_audioSource.isPlaying)
            {
                _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                _audioSource.Play();
                TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), "Foreground2", 6);
            }
            otherObj.DealTempDamage(damage * damageMod * 0.9f);
            otherObj.Knockback(directionVector, force, 0.15f);
            break;

        case (2):
            if (!_audioSource.isPlaying)
            {
                _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                _audioSource.Play();
                TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), "Foreground2", 6);
            }
            otherObj.DealTempDamage(damage * damageMod * 0.8f);
            otherObj.Knockback(directionVector, force, 0.10f);
            break;

        case (3):
            if (!_audioSource.isPlaying)
            {
                _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                _audioSource.Play();
                TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), "Foreground2", 6);
            }
            otherObj.DealTempDamage(damage * damageMod * 0.7f);
            otherObj.Knockback(directionVector, force, 0.05f);
            break;
        }
    }
Example #17
0
 // Update is called once per frame
 void Update()
 {
     TempSpriteManager.GetInstance().Update();
     EffectManager.GetInstance().Update();
 }
    public override void OnHit(Collider2D other)
    {
        BaseGameEntity otherObj         = other.gameObject.GetComponent <BaseGameEntity>();
        Vector2        directionVector  = (otherObj.transform.position - transform.position).normalized;
        Vector2        horizontalVector = Vector2.right;
        Vector2        knockbackVector  = Quaternion.AngleAxis(-90, new Vector3(0.0f, 0.0f, 1.0f)) * directionVector;

        if (Mathf.Sign(transform.localScale.x) == -1.0f)
        {
            horizontalVector = Vector2.left;
            knockbackVector  = Quaternion.AngleAxis(90, new Vector3(0.0f, 0.0f, 1.0f)) * directionVector;
        }

        //Get the angle between the vector connecting the attacker and defender
        //angle between vetors : cosTheta = a dot b (if normlized skip we can skip devision step)
        float attackAngle = Mathf.Rad2Deg * Mathf.Acos(Vector2.Dot(directionVector, horizontalVector));

        //if the attack angle is within 30 degrees  then its a crit
        if (Mathf.Abs(attackAngle) <= 40.0f)
        {
            crit = true;
        }
        else
        {
            crit = false;
        }

        switch (_animator.currAnim.currFrame)
        {
        case (0):
            if (crit)
            {
                otherObj.DealTempDamage(damage * damageMod * 2.0f);
                otherObj.LinearKnockback(knockbackVector, 0.4f);
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("StrongPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Large_Hit_02", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), attackAngle, "Foreground2", 6);
                }
            }
            else
            {
                otherObj.DealTempDamage(damage * damageMod);
                otherObj.Knockback(knockbackVector, force, 0.15f);
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), attackAngle, "Foreground2", 6);
                }
            }
            break;

        case (1):
            if (crit)
            {
                otherObj.DealTempDamage(damage * damageMod * 2.0f);
                otherObj.LinearKnockback(knockbackVector, 0.4f);
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("StrongPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Large_Hit_02", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), attackAngle, "Foreground2", 6);
                }
            }
            else
            {
                otherObj.DealTempDamage(damage * damageMod);
                otherObj.Knockback(knockbackVector, force, 0.15f);
                if (!_audioSource.isPlaying)
                {
                    _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("MediumPunch");
                    _audioSource.Play();
                    TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), attackAngle, "Foreground2", 6);
                }
            }
            break;

        case (2):
            otherObj.DealTempDamage(damage * damageMod);
            otherObj.Knockback(knockbackVector, force, 0.05f);
            if (!_audioSource.isPlaying)
            {
                _audioSource.clip = ResourceManager.GetInstance().GetAudioManager().GetAudioClip("WeakKick");
                _audioSource.Play();
                TempSpriteManager.GetInstance().PlayAnimation("Mid_Hit_01", other.transform.position, new Vector2(1 * Mathf.Sign(player.transform.localScale.x), 1), attackAngle, "Foreground2", 6);
            }
            break;
        }
    }
Example #19
0
 void Start()
 {
     TempSpriteManager.GetInstance().PlayAnimation("Title_Intro", new Vector2(0, 0), new Vector2(1.1f, 1), "UI", 4);
     startText.enabled = false;
     Invoke("EnableStartText", 4.5f);
 }