//Oar, cannon public void AddOar(bool left) { if (oar == null && cannon == null) { oar = ObjectManager.AddOar(this, left); } }
public static Oar AddOar(Point parent, bool left) { Oar o = Instantiate(instance.oar, parent.position, Quaternion.identity) as Oar; o.transform.parent = parent.transform; o.left = left; o.gameObject.name = "Oar (" + (left?"Left)":"Right)"); return(o); }
public bool RemoveOar(Oar oar) { if (oars.Remove(oar)) { RemoveComponent(oar); RecalculateLayout(); return(true); } return(false); }
private void ParseData(Oar oar, Vector3 acceleration) { Vector3 accelerationDelta = (oar.acceleration - acceleration) * Time.deltaTime; oar.acceleration = acceleration; oar.inWater = acceleration.y < angleToBeInWater; oar.isRotating = Mathf.Abs(accelerationDelta.x) > individualAxisThreshold && Mathf.Abs(accelerationDelta.z) > individualAxisThreshold; float radius = Mathf.Sqrt(oar.acceleration.x * oar.acceleration.x + oar.acceleration.z * oar.acceleration.z); float angle = Mathf.Atan2(oar.acceleration.z, oar.acceleration.x) * Mathf.Rad2Deg; float angleDelta = (oar.angle - angle) * Time.deltaTime; oar.angle = angle; if (oar.isRotating) { // Probably crossed the line between 180 and -180 if (Mathf.Abs(angleDelta) > 1) { oar.speed = 0; } else { oar.speed = angleDelta * speedMultiplier; } } else { oar.speed = 0; } oar.smoothSpeed = Mathf.SmoothDamp(oar.smoothSpeed, oar.speed, ref oar.yVelocity, oar.smoothTime); if (oar.inWater) { if (oar.side == Oar.SIDES.RIGHT) { oar.direction = oar.smoothSpeed > 0 ? DIRECTIONS.BACKWARDS : DIRECTIONS.FORWARDS; } else if (oar.side == Oar.SIDES.LEFT) { oar.direction = oar.smoothSpeed < 0 ? DIRECTIONS.BACKWARDS : DIRECTIONS.FORWARDS; } } oar.paddlingStateQueue.Enqueue(oar.inWater && oar.isRotating ? 1 : 0); if (oar.paddlingStateQueue.Count > paddleStateFramesToAverage) { // relies on fixed update for speed consistency oar.paddlingStateQueue.Dequeue(); } oar.isPaddling = oar.paddlingStateQueue.Average() > 0.5f; }
public bool AddOar(Oar oar) { if (!oars.Contains(oar) && CanPickupOar) { oars.Add(oar); AddComponent(oar); RecalculateLayout(); return(true); } if (oars.Count >= Height * 2) { PopupText("Need more planks!", oar.transform.position); } return(false); }
public void Initialize(int count = 4) { BeginSearch(); oars = new Oar[count]; for (int i = 0; i < count; i++) { oars[i] = new Oar(); oars[i].index = i; switch (i) { case 0: oars[i].side = Oar.SIDES.LEFT; break; case 1: oars[i].side = Oar.SIDES.RIGHT; break; default: oars[i].side = Oar.SIDES.MASTER; break; } } }