/// <summary> /// Call this to initialize a Behaviour with data supplied in a file. /// </summary> /// <param name="fileName">The file to load from.</param> public override void LoadContent(String fileName) { base.LoadContent(fileName); PickupDefinition def = GameObjectManager.pInstance.pContentManager.Load <PickupDefinition>(fileName); mInventoryTemplateFileName = def.mInventoryTemplateFileName; mAddObjectMsg = new Inventory.AddObjectMessage(); }
public bool CanSelectPickup(PickupDefinition pickup) { if (categorySimpleUI.currentPickup == null) { return(pickup.type == PickupType.Category); } else if (effect1SimpleUI.currentPickup == null) { return(pickup.type == PickupType.Effect); } //TODO if multiple possible effects; disable already selected ones return(false); }
public void EarnPickup(PickupDefinition pickup) { if (pickups.Count >= maxPickupsAmount) { //Debug.LogError("Error: can't add pickup"); return; } PickupUI newPickupUI = Instantiate(pickupModel.gameObject, pickupModel.transform.parent).GetComponent <PickupUI>(); newPickupUI.gameObject.SetActive(true); newPickupUI.Init(pickup, this); pickups.Add(newPickupUI); Reorganize(); }
public void Init(PickupDefinition pickup, PickupCollection _collection) { backgroundImage.color = pickup.GetBackgroundColor(); iconImage.sprite = pickup.GetSprite(); descriptionLabel.text = pickup.GetDescription(); description.SetActive(false); collection = _collection; selectedBackground.SetActive(false); pickupDefinition = pickup; disabledImage.SetActive(false); }
public void ReapReward() { GlobalGameManager.Instance.CoinsAmount += card.cardDefinition.goldReward; PickupDefinition earnedPickup = null; if (GlobalGameManager.Instance.tutoManager.CurrentTutoStep == TutoManager.TutoStep.ToCardCrafting && GlobalGameManager.Instance.pickupCollection.GetCurrentPickupsAmount() == 0) { earnedPickup = new PickupCategoryDefinition(CardCategory.Creature); } else { for (int i = 0; i < 3; i++) { if (Random.Range(0f, 1f) < 0.6f) { if (Random.Range(0f, 1f) < 0.3f) { System.Array categories = System.Enum.GetValues(typeof(CardCategory)); int categoriesAmount = categories.Length; CardCategory category = CardCategory.None; while (category == CardCategory.None) { category = (CardCategory)categories.GetValue(Random.Range(0, categoriesAmount)); } earnedPickup = new PickupCategoryDefinition(category); } else { System.Array effects = System.Enum.GetValues(typeof(PickupEffect)); int effectsAmount = effects.Length; PickupEffect effect = PickupEffect.None; while (effect == PickupEffect.None) { effect = (PickupEffect)effects.GetValue(Random.Range(0, effectsAmount)); } earnedPickup = new PickupEffectDefinition(effect); } } } } if(earnedPickup != null) GlobalGameManager.Instance.pickupCollection.EarnPickup(earnedPickup); }
public void TestPickup() { //oping hours var openingHours = new DateTimeTerm() { Inclusive = new List <DateTimePeriod> { new DateTimePeriod { Times = { "10:00-2:00" } } }, Exclusive = new List <DateTimePeriod> { new DateTimePeriod { Times = { "10:00-2:00" }, Dates = { "2016/10/20" } }, new DateTimePeriod { Times = { "13:00-18:00" }, Dates = { "2016/10/21" } } } }; //definition var definition = new PickupDefinition() { Available = true, Rules = new List <PickupRule>() }; definition.Rules.Add(new PickupRule() { Addresses = { "Address A", "Address D" }, DateTimes = new DateTimeTerm() { Inclusive = new List <DateTimePeriod> { new DateTimePeriod { Times = { "10:00-17:00" }, DaysOfWeek = { "3", "4" } } } } }); definition.Rules.Add(new PickupRule() { Addresses = { "Address B", "Address E" }, DateTimes = new DateTimeTerm() { Inclusive = new List <DateTimePeriod> { new DateTimePeriod { Times = { "12:00-18:00" }, DaysOfWeek = { "2", "4" } } } } }); definition.Rules.Add(new PickupRule() { SameAsOpeningHours = true, Addresses = { "Address C" } }); //result var opts = definition.GetOptions(new DateTime(2016, 10, 19), 6, openingHours); Assert.AreEqual(15, opts.Count); Assert.AreEqual("Address A", opts[0].Address); Assert.AreEqual("Address B", opts[2].Address); Assert.AreEqual("Address C", opts[4].Address); Assert.AreEqual("Address D", opts[11].Address); Assert.AreEqual("Address E", opts[13].Address); }
//TargettingType GetTargetingType() //{ // switch (cardBase) // { // case CardDefinitionType.Fireball: // return TargettingType.AnySpot; // default: // Debug.LogError("Error: card base " + cardBase + " isn't handled in GetTargetingType."); // return TargettingType.AnySpot; // } //} public bool AddBonus(PickupDefinition pickup, bool apply = false) { if (pickup.type == PickupType.Category) { CardCategory pickupCategory = (pickup as PickupCategoryDefinition).category; switch (pickupCategory) { // Applying a Creature pickup case CardCategory.Creature: if (cardDefinition.cardCategory == CardCategory.Creature) { if (apply) { healthBonus += 1; } return(true); } else { return(false); } // Applying an InstantSpell pickup case CardCategory.InstantSpell: if (cardDefinition.cardCategory == CardCategory.Creature) { if (apply) { movesBonus += 1; } return(true); } else { return(false); } default: Debug.LogError("Pickup category " + pickupCategory + " not handled in AddBonus"); return(false); } } else if (pickup.type == PickupType.Effect) { PickupEffect pickupEffect = (pickup as PickupEffectDefinition).effect; switch (pickupEffect) { // Applying a Creature pickup case PickupEffect.Damage: if (cardDefinition.cardCategory == CardCategory.Creature) { if (apply) { damageBonus += 1; } return(true); } else { switch (cardDefinition.cardType) { case CardDefinitionType.Fireball: if (apply) { damageBonus += 1; } return(true); default: Debug.LogError("Pickup effect " + pickupEffect + " not handled for card type " + cardDefinition.cardType + " in AddBonus"); return(false); } } default: Debug.LogError("Pickup effect " + pickupEffect + " not handled in AddBonus"); return(false); } } else { Debug.LogError("Wtf, what this pickup of type " + pickup.type + "?!"); } return(false); }