예제 #1
0
 void SetBorderColor()
 {
     //Unlocked
     if (!locked)
     {
         border.color = unlockedColor;
     }
     //Selected
     else if (selected)
     {
         border.color = selectedColor;
     }
     //Has enought money, parent unlocked, not selected
     else if (!selected && ability.cost <= GameDatas.BankAccount && GameDatas.HasAbility(ability.parentAbility))
     {
         border.color = lockedColor;
     }
     //no money OR no parent unlocked AND not selected
     else if (!selected && (ability.cost > GameDatas.BankAccount || !GameDatas.HasAbility(ability.parentAbility)))
     {
         border.color = disabledColor;
     }
     else
     {
         Debug.Log("Something is not covered");
     }
 }
예제 #2
0
    public void SetSelectedAbilityData(AbilitySO ability)
    {
        abilitiesTabCost.text  = "cost: " + ability.cost.ToString();
        abilitiesTabTitle.text = ability.title;

        selectedAbility = ability;

        if (GameDatas.HasAbility(ability.parentAbility))
        {
            if (GameDatas.BankAccount >= ability.cost)
            {
                abilitiesTabDescription.text = ability.description;
            }
            else
            {
                abilitiesTabDescription.text = "You don't have enough money for this.";
            }
        }
        else
        {
            abilitiesTabDescription.text = "You should unlock the parent ability first.";
        }

        OnAbilitySelected?.Invoke(ability);
    }
예제 #3
0
    // Start is called before the first frame update
    void Start()
    {
        menuController = FindObjectOfType <MenuController>();
        menuController.AddListenerOnAbilitySelectedEvent(OtherIconSelected);
        menuController.AddListenerOnAbilityUnlockEvent(AbilityUnlocked);

        locked   = !GameDatas.HasAbility(ability.type);
        selected = false;

        Image[] images = GetComponentsInChildren <Image>();

        foreach (Image iconPart in images)
        {
            if (iconPart.tag == "IconBorder")
            {
                border = iconPart;
            }
            else if (iconPart.tag == "IconBackground")
            {
                background = iconPart;
            }
            else if (iconPart.tag == "IconImage")
            {
                icon = iconPart;
            }
        }

        SetBorderColor();
        SetIconImage();
    }
예제 #4
0
    public void UnlockButtonAction()
    {
        if (GameDatas.HasAbility(selectedAbility.parentAbility) && GameDatas.BankAccount >= selectedAbility.cost)
        {
            GameDatas.SetAbility(selectedAbility.type, true);
            GameDatas.SpendMoney(selectedAbility.cost);

            UpdateAccounts();
            OnAbilityUnlock?.Invoke(selectedAbility.type);
        }
    }
예제 #5
0
    void SpawnLevelPart()
    {
        Vector3 position = new Vector3(-1.5f * tileSize, 0, levelPartCount * tileSize);

        Instantiate(levelPartPrefab, position, Quaternion.identity, this.transform);

        if (levelPartCount >= 8)
        {
            SpawnItemOnGround();
        }

        if (GameDatas.HasAbility(AbilityType.FARE_BLUE))
        {
            SpawnFare(position);
        }

        levelPartCount++;
    }
예제 #6
0
 public static float GetCarSpeedMultiplier()
 {
     if (GameDatas.HasAbility(AbilityType.SPEED_175))
     {
         return(1.75f);
     }
     else if (GameDatas.HasAbility(AbilityType.SPEED_150))
     {
         return(1.5f);
     }
     else if (GameDatas.HasAbility(AbilityType.SPEED_125))
     {
         return(1.25f);
     }
     else
     {
         return(1.0f);
     }
 }
예제 #7
0
    FareColor GetRandomColor()
    {
        int endRange  = GameDatas.HasAbility(AbilityType.FARE_GREEN) ? 3 : GameDatas.HasAbility(AbilityType.FARE_RED) ? 2 : 1;
        int randomInt = Random.Range(0, endRange);

        switch (randomInt)
        {
        case 0:
            return(FareColor.BLUE);

        case 1:
            return(FareColor.RED);

        case 2:
            return(FareColor.GREEN);

        default:
            return(FareColor.BLUE);
        }
    }
예제 #8
0
    void SetFareImages()
    {
        blueFare.gameObject.SetActive(false);
        redFare.gameObject.SetActive(false);
        greenFare.gameObject.SetActive(false);

        if (GameDatas.HasAbility(AbilityType.FARE_BLUE))
        {
            blueFare.gameObject.SetActive(true);
            blueFare.sprite = grayFareSprite;
        }
        if (GameDatas.HasAbility(AbilityType.FARE_RED))
        {
            redFare.gameObject.SetActive(true);
            redFare.sprite = grayFareSprite;
        }
        if (GameDatas.HasAbility(AbilityType.FARE_GREEN))
        {
            greenFare.gameObject.SetActive(true);
            greenFare.sprite = grayFareSprite;
        }
    }