コード例 #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
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
    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
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
 IEnumerator StopHurt()
 {
     yield return new WaitForSeconds(0.3f);
     if(!dead){
         status = ebStatus.WALKING;
     }
 }
コード例 #12
0
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
 void testGrounded()
 {
     //print ("TEST GROUND "+Time.deltaTime);
     if(Physics2D.Linecast (transform.position, groundCheck.position, layerMsk)){
         status = ebStatus.WALKING;
         //print ("walk");
     }
 }
コード例 #13
0
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
    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
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
    //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
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
 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
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
 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
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
    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
ファイル: Enemy_Dickbug.cs プロジェクト: Libeedo/psycho-bob
 IEnumerator StopHurtPlayer()
 {
     yield return new WaitForSeconds(.5f);
     status = ebStatus.WALKING;
     dickT.rotation = Quaternion.identity;
     //headA.GetComponent<SpriteRenderer>().sprite = Soldier_Sprites.S.getHead(0);
 }