private void CarSpawn_Tick(object sender, EventArgs e) { stage.addCar(rnd.Next(4), rnd.Next(8)); if (stage.checkJam()) { NextMove.Stop(); CarSpawn.Stop(); ManSpawn.Stop(); GameOver go = new GameOver(defOptions, "TRAFFIC JAM"); go.StartPosition = FormStartPosition.CenterScreen; go.ShowDialog(); if (go.nova == true) { stage = new Stage(defOptions); NextMove.Start(); CarSpawn.Start(); ManSpawn.Start(); Invalidate(); } else { this.Close(); } } }
private void NextMove_Tick(object sender, EventArgs e) { lblScore.Text = Stage.score.ToString(); pCars = stage.checkCollisionCars(); pMan = stage.checkCollisionMan(); if (!pCars.IsEmpty) { NextMove.Stop(); CarSpawn.Stop(); ManSpawn.Stop(); Delay.Start(); Graphics g = CreateGraphics(); stage.drawBam(pCars, g); } else if (!pMan.IsEmpty) { NextMove.Stop(); CarSpawn.Stop(); ManSpawn.Stop(); Delay.Start(); if (defOptions.sound == true) { scream.Play(); } Graphics g = CreateGraphics(); Image blood = (Bitmap)Resources.tomato.Clone(); g.DrawImage(blood, pMan.X - 10, pMan.Y - 10, blood.Width / 3, blood.Height / 3); } else { stage.move(); stage.inCollisionArea(); Invalidate(); } }
public void GetStatus() { CarSpawn spawn = GameManager.instance.spawner.carSpawns[index]; carText.text = spawn.type.ToString(); carCost.text = spawn.blocked ? "Cost " + spawn.unblockCost : "Owned"; carImage.sprite = spawn.carSprite; blockedIcon.SetActive(spawn.blocked); unblockButton.SetActive(spawn.blocked); }
//================================================================ Car Spawn Setting ================================================================ private CarSpawn CreateCarSpawn(Vector2 p_position, Vector2 p_direction) { GameObject carSpawnObject = GameObject.Instantiate(carSpawnPrefab); CarSpawn carSpawnScript = carSpawnObject.GetComponent <CarSpawn>(); Transform carSpawnHolder = transform.Find("CarSpawnList"); carSpawnObject.transform.SetParent(carSpawnHolder); carSpawnObject.transform.position = p_position; carSpawnScript.SetUp(p_direction, _gameManager._roundSystemManager.GetVehecleJSON()); return(carSpawnScript); }
//method to spawn a car void SpawnCar() { CarMovement car = Instantiate(carPrefab, carParent).GetComponent <CarMovement>(); CarSpawn startPoint = carSpawnPoints[Random.Range(0, carSpawnPoints.Count)]; //Debug.Log("spawning car at " + startPoint); car.transform.position = startPoint.transform.position; car.Direction = startPoint.direction; car.Speed = Random.Range(speedMin, speedMax); Cars.Add(car); }
private void Delay_Tick(object sender, EventArgs e) { Delay.Stop(); GameOver go = new GameOver(defOptions, "COLLISION"); go.StartPosition = FormStartPosition.CenterScreen; go.ShowDialog(); if (go.nova == true) { stage = new Stage(defOptions); NextMove.Start(); CarSpawn.Start(); ManSpawn.Start(); bgSound.Play(); Invalidate(); } else { this.Close(); } }
public void Buy() { //TODO hacer el chequeo de recursos CarSpawn spawn = GameManager.instance.spawner.carSpawns[index]; if (GameManager.instance.profile.points > spawn.unblockCost) { spawn.blocked = false; GameManager.instance.profile.blockedData[index] = false; blockedIcon.SetActive(spawn.blocked); unblockButton.SetActive(spawn.blocked); Debug.Log("Car buyed " + spawn.type); GameManager.instance.profile.points -= spawn.unblockCost; moneyText.text = "Points " + GameManager.instance.profile.points; if (onCarBuyed != null) { onCarBuyed(); } GameManager.instance.SaveData(); } }
private void SetCarSpawnGenerator(float p_streetBottomPosition, int p_carSlot) { float centerAxisX = streetObject.transform.position.x, halfWidth = (streetObject.size.x / 2), xLeftPos = centerAxisX - halfWidth, xRightPos = centerAxisX + halfWidth; for (int i = 0; i < p_carSlot; i++) { bool isFaceLeft = UtilityColl.FlipCoin(0.5f); float carSpawnYPos = p_streetBottomPosition + (slotheight * i) + (slotheight / 2f); Vector2 carSpawnPos = new Vector2((isFaceLeft) ? xLeftPos : xRightPos, carSpawnYPos); Vector2 carDirection = (isFaceLeft) ? Vector2.right :Vector2.left; CarSpawn gCarSpawn = CreateCarSpawn(carSpawnPos, carDirection); // Vector2 carSpawnPosition, // spawnDir = ; carSpawnPointList.Add(gCarSpawn); } }
void Awake() { manage = this; }
private void NewGame_FormClosing(object sender, FormClosingEventArgs e) { NextMove.Stop(); CarSpawn.Stop(); ManSpawn.Stop(); }
public void AddSpawner(CarSpawn spawner) { _spawners.Add(spawner); }
void Spawn() { GameObject prefab; dir = Directions.NONE; CarSpawn carSpawn = GetCar(); CarType ct = carSpawn.type; if (hasQueue) { prefab = queuePrefab; dir = queueDirection; hasQueue = false; ct = queueType; } else { prefab = carSpawn.prefab; if (nextDir == Directions.NONE) { int pos = Random.Range(0, 4); dir = (Directions)pos; nextDir = dir; } else { dir = nextDir; int pos = Random.Range(0, 4); nextDir = (Directions)pos; } } Transform spawner = GetSpawner(dir); Vector3 carDir = GetDirection(dir); Car car = null; if (usesPool) { car = pool.GetCar(ct); } else { GameObject carGo = GameObject.Instantiate(prefab, spawner.transform.position, Quaternion.identity); car = carGo.GetComponent <Car>(); } car.Init(); car.GetComponent <Rigidbody>().angularVelocity = Vector3.zero; car.GetComponent <Rigidbody>().velocity = Vector3.zero; car.transform.eulerAngles = Vector3.zero; car.transform.position = spawner.transform.position; car.SetDirection(carDir, dir); car.spawner = this; Color c = possibleColors[Random.Range(0, possibleColors.Count)]; car.SetColor(c); currentCars.Add(car.gameObject); CalculateFrequency(); Invoke("Spawn", frequency); }