Esempio n. 1
0
 public Vector3 GetPosition(ResourceCard card)
 {
     int count = transform.childCount;
     var deck = GetDeck(card.ResourceType);
     var position = new Vector3(-0.3f*count,0,0.04f*count);
     return position;
 }
Esempio n. 2
0
    void Start()
    {
        // Add 12 of each card to the deck
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.Black));
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.Blue));
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.Green));
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.Orange));
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.Pink));
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.Red));
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.White));
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(12, ResourceColor.Yellow));

        // 14 wild cards
        resourceDeck.Add(ResourceCard.CreateSeveralResourceCards(14, ResourceColor.Wild));

        // Shuffle Train cards***************
        resourceDeck.Shuffle();
        Debug.Log("Resource deck:" + resourceDeck.ToString());

        // Draws River***********************
        for (int i = 0; i < river.Length; i++)
        {
            river[i] = resourceDeck.Draw();
        }
        Debug.Log(StringRiver());

        // Creates the Route Deck
        // Need to implement this
    }
 public override void executeUpdate(Object sender, EventArgs e)
 {
     if (sender is Dice)
     {
         //
         Dice dice = (Dice)sender;
         theBoard.addEventText(theBoard.currentPlayer.getName() + " rolled a " + dice.getRollValue());
         if (dice.getRollValue() == 7)
         {
             ////Thief event!!
             ////Go through each player to see if they loose thier resources
             ////Once the thief event has successfully run, we can terminate this event.
             //MessageBox.Show(theBoard.currentPlayer.getName() + " rolled a 7. The thief has been activated!");
             //RobberStealEvt evt = new RobberStealEvt();
             //disableEventObjects();
             //evt.beginExecution(theBoard, this);
         }
         else
         {
             //Players get resources
             foreach (Tile tile in theBoard.boardTiles)
             {
                 if (tile is TerrainTile)
                 {
                     TerrainTile tt = (TerrainTile)tile;
                     if (tt.getGatherChance() == dice.getRollValue())
                     {
                         if (!tt.isGatherBlocked())
                         {
                             //All players here get the resource.
                             foreach (Settlement set in tt.adjascentSettlements)
                             {
                                 if (set.getOwningPlayer() != null)
                                 {
                                     ResourceCard rc = Board.TheBank.giveOutResource(tt.getResourceType());
                                     if (rc != null)
                                     {
                                         set.getOwningPlayer().giveResource(rc);
                                         if (set.city())
                                         {
                                             //Give an extra for cities
                                             set.getOwningPlayer().giveResource(rc);
                                         }
                                     }
                                     else
                                     {
                                         theBoard.addEventText("Not enough " + Board.RESOURCE_NAMES[(int)tt.getResourceType()] + " to give  to " + set.getOwningPlayer().getName());
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //Event resolved
         endExecution();
     }
 }
Esempio n. 4
0
    public Vector3 GetPosition(ResourceCard card)
    {
        int count    = transform.childCount;
        var deck     = GetDeck(card.ResourceType);
        var position = new Vector3(-0.3f * count, 0, 0.04f * count);

        return(position);
    }
Esempio n. 5
0
    // public Person owner;


    public House(string type, string address, List <BuildingPart> houseParts)
    {
        this.type    = type;
        this.address = address;
        stuff        = houseParts;
        value        = CalculateHouseValue(houseParts);
        resources    = CalculateTotalResourceCost(houseParts);
    }
Esempio n. 6
0
 public static void Show(string message, ResourceCard inventoryCard = null)
 {
     if (singleton == null)
     {
         return;
     }
     singleton.ShowTooltip(message);
     singleton.InventoryCard = inventoryCard;
 }
Esempio n. 7
0
 // Constructor
 public Faction(string name)
 {
     this.name = name;
     cities    = new List <Town>();
     resources = new ResourceCard(0, 0, 0, 0, 0);
     money     = 0.00;
     inventory = new List <Items>();
     laws      = new List <string>();
 }
    /// <summary>
    /// Build the building within the city if building conditions are met.
    /// </summary>
    /// <param name="building">The building card to build.</param>
    /// <param name="isFreeBuild">If the building can be built for free.</param>
    /// <returns>True if built.</returns>
    public bool Build(Card building, bool isFreeBuild)
    {
        if (IsBuildable(building, isFreeBuild))
        {
            this.Owner.Coins -= this.IsMoneyRequired(building);
            switch (building.Type)
            {
            case CardType.RESOURCE:
                ResourceCard rc = (ResourceCard)building;
                this.Resources.Add(rc);
                this.IsLastCardResource = true;
                this.AddToResourceTree(rc.Resources, rc.IsOptional, rc.IsBuyable);
                break;

            case CardType.WAR:
                this.WarBuildings.Add((WarCard)building);
                break;

            case CardType.CIVIL:
                this.CivilBuildings.Add((CivilCard)building);
                break;

            case CardType.COMMERCIAL:
                this.CommercialBuildings.Add(building);
                if (building is ResourceCard comResCard)
                {
                    this.AddToResourceTree(comResCard.Resources, comResCard.IsOptional, comResCard.IsBuyable);
                }
                else if (building is BonusCard bc)
                {
                    this.ApplyDirectCommercialBonus(bc);
                }
                else if (building is CommercialCard cc)
                {
                    this.ApplyTradeReduction(cc);
                }
                break;

            case CardType.SCIENCE:
                this.ScienceBuildings.Add((ScienceCard)building);
                break;

            case CardType.GUILD:
                this.Bonus.Add((BonusCard)building);
                break;
            }
            this.Owner.Hand.Remove(building);

            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 9
0
    void MouseClicked()
    {
        ResourceCard activeCard = HandControllerInstance.GetActiveCard();
        Reactor      reactor    = PlayFieldControllerInstance.GetHoveredReactor();

        if (activeCard != null && reactor != null && reactor.Activated && reactor.Accepts(activeCard.RepresentedResource))
        {
            reactor.Fuel(activeCard.RepresentedResource);
            HandControllerInstance.ConsumeActiveCard();
            PlayFieldControllerInstance.ResourceSelected(HandControllerInstance.GetActiveCard()?.RepresentedResource);
        }
    }
Esempio n. 10
0
 private void BuildResourceCard(ResourceCard card)
 {
     foreach (var avaivableResource in card.AvaivableResources)
     {
         if (AvaivableResources.ContainsKey(avaivableResource.Key))
         {
             AvaivableResources[avaivableResource.Key] += avaivableResource.Value;
         }
         else
         {
             AvaivableResources.Add(avaivableResource.Key, avaivableResource.Value);
         }
     }
 }
Esempio n. 11
0
    private ResourceCard CalculateTotalResourceCost(List <BuildingPart> houseParts)
    {
        ResourceCard sum = new ResourceCard(0, 0, 0, 0, 0);

        for (int i = 0; i < houseParts.Count; i++)
        {
            sum.brick += houseParts[i].componentType.resources.brick;
            sum.ore   += houseParts[i].componentType.resources.ore;
            sum.wheat += houseParts[i].componentType.resources.wheat;
            sum.wood  += houseParts[i].componentType.resources.wood;
            sum.wool  += houseParts[i].componentType.resources.wool;
        }

        return(sum);
    }
 public BuildingComponent(string name, string furniture, Vector2 area, double height, int cost, ResourceCard resources, double weight, int HP, bool lockable, bool sleepable, bool fire, bool rotate)
 {
     this.name      = name;
     this.type      = furniture;
     this.area      = area;
     this.height    = height;
     this.cost      = cost;
     this.resources = resources;
     this.weight    = weight;
     this.HP        = HP;
     this.lockable  = lockable;
     this.sleepable = sleepable;
     this.fire      = fire;
     rotatable      = rotate;
 }
Esempio n. 13
0
    private BuildingComponent[] LoadComponents()
    {
        BuildingComponent[] components = new BuildingComponent[4];
        // Wall
        ResourceCard resources = new ResourceCard(2, 0, 0, 0, 0);

        components[0] = new BuildingComponent("wall", "border", new Vector2(1, 1), 10.0, 25, resources, 1000, 100, false, false, false, true);
        // Door
        resources     = new ResourceCard(2, 0, 1, 0, 0);
        components[1] = new BuildingComponent("doorUp", "border", new Vector2(1, 1), 10.0, 25, resources, 1000, 70, true, false, false, true);
        // Floor
        resources     = new ResourceCard(0, 0, 0, 0, 0);
        components[2] = new BuildingComponent("floor", "floor", new Vector2(1, 1), 0.0, 5, resources, 0, 50, false, false, false, false);
        return(components);
    }
Esempio n. 14
0
        public static List <Card> ReadAllCards()
        {
            string strCommand = File.ReadAllText("Database/select_cards_script.sql");
            var    result     = new List <Card>();

            using (SQLiteConnection objConnection = new SQLiteConnection(strConnection))
            {
                objConnection.Open();
                using (SQLiteCommand command = new SQLiteCommand(strCommand, objConnection))
                {
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Card card;
                            var  type = (CardType)reader.GetInt32(3);
                            switch (type)
                            {
                            case CardType.MilitaryCard:
                                card = new MilitaryCard();
                                break;

                            case CardType.CultureCard:
                                card = new CultureCard();
                                break;

                            case CardType.ResourceCard:
                                card = new ResourceCard();
                                break;

                            case CardType.ScienceCard:
                                card = new ScienceCard();
                                break;

                            default:
                                card = new TradeCard();
                                break;
                            }
                            Read(reader, card);
                            result.Add(card);
                        }
                    }
                }
                objConnection.Close();
            }
            return(result);
        }
 public BuildingComponent(string[] columns)
 {
     name = columns[0];
     type = columns[1];
     string[] dim = columns[2].Split('x');
     area       = new Vector2((float)Convert.ToDouble(dim[0]), (float)Convert.ToDouble(dim[1]));
     height     = Convert.ToDouble(columns[3].Split('f')[0]);
     columns[4] = columns[4].Remove(0, 1);
     cost       = Convert.ToInt32(columns[4]);
     resources  = ResourceCard.StringToObject(columns[5]);
     weight     = Convert.ToInt32(columns[6]);
     HP         = Convert.ToInt32(columns[7]);
     lockable   = YesNoToBool(columns[8].Trim());
     sleepable  = YesNoToBool(columns[9].Trim());
     fire       = YesNoToBool(columns[10].Trim());
     rotatable  = YesNoToBool(columns[11].Trim());
 }
Esempio n. 16
0
    void PlayCard(GameResource resource)
    {
        ResourceCard newCard = Instantiate(ResourceCardPF, HandLocation);

        newCard.transform.position = HandLocation.position + Vector3.right * 12f;
        newCard.SetResource(resource);
        CardsInHand.Add(newCard);

        if (CardsInHand.Count() == MaxHandSize + 1) // we just drew the first overflowing card
        {
            HandIsTooFullCallback();
        }
        else if (CardsInHand.Count() == 1) // this is our first card
        {
            MyAudioSource.clip = resource.ActiveCardSound;
            MyAudioSource.Play();
        }

        AdjustCardsInHandPosition();
    }
Esempio n. 17
0
    public void ConsumeActiveCard()
    {
        /*
         * MyAudioSource.pitch = Random.Range(.95f, 1.05f);
         * MyAudioSource.clip = CardPlacedSound;
         * MyAudioSource.Play();
         */
        ResourceCard removedCard = GetActiveCard();

        CardsInHand.RemoveAt(0);
        Destroy(removedCard.gameObject);

        if (CardsInHand.Count() == MaxHandSize) // we just went down to less than overflowing
        {
            HandIsNoLongerTooFullCallback();
        }
        else if (CardsInHand.Count > 0)
        {
            MyAudioSource.clip = CardsInHand[0].RepresentedResource.ActiveCardSound;
            MyAudioSource.Play();
        }

        AdjustCardsInHandPosition();
    }
Esempio n. 18
0
    public static ResourceCard StringToObject(string CSResources)
    {
        ResourceCard resources = new ResourceCard(0, 0, 0, 0, 0);

        if (CSResources != "-" && CSResources != "" && CSResources != "none")
        {
            if (CSResources.Contains(","))
            {
                string[] data = CSResources.Split(',');
                for (int i = 0; i < data.Length; i++)
                {
                    string[] numAndName = data[i].Split(' ');
                    resources.AddResourceByName(numAndName[0], numAndName[1]);
                }
            }
            else
            {
                string[] numAndName = CSResources.Split(' ');
                resources.AddResourceByName(numAndName[0], numAndName[1]);
            }
        }

        return(resources);
    }
Esempio n. 19
0
    // Always use TakeFromRiver() to take a card from the river. Don't directly reference Cards.river[someNumber].
    public static ResourceCard TakeFromRiver(int desiredCardIndex, bool canDrawLocomotive)
    {
        // Ensure the card you want exists
        ResourceCard desiredCard = river[desiredCardIndex];

        if (desiredCard == null)
        {
            Debug.LogWarning("You can't take \"nothing\" from a blank river slot");
            return(null);
        }
        // You can restrict the player from taking locomotives
        if (desiredCard.color == ResourceColor.Wild && !canDrawLocomotive)
        {
            Debug.Log("The player can't take this locomotive");
            return(null);
        }
        // Take the card out of the river
        river[desiredCardIndex] = null;

        // Replenish the river if possible
        river[desiredCardIndex] = resourceDeck.Draw();

        return(desiredCard);
    }
Esempio n. 20
0
        /*
         *  A bit of an odd workaround for the issue of having no way to handle exceptions from buttons firing these
         *      methods.
         */
        public void exec(object sender, EventArgs e)
        {
            //Check
            switch (state)
            {
            case 0:
                if (sender is NumberChip)
                {
                    NumberChip nc = (NumberChip)sender;

                    //Check if the player has selected the desert
                    if (Board.THIEF_MUST_MOVE && nc.isBlocked())
                    {
                        throw new ThiefException(ThiefException.THIEF_CANNOT_STAY);
                    }

                    if (Board.THIEF_CANNOT_GO_HOME && nc.getNumber() == 0)
                    {
                        throw new ThiefException(ThiefException.THIEF_CANNOT_GO_DESERT);
                    }

                    theBoard.addEventText(UserMessages.RobberHasMoved(theBoard.currentPlayer));
                    oldThiefLocation.removeThief();
                    nc.placeThief();
                    oldThiefLocation = nc;
                    if (chitHasPlayers())
                    {
                        state++;
                        theBoard.addEventText(UserMessages.PLAYER_STEAL_RESOURCES);
                    }
                    else
                    {
                        endExecution();
                    }
                }
                break;

            case 1:
                if (!(sender is Settlement))
                {
                    //We only run this check in case something did not clean up properly from a previous event.
                    return;
                }

                //We check if the settlement is actually adjascent to the thief.
                if (!terrainTileWithThief.hasSettlement((Settlement)sender))
                {
                    throw new ThiefException(ThiefException.CANT_STEAL_FROM_PLAYER);
                }

                //Get the player at the chosen location (sender is that location)
                Player playerToStealFrom = ((Settlement)sender).getOwningPlayer();

                //Check if there is a player at the location.
                if (playerToStealFrom == null)
                {
                    throw new ThiefException(ThiefException.NO_PLAYER);
                }

                //Check if the player is not the current player.
                if (playerToStealFrom == theBoard.currentPlayer)
                {
                    throw new ThiefException(ThiefException.YOU_OWN_THIS_SETTLEMENT);
                }

                //At this point we can safely assume a card can be taken.
                ResourceCard rCard = playerToStealFrom.takeRandomResource();
                //We check if the card is null because if the player has no cards to give takeRandomResource() returns null.
                if (rCard != null)
                {
                    //What happens if there were cards to steal
                    theBoard.currentPlayer.giveResource(playerToStealFrom.takeRandomResource());
                    theBoard.addEventText(UserMessages.PlayerGotResourceFromPlayer(theBoard.currentPlayer, playerToStealFrom, rCard.getResourceType()));
                    state++;
                    endExecution();
                }
                else
                {
                    //What happens if there were no cards to steal.
                    theBoard.addEventText(UserMessages.PlayerGoNoResourceFromPlayer(theBoard.currentPlayer, playerToStealFrom));
                    state++;
                    endExecution();
                }
                break;
            }
        }
Esempio n. 21
0
    /// <summary>
    /// Get the list of symbols names present on given card.
    /// </summary>
    /// <param name="card">The card to analyze.</param>
    /// <returns>The list of symbols present on the card.</returns>
    private string[] GetSymbolNames(Card card)
    {
        List <string> symbolNames = new List <string>();

        switch (card.Type)
        {
        case Card.CardType.RESOURCE:
            ResourceCard rc = ((ResourceCard)card);
            foreach (Card.ResourceQuantity rq in rc.Resources)
            {
                for (int i = 0; i < rq.Quantity; i++)
                {
                    symbolNames.Add(rq.Type.ToString());
                }
            }
            break;

        case Card.CardType.WAR:
            for (int i = 0; i < ((WarCard)card).WarPoints; i++)
            {
                symbolNames.Add(card.Type.ToString());
            }
            break;

        case Card.CardType.CIVIL:
            symbolNames.Add(card.Type.ToString());
            break;

        case Card.CardType.COMMERCIAL:
            switch (card)
            {
            case ResourceCard rec:
                symbolNames.AddRange(rec.Resources.Select(c => c.Type.ToString()));
                break;

            case BonusCard boc:
                if (boc.Bonus == BonusCard.BonusType.WONDER_BONUS)
                {
                    symbolNames.Add("MEDIUM_WONDER_BONUS");
                }
                else
                {
                    if (!(boc.CheckLeft && boc.CheckRight))
                    {
                        if (boc.BonusCardType.Length == 0)
                        {
                            symbolNames.Add("coin");
                        }
                        else if (boc.BonusCardType[0] == Card.CardType.COMMERCIAL)
                        {
                            symbolNames.Add("MEDIUM_COMMERCIAL_BONUS");
                        }
                        else if (boc.BonusCardType[0] == Card.CardType.RESOURCE)
                        {
                            if (boc.ResourceKind == BonusCard.ResourceMetaType.RAW)
                            {
                                symbolNames.Add("MEDIUM_RAW_BONUS");
                            }
                            else
                            {
                                symbolNames.Add("MEDIUM_MANUFACTURED_BONUS");
                            }
                        }
                    }
                    else
                    {
                        if (boc.ResourceKind == BonusCard.ResourceMetaType.RAW)
                        {
                            symbolNames.Add("BIG_RAW_BONUS_COINS");
                        }
                        else
                        {
                            symbolNames.Add("BIG_MANUFACTURED_BONUS_COINS");
                        }
                    }
                }
                break;

            case CommercialCard cc:
                string comSymbol = "";
                if (CityManager.RAW_RESOURCES.Where(rr => rr == cc.Resources.First().Type).Count() > 0)
                {
                    comSymbol += "BIG_RAW";
                    if (cc.LeftPlayer)
                    {
                        comSymbol += "_LEFT";
                    }
                    else
                    {
                        comSymbol += "_RIGHT";
                    }
                }
                else
                {
                    comSymbol += "BIG_MANUFACTURED";
                }
                symbolNames.Add(comSymbol);
                break;
            }
            break;

        case Card.CardType.SCIENCE:
            symbolNames.Add(((ScienceCard)card).ScienceCardType.ToString());
            break;

        case Card.CardType.GUILD:
            BonusCard bc = (BonusCard)card;
            switch (bc.Bonus)
            {
            case BonusCard.BonusType.CARD_BONUS:
                if (bc.BonusCardType.Length > 1)
                {
                    symbolNames.Add("BIG_GUI_3_CARDS");
                }
                else
                if (bc.BonusCardType[0] == Card.CardType.RESOURCE)
                {
                    if (bc.ResourceKind == BonusCard.ResourceMetaType.RAW)
                    {
                        symbolNames.Add("BIG_GUI_RAW");
                    }
                    else
                    {
                        symbolNames.Add("BIG_GUI_MANUFACTURED");
                    }
                }
                else
                {
                    symbolNames.Add("BIG_GUI_" + bc.BonusCardType[0].ToString());
                }
                break;

            case BonusCard.BonusType.DEFEAT_BONUS:
                symbolNames.Add("BIG_GUI_DEFEAT");
                break;

            case BonusCard.BonusType.SCIENCE_BONUS:
                foreach (Card.ScienceType science_symbol in System.Enum.GetValues(typeof(Card.ScienceType)))
                {
                    symbolNames.Add(science_symbol.ToString());
                }
                break;

            case BonusCard.BonusType.WONDER_BONUS:
                symbolNames.Add("BIG_GUI_WONDER");
                break;
            }
            break;
        }

        return(symbolNames.ToArray());
    }
Esempio n. 22
0
 public void OnGot(ResourceCard card)
 {
     GetDeck(card.ResourceType).Add(card);
 }
Esempio n. 23
0
 public void OnGot(ResourceCard card)
 {
     GetDeck(card.ResourceType).Add(card);
 }
Esempio n. 24
0
 public int CompareTo(ResourceCard card)
 {
     return this._resourceType.CompareTo(card._resourceType);
 }
Esempio n. 25
0
    // Called by game manager
    // states this player wants to draw a car
    // !!! NEED TO ADD RESTRICTION FOR DRAWING CARDS
    public void drawResource(int playerNumber)
    {
        ResourceCard drawn = Cards.resourceDeck.Draw();

        PlayerList.playerInfos[playerNumber].resourceCards.Add(drawn);
    }
Esempio n. 26
0
 public int CompareTo(ResourceCard card)
 {
     return(this._resourceType.CompareTo(card._resourceType));
 }