void SpawnFare(Vector3 position) { if (levelPartCount % fareDistance == 0 && levelPartCount != 0) { xPosition = ((xPosition + 2) % 3) - 1; position = new Vector3(xPosition * tileSize, 0, tileSize * levelPartCount); FareColor randomColor = GetRandomColor(); Material fareMaterial = GetFareMaterial(randomColor); if (HasFare(randomColor)) { position.y = fareTarget.transform.position.y; GameObject fareTargetObject = Instantiate(fareTarget, position, fareTarget.transform.rotation, this.transform); fareTargetObject.GetComponent <ColorController>().SetFareColor(randomColor); ChangeColor(fareMaterial, fareTargetObject); ChangeSpawnedFareBool(randomColor); } else { int gender = Random.Range(0, 2); position.y = fares[gender].transform.position.y; GameObject fareObject = Instantiate(fares[gender], position, Quaternion.identity, this.transform); fareObject.GetComponent <ColorController>().SetFareColor(randomColor); ChangeColor(fareMaterial, fareObject); ChangeSpawnedFareBool(randomColor); } } }
void ChangeSpawnedFareBool(FareColor color) { switch (color) { case FareColor.BLUE: hasBlueFare = !hasBlueFare; break; case FareColor.RED: hasRedFare = !hasRedFare; break; case FareColor.GREEN: hasGreenFare = !hasGreenFare; break; } }
bool HasFare(FareColor color) { switch (color) { case FareColor.BLUE: return(hasBlueFare); case FareColor.RED: return(hasRedFare); case FareColor.GREEN: return(hasGreenFare); default: return(false); } }
Material GetFareMaterial(FareColor color) { switch (color) { case FareColor.BLUE: return(blueFareMaterial); case FareColor.RED: return(redFareMaterial); case FareColor.GREEN: return(greenFareMaterial); default: return(blueFareMaterial); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Obstacle") { TransitionState(explosionState); } else if (other.tag == "Fare") { FareColor color = other.GetComponent <ColorController>().GetFareColor(); OnPickUpFare?.Invoke(color); Destroy(other.gameObject); } else if (other.tag == "FareTarget") { FareColor color = other.GetComponent <ColorController>().GetFareColor(); OnTransferFare?.Invoke(color); Destroy(other.gameObject); } }
void ChangeFareImageColor(FareColor color) { Sprite change = grayFareSprite; switch (color) { case FareColor.BLUE: change = blueFare.sprite == grayFareSprite ? blueFareSprite : grayFareSprite; blueFare.sprite = change; break; case FareColor.RED: change = redFare.sprite == grayFareSprite ? redFareSprite : grayFareSprite; redFare.sprite = change; break; case FareColor.GREEN: change = greenFare.sprite == grayFareSprite ? greenFareSprite : grayFareSprite; greenFare.sprite = change; break; } }
void AddFarePrice(FareColor color) { CollectCoin(GameDatas.GetFarePrice()); }
public void SetFareColor(FareColor fc) { fareColor = fc; }