public void NotifyStockMove() { if (StockPile.Count > 0) { List <Card> movedCards = new List <Card>(); movedCards.Add(StockPile.Peek()); Move move = new Move(movedCards, new TablePosition(Zone.Stock, -1), new TablePosition(Zone.Waste, -1), gameState.Clone() as GameState); foreach (ISolitaireEventsHandlers subscribedHandler in subscribedInstances) { subscribedHandler.NotifyFlipStockCardMove(move); } //Update Game Data Card nextCard = StockPile.Pop(); WastePile.Push(nextCard); movesHistory.Push(move); } else { Move move = new Move(this.WastePile.Reverse().ToList(), new TablePosition(Zone.Waste, -1), new TablePosition(Zone.Stock, -1), gameState.Clone() as GameState); foreach (ISolitaireEventsHandlers subscribedHandler in subscribedInstances) { subscribedHandler.NotifyRestoreStockpileFromWastePile(new List <Card>(WastePile)); } while (WastePile.Count > 0) { Card card = WastePile.Pop(); StockPile.Push(card); } movesHistory.Push(move); } }
void Awake() { planetHealth = GetComponent <PlanetHealth>(); planetShield = GetComponent <PlanetShield>(); stockPile = GetComponent <StockPile>(); planetStats = GetComponent <PlanetStats>(); }
// Use this for initialization void Start() { localPlayer = PlayerManager.LocalPlayerInstance; stockpile = localPlayer.GetComponent <StockPile>(); currency = localPlayer.GetComponent <Currency>(); interceptor = localPlayer.GetComponent <PlanetInterceptor>(); planetShield = localPlayer.GetComponent <PlanetShield>(); SetCostForAllWeapons(); }
private void ValidateItem(string item) { if (!StockPile.ContainsKey(item)) { StockPile.Add(item, new StockPileData() { Item = item }); } }
public void TestAddRemove() { Corporation corporation = new Corporation(ECorporation.WorldWide); StockPile pile = new StockPile(corporation, 3); // Start with 3 pile.add(3); Assert.AreEqual(6, pile.NumStocks); Assert.IsFalse(pile.remove(7)); pile.remove(6); Assert.AreEqual(0, pile.NumStocks); }
public void Should_Not_Pop_If_Target_Is_Stock() { IPile pile = new FoundationPile(); var cardACE = new Card(1, CardType.Spade); pile.Push(cardACE); IPile target = new StockPile(); Assert.False(pile.PopRefactor(target)); }
public bool ChoiceStockPile() { float countFree = 0; foreach (GameObject o in _village.Building) { StockPile stocks = o.GetComponent <StockPile>(); if (stocks != null) { Inventory inv = stocks.GetComponent <Inventory>(); countFree += inv.MaxWeight - inv.Weight; } } return(countFree < 100f); }
public bool NoBuildNeeded() { bool need = true; foreach (GameObject o in _village.Building) { House house = o.GetComponent <House>(); if (house != null && house.Villagers.Length < house.MaxCount) { need = false; } } if (need) { return(false); } int consomation = (int)(_village.Villagers.Length * ( (float)Manager.Instance.Properties.GetElement("Agent.Hunger").Value / (float)Manager.Instance.Properties.GetElement("Delay.Hungry").Value ) * (float)Manager.Instance.Properties.GetElement("Delay.Season").Value * 5f); int count = _village.GetComponentsInChildren <Cornfield>().Length; int cornfieldProduction = (int)(float)Manager.Instance.Properties.GetElement("Harvest.Cornfield").Value; float cornfieldDuration = (float)Manager.Instance.Properties.GetElement("Delay.Cornfield.Seeding").Value + (float)Manager.Instance.Properties.GetElement("Delay.Cornfield.Growing").Value + (float)Manager.Instance.Properties.GetElement("Delay.Cornfield.Harvest").Value; int production = (int)(Manager.Instance.SeasonDuration * 3f / cornfieldDuration) * count * cornfieldProduction * (int)(float)Manager.Instance.Properties.GetElement("FoodValue.Corn").Value; if (consomation > production) { return(false); } float countFree = 0; foreach (GameObject o in _village.Building) { StockPile stocks = o.GetComponent <StockPile>(); if (stocks != null) { Inventory inv = stocks.GetComponent <Inventory>(); countFree += inv.MaxWeight - inv.Weight; } } return(countFree > 100f); }
void Awake() { planet = GetComponent<Planet>(); stockPile = GetComponent<StockPile>(); }