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"); } }
IEnumerator StopHurtPlayer() { yield return(new WaitForSeconds(.5f)); status = ebStatus.WALKING; dickT.rotation = Quaternion.identity; //headA.GetComponent<SpriteRenderer>().sprite = Soldier_Sprites.S.getHead(0); }
void testGrounded() { //print ("TEST GROUND "+Time.deltaTime); if (Physics2D.Linecast(transform.position, groundCheck.position, layerMsk)) { status = ebStatus.WALKING; //print ("walk"); } }
IEnumerator StopHurt() { yield return(new WaitForSeconds(0.3f)); if (!dead) { status = ebStatus.WALKING; } }
//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(); } //} }
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; }
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(); } }
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); }
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; }
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; }
IEnumerator StopHurt() { yield return new WaitForSeconds(0.3f); if(!dead){ status = ebStatus.WALKING; } }
void testGrounded() { //print ("TEST GROUND "+Time.deltaTime); if(Physics2D.Linecast (transform.position, groundCheck.position, layerMsk)){ status = ebStatus.WALKING; //print ("walk"); } }
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(); } }
//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(); } //} }
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); }
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; }
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"); } }
IEnumerator StopHurtPlayer() { yield return new WaitForSeconds(.5f); status = ebStatus.WALKING; dickT.rotation = Quaternion.identity; //headA.GetComponent<SpriteRenderer>().sprite = Soldier_Sprites.S.getHead(0); }