public static int CalculateLocalPrice(int basePrice, IWIBase item) { if (item == null) { Debug.Log("Local price in container null, returning"); return(basePrice); } if (item.IsWorldItem) { basePrice *= Mats.MatTypeToInt(item.worlditem.Props.Global.MaterialType); } else { basePrice *= Mats.MatTypeToInt(item.GetStackItem(WIMode.None).GlobalProps.MaterialType); } if (item.IsStackContainer) { for (int i = 0; i < item.StackContainer.StackList.Count; i++) { for (int j = 0; j < item.StackContainer.StackList[i].Items.Count; j++) { basePrice += Mathf.CeilToInt(item.StackContainer.StackList[i].Items[j].BaseCurrencyValue); } } } return(basePrice); }
// Update is called once per frame void Update() { lazer.enabled = false; Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 direction = new Vector2( mousePosition.x - transform.position.x, mousePosition.y - transform.position.y ); transform.up = -direction; if (Input.GetAxisRaw("Fire1") > 0) { lazer.enabled = true; lazer.SetPosition(0, shootingPoint.position); lazer.SetPosition(1, mousePosition); // Debug.DrawRay(shootingPoint.position, direction); RaycastHit2D fire = Physics2D.Raycast(shootingPoint.position, direction, 6f, shootable); if (fire) { Mats mat = fire.transform.GetComponent <Mats>(); if (mat != null) { mat.takeDamage(Damage, direction); } } } }
public void AddFrom(MfModelDicts dict) { foreach (var c in dict.Cates) { if (!Cates.ContainsKey(c.Key)) { Cates.Add(c.Key, c.Value); } } foreach (var c in dict.Elems) { if (!Elems.ContainsKey(c.Key)) { Elems.Add(c.Key, c.Value); } } foreach (var c in dict.Fams) { if (!Fams.ContainsKey(c.Key)) { Fams.Add(c.Key, c.Value); } } foreach (var c in dict.Floors) { if (!Floors.ContainsKey(c.Key)) { Floors.Add(c.Key, c.Value); } } foreach (var c in dict.Mats) { if (!Mats.ContainsKey(c.Key)) { Mats.Add(c.Key, c.Value); } } foreach (var c in dict.Types) { if (!Types.ContainsKey(c.Key)) { Types.Add(c.Key, c.Value); } } foreach (var c in dict.Views) { if (!Views.ContainsKey(c.Key)) { Views.Add(c.Key, c.Value); } } }
void UpdateEquip(Text t, int itemId) { if (itemId > 0) { Mats mat = new Mats(); mat = LoadTxt.MatDic[(int)(itemId / 10000)]; t.text = mat.name; t.color = GameConfigs.MatColor[mat.quality]; } else { t.text = ""; } }
void SetMakingTipDesc(Mats m) { makingTipText[1].text = m.description; makingTipText [1].color = new Color(24f / 255f, 193f / 255f, 172f / 255f, 1f); makingTipText[2].text = "Property:"; makingTipText [2].color = new Color(24f / 255f, 193f / 255f, 172f / 255f, 1f); int i = 3; if (m.property != null) { foreach (int key in m.property.Keys) { makingTipText [i].text = PlayerData.GetPropName(key) + " " + (m.property [key] > 0 ? "+" : "") + m.property [key]; i++; makingTipText [i].alignment = TextAnchor.MiddleCenter; } } else { makingTipText [i].text = "Can not use directly."; makingTipText [i].alignment = TextAnchor.MiddleCenter; i++; } makingTipText [i].text = "Requirement:"; makingTipText [i].color = new Color(24f / 255f, 193f / 255f, 172f / 255f, 1f); makingTipText [i].alignment = TextAnchor.MiddleLeft; i++; foreach (int key in m.combReq.Keys) { if (_gameData.CountInHome(key) < m.combReq [key]) { makingTipText [i].text = LoadTxt.MatDic [key].name + " × " + m.combReq [key] + " /" + _gameData.CountInHome(key); makingTipText [i].color = Color.red; makingTipText [i].alignment = TextAnchor.MiddleCenter; } else { makingTipText [i].text = LoadTxt.MatDic [key].name + " × " + m.combReq [key] + " /" + _gameData.CountInHome(key); makingTipText [i].color = Color.green; makingTipText [i].alignment = TextAnchor.MiddleCenter; } i++; } float discount = (m.makingType == "Kitchen") ? GameData._playerData.CookingTimeDiscount : GameData._playerData.BlackSmithTimeDiscount; makingTipText [i].text = "Time: " + GetTime(m.makingTime * discount); makingTipText [i].color = new Color(24f / 255f, 193f / 255f, 172f / 255f, 1f); makingTipText [i].alignment = TextAnchor.MiddleLeft; }
public void DoSacrifice(int index) { ShopItem s = LoadTxt.GetShopItem(GameData._playerData.sacrificeList [index]); Mats m = LoadTxt.MatDic [s.itemId]; int price = s.bundleNum * m.price; if (_gameData.CountInHome(GameConfigs.AltarMarkId / 10000) < price) { return; } _gameData.ConsumeItemInHome(GameConfigs.AltarMarkId / 10000, price); _gameData.AddItem(m.id * 10000, s.bundleNum); _floating.CallInFloating(m.name + " +" + s.bundleNum, 0); UpdateSacrifice(); }
void LoadMats() { string[][] strs = ReadTxt.ReadText("mats"); mats = new Mats[strs.Length - 1]; for (int i = 0; i < mats.Length; i++) { mats [i] = new Mats(); mats [i].id = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 0)); mats [i].type = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 1)); mats [i].name = ReadTxt.GetDataByRowAndCol(strs, i + 1, 2); mats [i].desc = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 3)); mats [i].price = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 4)); string[][] prop = ReadTxt.GetRequire(ReadTxt.GetDataByRowAndCol(strs, i + 1, 5)); if (prop != null) { mats[i].property = new Dictionary <int, float>(); for (int j = 0; j < prop.Length; j++) { mats [i].property.Add(int.Parse(prop[j][0]), float.Parse(prop[j][1])); } } string[][] req = ReadTxt.GetRequire(ReadTxt.GetDataByRowAndCol(strs, i + 1, 6)); if (req != null) { mats [i].combGet = int.Parse(req [0] [0]); mats[i].combReq = new Dictionary <int, int>(); for (int j = 1; j < req.Length; j++) { mats [i].combReq.Add(int.Parse(req [j] [0]), int.Parse(req [j] [1])); } } mats [i].needBlueprint = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 7)); mats [i].makingType = ReadTxt.GetDataByRowAndCol(strs, i + 1, 8); mats [i].makingTime = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 9)); mats [i].castSpirit = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 10)); mats [i].tags = ReadTxt.GetDataByRowAndCol(strs, i + 1, 11); mats [i].skillId = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 12)); mats [i].quality = int.Parse(ReadTxt.GetDataByRowAndCol(strs, i + 1, 13)); mats [i].description = ReadTxt.GetDataByRowAndCol(strs, i + 1, 14); MatDic.Add(mats [i].id, mats [i]); } }
void UseItem(int itemId) { if (!GameData._playerData.bp.ContainsKey(itemId)) { return; } int id = (int)(itemId / 10000); Mats m = LoadTxt.MatDic [id]; switch (m.type) { case 0: _floating.CallInFloating("Can not use directly!", 1); break; case 2: _gameData.EatFood(itemId); if (!GameData._playerData.bp.ContainsKey(itemId)) { OnNormalTipCover(); } _backpackActions.UpdataPanel(); break; case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: _gameData.ChangeEquip(itemId); OnNormalTipCover(); _backpackActions.UpdataPanel(); break; default: break; } }
public void UpdateSacrifice() { for (int i = 0; i < Items.Length; i++) { Text[] ts = Items [i].GetComponentsInChildren <Text> (); Button b = Items [i].GetComponentInChildren <Button> (); ShopItem s = LoadTxt.GetShopItem(GameData._playerData.sacrificeList [i]); Mats m = LoadTxt.MatDic [s.itemId]; int price = s.bundleNum * m.price; ts [0].text = m.name + "×" + s.bundleNum; ts [0].color = GameConfigs.MatColor [m.quality]; ts [1].text = m.description; int j = 2; if (m.property != null) { foreach (int key in m.property.Keys) { ts [j].text = PlayerData.GetPropName(key) + " " + (m.property [key] > 0 ? "+" : "-") + m.property [key]; ts [j].color = Color.white; j++; } } else { ts [j].text = "Can not use directly."; ts [j].color = Color.white; j++; } ts [4].text = "Pray(" + price + ")"; bool isEnough = _gameData.CountInHome(GameConfigs.AltarMarkId / 10000) >= price; b.interactable = isEnough; ts [4].color = isEnough ? Color.green : Color.gray; } }
static public Material GetMaterialQueue(Material mat, int renderQueue) { if (mat == null) { return(null); } if (mat.renderQueue == renderQueue) { return(mat); } List <Material> Mats = null; if (sMaterialList.TryGetValue(mat, out Mats)) { if (Mats != null) { foreach (Material m in Mats) { if ((m != null) && (m.renderQueue == renderQueue)) { return(m); } } } else { Mats = new List <Material>(); sMaterialList[mat] = Mats; } } else { Mats = new List <Material>(); sMaterialList.Add(mat, Mats); } Material copy_mat = new Material(mat); copy_mat.name = mat.name + renderQueue; #if UNITY_EDITOR if (!Application.isPlaying) { string path = UnityEditor.AssetDatabase.GetAssetPath(mat); if (string.IsNullOrEmpty(path)) { copy_mat.name = mat.name; } else { string guid = UnityEditor.AssetDatabase.AssetPathToGUID(path); if (!string.IsNullOrEmpty(guid)) { copy_mat.name = guid; } else { copy_mat.name = mat.name; } } } #endif copy_mat.renderQueue = renderQueue; Mats.Add(copy_mat); return(copy_mat); }
/// <summary> /// Shows item tips. /// </summary> /// <param name="itemId">type:0 warehouseCell;1 bpCell in warehouse;2 bpCell in Backpack;3 character Cell;4 character Ammo</param> public void ShowNormalTips(int itemId, int type) { ShowTipPanel(); ClearCommonTipTexts(); int orgId = (int)(itemId / 10000); int ex = (int)((itemId % 10000) / 1000); Mats m = LoadTxt.MatDic [orgId]; string itemName = m.name; if (itemId % 10000 != 0) { if (LoadTxt.MatDic [orgId].type == 3) { itemName += "[" + LoadTxt.GetExtraMelee(ex).name + "]"; } if (LoadTxt.MatDic [orgId].type == 4) { itemName += "[" + LoadTxt.GetExtraRanged(ex).name + "]"; } } commonTipText [0].text = itemName + ((type == 4) ? (" ×" + GameData._playerData.AmmoNum) : ""); commonTipText [0].color = GameConfigs.MatColor [m.quality]; commonTipText[1].text = m.description; commonTipText[1].color = new Color(24f / 255f, 193f / 255f, 172f / 255f, 1f); int i = 4; if (m.property != null) { foreach (int key in m.property.Keys) { commonTipText [i].text = PlayerData.GetPropName(key) + " " + (m.property [key] > 0 ? "+" : "-") + m.property [key]; commonTipText [i].color = Color.white; i++; } } else { commonTipText[i].text = "Can not use directly."; commonTipText [i].color = Color.white; i++; } //附加属性 string de = ""; float p; if (itemId % 10000 != 0) { if (LoadTxt.MatDic [orgId].type == 3) { Extra_Weapon extraM = LoadTxt.GetExtraMelee(ex); foreach (int key in extraM.property.Keys) { de = PlayerData.GetPropName(key) + " "; p = extraM.property [key]; de += (p > 0 ? "+" : ""); if (key < 25) { de += p.ToString(); } else { de += ((int)(p * 100f)).ToString() + "%"; } commonTipText [i].text = de; if (p > 0) { commonTipText [i].color = Color.green; } else { commonTipText [i].color = Color.red; } i++; } } if (LoadTxt.MatDic [orgId].type == 4) { Extra_Weapon extraR = LoadTxt.GetExtraRanged(ex); foreach (int key in extraR.property.Keys) { de = PlayerData.GetPropName(key) + " "; p = extraR.property [key]; de += (p > 0 ? "+" : "-"); if (key < 25) { de += p.ToString(); } else { de += ((int)(p * 100f)).ToString() + "%"; } commonTipText [i].text = de; if (p > 0) { commonTipText [i].color = Color.green; } else { commonTipText [i].color = Color.red; } i++; } } } commonTipButton [0].gameObject.GetComponentInChildren <Text> ().text = "Pray"; commonTipButton [1].gameObject.SetActive(true); commonTipButton[2].gameObject.GetComponentInChildren <Text>().text = "Cancel"; commonTipButton [2].gameObject.SetActive(true); switch (type) { case 0: commonTipButton[0].gameObject.SetActive(true); commonTipButton[0].gameObject.name = "warehouse_warehouse|" + itemId; commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "Withdraw"; commonTipButton[1].interactable = true; break; case 1: commonTipButton[0].gameObject.SetActive(true); commonTipButton[0].gameObject.name = "warehouse_backpack|" + itemId; commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "Store"; commonTipButton[1].interactable = true; break; case 2: commonTipButton[0].gameObject.SetActive(true); commonTipButton[0].gameObject.name = "backpack_backpack|" + itemId; commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "Use"; bool canUse = !(m.property == null); commonTipButton[1].interactable = canUse; break; case 3: case 4: commonTipButton[0].gameObject.SetActive(false); commonTipButton[1].gameObject.GetComponentInChildren <Text>().text = "TakeOff"; commonTipButton[1].interactable = true; break; default: break; } commonTipButton [1].gameObject.name = itemId.ToString(); }
public void Respawn() { Debug.Log("Respawn()"); Transform t = null; if /***/ (!net.CurrMatch.teamBased) { t = getRandomSpawn("FFA"); } else if (User.team == 1) { t = getRandomSpawn("TeamRed"); } else if (User.team == 2) { t = getRandomSpawn("TeamBlue"); } transform.position = t.position + Vector3.up; transform.LookAt(transform.position + Vector3.forward, Vector3.up); camAngle = t.eulerAngles; moveVec = Vector3.zero; bod.yMove = 0f; bod.sprinting = false; // make blocky pink guns invisible if (prevGunInHand == Gun.None) { Debug.Log("make blocky pink guns invisible "); MeshInHand.GetComponent <Renderer>().material = Mats.Get("InvisibleShadow"); MeshInHand.GetComponent <Renderer>().enabled = false; MeshOnBack.GetComponent <Renderer>().material = Mats.Get("InvisibleShadow"); MeshOnBack.GetComponent <Renderer>().enabled = false; for (int i = 0; i < gameObject.transform.childCount; i++) { var tr = gameObject.transform.GetChild(i); Debug.Log("---------> tr.name: " + tr.name); var mrs = tr.GetComponentsInChildren <MeshRenderer>(); for (int j = 0; j < mrs.Length; j++) { Debug.Log("---------> mrs[j].name: " + mrs[j].name); mrs[j].enabled = false; mrs[j].material = Mats.Get("InvisibleShadow"); } } } // assign spawn guns GunInHand = net.CurrMatch.spawnGunA; GunOnBack = net.CurrMatch.spawnGunB; prevGunInHand = Gun.None; prevGunOnBack = Gun.None; arse.Guns[(int)GunInHand].Instance = (GameObject)GameObject.Instantiate(arse.Guns[(int)GunInHand].Prefab); arse.Guns[(int)GunOnBack].Instance = (GameObject)GameObject.Instantiate(arse.Guns[(int)GunOnBack].Prefab); arse.Guns[(int)GunInHand].Renderer = arse.Guns[(int)GunInHand].Instance.GetComponentInChildren <Renderer>(); arse.Guns[(int)GunOnBack].Renderer = arse.Guns[(int)GunOnBack].Instance.GetComponentInChildren <Renderer>(); // clear & setup inventory for (int i = 0; i < arse.Guns.Length; i++) { arse.Guns[i].Cooldown = 0f; if ((Gun)i == GunInHand || (Gun)i == GunOnBack // ||Debug.isDebugBuild) // carry full arsenal if in IDE ) { arse.Guns[i].Carrying = true; } else { arse.Guns[i].Carrying = false; Destroy(arse.Guns[i].Instance); arse.Guns[i].Instance = null; } } }
public void SetModelVisibility(bool visible) { Material[] mats = meshObj.GetComponent <Renderer>().materials; var inv = Mats.Get("InvisibleShadow"); var a = new Material(Mats.Get("ColorA")); var b = new Material(Mats.Get("ColorB")); var c = new Material(Mats.Get("ColorC")); a.color = User.colA; b.color = User.colB; c.color = User.colC; if (net.CurrMatch.teamBased) { if (User.team == 1) { a.color = Color.red; } if (User.team == 2) { a.color = Color.cyan; } } if (!visible) { mats[0] = inv; mats[1] = inv; mats[2] = inv; meshObj.GetComponent <Renderer>().materials = mats; } else { mats[0] = a; mats[1] = b; mats[2] = c; meshObj.GetComponent <Renderer>().materials = mats; } // heads for (int i = 0; i < heads.Length; i++) { if (i != headType) { heads[i].GetComponent <Renderer>().enabled = false; } if (!visible) { heads[i].GetComponent <Renderer>().material = inv; } } if (visible) // OPTME: don't set these regardless? { heads[0].GetComponent <Renderer>().material = a; heads[1].GetComponent <Renderer>().material = Mats.Get("CardboardBox"); heads[2].GetComponent <Renderer>().material = Mats.Get("Fish"); heads[3].GetComponent <Renderer>().material = Mats.Get("Banana"); heads[4].GetComponent <Renderer>().material = Mats.Get("Creeper"); heads[5].GetComponent <Renderer>().material = Mats.Get("Elephant"); heads[6].GetComponent <Renderer>().material = Mats.Get("MoonTM0360"); heads[7].GetComponent <Renderer>().material = Mats.Get("Pyramid"); heads[8].GetComponent <Renderer>().material = Mats.Get("Chocobo"); heads[9].GetComponent <Renderer>().material = Mats.Get("Spike"); } if (User.local && MeshInHand != null && MeshInHand.GetComponent <Renderer>() && GunInHand >= Gun.Pistol ) { if (visible) { MeshInHand.GetComponent <Renderer>().enabled = false; } else { MeshInHand.GetComponent <Renderer>().enabled = true; MeshInHand.GetComponent <Renderer>().material = arse.Guns[(int)GunInHand].Mat; } } if (!net.CurrMatch.pitchBlack || !User.local) { firstPersonLight.enabled = false; } else { firstPersonLight.enabled = true; } if (!User.local && net.CurrMatch.pitchBlack) { if (net.CurrMatch.teamBased && User.team == net.LocEnt.team) { firstPersonLight.enabled = true; if (User.team == 1) { firstPersonLight.color = Color.red; } else { firstPersonLight.color = Color.cyan; } } } }