Пример #1
0
    public static string GetBeerNameByTag(BeerTag beerTag)
    {
        switch (beerTag)
        {
        case BeerTag.STOUT: return("STOUT");

        case BeerTag.RED: return("RED");

        case BeerTag.PILSNER: return("PILSNER");

        default: return("?");
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!GameManager.IsGameRunning())
        {
            return;
        }

        if (waitingForNewRoundTimer >= MAX_SPAWNING_INTERVAL)
        {
            waitingForNewRoundTimer = 0.0f;

            // decide what is the next beer
            List <HouseHandler> allHouseHandlers = LevelLoader.getInstance().GetAllHouseHandlers();

            Dictionary <BeerTag, int> beerDemands = new Dictionary <BeerTag, int>();
            beerDemands[BeerTag.STOUT]   = 0;
            beerDemands[BeerTag.RED]     = 0;
            beerDemands[BeerTag.PILSNER] = 0;

            foreach (HouseHandler houseHandler in allHouseHandlers)
            {
                if (houseHandler.getBeerTag() != BeerTag.UKNOWN)
                {
                    beerDemands[houseHandler.getBeerTag()]++;
                }
            }

            BeerTag bestBeerToDispatch = BeerTag.UKNOWN;
            int     bestHouses         = 0;

            foreach (var pair in beerDemands)
            {
                if (beerDemands[pair.Key] > bestHouses)
                {
                    bestHouses         = pair.Value;
                    bestBeerToDispatch = pair.Key;
                }
            }

            if (bestBeerToDispatch != BeerTag.UKNOWN)
            {
                beerColorIndex = (int)bestBeerToDispatch;
                DispatchAnotherRound();
            }
        }
        else
        {
            waitingForNewRoundTimer += Time.deltaTime;
            GameManager.UpdateNextRoundInfo((int)(MAX_SPAWNING_INTERVAL - waitingForNewRoundTimer), numberOfBeerUnitsPerRound);
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (!GameManager.IsGameRunning())
        {
            return;
        }

        if (this.IsOutOfCameraBounds())
        {
            DestroyAndNotify();
            return;
        }

        if (nodeToVisit == null)
        {
            nodeToVisit = lastVisitedSwitchNode.GetNextNode();
        }

        if (nodeToVisit != null && (new Vector2(transform.position.x, transform.position.y) - nodeToVisit.coordinates).sqrMagnitude <= 0.1)
        {
            // check where to go
            this.transform.position = nodeToVisit.coordinates;

            if (nodeToVisit.GetType() == typeof(SwitchNode))
            {
                direction             = ((SwitchNode)nodeToVisit).GetDirectionVector();
                lastVisitedSwitchNode = (SwitchNode)nodeToVisit;
                nodeToVisit           = null;
            }
            else
            {
                BeerTag      beerTag        = TagResolver.GetTagByName(gameObject.tag);
                GameObject   houseSpriteObj = GameObject.Find("HouseNode#" + nodeToVisit.nodeId);
                HouseHandler houseHandler   = houseSpriteObj.GetComponent <HouseHandler>() as HouseHandler;
                BeerTag      houseBeerTag   = houseHandler.getBeerTag();

                if (beerTag == houseBeerTag)
                {
                    houseHandler.addLiter();
                    houseHandler.CheckAndReset();
                    GameManager.UpdateScore(1);
                }
                DestroyAndNotify();
            }
        }

        Vector2 translation = Time.deltaTime * beerSpeed * direction;

        this.transform.Translate(translation);
    }
Пример #4
0
    void AskForBeer()
    {
        currentBeerLitersGoal = demandingLiters;
        currentLiters         = 0;
        beerType = (BeerTag)RandomUtils.GetRandomNumber(0, 3);

        if (beerNotificationSpriteGO)
        {
            Destroy(beerNotificationSpriteGO);
        }
        beerNotificationSpriteGO = new GameObject();
        beerNotificationSpriteGO.AddComponent <SpriteRenderer>();
        beerNotificationSpriteGO.GetComponent <SpriteRenderer>().sprite           = beerSprites[(int)beerType];
        beerNotificationSpriteGO.GetComponent <SpriteRenderer>().sortingLayerName = "NotificationsLayer";
        beerNotificationSpriteGO.transform.position = this.gameObject.transform.position + new Vector3(0.5f, 0.5f);
    }
Пример #5
0
 public static int GetIndexByTag(BeerTag beerTag)
 {
     return((int)beerTag);
 }
Пример #6
0
    public static string GetNameByIndex(int index)
    {
        BeerTag beerTag = (BeerTag)index;

        return(GetBeerNameByTag(beerTag));
    }