// Use this for initialization void Start() { LoadDummyPositions(); LoadMapping(); int layoutCounter = 0; foreach (string objName in objectNames) { // TODO: smarter layout choices OR fixed grid Vector3 position = GenerateRandomPosition(layoutPositions[layoutCounter]); GameObject newObject = (GameObject)GameObject.Instantiate(prefab, position, prefab.transform.rotation); newObject.AddComponent("ScoreTriggerLookupAgreement"); if (GameState.Singleton.ScoringMode == ScoringMode.Collaborative) { newObject.AddComponent("ScoreTriggerTagAgreement"); } else if (GameState.Singleton.ScoringMode == ScoringMode.Competitive) { newObject.AddComponent("ScoreTriggerTagBlocked"); } else // Both // XXX (kasiu): Currently adds both. This is bad. //newObject.AddComponent("ScoreTriggerTagAgreement"); //newObject.AddComponent("ScoreTriggerTagBlocked"); { newObject.AddComponent("ScoreTriggerTagBoth"); } DebugConsole.Log("Added object of : " + prefab.name); newObject.name = objName; newObject.transform.FindChild("Tag1").name = tagNames[0]; newObject.transform.FindChild("Tag2").name = tagNames[1]; if (newObject.transform.FindChild("Tag3") != null) { newObject.transform.FindChild("Tag3").name = tagNames[2]; } // Add the tooltip newObject.AddComponent("MouseHoverTooltip"); MouseHoverTooltip mhtComponent = newObject.GetComponent <MouseHoverTooltip>(); mhtComponent.text = objName; mhtComponent.fontSize = 10; mhtComponent.fontColor = Color.black; mhtComponent.fontBackground = Color.white; Transform spriteChild = newObject.transform.FindChild("TexturedQuad"); if (spriteChild != null) { DebugConsole.Log("Attempting to attach textures: " + objName); spriteChild.gameObject.AddComponent("LoadSprite"); LoadSprite spriteComponent = spriteChild.GetComponent <LoadSprite>(); //spriteComponent.texture = itemImageMap[objName]; spriteComponent.texture = TextToTextureLoader.RetrieveTexture(objName); } layoutCounter++; } }
private void OnUpdateCost(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } EquipCostInfo info = item.oData as EquipCostInfo; UISprite color = item.mScripts[0] as UISprite; UITexture icon = item.mScripts[1] as UITexture; UILabel num = item.mScripts[2] as UILabel; ItemInfo item_info = ItemManager.GetItemInfo(info.item_id.ToString()); if (item_info == null) { return; } color.spriteName = "color" + item_info.color; LoadSprite.LoaderItem(icon, info.item_id.ToString(), false); int total_num = ItemManager.GetBagItemCount(info.item_id.ToString()); num.text = string.Format("{0}/{1}", total_num, info.need_num.ToString()); num.color = total_num >= info.need_num ? Color.white : Color.red; }
public void CharacterIcon() { GameObject characterCompass = GameObject.Find("CharacterCompass"); LoadSprite.FindSprite(characterCompass, PlayerPrefs.GetString("P1-Name")); characterCompass.transform.localPosition = tilemap.CellToWorld(new Vector3Int(PlayerPrefs.GetInt("CurrentTileX"), PlayerPrefs.GetInt("CurrentTileY"), 0)); }
/// <summary> /// 设置宝石组件信息 /// </summary> private void SetGemItemInfo(GameObject child, HoldInfo info) { GameObject suo = child.transform.FindChild("suo").gameObject; GameObject takeBtn = child.transform.FindChild("takeBtn").gameObject; GameObject openBtn = child.transform.FindChild("openBtn").gameObject; GameObject insetBtn = child.transform.FindChild("insetBtn").gameObject; UITexture icon = child.transform.FindChild("icon").GetComponent <UITexture>(); UILabel descTxt = child.transform.FindChild("descTxt").GetComponent <UILabel>(); UISprite color = child.transform.FindChild("color").GetComponent <UISprite>(); icon.gameObject.SetActive(info.m_gem_id > 0); color.gameObject.SetActive(info.m_gem_id > 0); if (info.m_gem_id > 0) { ItemInfo item_info = ItemManager.GetItemInfo(info.m_gem_id.ToString()); color.spriteName = "color" + item_info.color; LoadSprite.LoaderItem(icon, info.m_gem_id.ToString(), false); } suo.SetActive(info.m_type == Hold_STATE.MATERIAL_LOCK || info.m_type == Hold_STATE.NOT_OPEN_LOCK || info.m_type == Hold_STATE.CAN_OPEN); takeBtn.SetActive(info.m_type == Hold_STATE.EQUIP); openBtn.SetActive(info.m_type == Hold_STATE.CAN_OPEN); insetBtn.SetActive(info.m_type == Hold_STATE.EMPTY); string des = GetGemDesc(info); descTxt.text = des; }
/// <summary> /// 刷新上阵卡牌信息 /// </summary> /// <param name="item"></param> void UpdateCardFightGrid(UIGridItem item) { if (item == null || item.oData == null || item.mScripts == null) { return; } CardDataMsg info = item.oData as CardDataMsg; UILabel nofight = item.mScripts[0] as UILabel; UILabel fight = item.mScripts[1] as UILabel; UILabel cardName = item.mScripts[2] as UILabel; UITexture head = item.mScripts[3] as UITexture; UILabel skillType = item.mScripts[4] as UILabel; nofight.gameObject.SetActive(info.configId < 4); fight.gameObject.SetActive(info.configId > 4); item.name = "fight" + item.miCurIndex; if (fight.gameObject.activeSelf) { TD_Card card = CardConfig.GetItem(info.configId); cardName.text = card.name; LoadSprite.LoaderCard(head, card.res); skillType.text = UtilTools.GetSKillTypeName((int)card.type); } }
public static void ItemReward() { if (PlayerPrefs.GetInt("ItemReward") == 0) { string tile = PlayerPrefs.GetString("CurrentTile"); string item = ""; if (tile[0] == 'C') { int combatNumber = 0; if (tile.Length == 7) { combatNumber = Int32.Parse(tile[6].ToString()); } if (tile.Length == 8) { combatNumber = Int32.Parse(tile[6].ToString() + tile[7].ToString()); } item = PlayerPrefs.GetString("Combat" + combatNumber + "ItemReward"); } if (tile[0] == 'M') { item = PlayerPrefs.GetString("MinibossItemReward"); } if (tile[0] == 'B') { item = PlayerPrefs.GetString("BossItemReward"); } GameObject.Find("ItemRewardText").GetComponent <Text>().text = item; LoadSprite.FindSprite(GameObject.Find("ItemReward"), item); int itemCount = PlayerPrefs.GetInt(item + "Count"); itemCount++; PlayerPrefs.SetInt(item + "Count", itemCount); PlayerPrefs.SetInt("ItemReward", 1); } }
void UpdatePieceGrid(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } RewardInfo rewardInfo = item.oData as RewardInfo; UISprite color = item.mScripts[0] as UISprite; UITexture head = item.mScripts[1] as UITexture; UILabel Name = item.mScripts[2] as UILabel; UISlider slider = item.mScripts[3] as UISlider; UISprite btn = item.mScripts[4] as UISprite; UILabel Num = item.mScripts[5] as UILabel; UISprite hetong = item.mScripts[6] as UISprite; slider.value = 0; ItemInfo info = ItemManager.GetItemInfo(rewardInfo.itemID); color.spriteName = UtilTools.StringBuilder("color" + info.color); Name.text = TextManager.GetItemString(rewardInfo.itemID); if (info.color == 5) { hetong.spriteName = "jinhetong"; } else { hetong.spriteName = "zihetong"; } LoadSprite.LoaderItem(head, rewardInfo.itemID, false); }
public static void RewardDisplay(string currentStage) { if (PlayerPrefs.GetInt("RewardDisplayOn") == 0) { PlayerPrefs.SetInt("RewardDisplayOn", 1); string tile = PlayerPrefs.GetString("CurrentTile"); int combatNumber = 0; if (tile.Length == 7) { combatNumber = Int32.Parse(tile[6].ToString()); } if (tile.Length == 8) { combatNumber = Int32.Parse(tile[6].ToString() + tile[7].ToString()); } for (int i = 1; i <= 2; i++) { PlayerXP(currentStage, combatNumber, i); } GameObject rewardsBackground = GameObject.Find("RewardsBackground"); rewardsBackground.transform.localPosition = new Vector3(0, 0, -1); GameObject mapButton = GameObject.Find("MapButton"); LoadSprite.FindSprite(mapButton, "none"); mapButton.transform.localPosition += new Vector3(0, 0, +2); ShardReward(); if (PlayerPrefs.GetInt("P1LevelUpAvailable") == 0 && PlayerPrefs.GetInt("P2LevelUpAvailable") == 0) { LoadSprite.FindSprite(mapButton, "MapButton"); mapButton.transform.localPosition += new Vector3(0, 0, -2); } } }
private void CostUpdataItem(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } CompoundInfo info = item.oData as CompoundInfo; UISprite color = item.mScripts[0] as UISprite; UITexture icon = item.mScripts[1] as UITexture; UILabel num = item.mScripts[2] as UILabel; UISprite add = item.mScripts[3] as UISprite; color.spriteName = "color" + 1; add.transform.gameObject.SetActive(info.m_select == 0); item.transform.FindChild("contain").gameObject.SetActive(info.m_select == 1); if (info.m_gem != null) { GemItem gem = GemItemConfig.GetGemItem(int.Parse(info.m_gem.itemID)); ItemInfo item_info = ItemManager.GetItemInfo(info.m_gem.itemID); num.text = "1"; color.spriteName = "color" + item_info.color; LoadSprite.LoaderItem(icon, item_info.itemID, false); } }
/// <summary>刷新英雄信息</summary> /// <param name="item"></param> void UpdateHeroGrid(UIGridItem item) { if (item == null || item.oData == null || item.mScripts == null) { return; } //item.onClick = SetHeroItem; FightCardMsg info = item.oData as FightCardMsg; UITexture texture = item.mScripts[0] as UITexture; UILabel name = item.mScripts[1] as UILabel; UILabel leftNumLab = item.mScripts[2] as UILabel; UILabel rightNumLab = item.mScripts[3] as UILabel; TD_Card card = CardConfig.GetItem(info.cardId); if (card == null) { Debug.LogError("no this card cfg:" + info.cardId); return; } name.text = card.name; LoadSprite.LoaderCard(texture, card.res); }
void CreateRewardItem() { if (rewardIndex == rewardList.Count - 1) { m_Panel.Mask.GetComponent <BoxCollider>().enabled = true; return; } string itemID = rewardList[rewardIndex] as string; ItemInfo info = ItemManager.GetItemInfo(itemID); GameObject go = GameObject.Instantiate(PoolManager.PopPrefab(PoolManager.PoolKey.Prefab_RewardItem).gameObject); go.transform.parent = m_Panel.getReward.transform; go.transform.localScale = Vector3.zero; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.GetComponent <UISprite>().spriteName = "color" + info.color; LoadSprite.LoaderItem(go.GetComponentInChildren <UITexture>(), itemID, false); go.gameObject.SetActive(true); TweenScale.Begin(go, 0.02f, Vector3.one); if (rewardIndex <= 4) { TweenPosition.Begin(go, 0.02f, new Vector3(-230 + rewardIndex * 130, 90, 0)); } else { TweenPosition.Begin(go, 0.02f, new Vector3(-230 + (rewardIndex - 5) * 130, -35, 0)); } rewardIndex++; TimerManager.AddTimer("rewardIndex", 0.2f, CreateRewardItem); }
private void ChooseGrid_UpdateItem(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } EquipItemInfo info = item.oData as EquipItemInfo; item.onClick = ClickEquipItem; UILabel name = item.mScripts[0] as UILabel; UISprite color = item.mScripts[1] as UISprite; UITexture icon = item.mScripts[2] as UITexture; UILabel level = item.mScripts[7] as UILabel; UITexture star = item.mScripts[8] as UITexture; UISprite[] equip_star = UtilTools.GetChilds <UISprite>(item.transform, "star"); ItemInfo item_info = ItemManager.GetItemInfo(info.itemID.ToString()); if (item_info == null) { return; } level.text = info.strongLevel.ToString(); name.text = TextManager.GetItemString(info.itemID); color.spriteName = "color" + info.star; LoadSprite.LoaderItem(icon, item_info.itemID, false); UtilTools.SetStar(info.star, equip_star); }
private void OnUpdateEquip(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } item.onClick = ClickEquipItem; item.Selected = false; UITexture star = item.mScripts[0] as UITexture; UISprite color = item.mScripts[1] as UISprite; UITexture icon = item.mScripts[3] as UITexture; UILabel name = item.mScripts[2] as UILabel; UISprite[] equip_star = UtilTools.GetChilds <UISprite>(item.transform, "star"); EquipMakeInfo info = item.oData as EquipMakeInfo; EquipInfo equip_info = EquipConfig.GetEquipInfo(info.ID); name.text = TextManager.GetItemString(info.ID.ToString()); color.spriteName = "color" + equip_info.star; LoadSprite.LoaderItem(icon, info.ID.ToString(), false); UtilTools.SetTextColor(name, equip_info.star); UtilTools.SetStar(equip_info.star, equip_star); }
void UpdateShopGrid(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } item.gameObject.SetActive(false); item.gameObject.SetActive(true); ShopItemInfo info = item.oData as ShopItemInfo; UISprite money = item.mScripts[0] as UISprite; UILabel price = item.mScripts[1] as UILabel; UISprite color = item.mScripts[2] as UISprite; UITexture icon = item.mScripts[3] as UITexture; UILabel limit = item.mScripts[4] as UILabel; UILabel Name = item.mScripts[5] as UILabel; UISprite recommend = item.mScripts[6] as UISprite; UISprite discount = item.mScripts[7] as UISprite; UILabel discountNum = item.mScripts[8] as UILabel; UISprite islimit = item.mScripts[9] as UISprite; item.onClick = OnClickItem; recommend.gameObject.SetActive(chooseType != 3); discount.gameObject.SetActive(chooseType != 3); islimit.gameObject.SetActive(chooseType != 3); ItemInfo data; if (chooseType == 3) { data = ItemManager.GetItemInfo(info.itemID); LoadSprite.LoaderItem(icon, info.itemID); UtilTools.SetMoneySprite(3, money); price.text = info.itemPrice.ToString(); Name.text = TextManager.GetItemString(info.itemID); limit.gameObject.SetActive(info.limitTime != 0); limit.text = info.limitTime.ToString(); islimit.gameObject.SetActive(info.limitTime == 0); color.spriteName = UtilTools.StringBuilder("color", data.color); return; } data = ItemManager.GetItemInfo(info.itemID.Substring(0, info.itemID.Length - 1)); color.spriteName = UtilTools.StringBuilder("color", data.color); price.text = (info.itemPrice * (info.disCount * 1.0f / 100)).ToString(); Name.text = TextManager.GetItemString(data.itemID); UtilTools.SetTextColor(Name, data.color); LoadSprite.LoaderItem(icon, data.itemID); UtilTools.SetMoneySprite(info.moneyType, money); limit.gameObject.SetActive(info.limitTime != 0); islimit.gameObject.SetActive(false); if (info.isLimit != 0) { limit.text = info.limitTime.ToString(); islimit.gameObject.SetActive(info.limitTime == 0); } recommend.gameObject.SetActive(info.recommend == 1); discount.gameObject.SetActive(info.disCount != 100); if (discount.gameObject.activeSelf) { discountNum.text = string.Format(TextManager.GetUIString("UIshop4"), info.disCount / 10); } }
private void CharacterStats() { for (int x = 1; x <= 4; x++) { Vector3 position = GameObject.Find("Character" + x).transform.localPosition; if (PlayerPrefs.GetString("P" + x + "-Name") != "null") { string characterName = PlayerPrefs.GetString("P" + x + "-Name"); LoadSprite.FindSprite(GameObject.Find("Character" + x), characterName + "Head"); int currentHP = PlayerPrefs.GetInt("P" + x + "-CHP"); int maxHP = PlayerPrefs.GetInt("P" + x + "-HP"); int currentSP = PlayerPrefs.GetInt("P" + x + "-CSP"); int maxSP = PlayerPrefs.GetInt("P" + x + "-SP"); float percentHP = currentHP / maxHP; float percentSP = currentSP / maxSP; GameObject.Find("Character" + x + "HP").transform.localScale = new Vector3(percentHP, 1, 1); GameObject.Find("Character" + x + "SP").transform.localScale = new Vector3(percentSP, 1, 1); GameObject.Find("Character" + x).transform.localPosition = new Vector3(position.x, position.y, -2); } else { GameObject.Find("Character" + x).transform.localPosition = new Vector3(position.x, position.y, 2); } } }
private void ChooseGrid_UpdateItem(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } Item info = item.oData as Item; item.onClick = ClickGemItem; UILabel name = item.mScripts[0] as UILabel; UITexture icon = item.mScripts[1] as UITexture; UILabel num = item.mScripts[2] as UILabel; name.text = TextManager.GetItemString(info.itemID); num.text = info.amount.ToString(); ItemInfo item_info = ItemManager.GetItemInfo(info.itemID.ToString()); if (item_info == null) { return; } LoadSprite.LoaderItem(icon, item_info.itemID, false); }
private IEnumerator LoadFromUrl(string path, LoadSprite ls) { string url = Config.Server + path; WWW www = new WWW(url); yield return(www); if (www.error != null) { //will retry if (!Retries.ContainsKey(path)) { Retries.Add(path, 0); } Retries[path]++; if (Retries[path] < 3) { Debug.Log("Error " + www.error + ", when downloading " + path + ", retries: " + Retries[path]); SpritesToLoad.Add(new KeyValuePair <string, LoadSprite>(path, ls)); } } else { Sprite s = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0.5f, 0.5f)); s.texture.filterMode = FilterMode.Point; ls(s); } DownloadingNow = false; }
/// <summary> /// 放弃任务的更新 /// </summary> void AbortUpdate() { M_ShowTask.GiveUP(); m_Btn.transform.Find("Text").GetComponent <Text>().text = "接受"; AddBtnListener(MyEvent.MyEventType.TaskAccept); transform.GetComponent <Image>().sprite = LoadSprite.LoadSpriteByName("CommonUI/RestaurantAtlas", "RestaurantAtlas_3"); }
private void ChooseGrid_UpdateItem(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } Item info = item.oData as Item; item.onClick = ClickGemItem; UILabel name = item.mScripts[0] as UILabel; UITexture icon = item.mScripts[1] as UITexture; UILabel level = item.mScripts[2] as UILabel; UISprite color = item.mScripts[3] as UISprite; ItemInfo item_info = ItemManager.GetItemInfo(info.itemID); GemItem gem = GemItemConfig.GetGemItem(int.Parse(info.itemID)); if (item_info == null) { return; } color.spriteName = "color" + item_info.color; name.text = TextManager.GetItemString(info.itemID); level.text = info.amount.ToString(); LoadSprite.LoaderItem(icon, item_info.itemID, false); }
private void SetGemInfo() { GameObject child_gem; int gem_state; string gem_data_info = select_equip.gem1 + ";" + select_equip.gem2 + ";" + select_equip.gem3;; string[] gem_data_arr = gem_data_info.Split(';'); for (int i = 0; i < 3; i++) { child_gem = panel.gemInfo.GetChild(i).gameObject; gem_state = GameConvert.IntConvert(gem_data_arr[i]); GameObject suo = child_gem.transform.FindChild("suo").gameObject; UITexture icon = child_gem.transform.FindChild("icon").GetComponent <UITexture>(); suo.SetActive(gem_state == -1); icon.transform.gameObject.SetActive(gem_state > 0); if (gem_state > 0) { LoadSprite.LoaderItem(icon, gem_state.ToString(), false); } } }
private void OnUpdateEquip(UIGridItem item) { if (item == null || item.mScripts == null || item.oData == null) { return; } item.onClick = ClickEquipItem; EquipItemInfo info = item.oData as EquipItemInfo; UISprite color = item.mScripts[0] as UISprite; UILabel level = item.mScripts[1] as UILabel; UITexture icon = item.mScripts[2] as UITexture; UILabel name = item.mScripts[3] as UILabel; UISprite select = item.mScripts[4] as UISprite; UITexture star = item.mScripts[5] as UITexture; bool show = false; if (cur_equip != null) { show = cur_select_player_id == 0? info.uuid == cur_equip.uuid: info.itemID == cur_equip.itemID; } select.transform.gameObject.SetActive(show); if (show) { last_equip_item = item; } Transform addbg = UtilTools.GetChild <Transform>(item.transform, "addbg"); Transform content = UtilTools.GetChild <Transform>(item.transform, "content"); UISprite[] equip_star = UtilTools.GetChilds <UISprite>(content, "star"); addbg.gameObject.SetActive(string.IsNullOrEmpty(info.itemID)); content.gameObject.SetActive(!string.IsNullOrEmpty(info.itemID)); if (string.IsNullOrEmpty(info.itemID)) { UILabel pos_txt = UtilTools.GetChild <UILabel>(addbg, "pos"); pos_txt.text = TextManager.GetUIString(string.Format("position_{0}", info.position)); return; } ItemInfo item_info = ItemManager.GetItemInfo(info.itemID.ToString()); if (item_info == null) { return; } level.text = TextManager.GetUIString("UI2010") + info.strongLevel.ToString(); name.text = TextManager.GetItemString(info.itemID); color.spriteName = "color" + info.star; LoadSprite.LoaderItem(icon, info.itemID, false); //UtilTools.SetTextColor(name, info.star); UtilTools.SetStar(info.star, equip_star); }
/// <summary> /// 界面显示 /// </summary> protected override void OnShow(INotification notification) { ShowItemInfo showItemInfo = (notification.Body as List <object>)[0] as ShowItemInfo; shopItemInfo = (notification.Body as List <object>)[1] as ShopItemInfo; buyItem = showItemInfo.buyItem; panel.changeNum.text = "1"; if (shopItemInfo.moneyType == 3) { itemID = shopItemInfo.itemID; panel.buyPrcie.text = shopItemInfo.itemPrice.ToString(); } else { panel.buyPrcie.text = (shopItemInfo.itemPrice * (shopItemInfo.disCount * 1.0f / 100)).ToString(); itemID = shopItemInfo.itemID.Substring(0, shopItemInfo.itemID.Length - 1); } UtilTools.SetMoneySprite(shopItemInfo.moneyType, panel.moneyType); ItemInfo info = ItemManager.GetItemInfo(itemID); LoadSprite.LoaderItem(panel.itemIcon, itemID, false); panel.itemcolor.spriteName = UtilTools.StringBuilder("color", info.color); panel.itemName.text = TextManager.GetItemString(itemID); panel.itemdesc.text = TextManager.GetPropsString("description_" + itemID); }
/// <summary> /// 设置装备信息 /// </summary> private void SetEquipInfo() { UILabel pos_txt = UtilTools.GetChild <UILabel>(panel.equipProp, "pos_info"); pos_txt.text = TextManager.GetUIString("position_" + cur_equip_info.position); UILabel des_txt = UtilTools.GetChild <UILabel>(panel.equipInfo, "des_txt"); des_txt.text = TextManager.GetPropsString("description_" + cur_equip_info.id); UILabel name_txt = UtilTools.GetChild <UILabel>(panel.equipInfo, "name"); name_txt.text = TextManager.GetItemString(select_equip.itemID); UILabel level_txt = UtilTools.GetChild <UILabel>(panel.equipInfo, "level"); level_txt.text = select_equip.strongLevel.ToString(); UISprite[] cur_star_obj = UtilTools.GetChilds <UISprite>(panel.equipInfo, "star"); UtilTools.SetStar(select_equip.star, cur_star_obj); UISprite cur_color = UtilTools.GetChild <UISprite>(panel.equipInfo, "color"); cur_color.spriteName = "color" + select_equip.star; UITexture icon = UtilTools.GetChild <UITexture>(panel.equipInfo, "icon"); LoadSprite.LoaderItem(icon, select_equip.itemID, false); }
private void Start() { LoadSprite.FindSprite(GameObject.Find("P2"), PlayerPrefs.GetString("P2-Name")); BoxCollider2D _boxCollider = GetComponent <BoxCollider2D>(); Destroy(_boxCollider); _boxCollider = gameObject.AddComponent <BoxCollider2D>() as BoxCollider2D; LoadSprite.FindSprite(GameObject.Find("P2Holo"), PlayerPrefs.GetString("P2-Name")); }
private void Equip() { int characterNumber = Int32.Parse(this.name[16].ToString()); string equipmentType = this.name.Remove(0, 17); LoadSprite.FindSprite(this.gameObject, PlayerPrefs.GetString("InventoryClickedItem")); PlayerPrefs.SetString("P" + characterNumber + "-" + equipmentType, PlayerPrefs.GetString("InventoryClickedItem")); PlayerPrefs.SetString("InventoryClickedItem", "null"); }
public static void PlayerXP(string currentStage, int combatNumber, int playerNumber) { if (PlayerPrefs.GetString("P" + playerNumber + "-Name") != "null") { GameObject p1Icon = GameObject.Find("P" + playerNumber + "Icon"); LoadSprite.FindSprite(p1Icon, PlayerPrefs.GetString("P" + playerNumber + "-Name") + "Head"); GameObject p1LevelUp = GameObject.Find("P" + playerNumber + "LevelUp"); LoadSprite.FindSprite(p1LevelUp, "none"); p1LevelUp.transform.localPosition += new Vector3(0, 0, 2); int xPReward = PlayerPrefs.GetInt(currentStage + "Combat" + combatNumber + "-XP"); int p1XP = PlayerPrefs.GetInt("P" + playerNumber + "-XP") + xPReward; GameObject p1XPBar = GameObject.Find("P" + playerNumber + "XPBar"); int p1XPMax = PlayerPrefs.GetInt("P" + playerNumber + "-XPMax"); if (p1XP >= p1XPMax) { int p1XPOverflow = p1XP - p1XPMax; PlayerPrefs.SetInt("P" + playerNumber + "-Level", PlayerPrefs.GetInt("P" + playerNumber + "-Level") + 1); switch (PlayerPrefs.GetInt("P" + playerNumber + "-Level")) { case 2: { PlayerPrefs.SetInt("P" + playerNumber + "-XPMax", 150); p1XPMax = 150; break; } case 3: { PlayerPrefs.SetInt("P" + playerNumber + "-XPMax", 400); p1XPMax = 400; break; } default: { break; } } p1XP = p1XPOverflow; LoadSprite.FindSprite(p1LevelUp, "LevelUp"); p1LevelUp.transform.localPosition += new Vector3(0, 0, -2); PlayerPrefs.SetInt("P" + playerNumber + "LevelUpAvailable", 1); } PlayerPrefs.SetInt("P" + playerNumber + "-XP", p1XP); float p1XPPercent = (float)p1XP / (float)p1XPMax; p1XPBar.transform.localScale = new Vector3(p1XPPercent, (float)0.45, 1); GameObject p1XPText = GameObject.Find("P" + playerNumber + "XPText"); p1XPText.transform.localPosition = new Vector3(170, 114 - 90 * (playerNumber - 1), -1); p1XPText.GetComponent <Text>().text = p1XP + "/" + p1XPMax; } else if (PlayerPrefs.GetString("P" + playerNumber + "-Name") == "null") { GameObject p1Icon = GameObject.Find("P" + playerNumber + "Icon"); LoadSprite.FindSprite(p1Icon, "none"); GameObject p1XPBar = GameObject.Find("P" + playerNumber + "XPBar"); LoadSprite.FindSprite(p1XPBar, "none"); GameObject p1XPText = GameObject.Find("P" + playerNumber + "XPText"); p1XPText.GetComponent <Text>().text = ""; } }
void Summon(string summonName) { int eNumber = Int32.Parse(this.name[1].ToString()); int loc = PlayerPrefs.GetInt("E" + eNumber + "-Loc"); int newENumber; int enemyLimit = 0; for (int i = 1; i <= 8; i++) { if (PlayerPrefs.GetString("E" + i + "-Name") != "null") { enemyLimit++; } } if (enemyLimit == 8) { } else { do { newENumber = UnityEngine.Random.Range(1, 9); }while (GameObject.Find("E" + newENumber.ToString()).name != "null"); int random = UnityEngine.Random.Range(1, 5); if (random == 1 && PlayerPrefs.GetInt("E-Block-" + (loc - 1) + "-Moveable") == 1) { GameObject summon = GameObject.Find("E" + newENumber.ToString()); LoadSprite.FindSprite(summon, summonName); PlayerPrefs.SetString("E" + newENumber + "-Name", summonName); summon.GetComponent <ESummon>().SetLoc(loc - 1); } else if (random == 2 && PlayerPrefs.GetInt("E-Block-" + (loc + 4) + "-Moveable") == 1) { GameObject summon = GameObject.Find("E" + newENumber.ToString()); LoadSprite.FindSprite(summon, summonName); PlayerPrefs.SetString("E" + newENumber + "-Name", summonName); summon.GetComponent <ESummon>().SetLoc(loc + 4); } else if (random == 3 && PlayerPrefs.GetInt("E-Block-" + (loc - 4) + "-Moveable") == 1) { GameObject summon = GameObject.Find("E" + newENumber.ToString()); LoadSprite.FindSprite(summon, summonName); PlayerPrefs.SetString("E" + newENumber + "-Name", summonName); summon.GetComponent <ESummon>().SetLoc(loc - 4); } else if (random == 4 && PlayerPrefs.GetInt("E-Block-" + (loc + 1) + "-Moveable") == 1) { GameObject summon = GameObject.Find("E" + newENumber.ToString()); LoadSprite.FindSprite(summon, summonName); PlayerPrefs.SetString("E" + newENumber + "-Name", summonName); summon.GetComponent <ESummon>().SetLoc(loc + 1); } else { } } }
/// <summary> /// 技能面板显示时的初始信息 /// </summary> public override void UpdateShow() { if (M_ShowTask == null) { return; } if (M_ShowTask.M_TaskState == Task.TaskState.Accepted) { AddBtnListener(MyEvent.MyEventType.TaskAbort); m_Btn.transform.Find("Text").GetComponent <Text>().text = "放弃"; transform.GetComponent <Image>().sprite = LoadSprite.LoadSpriteByName("CommonUI/RestaurantAtlas", "RestaurantAtlas_1"); } else if (M_ShowTask.M_TaskState == Task.TaskState.Finished) { m_Btn.enabled = false; m_Btn.transform.Find("Text").GetComponent <Text>().text = "已完成"; transform.GetComponent <Image>().sprite = LoadSprite.LoadSpriteByName("CommonUI/RestaurantAtlas", "RestaurantAtlas_0"); } else if (M_ShowTask.M_TaskState == Task.TaskState.Normal) { AddBtnListener(MyEvent.MyEventType.TaskAccept); m_Btn.transform.Find("Text").GetComponent <Text>().text = "接受"; transform.GetComponent <Image>().sprite = LoadSprite.LoadSpriteByName("CommonUI/RestaurantAtlas", "RestaurantAtlas_3"); } else if (M_ShowTask.M_TaskState == Task.TaskState.Reach) { //TODO AddBtnListener(MyEvent.MyEventType.TaskReach); m_Btn.transform.Find("Text").GetComponent <Text>().text = "完成"; transform.GetComponent <Image>().sprite = LoadSprite.LoadSpriteByName("CommonUI/RestaurantAtlas", "RestaurantAtlas_3"); } //m_TaskInfo.gameObject.SetActive(true); m_TaskTitle.text = M_ShowTask.M_TaskTitle; m_TaskContent.text = M_ShowTask.M_TaskContent; m_AwardEXP.text = M_ShowTask.M_AwardEXP == 0 ? "" : M_ShowTask.M_AwardEXP + ""; m_AwardCoin.text = M_ShowTask.M_AwardCoin + ""; foreach (Transform t in m_AwardItem) { if (t == null) { return; } Destroy(t.gameObject); } //显示奖励物品 for (int i = 0; i < M_ShowTask.M_AwardItemsID.Length; i++) { if (M_ShowTask.M_AwardItemsID[i] == 0) { return; } GameObject go = new GameObject("AwardItem"); go.AddComponent <Image>().sprite = Resources.Load <Sprite>(Inventory.Instance.GetItemByID(M_ShowTask.M_AwardItemsID[i]).m_Sprite); go.transform.SetParent(m_AwardItem); } }
/// <summary> /// 设置技能栏的技能 /// </summary> /// <param name="skill"></param> public void SetSkill(SkillInfo skill) { //print(skill.M_Icon); if (skill == null) { return; } gameObject.GetComponent <Image>().sprite = LoadSprite.LoadSpriteBySkill(skill); m_skillinfo = skill; }
//used for initial movement void SetLoc() { if (PlayerPrefs.GetString("E2-Name") == "null") { } else { int time = (int)System.DateTime.Now.Ticks; UnityEngine.Random.seed = time; // the seed a number in that range int Loc = 0; PlayerPrefs.SetInt("E-Block-" + PlayerPrefs.GetInt("E2-Loc") + "-Moveable", 1); PlayerPrefs.SetInt("E-Block-0-Moveable", 0); while (Loc == 0) { Loc = UnityEngine.Random.Range(1, 16); if (PlayerPrefs.GetInt("E-Block-" + Loc.ToString() + "-Moveable") == 0) { Loc = 0; } PlayerPrefs.SetInt("E-Block-" + Loc.ToString() + "-Moveable", 0); } PlayerPrefs.SetInt("E2-Loc", Loc); GameObject Vill = GameObject.Find("E2"); string e2Name = PlayerPrefs.GetString("E2-Name"); LoadSprite.FindSprite(Vill, e2Name); GameObject VillHp = GameObject.Find("E2-Hp"); GameObject VillHpBack = GameObject.Find("E2-HpBack"); GameObject VillGuard = GameObject.Find("E2-Guard"); GameObject VillStatus0 = GameObject.Find("E2Status0"); GameObject VillStatus0X = GameObject.Find("E2Status0X"); Vector3 E2LocQuards = GameObject.Find("E-Block-" + Loc.ToString()).transform.position; Vill.transform.position = E2LocQuards + new Vector3(0, +67, -3); SpriteRenderer sprite = Vill.GetComponent <SpriteRenderer>(); int l = Loc + 3; l = l / 4; sprite.sortingLayerName = "Char" + l; VillHp.transform.position = E2LocQuards + new Vector3(-100, -17, 1); VillHp = VillHp.transform.GetChild(0).gameObject; sprite = VillHp.GetComponent <SpriteRenderer>(); sprite.sortingLayerName = "Bar" + l; VillHpBack.transform.position = E2LocQuards + new Vector3(0, -17, 1); sprite = VillHpBack.GetComponent <SpriteRenderer>(); sprite.sortingLayerName = "Back" + l; VillStatus0.transform.position = E2LocQuards + new Vector3(-40, 20, 1); sprite = VillStatus0.GetComponent <SpriteRenderer>(); sprite.sortingLayerName = "Status" + 1; VillStatus0X.transform.position = E2LocQuards + new Vector3(-40, 20, 1); VillGuard.transform.position = E2LocQuards + new Vector3(-100, -17, 1); VillGuard = VillGuard.transform.GetChild(0).gameObject; sprite = VillGuard.GetComponent <SpriteRenderer>(); sprite.sortingLayerName = "Guard" + l; } }