private void Update() { if (Input.GetKey(KeyCode.Mouse0)) { ray = gameCam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hitInfo, Mathf.Infinity, jellyLayer)) { jellyObj = hitInfo.transform.gameObject.GetComponent <JellyObject>(); jellyObj.ApplyPressureToPoint(hitInfo.point, pressure); } } }
private void GenerateNextJelly() { JellyObject jo = null; const float height = 350; switch (random.Next(6)) { /*jo = new JellyBox(graphicsDevice, unitMass, unitSize, * colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); * break; * jo = new JellyDouble(graphicsDevice, unitMass, unitSize, * colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); * break;*/ case 0: jo = new JellyTripleL(graphicsDevice, unitMass, unitSize, colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); break; case 1: jo = new JellyBigBox(graphicsDevice, unitMass, unitSize, colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); break; case 2: jo = new JellyTShape(graphicsDevice, unitMass, unitSize, colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); break; case 3: jo = new JellyZShape(graphicsDevice, unitMass, unitSize, colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); break; case 4: jo = new JellyLong(graphicsDevice, unitMass, unitSize, colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); break; case 5: jo = new JellyLShape(graphicsDevice, unitMass, unitSize, colorTab[random.Next(colorTab.Length)], new JellyVector2(0, height)); break; } jellyObjectList.Add(jo); }
private void Update(GameTime gameTime) { float timestep = (float)gameTime.ElapsedGameTime.TotalSeconds; foreach (JellyObject jo in jellyObjectList) { jo.Gravity(); } foreach (JellyObject jo in jellyObjectList) { jo.Preservation(); } for (int i = 0; i < jellyObjectList.Count; ++i) { JellyObject joi = jellyObjectList[i]; for (int j = i + 1; j < jellyObjectList.Count; ++j) { JellyObject joj = jellyObjectList[j]; foreach (JellyVertex jv in joj.Edge) { JellyCollision.ProcessEdgeForce(joi.Edge, jv); } foreach (JellyVertex jv in joi.Edge) { JellyCollision.ProcessEdgeForce(joj.Edge, jv); } } } foreach (JellyObject jo in jellyObjectList) { jo.Integrate(timestep); } foreach (JellyObject jo in jellyObjectList) { jo.UpdateDraw(); } }
protected override void RunGame(GameTime gameTime) { float timestep = (float)gameTime.ElapsedGameTime.TotalSeconds; #region Physic foreach (JellyObject jo in jellyObjectList) { jo.Gravity(); } foreach (JellyObject jo in jellyObjectList) { jo.Preservation(); } for (int i = 0; i < jellyObjectList.Count; ++i) { JellyObject joi = jellyObjectList[i]; for (int j = i + 1; j < jellyObjectList.Count; ++j) { JellyObject joj = jellyObjectList[j]; foreach (JellyVertex jv in joj.Edge) { JellyCollision.ProcessEdgeForce(joi.Edge, jv); } foreach (JellyVertex jv in joi.Edge) { JellyCollision.ProcessEdgeForce(joj.Edge, jv); } } } foreach (JellyObject jo in jellyObjectList) { jo.Integrate(timestep); } #endregion foreach (JellyObject jo in jellyObjectList) { jo.UpdateDraw(); } #region Check int type = 0; foreach (JellyObject jo in jellyObjectList) { foreach (JellyVertex jv in jo.Edge) { if (jv.Y > 300) { switch (type) { case 0: //Classical gameState = GameState.Exit; exitBeginTime = Environment.TickCount; exitToGame = GameType.Classical; return; case 1: //Time Limit gameState = GameState.Exit; exitBeginTime = Environment.TickCount; exitToGame = GameType.TimeLimit; return; case 2: //About About(); break; case 3: Setting(); break; } } } ++type; } #endregion }