public void SetPositionCar(VictimCar pCar, float pX, float pY) { pCar.SetXY(pX, pY); if (_level.carsList.Count > 0) { foreach (VictimCar otherCar in _level.carsList) { if (pCar.HitTest(otherCar)) { SetPositionCar(pCar, pCar.CorrectLane(pX, pCar.facing), pY); } } } }
private void CreateCar() { string facing = (OurUtils.RandomBool()) ? "up" : "down"; VictimCar newCar = new VictimCar(this, facing); _victimLayer.AddChild(newCar); newCar.SetScaleXY(CAR_SCALE, CAR_SCALE); float positionModifier = MyGame.OldY() * ((facing == "up") ? 1 : -1); float positionX = 0; float positionY = Utils.Random(newCar.height / 2, MyGame.OldY() - newCar.height / 2) + positionModifier; positionX = newCar.CorrectLane(positionX, facing); newCar.SetPositionCar(newCar, positionX, positionY); carsList.Add(newCar); }