コード例 #1
0
    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);
            }
        }
    }
コード例 #2
0
    void ChangeSpawnedFareBool(FareColor color)
    {
        switch (color)
        {
        case FareColor.BLUE:
            hasBlueFare = !hasBlueFare;
            break;

        case FareColor.RED:
            hasRedFare = !hasRedFare;
            break;

        case FareColor.GREEN:
            hasGreenFare = !hasGreenFare;
            break;
        }
    }
コード例 #3
0
    bool HasFare(FareColor color)
    {
        switch (color)
        {
        case FareColor.BLUE:
            return(hasBlueFare);

        case FareColor.RED:
            return(hasRedFare);

        case FareColor.GREEN:
            return(hasGreenFare);

        default:
            return(false);
        }
    }
コード例 #4
0
    Material GetFareMaterial(FareColor color)
    {
        switch (color)
        {
        case FareColor.BLUE:
            return(blueFareMaterial);

        case FareColor.RED:
            return(redFareMaterial);

        case FareColor.GREEN:
            return(greenFareMaterial);

        default:
            return(blueFareMaterial);
        }
    }
コード例 #5
0
    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);
        }
    }
コード例 #6
0
ファイル: GameUIController.cs プロジェクト: KreWorks/loopfare
    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;
        }
    }
コード例 #7
0
 void AddFarePrice(FareColor color)
 {
     CollectCoin(GameDatas.GetFarePrice());
 }
コード例 #8
0
ファイル: ColorController.cs プロジェクト: KreWorks/loopfare
 public void SetFareColor(FareColor fc)
 {
     fareColor = fc;
 }