public void ChargeShotEvent() { if (C_GAMEMANAGER.GetInstance().GetPlayer().GetCurrentChargeBulletCount() > 0) { GameObject ChargeInst = chars.Alloc(); if (ChargeInst == null) { chars.AllFree(); ChargeInst = chars.Alloc(); if (ChargeInst == null) { return; } } ChargeInst.GetComponent <Transform>().position = transform.Find("ArrowSpot").position; float fDegree = C_GAMEMANAGER.GetInstance().GetPlayer().GetPlayerStats().m_fChargeBulletDegree; Vector3 dir = C_GAMEMANAGER.GetInstance().GetPlayer().GetRealForwardDir(); float fBulletShotAng = 0.0f; Vector2 jdir = C_GAMEMANAGER.GetInstance().GetJoyStickDir(); if (jdir.y >= 0.0f) { fBulletShotAng = Mathf.Acos(Vector2.Dot(jdir, Vector2.right)) * Mathf.Rad2Deg; } else { fBulletShotAng = 360.0f - Mathf.Acos(Vector2.Dot(jdir, Vector2.right)) * Mathf.Rad2Deg; } dir = Quaternion.Euler(0.0f, 0.0f, fBulletShotAng + fDegree) * dir; Vector3 vAdd = new Vector3(C_GAMEMANAGER.GetInstance().GetPlayer().GetCurrentSpeed(), C_GAMEMANAGER.GetInstance().GetPlayer().GetVerticalSpeed(), 0.0f); ChargeInst.transform.rotation = Quaternion.Euler(0.0f, 0.0f, transform.eulerAngles.z + fBulletShotAng + fDegree); ChargeInst.GetComponent <Rigidbody2D>().velocity = (dir.normalized * C_GAMEMANAGER.GetInstance().GetPlayer().GetPlayerStats().m_fChargeBulletSpeed * 50.0f) + vAdd; if (ChargeInst.name.Equals("Chicken_Bullet_Charge(Clone)")) { ChargeInst.GetComponent <ChickenChargeMovement>().Movement(); } int ccb = C_GAMEMANAGER.GetInstance().GetPlayer().GetCurrentChargeBulletCount(); C_GAMEMANAGER.GetInstance().GetPlayer().SetCurrentChargeBulletCount(ccb - 1); } }
public void ShotEvent() { if (C_GAMEMANAGER.GetInstance().GetPlayer().GetCurrentBulletCount() > 0) { GameObject BulletInstance = bulls.Alloc(); if (BulletInstance == null) { bulls.AllFree(); BulletInstance = bulls.Alloc(); if (BulletInstance == null) { return; } } BulletInstance.GetComponent <Transform>().position = transform.Find("ArrowSpot").position; float fDegree = C_GAMEMANAGER.GetInstance().GetPlayer().GetPlayerStats().m_fBulletDegree; Vector3 dir = C_GAMEMANAGER.GetInstance().GetPlayer().GetRealForwardDir(); float fBulletShotAng = 0.0f; Vector2 jdir = C_GAMEMANAGER.GetInstance().GetJoyStickDir(); if (jdir.y >= 0.0f) { fBulletShotAng = Mathf.Acos(Vector2.Dot(jdir, Vector2.right)) * Mathf.Rad2Deg; } else { fBulletShotAng = 360.0f - Mathf.Acos(Vector2.Dot(jdir, Vector2.right)) * Mathf.Rad2Deg; } dir = Quaternion.Euler(0.0f, 0.0f, fBulletShotAng + fDegree) * dir; Vector3 vAdd = new Vector3(C_GAMEMANAGER.GetInstance().GetPlayer().GetCurrentSpeed(), C_GAMEMANAGER.GetInstance().GetPlayer().GetVerticalSpeed(), 0.0f); BulletInstance.transform.rotation = Quaternion.Euler(0.0f, 0.0f, transform.eulerAngles.z + fBulletShotAng + fDegree); BulletInstance.GetComponent <Rigidbody2D>().velocity = (dir.normalized * C_GAMEMANAGER.GetInstance().GetPlayer().GetPlayerStats().m_fBulletSpeed *50.0f) + vAdd; int b = C_GAMEMANAGER.GetInstance().GetPlayer().GetCurrentBulletCount(); C_GAMEMANAGER.GetInstance().GetPlayer().SetCurrentBulletCount(b - 1); } }