void CreateNewSpurting(DrawerController drawer) { position.y -= 1; Vector2 velo = Vector2.zero; HelperAPIMethods.RandomVelocity(ref velo, -1f, 1f, 0, 1f); drawer.CreateLivePixel <Spurting>(position, attach).velocity = 20f * velo; //溅起水花 }
public override void Update(DrawerController drawer) { velocity.y += gravity * Time.deltaTime; velocity *= 1f - 0.1f * Time.deltaTime; position += velocity * Time.deltaTime; if (x > renderWEnd || y > renderHEnd || y < renderHStart || x < renderWStart) { Die(); //都跑地图外了,那就让他去死吧 } if (!ClearAt(drawer, x, y)) { // 这个粒子碰到了什么东西, 如果是的话就判断是否清理两边。 clearLeft = ClearAt(drawer, x - 1, y); clearRight = ClearAt(drawer, x + 1, y); if (clearLeft && clearRight) { if (UnityEngine.Random.Range(0f, 1f) > 0.5f) { position.x -= 1; velocity = left; return; } else { position.x += 1; velocity = right; return; } } else if (clearLeft) { position.x -= 1; velocity = left; return; } else if (clearRight) { position.x += 1; velocity = right; return; } else if (velocity.y < 0) { // 他正在下坠,如果没发现找到符合清理要求的地方,那就网上移动一格,然后就去死吧 position.y += 1; DieClear(); Vector2 velo = Vector2.zero; HelperAPIMethods.RandomVelocity(ref velo, -1f, 1f, 0, 1f); drawer.CreateLivePixel <Spurting>(position, attach).velocity = 20f * velo; } velocity = Vector2.zero; } }
void Update() { if (!Input.GetMouseButton(0)) { return; } if (!EventSystem.current.IsPointerOverGameObject()) { Vector2 pos; int c; if (drawer.PixelPosAtScreenPos(Input.mousePosition, out pos)) { pos.Set(Mathf.RoundToInt(pos.x), Mathf.RoundToInt(pos.y)); for (c = 0; c < cc; c++) { HelperAPIMethods.RandomVelocity(ref velo, -.2f, .5f, 0, -1f); drawer.CreateLivePixel <Water>(pos, brush).velocity = 60f * velo; } } } }