public CGPhysicsObject(CGThrowableObject o, Vector3 d, float p, WorldSetter ws) { WorldSetter.ECubeArea ae = ws.GetCubeAreaEnum(o.transform.position); this.ePreviousArea = ae; this.eCurrentArea = ae; this.eTargetArea = WorldSetter.ECubeArea.NONE; this.eObjectState = EObjectState.OBJECT_LAUNCH_TRIGGER; this.throwableObject = o; this.objectRigidBody = this.throwableObject.GetComponent <Rigidbody>(); this.launchDirection = d; this.launchPower = p; this.isAreaChanged = false; }
private void DoObjectMoving(int objectIndex) { WorldSetter.ECubeArea eCubeArea = this.m_worldSetter.GetCubeAreaEnum(this.m_objects[objectIndex].throwableObject.transform.position); Bounds areaWorldBound = this.m_worldSetter.GetCubeAreaBound(eCubeArea); Bounds objWorldBound = this.m_objects[objectIndex].throwableObject.GetComponent <Renderer>().bounds; bool isInside = WorldSetter.IsAInsideB(objWorldBound.min, objWorldBound.max, areaWorldBound.min, areaWorldBound.max); // Area가 한 번 바뀌었으므로, Target으로 가는 중이다. // Target Area에 있다면, TARGET_AREA state로 바꾸고, Update() 함수에서 없애준다. if (this.m_objects[objectIndex].isAreaChanged == true) { // 해당 target area에 넘어왔고, bound box가 완전히 들어왔다면 // Layer 설정을 바꾸어서 plane과 충돌처리 되게 한다. if (this.m_objects[objectIndex].eTargetArea == eCubeArea && isInside) { this.m_objects[objectIndex].eObjectState = CGPhysicsObject.EObjectState.OBJECT_TARGET_AREA; this.m_objects[objectIndex].throwableObject.SetLayerAsInArea(); // In order to make CGThrowableObject collide with world barrier planes // 해당 지역의 gravity로 설정해준다. Vector3 targetGravity = this.m_cubeAreaGravity[(uint)eCubeArea]; this.m_objects[objectIndex].throwableObject.SetCubeAreaGravity(targetGravity); } } else if (this.m_objects[objectIndex].eCurrentArea != eCubeArea) { // 해당 넘어가는 지역으로 완전히 들어 갔으면, Area Changed를 true로 해주고, // 해당 지역의 Force를 넘겨준다. if (isInside == true) { this.m_objects[objectIndex].isAreaChanged = true; this.m_objects[objectIndex].ePreviousArea = m_objects[objectIndex].eCurrentArea; this.m_objects[objectIndex].eCurrentArea = eCubeArea; this.m_objects[objectIndex].eTargetArea = m_targetArea[(uint)m_objects[objectIndex].ePreviousArea, (uint)m_objects[objectIndex].eCurrentArea]; if (true == this.m_isValidAreaChange[(uint)m_objects[objectIndex].ePreviousArea, (uint)m_objects[objectIndex].eCurrentArea]) { // 다른 지역으로 넘어갔다. } else { // PutBack the Throwable Object this.m_objects[objectIndex].throwableObject.ResetObject(); this.m_objects.RemoveAt(objectIndex); } } } }
public virtual void InitPlayer() { this.gameObject.layer = LayerMask.NameToLayer("CGPlayer"); this.m_pwManager = GameObject.Find("PhysicsWorldManager").GetComponent <PhysicsWorldManager>(); this.m_worldSetter = GameObject.Find("WorldSetter").GetComponent <WorldSetter>(); this.m_characterController = GetComponent <CharacterController>(); // @Chan : upVector도 eCubeArea에 따라 설정되게 해야하지 않을까? 예를들어 Cube아래에 있는 캐릭터의 up vector가 전혀 다를거라서. this.m_playerUpVector = this.transform.up; this.m_originQuaternion = this.transform.localRotation; this.m_playerHeight = this.m_characterController.height; this.m_playerGravityScale = 0.25f; this.m_overlapBoxCenter = new Vector3(0.0f, 0.0f, 0.0f); this.m_overlapBoxHalfExtent = new Vector3(0.05f, 0.1f, 0.05f); SetPlayerDirectionVectors(); }
private void InitPhysicsWorldManager() { this.m_worldSetter = GameObject.Find("WorldSetter").GetComponent <WorldSetter>(); // 동적 할당 this.m_targetArea = new WorldSetter.ECubeArea[(uint)WorldSetter.ECubeArea.NONE, (uint)WorldSetter.ECubeArea.NONE]; this.m_cubeAreaGravity = new Vector3[6]; this.m_forceSpace = new Vector3[(uint)WorldSetter.ECubeArea.NONE, (uint)WorldSetter.ECubeArea.NONE]; this.m_isValidAreaChange = new bool[(uint)WorldSetter.ECubeArea.NONE, (uint)WorldSetter.ECubeArea.NONE]; this.m_objects = new List <CGPhysicsObject>(); // 초기화 for (int i = 0; i < (uint)WorldSetter.ECubeArea.NONE; ++i) { for (int j = 0; j < (uint)WorldSetter.ECubeArea.NONE; ++j) { this.m_isValidAreaChange[i, j] = false; this.m_forceSpace[i, j] = new Vector3(0f, 0f, 0f); this.m_targetArea[i, j] = WorldSetter.ECubeArea.NONE; } } }