예제 #1
0
    private void switchToFlipped()
    {
        //yield return new WaitForSeconds (1.5f);

        var vel = Mathf.Abs(rb2D.velocity.x) + Mathf.Abs(rb2D.velocity.y);

        if (vel < 0.1f)
        {
            if (dead)
            {
                CancelInvoke("switchToFlipped");
                return;
            }

            body.SetActive(true);
            rdBody.SetActive(false);
            if (equipped == Equipped.SHIELD)
            {
                shield.SetActive(false);
                shieldFake.SetActive(true);
            }
            transform.rotation = Quaternion.identity;
            rb2D.constraints   = RigidbodyConstraints2D.FreezeRotation;          /// backwards?????
            status             = ebStatus.FLIPPED;
            anim.Play("dickBugFlipped");
            StartCoroutine(switchToNormal());

            CancelInvoke("switchToFlipped");
        }
    }
예제 #2
0
    IEnumerator StopHurtPlayer()
    {
        yield return(new WaitForSeconds(.5f));

        status         = ebStatus.WALKING;
        dickT.rotation = Quaternion.identity;
        //headA.GetComponent<SpriteRenderer>().sprite = Soldier_Sprites.S.getHead(0);
    }
예제 #3
0
 void testGrounded()
 {
     //print ("TEST GROUND "+Time.deltaTime);
     if (Physics2D.Linecast(transform.position, groundCheck.position, layerMsk))
     {
         status = ebStatus.WALKING;
         //print ("walk");
     }
 }
예제 #4
0
    IEnumerator StopHurt()
    {
        yield return(new WaitForSeconds(0.3f));

        if (!dead)
        {
            status = ebStatus.WALKING;
        }
    }
예제 #5
0
 //IEnumerator delayAnim()
 //{
 //yield return new WaitForSeconds(0.01f);
 //enemyA.Play ("enemyWalk");
 //}
 void testFalling()
 {
     //if(rb2D.velocity.y < -20f){
     if (!Physics2D.Linecast(transform.position, groundCheck.position, layerMsk))
     {
         //print ("paracuting "+grounded);
         //if(!grounded){
         //print ("fall");
         status = ebStatus.FALLING;
         //startFalling();
         //switchToRagdoll();
     }
     //}
 }
예제 #6
0
    private IEnumerator switchToNormal()
    {
        yield return(new WaitForSeconds(2));

        if (dead)
        {
            return(false);
        }
        if (equipped == Equipped.SHIELD)
        {
            shield.SetActive(true);
            shieldFake.SetActive(false);
        }
        gameObject.layer = LayerMask.NameToLayer("Enemies");
        //rb2D.fixedAngle = false;
        anim.Play("dickBugWalk");
        status = ebStatus.WALKING;
    }
예제 #7
0
    public override void Shot(bool headshot, float damage, Vector2 force, Vector2 pos)
    {
        eDamage.makeBodyBulletHole();
        base.Shot(headshot, damage, force, pos);
        //switchToRagdoll();
        status = ebStatus.HURT;
        //Vector3 force = GetBlastDirection(transform.position,ePos);
        StartCoroutine("StopHurt");
        //var d = GetBlastTorque(force);
        //force.y = damage/2;

        rb2D.AddForce(force * damage / 10, ForceMode2D.Impulse);
        //rb2D.AddTorque(damage * d);

        if (died)
        {
            Death();
        }
    }
예제 #8
0
    private void switchToRagdoll()
    {
        gameObject.layer = LayerMask.NameToLayer("EnemyRagdoll");
        status           = ebStatus.RAGDOLL;
        body.SetActive(false);
        var scl = Vector3.one;

        if (!facingRight)
        {
            scl.x       = -1;
            facingRight = true;
        }
        rdBody.transform.localScale = scl;
        rdBody.SetActive(true);
        rb2D.constraints = RigidbodyConstraints2D.None;        // backwards????
        //rb2D.fixedAngle = false;
        //StartCoroutine (switchToFlipped ());
        InvokeRepeating("switchToFlipped", 1.5f, 0.3f);
    }
예제 #9
0
    public override void HurtPlayer(Vector3 pos)
    {
        status = ebStatus.ATTACK;
        FlipTowardsPlayer();
        pos.y += 2f;
        Vector3 charPos = transform.position;

        float diffX = pos.x - charPos.x;
        float diffY = pos.y - charPos.y;

        float angle2 = Mathf.Atan2(diffY, diffX) * Mathf.Rad2Deg;

        //print (angle2);
        if (angle2 < -40f)
        {
            angle2 = -40f;
        }
        Quaternion angle3 = Quaternion.Euler(new Vector3(0, 0, angle2));

        if (!facingRight)
        {
            angle2 = Mathf.Atan2(diffY, diffX * -1) * Mathf.Rad2Deg;
            angle3 = Quaternion.Euler(new Vector3(0, 0, angle2));
            if (angle2 < -90f)
            {
                angle2 = -90f;
            }
        }
        dickT.rotation = angle3;
        dickA.Play("enemyShootGun");

        AudioSource.PlayClipAtPoint(growlFX[UnityEngine.Random.Range(0, growlFX.Length)], transform.position);

        StartCoroutine("StopHurtPlayer");
        //return true;
    }
예제 #10
0
    public override void HurtPlayer(Vector3 pos)
    {
        status = ebStatus.ATTACK;
        FlipTowardsPlayer();
        pos.y += 2f;
        Vector3 charPos = transform.position;

        float diffX = pos.x - charPos.x;
        float diffY = pos.y - charPos.y;

        float angle2 = Mathf.Atan2(diffY, diffX) * Mathf.Rad2Deg;
        //print (angle2);
        if(angle2 < -40f){
            angle2 = -40f;
        }
        Quaternion angle3 = Quaternion.Euler(new Vector3(0, 0, angle2));
        if(!facingRight){
            angle2 = Mathf.Atan2(diffY, diffX * -1) * Mathf.Rad2Deg;
            angle3 = Quaternion.Euler(new Vector3(0, 0, angle2));
            if(angle2 < -90f){
                angle2 = -90f;
            }
        }
        dickT.rotation = angle3;
        dickA.Play ("enemyShootGun");

        AudioSource.PlayClipAtPoint(growlFX[UnityEngine.Random.Range (0, growlFX.Length)], transform.position);

        StartCoroutine("StopHurtPlayer");
        //return true;
    }
예제 #11
0
 IEnumerator StopHurt()
 {
     yield return new WaitForSeconds(0.3f);
     if(!dead){
         status = ebStatus.WALKING;
     }
 }
예제 #12
0
 void testGrounded()
 {
     //print ("TEST GROUND "+Time.deltaTime);
     if(Physics2D.Linecast (transform.position, groundCheck.position, layerMsk)){
         status = ebStatus.WALKING;
         //print ("walk");
     }
 }
예제 #13
0
    public override void Shot(bool headshot, float damage,Vector2 force, Vector2 pos)
    {
        eDamage.makeBodyBulletHole();
        base.Shot (headshot, damage,force,pos);
        //switchToRagdoll();
        status = ebStatus.HURT;
        //Vector3 force = GetBlastDirection(transform.position,ePos);
        StartCoroutine("StopHurt");
        //var d = GetBlastTorque(force);
        //force.y = damage/2;

        rb2D.AddForce (force * damage/10,ForceMode2D.Impulse);
        //rb2D.AddTorque(damage * d);

        if (died) {
            Death();
        }
    }
예제 #14
0
    //IEnumerator delayAnim()
    //{
    //yield return new WaitForSeconds(0.01f);
    //enemyA.Play ("enemyWalk");
    //}
    void testFalling()
    {
        //if(rb2D.velocity.y < -20f){
            if(!Physics2D.Linecast (transform.position, groundCheck.position, layerMsk)){
            //print ("paracuting "+grounded);
            //if(!grounded){
                //print ("fall");
                status = ebStatus.FALLING;
                //startFalling();
                //switchToRagdoll();

            }
        //}
    }
예제 #15
0
 private void switchToRagdoll()
 {
     gameObject.layer = LayerMask.NameToLayer("EnemyRagdoll");
     status = ebStatus.RAGDOLL;
     body.SetActive (false);
     var scl = Vector3.one;
     if (!facingRight) {
         scl.x = -1;
         facingRight = true;
     }
     rdBody.transform.localScale = scl;
     rdBody.SetActive (true);
     rb2D.constraints = RigidbodyConstraints2D.None;// backwards????
     //rb2D.fixedAngle = false;
     //StartCoroutine (switchToFlipped ());
     InvokeRepeating("switchToFlipped",1.5f,0.3f);
 }
예제 #16
0
 private IEnumerator switchToNormal()
 {
     yield return new WaitForSeconds (2);
     if (dead) {return false;}
     if(equipped == Equipped.SHIELD){
         shield.SetActive(true);
         shieldFake.SetActive(false);
     }
     gameObject.layer = LayerMask.NameToLayer("Enemies");
     //rb2D.fixedAngle = false;
     anim.Play ("dickBugWalk");
     status = ebStatus.WALKING;
 }
예제 #17
0
    private void switchToFlipped()
    {
        //yield return new WaitForSeconds (1.5f);

        var vel = Mathf.Abs(rb2D.velocity.x) + Mathf.Abs(rb2D.velocity.y);
        if(vel < 0.1f){

            if (dead) {
                CancelInvoke("switchToFlipped");
                return;
            }

            body.SetActive (true);
            rdBody.SetActive (false);
            if(equipped == Equipped.SHIELD){
                shield.SetActive(false);
                shieldFake.SetActive(true);
            }
            transform.rotation = Quaternion.identity;
            rb2D.constraints = RigidbodyConstraints2D.FreezeRotation;/// backwards?????
            status = ebStatus.FLIPPED;
            anim.Play ("dickBugFlipped");
            StartCoroutine (switchToNormal ());

            CancelInvoke("switchToFlipped");
        }
    }
예제 #18
0
 IEnumerator StopHurtPlayer()
 {
     yield return new WaitForSeconds(.5f);
     status = ebStatus.WALKING;
     dickT.rotation = Quaternion.identity;
     //headA.GetComponent<SpriteRenderer>().sprite = Soldier_Sprites.S.getHead(0);
 }