void MakeSlots() { int count = getHighestSlotCount(); Slots = new List <UI_SquadSlot>(); List <Unlockable <SquadSizeConfig> > sizes = new List <Unlockable <SquadSizeConfig> >(SquadManager.Instance.GetSquadSizeUnlockes()); Unlockable <SquadSizeConfig> current = sizes[0]; for (int i = 0; i < count; i++) { if (i == current.Item.Size) { sizes.Remove(current); if (sizes.Count > 0) { current = sizes[0]; } } Slots.Add(UI_SquadSlot.MakeSlot(current, target.transform)); } }
public void Activate() { Unlockable _lock = gameObject.transform.GetComponent <Unlockable>(); if (_lock != null) { if (_lock.isActive() == false) { if (_isActive == true) { _isActive = false; } else { _isActive = true; } } } else { if (_isActive == true) { _isActive = false; } else { _isActive = true; } } }
//desbloquea un item y lo remueve de la lista de items disponibles void UnlockItem(Unlockable u, int k) { u.unlocked = true; PlayerPrefs.SetInt(u.name, 1); availableRewards.Remove(k); Debug.Log("Unlocked " + u.name); }
public Unlockable UnlockRandom() { IEnumerable <Unlockable> locked = allUnlockables.Where(u => !u.unlocked); if (locked.Count() == 0) { return(null); } float r = Random.value; float chanceSum = 0.0f; Unlockable unlockable = null; foreach (Unlockable u in locked) { chanceSum += 1.0f / u.Price; if (r < chanceSum) { unlockable = u; break; } } //Unlockable unlockable = locked.ElementAt(Random.Range(0, locked.Count())); if (!unlockable) { return(null); } unlockable.unlocked = true; SaveUnlocks(); return(unlockable); }
public void UnlockItem(Unlockable item) { item.unlocked = true; PlayerPrefs.SetInt(item.unlockableID, item.unlocked ? PP_TRUE : PP_FALSE); PlayerPrefs.SetInt(PP_UNLOCKS_SAVED, PP_TRUE); PlayerPrefs.Save(); }
void OnUnlock(Unlockable unlockable) { if (unlockable.Unlocked) { image.color = Color.white; } }
public string UseItem(Item itemName) { if (Unlockable.Contains(itemName)) { if (itemName.Name.ToString().ToLower() == "sword") { Items.Add(new Item("Chainmail", "This would provide some good protection.")); Locked = false; return("You manage to slice the guards down with little effort."); } else if (itemName.Name.ToString().ToLower() == "torch") { Locked = false; return("You wield the torch. Hopefully it doesn't go out."); } else if (itemName.Name.ToString().ToLower() == "ale") { Locked = false; count++; if (count > 8) { return("You drink until you can't see straight"); } return("You drink the ale. Another drink might not be so bad."); } Locked = false; return("Unlocked door"); } else { return("Item has no use here"); } }
internal void Populate(Unlockable unlockable, UIListUnlockable uIListUnlockable, Action <Unlockable, UIListItemUnlockable> callback) { _unlockable = unlockable; _uIListUnlockable = uIListUnlockable; _unlockableCallback = callback; Display(); }
internal void Show(Unlockable unlockable, UIListItemUnlockable uIListItemUnlockable) { this.gameObject.SetActive(true); _unlockable = unlockable; _uIListItemUnlockable = uIListItemUnlockable; _priceText.text = _unlockable.Price.ToString(); _previewRawImage.texture = _unlockable.Preview.texture; }
//Sets starting values void Start() { anim = GetComponent <Animator>(); if (GetComponent <Unlockable>() != null) { lockComponent = GetComponent <Unlockable>(); } }
public static UI_SquadSlot MakeSlot(Unlockable <SquadSizeConfig> config, Transform target) { GameObject prefab = Resources.Load("UI/ui_squad_slot") as GameObject; UI_SquadSlot slot = prefab.Instantiate <UI_SquadSlot>(target, true); slot.SetItem(config); return(slot); }
public void Activate() { RaycastHit hitInfo; if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hitInfo, InteractionRange, PropLayer)) { //Name of the items //Item checks Obtainable heldItem = cam.transform.GetComponentInChildren <Obtainable>(); Obtainable Obj = hitInfo.transform.GetComponentInParent <Obtainable>(); Unlockable _lock = hitInfo.transform.GetComponentInParent <Unlockable>(); Rotating_Door Door = hitInfo.transform.GetComponentInParent <Rotating_Door>(); //Instance Checks and Logic if (Door != null) { if (_lock != null) { foreach (Transform item in inventory) { _lock.Deactivate(item); } Door.Activate(); } else { Door.Activate(); } } if (Obj != null) { if (Obj.CompareTag("Collectable")) { inventory.Add(Obj.transform); Obj.Destroy(); Debug.Log(inventory); } } if (heldItem == null) { if (Obj != null) { Obj.Activate(cam); } } else { heldItem.Deactivate(); } } }
protected override void OnSet(Unlockable <SquadSizeConfig> item) { States = new UniqueSelectionGroup <GameObject>(); States.Init(new List <GameObject>() { Available, Locked, Filled }, state => state.SetActive(false), state => state.SetActive(true)); setState( ); }
internal int GetUnlockableIndex(Unlockable unlockable, Unlockable[] unlockables) { for (int i = 0; i < unlockables.Length; i++) { if (unlockables[i] == unlockable) { return(i); } } return(-1); }
void Awake() { foreach (Transform children in transform) { Unlockable toUnlock = children.GetComponent <Unlockable>(); if (toUnlock != null && !toUnlock.Equals(null)) { toUnlock.Lock(); } } }
public void Register(Unlockable unlockable, int questIdx) { if (_UnlockData.ContainsKey(questIdx)) { _UnlockData[questIdx].Unlockables.Add(unlockable); } else { _UnlockData.Add(questIdx, new UnlockData()); Register(unlockable, questIdx); } }
public override void SetItem(Unlockable <TieredUnit> item, Action <Unlockable <TieredUnit> > button_Callback) { // MDebug.Log("SetItem " + item.Item.Tiers[0].Config.ID); base.SetItem(item, button_Callback); ClassNameTF.text = item.Item.Tiers[0].Config.ID; Portrait.Init(item.Item.Tiers[0].Config, Color.white); item.AddUnlockListener(Updated); InfoButtonTarget.AddComponent <UI_ButtonGetSet_ScriptableUnitConfig>().SetItem(item.Item.Tiers[0].Config, SetUnitInfo); UnitTiers.Init(TieredUnit.Unlocks(item.Item.Tiers, PlayerLevel.Instance)); }
public string UseItem(Item itemName) { if (Unlockable.Contains(itemName)) { Locked = false; return("You place the cold gold crown upon your head"); } else { return("Item has no use here"); } }
public UnitSelecterButton MakeView(Unlockable <TieredUnit> unit_config, Transform target) { GameObject obj = Instantiate(Resources.Load("UI/ui_unit_selection_view")) as GameObject; obj.transform.SetParent(target, false); // obj.transform.localScale = Vector3.one; UnitSelecterButton selector = obj.GetComponent <UnitSelecterButton>(); selector.SetItem(unit_config, OnSelect); return(selector); }
void OnSelect(Unlockable <TieredUnit> tier) { MDebug.Log("SQUAD SELECTER SELECT TIER " + tier.Item.Tiers[0].Config.ID); if (SquadManager.Instance.selected_units.Contains(tier.Item)) { selector_buttons.GetView(tier).SetUnselected(); SquadManager.RemoveFromSquad(tier.Item); } else if (SquadManager.AddToSquad(tier)) { selector_buttons.GetView(tier).SetSelected(); } }
public static bool AddToSquad(Unlockable <TieredUnit> conf) { if (conf.IsUnlocked() && !Instance.selected_units.Contains(conf.Item) && Instance.selected_units.Count < Instance.GetMaxSquadsize()) { MDebug.Log("ADDING " + conf.Item.Tiers[0].Config.ID); Instance.selected_units.Add(conf.Item); Instance.OnSelectedUpdate.AttemptCall(Instance.selected_units); return(true); } SoundManager.PlayAtSourceTag("SoundSFXSource", "sfx_" + SoundManager.Presets.error); ToastNotification.SetToastMessage2("Squad is Full"); return(false); }
void Populate() { GameObject newObj; // Create GameObject instance foreach (var item in SettingController.Instance.SettingsFilter) { Unlockable unlockable = GameManagerInstance.Instance.GetUnlockable(item); // Create new instances of our prefab until we've created as many as we specified newObj = (GameObject)Instantiate(prefab, transform); SettingItemController SIC = newObj.GetComponent <SettingItemController>(); SIC.SetSettingItem(item, unlockable.Descriptions[0], unlockable.Cost); } }
System.Collections.IEnumerator DisplayUnlockMessage(Unlockable unlock) { while (!messageConfirmed) { unlockMessageBox.SetActive(true); unlockableHeadingText.text = unlock.heading; unlockableNameText.text = unlock.unlockableName; unlockableIconImage.sprite = unlock.unlockIcon; yield return(0); } unlockMessageBox.SetActive(false); unlockableNameText.text = ""; messageConfirmed = false; }
void Start() { itemDescriptionText = GameObject.Find("ItemDescriptionText").GetComponent <Text>(); itemDescriptionText.text = ""; /*Scale*/ animLB[0] = new AnimationCurve(new Keyframe(0, 9.0f), new Keyframe(fTimeToBurst, 8.0f), new Keyframe(fTimeToBurst + 1.0f, 7000.0f)); /* Yaw */ animLB[1] = new AnimationCurve(new Keyframe(0, 175), new Keyframe(1, 185)); animLB[0].postWrapMode = WrapMode.ClampForever; animLB[1].postWrapMode = WrapMode.PingPong; lootbox = Instantiate(Resources.Load <GameObject>("Prefabs/lootbox"), Vector3.zero, rotation, transform); lootbox.transform.localScale = new Vector3(animLB[0].Evaluate(Time.timeSinceLevelLoad), animLB[0].Evaluate(Time.timeSinceLevelLoad), animLB[0].Evaluate(Time.timeSinceLevelLoad)); UnlockManager um = GameObject.Find("UnlockManager").GetComponent <UnlockManager>(); Unlockable newItem = um.UnlockRandom(); if (newItem == null) { //SceneManager.LoadScene("GameOverScene"); //return; newItem = Coins.GetComponent <Unlockable>(); } { GameObject prefab = newItem.gameObject; newItemDisplay = Instantiate(prefab, Vector3.zero, rotation, transform); newItemDisplay.transform.localScale = Vector3.zero; } Keyframe kf2; fTimeToFullSize = fTimeToBurst + 0.8f; if (newItemDisplay.GetComponent <Unlockable>().type == UnlockableType.SKYSCRAPER) { kf2 = new Keyframe(fTimeToFullSize, 0.3f); } else if (newItemDisplay.GetComponent <Unlockable>().type == UnlockableType.HOUSE || newItemDisplay.GetComponent <Unlockable>().type == UnlockableType.SHOP) { kf2 = new Keyframe(fTimeToFullSize, 0.65f); } else { kf2 = new Keyframe(fTimeToFullSize, 1.5f); } animNID = new AnimationCurve(new Keyframe(0, 0), new Keyframe(fTimeToBurst, 0), kf2); animNID.postWrapMode = WrapMode.ClampForever; }
public static List<Unlockable<T>> MakeUnlockables<T, C>(List<C> configs, Levels level, Func<C, int> GetRequirement, Func<T, string> GetID, Func<C, T> GetItem, Action<T> CallBack) { List<Unlockable<T>> unlocks = new List<Unlockable<T>>(); foreach (var c in configs) { Unlockable<T> unlockable = new Unlockable<T>(GetItem(c), level, GetRequirement(c), GetID); if(CallBack != null) unlockable.AddUnlockListener(CallBack); unlocks.Add(unlockable); } return unlocks; }
public static List<Unlockable<T>> MakeUnlockables<T>(List<T> source, Levels level, Func<T, int> GetRequirement, Func<T, string> GetID, Action<T> CallBack) { List<Unlockable<T>> unlocks = new List<Unlockable<T>>(); foreach (var c in source) { Unlockable<T> unlockable = new Unlockable<T>(c, level, GetRequirement(c), GetID); if(CallBack != null) unlockable.AddUnlockListener(CallBack); unlocks.Add(unlockable); } return unlocks; }
void Populate() { GameObject newObj; // Create GameObject instance Dictionary <GameManagerInstance.UnlockStateID, Unlockable> UnlockCosts = GameManagerInstance.Instance.GetUnlockCosts(); foreach (var item in UnlockCosts) { Unlockable unlockable = item.Value; // Create new instances of our prefab until we've created as many as we specified newObj = (GameObject)Instantiate(prefab, transform); ShopItemController SIC = newObj.GetComponent <ShopItemController>(); SIC.SetShopItem(item.Key, unlockable.Descriptions[0], unlockable.Cost); } }
public void unlockSkill(int skillIndex) { Unlockable skill = (Unlockable)skillIndex; unlocks[skillIndex] = true; if (skill == Unlockable.BOW) { bowBack.GetComponent <MeshRenderer>().enabled = true; } else if (skill == Unlockable.IMPROVE) { slash.GetComponentInChildren <slash>().slow = true; bulletPrefab = improvedBullet; strikeCD /= 2f; } }
public string UseItem(Item itemName) { if (Unlockable.Contains(itemName)) { if (itemName.Name.ToString().ToLower() == "key") { Unlock(); Exits["west"].Unlock(); return("Unlocked door"); } } else { return("You wave your" + itemName.ToString() + " around but it has no use here"); } return(""); }
public void SetUnlockable(Unlockable unlockable) { this.unlockable = unlockable; switch (unlockable.type) { case UnlockableType.Emoji: openParticle = Instantiate(Resources.Load <GameObject>("Prefabs/Particles/EmojiParticle"), brokenParticle.gameObject.transform, false) .GetComponent <ParticleSystem>(); rewardImage.sprite = EmojiSprites.GetEmoji(unlockable.extra); text.text = "New emoji!"; break; case UnlockableType.Bluetooth: openParticle = Instantiate(Resources.Load <GameObject>("Prefabs/Particles/BluetoothParticle"), brokenParticle.gameObject.transform, false) .GetComponent <ParticleSystem>(); rewardImage.sprite = Resources.Load <Sprite>("Textures/GUI/BluetoothIcob"); rewardImage.color = new Color(0.24706f, 0.31765f, 0.7098f); text.text = "Bluetooth mode unlocked!"; break; // TODO change these to something else because this sucks case UnlockableType.EmojiSlot: openParticle = Instantiate(Resources.Load <GameObject>("Prefabs/Particles/EmojiParticle"), brokenParticle.gameObject.transform, false) .GetComponent <ParticleSystem>(); rewardImage.sprite = Resources.Load <Sprite>("Textures/emojiSlotUnlock"); text.text = "New slot for emojis!"; break; case UnlockableType.LocalMulti: rewardImage.sprite = Resources.Load <Sprite>("Textures/localMultiUnlock"); rewardImage.color = Color.white; text.text = "Local multiplayer unlocked!"; break; case UnlockableType.GooglePlay: rewardImage.sprite = Resources.Load <Sprite>("Textures/gpUnlock"); rewardImage.color = Color.white; text.text = "Google play multiplayer unlocked!"; break; } }
public void Unlock(Unlockable.Type type) { switch (type) { case Unlockable.Type.FirstWing: { firstWingUnlocked = true; if(player) { player.firstWing.SetUnlockedState(true); } currentSpawnPoint = firstWingSpawn; break; } case Unlockable.Type.SecondWing: { secondWingUnlocked= true; if(player) { player.secondWing.SetUnlockedState(true); } currentSpawnPoint = secondWingSpawn; break; } case Unlockable.Type.ArmsAndSword: { armsAndSwordUnlocked = true; if(player) { player.armsAndSword.SetUnlockedState(true); } currentSpawnPoint = armsAndSwordSpawn; break; } } }