public void RegisterBumper(Bumper bumper, Entity entity, GameObject go) { var bumperApi = new BumperApi(bumper, entity, this); _tableApi.Bumpers[bumper.Name] = bumperApi; _initializables.Add(bumperApi); _hittables[entity] = bumperApi; }
// private Bumper player1; // Start is called before the first frame update void Start() { speed = (isNegativePowerUp) ? -2 : 2; GameObject gm1 = GameObject.FindWithTag("Player1"); player1 = gm1.GetComponent <Bumper>(); GameObject gm2 = GameObject.FindWithTag("Player2"); player2 = gm2.GetComponent <Bumper>(); }
public Robot() { com = new MyCom(this); omniDrive = new OmniDrive(); bumper = new Bumper(); kinect = new MyKinect(this); omniDrive.setComId(com.id()); bumper.setComId(com.id()); kinect.setComId(com.id()); }
public Robot() { com = new MyCom(this); omniDrive = new OmniDrive(); bumper = new Bumper(); camera = new MyCamera(this); omniDrive.setComId(com.id()); bumper.setComId(com.id()); camera.setComId(com.id()); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Bumper")) { Bumper bumper = collision.gameObject.GetComponent <Bumper>(); if (bumper) { rb.velocity += bumper.GetPush(); } } }
private void OnTriggerEnter(Collider other) { var go = other.gameObject; if (go.tag == "Bumper") { Bumper bumper = go.GetComponent <Bumper>(); Rage -= bumper._length; _myAudioSource.PlayOneShot(_bumperCollectSounds[Random.Range(0, _bumperCollectSounds.Length)]); Destroy(go); } }
void InitThis() { previousPosition = target.transform.position; if (target.GetComponent <MovementHandler>() != null) { targetMovementHandler = target.GetComponent <MovementHandler>(); } _animator = GetComponent <CustomAnimator>(); _bumper = GetComponentInChildren <Bumper>(); GetComponent <SpriteRenderer>().color = color; Health = 25f; }
public void SetInBump(bool newState, Bumper bumper) { inBump = newState; if (inBump) { bumperRef = bumper; } else { bumperRef = null; } }
public Robot() { com = new MyCom(this); omniDrive = new OmniDrive(); bumper = new Bumper(); camera = new MyCamera(this); motor = new Motor(); Distance = new DistanceSensor(); omniDrive.setComId(com.id()); motor.setComId(com.id()); bumper.setComId(com.id()); camera.setComId(com.id()); Distance.setComId(com.id()); }
public Agent() { // create the short range sensor for wall following shortRangeSensor = new ProximitySensor(10, 10, 90); // Create the bumper sensor bumperSensor = new Bumper(12, 130); // create the movement interface movement = new Movement(); // create the cleaning module cleaner = new Cleaner(); random = new Random(); }
public void Test() { Car car = new XiaomiCar(); Decorator carWithBumper = new Bumper(car); carWithBumper.Show().ShouldBe("XiaomiCar+Bumper"); Decorator carWithSoundBox = new SoundBox(car); carWithSoundBox.Show().ShouldBe("XiaomiCar+SoundBox"); Decorator carWithBumperAndSoundBox = new SoundBox(carWithBumper); carWithBumperAndSoundBox.Show().ShouldBe("XiaomiCar+Bumper+SoundBox"); }
void HandleBumper(Bumper bumper) { Vector3 diff = transform.position - bumper.transform.position; velocity = diff.normalized * bumper.knockback; StartCoroutine(DisablePathRiding(bumper.disableTime)); if (bumper.durability == 0) { bumper.gameObject.SetActive(false); } else { bumper.durability--; } }
// Start is called before the first frame update void Start() { float rx = Random.Range(0, 2) == 0 ? -1 : 1; float ry = Random.Range(0, 2) == 0 ? -1 : 1; GetComponent <Rigidbody>().velocity = new Vector3(speed * rx, speed * ry, 0f); _originalPosition = transform.position; GameObject gm1 = GameObject.FindWithTag("Player1"); player1 = gm1.GetComponent <Bumper>(); GameObject gm2 = GameObject.FindWithTag("Player2"); player2 = gm2.GetComponent <Bumper>(); }
private void BumpPost(int id) { var publishedPostFromDb = _db.PublishedPosts.Single(p => p.PostId == id); var results = Bumper.ValidToBump(publishedPostFromDb); if (results.Item1 == true) { publishedPostFromDb.PublishTime = DateTime.Now; _db.SaveChanges(); ViewData["PublishSuccess"] = results.Item2; } else { ViewData["BumpAlert"] = results.Item2; } }
// Use this for initialization void Start() { body = GetComponent <Rigidbody>() as Rigidbody; mat = GetComponent <Material>() as Material; gameManager = FindObjectOfType <GameManager>() as GameManager; engineSound = GetComponents <AudioSource>().GetValue(0) as AudioSource; ramSound = GetComponents <AudioSource>().GetValue(1) as AudioSource; ramSmokeController = GetComponentInChildren <RamSmokeController>() as RamSmokeController; engineSound.volume = 0.0f; engineSound.Play(); bumper = GetComponentInChildren <Bumper>() as Bumper; }
private void UpdateCameraPosition() { Vector3 wantedPosition = target.TransformPoint(PanX.Current, height.Current, -distance.Current); // Only Update When Changes are Present if (wantedPosition != CameraTransform.position) { wantedPosition = Bumper.UpdatePosition(target, CameraTransform, wantedPosition, Time.deltaTime * damping); switch (translationType) { case MovementType.Instant: CameraTransform.position = wantedPosition; break; case MovementType.LinearInterpolation: CameraTransform.position = Vector3.Lerp(CameraTransform.position, wantedPosition, Time.deltaTime * damping); break; case MovementType.SphericalLinearInterpolation: CameraTransform.position = Vector3.Slerp(CameraTransform.position, wantedPosition, Time.deltaTime * damping); break; } /// Rotate Camera Vector3 lookPosition = target.TransformPoint(lookAtOffset + RuntimeOffset); Quaternion wantedRotation = Quaternion.LookRotation(lookPosition - CameraTransform.position, target.up); switch (rotationType) { case MovementType.Instant: CameraTransform.rotation = Quaternion.LookRotation(lookPosition - CameraTransform.position, target.up); break; case MovementType.LinearInterpolation: CameraTransform.rotation = Quaternion.Lerp(CameraTransform.rotation, wantedRotation, Time.deltaTime * rotationDamping); break; case MovementType.SphericalLinearInterpolation: CameraTransform.rotation = Quaternion.Slerp(CameraTransform.rotation, wantedRotation, Time.deltaTime * rotationDamping); break; } } }
public static ConvertedItem SetupGameObject(this Bumper bumper, GameObject obj) { var mainAuthoring = obj.AddComponent <BumperAuthoring>().SetItem(bumper); var meshAuthoring = new List <IItemMeshAuthoring>(); BumperColliderAuthoring colliderAuthoring = null; switch (bumper.SubComponent) { case ItemSubComponent.None: colliderAuthoring = obj.AddColliderComponent(bumper); meshAuthoring.Add(ConvertedItem.CreateChild <BumperBaseMeshAuthoring>(obj, BumperMeshGenerator.Base)); meshAuthoring.Add(ConvertedItem.CreateChild <BumperCapMeshAuthoring>(obj, BumperMeshGenerator.Cap)); var ring = ConvertedItem.CreateChild <BumperRingMeshAuthoring>(obj, BumperMeshGenerator.Ring); var skirt = ConvertedItem.CreateChild <BumperSkirtMeshAuthoring>(obj, BumperMeshGenerator.Skirt); ring.gameObject.AddComponent <BumperRingAnimationAuthoring>(); skirt.gameObject.AddComponent <BumperSkirtAnimationAuthoring>(); meshAuthoring.Add(ring); meshAuthoring.Add(skirt); break; case ItemSubComponent.Collider: { Logger.Warn("Bumper collider cannot be parented to anything else than bumpers."); break; } case ItemSubComponent.Mesh: { Logger.Warn("Bumper mesh cannot be parented to anything else than bumpers."); break; } default: throw new ArgumentOutOfRangeException(); } obj.AddComponent <ConvertToEntity>(); return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring)); }
/// <summary> /// Sent when another object enters a trigger collider attached to this /// object (2D physics only). /// </summary> /// <param name="other">The other Collider2D involved in this collision.</param> void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.layer == LayerMask.NameToLayer("Consumable")) { Consumable con = other.gameObject.GetComponent <Consumable>(); if (con.type.Equals(typeof(ResRegenConsumable))) { HandleResRegenConsumable(con.GetComponent <ResRegenConsumable>()); } else if (con.type.Equals(typeof(EnergyConsumable))) { HandleEnergyConsumable(con.GetComponent <EnergyConsumable>()); } } else if (other.gameObject.layer == LayerMask.NameToLayer("Obstacle")) { Bumper bumper = other.gameObject.GetComponent <Bumper>(); if (bumper) { HandleBumper(bumper); } } }
private static void onBumperWiggle(On.Celeste.Bumper.orig_UpdatePosition orig, Bumper self) { // we handle the wobbling ourselves, so deactivate it for our bumpers. if (!(self is BumperNotCoreMode)) { orig(self); } }
public void AddComponentsToSceneObject(AreaSceneObjectData jsonData, GameObject so) { if (jsonData.soData.Count > 0) { SceneObjectDataGeneric data = jsonData.soData [0]; SceneObjectData sceneObjectData = so.GetComponent <SceneObjectData> (); Bumper bumper = so.GetComponent <Bumper> (); if (data.bumperForce > 0) { if (bumper == null) { bumper = so.gameObject.AddComponent <Bumper> (); } bumper.force = data.bumperForce; } if (data.size != Vector3.zero) { if (sceneObjectData == null) { sceneObjectData = so.gameObject.AddComponent <SceneObjectData> (); } sceneObjectData.size = data.size; } if (data.random_pos_x != 0) { if (sceneObjectData == null) { sceneObjectData = so.gameObject.AddComponent <SceneObjectData> (); } sceneObjectData.random_pos_x = data.random_pos_x; } if (data.minPayers != 0) { if (sceneObjectData == null) { sceneObjectData = so.gameObject.AddComponent <SceneObjectData> (); } sceneObjectData.minPayers = data.minPayers; } } MaterialSwapper mat = so.GetComponent <MaterialSwapper>(); if (mat != null && jsonData.mat.Count > 0) { MaterialChanger data = jsonData.mat[0]; //if (mat == null) // mat = so.gameObject.AddComponent<MaterialSwapper>(); mat.Init(data.name); } FullRotation fullRotation = so.GetComponent <FullRotation> (); if (jsonData.fullRotationData.Count > 0) { FullRotationData data = jsonData.fullRotationData [0]; if (fullRotation == null) { fullRotation = so.gameObject.AddComponent <FullRotation> (); } fullRotation.rotateX = data.rotateX; fullRotation.rotateY = data.rotateY; fullRotation.rotateZ = data.rotateZ; fullRotation.speed = data.speed; fullRotation.randomRotation = data.random; } else if (fullRotation != null) { fullRotation.OnComponentDisposed(); } TimelineAnimation timelineAnimation = so.GetComponent <TimelineAnimation> (); if (jsonData.timelineAnimation.Count > 0) { TimelineAnimationData data = jsonData.timelineAnimation [0]; if (timelineAnimation == null) { timelineAnimation = so.gameObject.AddComponent <TimelineAnimation> (); } timelineAnimation.timeLineData = data.timeLineData; } else if (timelineAnimation != null) { timelineAnimation.OnComponentDisposed(); } if (jsonData.bossSettings.Count > 0) { BossSettingsData data = jsonData.bossSettings [0]; BossSettings newcomponent = so.GetComponent <BossSettings> (); if (newcomponent == null) { newcomponent = so.gameObject.AddComponent <BossSettings> (); } newcomponent.bossModule = data.bossModule; newcomponent.time_to_init_enemies = data.time_to_init_enemies; newcomponent.asset = data.asset; newcomponent.time_to_kill = data.time_to_kill; newcomponent.distance_from_avatars = data.distance_from_avatars; newcomponent.bundle = data.bundle; } if (jsonData.moveForward.Count > 0) { MoveForwardData data = jsonData.moveForward [0]; MoveForward newcomponent = so.GetComponent <MoveForward> (); if (newcomponent == null) { newcomponent = so.gameObject.AddComponent <MoveForward> (); } newcomponent.speed = data.speed; newcomponent.randomSpeedDiff = data.randomSpeedDiff; newcomponent.moveBackIn = data.moveBackIn; } }
public BumperAdapter(Bumper target) { _target = target; }
private static BumperColliderAuthoring AddColliderComponent(this GameObject obj, Bumper bumper) { return(bumper.Data.IsCollidable ? obj.AddComponent <BumperColliderAuthoring>() : null); }
public void AddComponentsToJson(AreaSceneObjectData newSOdata, GameObject go) { FullRotation fullRotation = go.GetComponent <FullRotation> (); MaterialSwapper mat = go.GetComponent <MaterialSwapper>(); TimelineAnimation timelineAnimation = go.GetComponent <TimelineAnimation> (); BossSettings bossSettings = go.GetComponent <BossSettings> (); MoveForward moveForward = go.GetComponent <MoveForward> (); Bumper bumper = go.GetComponent <Bumper> (); SceneObjectData soData = go.GetComponent <SceneObjectData> (); if (newSOdata.name == "wallSmall") { newSOdata.mat = new List <MaterialChanger>(); MaterialChanger mc = new MaterialChanger(); mc.name = go.GetComponent <MeshRenderer>().sharedMaterial.ToString().Split(" "[0])[0]; newSOdata.mat.Add(mc); } if (soData != null) { newSOdata.soData = new List <SceneObjectDataGeneric> (); SceneObjectDataGeneric data = new SceneObjectDataGeneric(); data.size = soData.size; data.random_pos_x = soData.random_pos_x; data.minPayers = soData.minPayers; data.minPayers = soData.minPayers; newSOdata.soData.Add(data); } if (bumper != null) { newSOdata.soData = new List <SceneObjectDataGeneric> (); SceneObjectDataGeneric data = new SceneObjectDataGeneric(); data.bumperForce = bumper.force; newSOdata.soData.Add(data); } if (fullRotation != null) { newSOdata.fullRotationData = new List <FullRotationData> (); FullRotationData data = new FullRotationData(); data.rotateX = fullRotation.rotateX; data.rotateY = fullRotation.rotateY; data.rotateZ = fullRotation.rotateZ; data.speed = fullRotation.speed; data.random = fullRotation.randomRotation; newSOdata.fullRotationData.Add(data); } if (timelineAnimation != null) { newSOdata.timelineAnimation = new List <TimelineAnimationData> (); TimelineAnimationData data = new TimelineAnimationData(); data.timeLineData = timelineAnimation.timeLineData; newSOdata.timelineAnimation.Add(data); } if (bossSettings != null) { newSOdata.bossSettings = new List <BossSettingsData> (); BossSettingsData data = new BossSettingsData(); data.bossModule = bossSettings.bossModule; data.asset = bossSettings.asset; data.time_to_init_enemies = bossSettings.time_to_init_enemies; data.time_to_kill = bossSettings.time_to_kill; data.distance_from_avatars = bossSettings.distance_from_avatars; data.bundle = bossSettings.bundle; newSOdata.bossSettings.Add(data); } if (moveForward != null) { newSOdata.moveForward = new List <MoveForwardData> (); MoveForwardData data = new MoveForwardData(); data.speed = moveForward.speed; data.randomSpeedDiff = moveForward.randomSpeedDiff; data.moveBackIn = moveForward.moveBackIn; newSOdata.moveForward.Add(data); } }
Dictionary <int, bool> instantiatedBeatMap; //prevent duplicate beat creation // Use this for initialization void Start() { audioSource = GetComponent <AudioSource>(); clip = audioSource.clip; fft = new LomontFFT(); float[] samples = new float[clip.samples * clip.channels]; clip.GetData(samples, 0); //convert float to double double[] samplesD = new double[samples.Length]; for (int i = 0; i < samplesD.Length; i++) { samplesD[i] = (double)samples[i]; } Debug.Log("clip samples: " + clip.samples); //debug Debug.Log("clip channels: " + clip.channels); //debug Debug.Log("clip duration: " + clip.length); //debug steps = Mathf.RoundToInt(samplingInterval / secondInMilliseconds * clip.frequency); Debug.Log("steps: " + steps); //debug int n = samplingWindowSize; int k = 0; for (int j = 0; j < samplingWindowSize; j++) { n = n / 2; if (n <= 0) { break; } k++; } band = new float[k + 1]; g = new GameObject[k + 1]; positions = new Dictionary <int, Vector3[]>(); for (int i = 0; i < band.Length; i++) { band[i] = 0; g[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere); g[i].GetComponent <Renderer>().material.SetColor("_Color", Color.cyan); g[i].transform.position = new Vector3(i, 0, 0); } for (int i = 0; i < samplesD.Length; i = i + steps) { double[] samplingWindow = new double[samplingWindowSize]; if (i > samplingWindowSize) { Array.Copy(samplesD, i - samplingWindowSize / 2, samplingWindow, 0, samplingWindowSize); } else //i = 0 { Array.Copy(samplesD, i, samplingWindow, 0, samplingWindowSize); } fft.FFT(samplingWindow, true); //convert double to float float[] samplingWindowF = new float[samplingWindow.Length]; for (int j = 0; j < samplingWindow.Length; j++) { samplingWindowF[j] = (float)samplingWindow[j]; } checkWindow(i, samplingWindowF); /* * if (i > 70000) * { * break; * }*/ } /* * using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\wgwong\Desktop\out2.txt")) * { * foreach (var entry in positions) * { * file.WriteLine("position: " + entry.Key); * for (int i = 0; i < entry.Value.Length; i++) { * var element = entry.Value[i]; * file.WriteLine("element[" + i + "]: " + element.x + ", " + element.y + ", " + element.z); * } * file.WriteLine("\n"); * } * }*/ leftLaneBalls = new ArrayList(); midLaneBalls = new ArrayList(); rightLaneBalls = new ArrayList(); leftBumper = new Bumper(new Vector3(12, 0, 2), Color.red); midBumper = new Bumper(new Vector3(14, 0, 2), Color.blue); rightBumper = new Bumper(new Vector3(16, 0, 2), Color.green); beatMap = new Dictionary <int, bool[]>(); instantiatedBeatMap = new Dictionary <int, bool>(); createBeatMap(); audioSource.Play(); }
private void patchBumperOnPlayer(On.Celeste.Bumper.orig_OnPlayer orig, Bumper self, Player player) { swapNoRefillsTemporarily(() => orig(self, player), self.SceneAs <Level>().Session); }
internal static IVpxPrefab InstantiatePrefab(this Bumper bumper) { var prefab = RenderPipeline.Current.PrefabProvider.CreateBumper(); return(new VpxPrefab <Bumper, BumperData, BumperComponent>(prefab, bumper)); }
static void Main(string[] args) { //Initialise everything World newWorld = new World(); Portal newPortal = new Portal(10, 35, 5, 100, 30); Bumper newBumper = new Bumper(); SuvatSolver newSuvatSolver = new SuvatSolver(newWorld.g, newWorld.WindConstant); ODESolution newOde = new ODESolution(newWorld.g, newWorld.WindConstant); NeuralNetworkParameters networkParameters = new NeuralNetworkParameters(); BruteForceMethods newBruteForceMethods = new BruteForceMethods(newOde, newBumper, networkParameters); for (int i = 1; i < 1000; i++) { Console.WriteLine("Starting simulation " + i + " of this batch"); // Generate the random values and save to sheet RandomPositionGenerator newGenerator = new RandomPositionGenerator(); SaveMethods saveMethods = new SaveMethods(_filePath); newGenerator.GenerateRandomValues(); saveMethods.SaveInputs(newGenerator); // Save to file //Create a 'fake' ShellshockWindow app or something var keyCollection = newGenerator.AllVariables.Keys; var valueCollection = newGenerator.AllVariables.Values; double[] xVals = new double[keyCollection.Count]; double[] yVals = new double[valueCollection.Count]; keyCollection.CopyTo(xVals, 0); valueCollection.CopyTo(yVals, 0); //Wind newWorld.Wind = (int)yVals[9]; // Tanks var myNewXPosition = xVals[0]; var myNewYPosition = yVals[0]; var enemyNewXPosition = xVals[1]; var enemyNewYPosition = yVals[1]; // Portals newPortal.BlueLeft = xVals[7]; newPortal.BlueTop = yVals[7]; newPortal.OrangeLeft = xVals[8]; newPortal.OrangeTop = yVals[8]; // Linear bumpers newBumper.LinearBumper1LeftPosition = xVals[2]; newBumper.LinearBumper1TopPosition = yVals[2]; newBumper.LinearBumper2LeftPosition = xVals[3]; newBumper.LinearBumper2TopPosition = yVals[3]; // Circular bumpers newBumper.CircularBumper1Left = xVals[4]; newBumper.CircularBumper1Top = yVals[4]; newBumper.CircularBumper2Left = xVals[5]; newBumper.CircularBumper2Top = yVals[5]; newBumper.CircularBumper3Left = xVals[6]; newBumper.CircularBumper3Top = yVals[6]; //Run methods to generate wind and power newBumper.isRebound = true; var isMirrored = myNewXPosition > enemyNewXPosition ? -1 : 1; double horizontalPixelDistance = Math.Abs(enemyNewXPosition - myNewXPosition); double horizontalMmDistance = horizontalPixelDistance * newWorld.ScreenWidthRatio * World.PixelToMm; newWorld.X = horizontalMmDistance; double verticalPixelDistance = myNewYPosition - enemyNewYPosition; double verticalMmDistance = verticalPixelDistance * newWorld.ScreenWidthRatio * World.PixelToMm; newWorld.Y = verticalMmDistance; // Now update portal positions newOde.BluePosition = newPortal.BluePosition(myNewXPosition, myNewYPosition, newWorld.ScreenWidthRatio, isMirrored); newOde.OrangePosition = newPortal.OrangePosition(myNewXPosition, myNewYPosition, newWorld.ScreenWidthRatio, isMirrored); newBumper.FindAllRelativePositions(myNewXPosition, myNewYPosition, newWorld.ScreenWidthRatio, isMirrored); newOde.NewBumper = newBumper; newOde.IsMirrored = isMirrored; Console.WriteLine("Finding power and angle ..."); double[] powerAngleGuess = BruteForceAsync(newBruteForceMethods, newWorld).Result; string powerGuess = powerAngleGuess[0].ToString("0"); string angleGuess = powerAngleGuess[1].ToString("0"); saveMethods.SaveOutputs(powerGuess, angleGuess); Console.WriteLine("Completed simulation " + i + " of this batch"); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here InitalizeSerialCommunication(); lowerLeftBumper = new Bumper(); upperLeftBumper = new Bumper(); upperRightBumper = new Bumper(); lowerRightBumper = new Bumper(); wheels = new CoupledWheels(); wheels.ClicksPerTurn = 3900; wheels.WheelDistance = 0.345f; wheels.WheelRadius = 0.0467f; wheels.Updated += new EventHandler(wheels_Updated); sonar0 = new MaxbotixSonar(); sonar1 = new MaxbotixSonar(); sonar2 = new MaxbotixSonar(); sonar3 = new MaxbotixSonar(); sonar4 = new MaxbotixSonar(); groundSensor0 = new InfraredSensor(); groundSensor1 = new InfraredSensor(); groundSensor2 = new InfraredSensor(); redLed = new LedPwm(); greenLed = new LedPwm(); blueLed = new LedPwm(); drive = new DifferentialDrive(wheels); odometry = new DifferentialOdometry(wheels); proximity = new ProximityArray { { new Transform(0.15f, 0.14f, MathHelper.ToRadians(45)), sonar0 }, { new Transform(0.165f, 0.07f, MathHelper.ToRadians(20)), sonar1 }, { new Transform(0.18f, 0.0f, MathHelper.ToRadians(0)), sonar2 }, { new Transform(0.165f, -0.07f, MathHelper.ToRadians(-20)), sonar3 }, { new Transform(0.15f, -0.14f, MathHelper.ToRadians(-45)), sonar4 }, }; protocol = new ProtocolManager(); protocol.SubscribeComponent(lowerLeftBumper); protocol.SubscribeComponent(upperLeftBumper); protocol.SubscribeComponent(upperRightBumper); protocol.SubscribeComponent(lowerRightBumper); protocol.SubscribeComponent(wheels); protocol.SubscribeComponent(sonar0); protocol.SubscribeComponent(sonar1); protocol.SubscribeComponent(sonar2); protocol.SubscribeComponent(sonar3); protocol.SubscribeComponent(sonar4); protocol.SubscribeComponent(groundSensor0); protocol.SubscribeComponent(groundSensor1); protocol.SubscribeComponent(groundSensor2); protocol.SubscribeComponent(greenLed); protocol.SubscribeComponent(redLed); protocol.SubscribeComponent(blueLed); transport.Protocol = protocol; renderer = new SpriteRenderer(this); renderer.PixelsPerMeter = 100; Components.Add(renderer); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Services.AddService(typeof(SpriteBatch), spriteBatch); base.Initialize(); }
// Increase our current score with the given amount of points. void IncreaseScore(Bumper bumper) { totalScore += bumper.BumpPoints; SetScoreText(); }
public VehicleModel() { VehicleOverview = new VehicleOverview(); engine = new Engine(); starter = new Starter(); gearBox = new GearBox(); vehGearNum = 0; for (int i = 0; i < subGears.Length; i++) { subGears[i] = new SubGear(); } windForce = new WindForce(); steeringFactor = new SteeringFactor(); steering = new Steering(); fuelTank = new FuelTank(); for (int i = 0; i < otherSteerings.Length; i++) { otherSteerings[i] = new OtherSteering(); } carVibration = new CarVibration(); brakesCommon = new Brakes(); physicsCrashSetting = new PhysicsCrashSetting(); ignoreHeadCollision = false; exhaust = new Exhaust(); roughness = new Roughness(); engineHealth = new EngineHealth(); fuelTankOnCrash = 0; engineParticles = new EngineParticles(); gearboxSettings = new GearboxSettings(); wheels = new Wheel(); body = new Body(); bumper = new Bumper(); windowGlass = new WindowGlass(); light = new Light(); licencePlate = new LicencePlate(); mirror = new Mirror(); wing = new Wing(); door = new Door(); roof = new Roof(); unknown = new Unknown(); engineSoundSet = new EngineSoundSet(); engineSound1 = new EngineSound(); engineSound2 = new EngineSound(); engineSound3 = new EngineSound(); engineSound4 = new EngineSound4(); insideSoundSet = new InsideSoundSet(); carSmallHitType = new CarSmallHitType(); carShortCrashTypeB1 = new CarShortCrashType(); carShortCrashWithGlassTypeC1 = new CarShortCrashType(); unknownSound1 = ""; unknownSound2 = ""; engineStartSound = new EngineStartSound(); engineSoundDriving = new EngineSoundDriving(); for (int i = 0; i < engineSoundOnGears.Length; i++) { engineSoundOnGears[i] = new EngineSoundOnGear(); } engineSoundIdle = new EngineSoundIdle(); wheelSoundWhilePunctured = new WheelSoundWhilePunctured(); carSmallHitType1 = new CarSmallHitType(); carLongCrashType1 = new CarLongCrashType(); carShortCrashWithGlassType1 = new CarShortCrashType(); doorOpenCloseSound = new DoorOpenCloseSound(); insideSoundSet = new InsideSoundSet(); carSmallHitType = new CarSmallHitType(); carLongCrashType2 = new CarLongCrashType(); carShortCrashTypeB1 = new CarShortCrashType(); carShortCrashWithGlassTypeC1 = new CarShortCrashType(); unknownSound1 = ""; unknownSound2 = ""; carShortCrashTypeB2 = new CarShortCrashType(); carShortCrashWithGlassType1 = new CarShortCrashType(); doorOpenCloseSound = new DoorOpenCloseSound(); }
public void replaceSceneObject(Area area, float areasLength, int areasX, bool oposite = false) { print(area.name + " AREA"); borderTransforms = new List <Transform> (); this.area = area; GameObject[] gos = area.getSceneObjects(); bool nubesOn = false; foreach (GameObject go in gos) { SceneObject sceneObject = null; Vector3 pos = go.transform.position; pos.z += areasLength; pos.x += areasX; if (oposite) { pos.z *= -1; } // if (!nubesOn) // { // nubesOn = true; // addDecoration("Nubes_real", pos, new Vector3(0, Random.Range(0,2), 5)); // } switch (go.name) { case "extralargeBlock1": case "flyer": case "largeBlock1": case "mediumBlock1": case "smallBlock1": case "extraSmallBlock1": case "Coin": case "bloodx1": //case "Yuyo": case "enemyFrontal": case "enemyWater": case "enemySide": case "enemyBack": case "castle": case "SideMountain": case "bonusEntrance": case "Cascade": case "firewall": case "Baranda1": case "Tumba": case "enemyNaveSimple": if (go.name == "smallBlock1" || go.name == "extraSmallBlock1") { sceneObject = Pool.GetObjectForType(go.name + "_real", true); } else { sceneObject = Pool.GetObjectForType(go.name + "_real", false); } if (sceneObject) { sceneObject.isActive = false; sceneObject.Restart(pos); sceneObject.transform.rotation = go.transform.rotation; //if (go.name == "Yuyo") // sceneObject.SetMaterialByVideoGame (); //sceneObject.changeMaterial("pasto"); if (go.name == "extralargeBlock1") { //GameObject goNew = new GameObject (); //goNew.transform.position = pos; //goNew.transform.rotation = go.transform.rotation; //borderTransforms.Add (goNew.transform); // int num = Random.Range(1, 4); // string decorationName = ""; // if (num == 1) // decorationName = "flores1_real"; // if (num == 2) // decorationName = "flores2_real"; // else if (num == 3) // decorationName = "floorFlowers_real"; // // if (decorationName != "") // addDecoration(decorationName, pos, Vector3.zero); } // } if (go.GetComponent <DecorationManager>()) { addDecoration("Baranda1_real", pos, new Vector3(5.5f, 0, 3)); addDecoration("Baranda1_real", pos, new Vector3(-5.5f, 0, 3)); addDecoration("Baranda1_real", pos, new Vector3(5.5f, 0, -3)); addDecoration("Baranda1_real", pos, new Vector3(-5.5f, 0, -3)); } } else { Debug.LogError("___________NO EXISTIO EL OBJETO: " + go.name); Data.Instance.events.ForceFrameRate(0); } break; } SceneObject clone = null; if (go.name == "FloorSurface") { clone = FloorSurface; } if (go.name == "PisoPinche") { clone = PisoPinche; } else if (go.name == "house1") { clone = house1; } else if (go.name == "house2") { clone = house2; } else if (go.name == "house3") { clone = house3; } else if (go.name == "house4") { clone = house4; } else if (go.name == "rampa") { clone = rampa; } else if (go.name == "rampaHuge") { clone = rampaHuge; } else if (go.name == "wallBig") { // addDecorationWithRotation("Graffiti_Real", pos, go.transform.localEulerAngles); clone = wallBig; } else if (go.name == "wallMedium") { clone = wallMedium; } else if (go.name == "wallSmall") { clone = wallSmall; } else if (go.name == "wallSuperSmall") { clone = wallSuperSmall; } else if (go.name == "jumper") { clone = jumper; } else if (go.name == "Lava") { clone = Lava; } else if (go.name == "Water") { clone = Water; } else if (go.name == "Boss1") { clone = Boss1; } else if (go.name == "Boss2") { clone = Boss2; } else if (go.name == "BossCalecitas1") { clone = BossCalecitas1; } else if (go.name == "BossCreator") { clone = BossCreator; } else if (go.name == "BossSpace1") { clone = BossSpace1; } else if (go.name == "BossPacmans") { clone = BossPacmans; } else if (go.name == "BossGalaga") { clone = BossGalaga; } else if (go.name == "BossPacmansIntro") { clone = BossPacmansIntro; } else if (go.name == "Calecita") { clone = Calecita; } else if (go.name == "Starting") { clone = Starting; } else if (go.name == "bomb1") { clone = bomb1; } else if (go.name == "tunel1") { clone = tunel1; } else if (go.name == "tunel2") { clone = tunel2; } else if (go.name == "cilindro") { clone = cilindro; } else if (go.name == "enemyGhost") { clone = enemyGhost; } else if (go.name == "palmTall") { clone = palm_tall; go.transform.localEulerAngles = new Vector3(0, Random.Range(0, 4) * 90, 0); } else if (go.name == "palm") { int ran = Random.Range(0, 60); if (ran < 20) { clone = palm; } else if (ran < 40) { clone = palm2; } else { clone = palm3; } go.transform.localEulerAngles = new Vector3(0, Random.Range(0, 4) * 90, 0); //} } else if (go.name == "streetFloor") { clone = streetFloor; } else if (go.name == "streetFloorSmall") { clone = streetFloorSmall; } else if (go.name == "levelSignal") { clone = levelSignal; } else if (go.name == "GrabbableJetpack") { clone = GrabbableJetpack; } else if (go.name == "GrabbableInvensible") { clone = GrabbableInvensible; } else if (go.name == "borde1") { clone = borde1; } else if (go.name == "fences") { clone = fences; } else if (go.name == "rainbow") { clone = rainbow; } else if (go.name == "Listener") { clone = Listener; } else if (go.name == "cruz") { clone = cruz; } else if (go.name == "CruzGrande") { clone = CruzGrande; } else if (go.name == "rueda1") { clone = rueda1; } else if (go.name == "helice1") { clone = helice1; } else if (go.name == "helice2") { clone = helice2; } else if (go.name == "subibaja") { clone = subibaja; } else if (go.name == "cepillo") { clone = cepillo; } else if (go.name == "pisoRotatorio") { clone = pisoRotatorio; } else if (go.name == "sombrilla") { clone = sombrilla; } else if (go.name == "GrabbableMissile") { clone = GrabbableMissile; } else if (go.name == "FloorSlider") { clone = FloorSlider; } if (clone) { sceneObject = Instantiate(clone, pos, Quaternion.identity) as SceneObject; sceneObject.transform.parent = Pool.Scene.transform; sceneObject.transform.rotation = go.transform.rotation; if (go.GetComponent <BossSettings>()) { BossSettings mo = go.GetComponent <BossSettings>(); CopyComponent(mo, sceneObject.gameObject); } sceneObject.Restart(pos); } if (go.GetComponent <Move>() && sceneObject.GetComponent <Move>() == null) { Move mo = go.GetComponent <Move>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <MoveObject>()) { MoveObject mo = go.GetComponent <MoveObject>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <Dropper>()) { Dropper mo = go.GetComponent <Dropper>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <EnemyPathRunnerBehavior>()) { EnemyPathRunnerBehavior mo = go.GetComponent <EnemyPathRunnerBehavior>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <EnemyShooter>()) { EnemyShooter mo = go.GetComponent <EnemyShooter>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <EnemyRunnerBehavior>()) { EnemyRunnerBehavior mo = go.GetComponent <EnemyRunnerBehavior>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <Jump>()) { Jump mo = go.GetComponent <Jump>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <EnemyPathsMultiples>()) { EnemyPathsMultiples mo = go.GetComponent <EnemyPathsMultiples>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <Subibaja>()) { Subibaja mo = go.GetComponent <Subibaja>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <ListenerDispatcher>()) { ListenerDispatcher mo = go.GetComponent <ListenerDispatcher>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <FlyingBehavior>()) { FlyingBehavior mo = go.GetComponent <FlyingBehavior>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <FullRotation>()) { FullRotation mo = go.GetComponent <FullRotation>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <Bumper>()) { Bumper mo = go.GetComponent <Bumper>(); CopyComponent(mo, sceneObject.gameObject); } if (go.GetComponent <RandomPosition>()) { RandomPosition mo = go.GetComponent <RandomPosition>(); pos = mo.getPosition(pos); } } //AddBorders (); }