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); } }
IEnumerator Start() { m_cPool = new C_ObjectPool(nSize, C_GAMEMANAGER.GetInstance().GetObjectMgr().GetObject(strObstacleName)); while (true) { if (C_GAMEMANAGER.GetInstance().GetPlayer().GetState() == E_PLAYERSTATE.E_PLAYERRELEASE) { break; } yield return(new WaitForSeconds(0.02f)); } int nCount = 0; while (true) { yield return(new WaitForSeconds(fCoolTime)); if (nCount >= nSize) { nCount = 0; m_cPool.DestroyAll(); m_cPool = new C_ObjectPool(nSize, C_GAMEMANAGER.GetInstance().GetObjectMgr().GetObject(strObstacleName)); } GameObject goObject = m_cPool.Alloc(); goObject.GetComponent <Transform>().position = transform.position + new Vector3(0, Random.Range(-7, 7)); nCount++; if (C_GAMEMANAGER.GetInstance().GetPlayer().GetState() == E_PLAYERSTATE.E_PLAYERDIE) { m_cPool.DestroyAll(); break; } } }
IEnumerator Start() { GameObject oo = C_GAMEMANAGER.GetInstance().GetObjectMgr().GetObject("EmptyItem_IM"); if (oo == null) { Debug.Log("Failed!~!"); yield return(new WaitForSeconds(0.0f)); } m_cPool = new C_ObjectPool(nSize, oo); while (true) { if (C_GAMEMANAGER.GetInstance().GetPlayer().GetState() == E_PLAYERSTATE.E_PLAYERRELEASE) { break; } yield return(new WaitForSeconds(0.02f)); } int nCount = 0; while (true) { yield return(new WaitForSeconds(fCoolTime)); if (nCount >= nSize) { nCount = 0; m_cPool.DestroyAll(); GameObject jj = C_GAMEMANAGER.GetInstance().GetObjectMgr().GetObject("EmptyItem_IM"); if (jj == null) { break; } m_cPool = new C_ObjectPool(nSize, jj); } GameObject goObject = m_cPool.Alloc(); ItemScript iss = goObject.GetComponent <ItemScript>(); if (iss != null) { iss.SetItemSpr(); } goObject.GetComponent <Transform>().position = transform.position + new Vector3(0, Random.Range(-7, 7)); nCount++; if (C_GAMEMANAGER.GetInstance().GetPlayer().GetState() == E_PLAYERSTATE.E_PLAYERDIE) { m_cPool.DestroyAll(); break; } } }