public void Remove(RandomWeapon wp) { items.Remove(wp); if (OnItemChangedCallback != null) { OnItemChangedCallback.Invoke(); } }
public static void EndMyClientsBind() { GM.ENDMODZ(); VSAT.ENDMODZ(); Speed.ENDMODZ(); NightVision.ENDMODZ(); RandomWeapon.ENDMODZ(); RandomCamo.ENDMODZ(); }
private void Start() { bat = GameObject.Find("bat"); baton = GameObject.Find("baton"); sign = GameObject.Find("sign"); axe = GameObject.Find("axe"); inventory = Inventory.instance; currentWeapon = null; bat.SetActive(false); baton.SetActive(false); axe.SetActive(false); sign.SetActive(false); }
public bool Add(RandomWeapon item) { if (items.Count >= space) { Debug.Log("Not enough room."); return(false); } items.Add(item); if (OnItemChangedCallback != null) { OnItemChangedCallback.Invoke(); } return(true); }
public void Unequip() { if (currentWeapon != null) { RandomWeapon oldItem = currentWeapon; inventory.Add(oldItem); // trigger changes for stats etc if (onEquipmentChanged != null) { onEquipmentChanged.Invoke(null, oldItem); } currentWeapon = null; ShowWeapon(Type.None); } }
public void Equip(RandomWeapon newItem) { RandomWeapon oldItem = null; if (currentWeapon != null) { oldItem = currentWeapon; inventory.Add(oldItem); } // trigger changes for stats etc if (onEquipmentChanged != null) { onEquipmentChanged.Invoke(newItem, oldItem); } currentWeapon = newItem; ShowWeapon(currentWeapon.type); }
void OnEquipmentChanged(RandomWeapon newItem, RandomWeapon oldItem) { if (newItem != null) { minDamage.AddModifier(newItem.minDmg); maxDamage.AddModifier(newItem.maxDmg); strengh.AddModifier(newItem.strModifier); agility.AddModifier(newItem.agiModifier); constitution.AddModifier(newItem.constiModifier); attackSpeed += newItem.attackSpeed; } if (oldItem != null) { minDamage.RemoveModifier(oldItem.minDmg); maxDamage.RemoveModifier(oldItem.maxDmg); strengh.RemoveModifier(oldItem.strModifier); agility.RemoveModifier(oldItem.agiModifier); constitution.RemoveModifier(oldItem.constiModifier); attackSpeed -= oldItem.attackSpeed; } }
public GameObject generateRandomWeapon() { // select a base int randi; float die; do { randi = Random.Range(0, randomWeapons.Count); die = Random.Range(0f, 1f); } while (die < randomWeapons[randi].rarity); reroll(ref randi, ref die, randomWeapons); // instantiate the selected prefab RandomWeapon choice = randomWeapons[randi]; GameObject wapon = Instantiate(choice.prefab); // the child is probably disabled, so pass true to search inactive WeaponStats stats = wapon.GetComponentInChildren <WeaponStats>(true); // randomize stuff // pick projectile configuration reroll(ref randi, ref die, choice.projectileConfigurations); ProjectileCombination combo = choice.projectileConfigurations[randi]; // update weaponstats stats.bulletPrefab = combo.bulletPrefab; stats.action = combo.firearmAction; stats.projectileType = combo.projectileType; stats.showCrosshair = combo.showCrosshair; float valueModifier = 1; // randomize stats // --- Strength --- float strMod = getStrengthModifier(); stats.strength = randomizeAndClamp(combo.strengthRange, strMod); float modifiedStrDev = strMod * combo.strengthRange.w * 0.5f; float diff = stats.strength - (combo.strengthRange.z * strMod); if (diff > modifiedStrDev) // unusually strong { stats.weaponName = getRandomString(choice.strongNames); } else if (diff < -modifiedStrDev) // unusually weak { stats.weaponName = getRandomString(choice.weakNames); } else { stats.weaponName = getRandomString(choice.boringNames); } valueModifier *= stats.strength / combo.strengthRange.z; // --- Accuracy --- stats.deviation = randomizeAndClamp(combo.accuracyRange); diff = stats.deviation - combo.accuracyRange.z; if (diff > combo.accuracyRange.w) // unusually high jitter { stats.suffix = getRandomString(choice.inaccurateSuffixes); } else if (diff < -combo.accuracyRange.w) // unusually low jitter { stats.suffix = getRandomString(choice.accurateSuffixes); } // Deviation should affect the price less. valueModifier *= Mathf.Clamp(combo.accuracyRange.z / ((stats.deviation + 1) * 5f), 0.1f, Mathf.Log(Mathf.Pow(StateManager.timesEntered, 2) + 20)); // --- Speed --- stats.fireDelay = randomizeAndClamp(combo.fireDelayRange); diff = stats.fireDelay - combo.fireDelayRange.z; if (diff > combo.fireDelayRange.w) // unusually high speed { stats.prefix = getRandomString(choice.highFireRatePrefixes); } else if (diff < -combo.accuracyRange.w) // unusually low speed { stats.prefix = getRandomString(choice.lowFireRatePrefixes); } if (stats.fireDelay >= 0.1f) // clear out looping clip { stats.gunAudioSource.clip = null; } valueModifier *= Mathf.Clamp(combo.fireDelayRange.z / (stats.fireDelay + 0.05f), 0.1f, Mathf.Log(Mathf.Pow(StateManager.timesEntered, 2) + 20)); stats.bulletCost = getBulletCost(stats.strength); // pricing: // auto - increase // homing - increase // so think of semiauto bullet as baseline if (stats.action == FirearmAction.Automatic) { valueModifier *= 2f; } if (stats.projectileType == ProjectileType.HomingMissile) { valueModifier *= 1.5f; } wapon.name = stats.fullName; valueModifier *= (float)System.Math.Log(StateManager.timesEntered + 2) ; float originalPrice = stats.price; stats.price *= (float)System.Math.Round(valueModifier, 2); stats.price += originalPrice; Debug.Log($"{stats}\nGenerated with value mod of {valueModifier}"); return(wapon); }
public void ClearSlot() { item = null; icon.sprite = null; icon.enabled = false; }
public void AddItem(RandomWeapon newItem) { item = newItem; icon.sprite = item.icon; icon.enabled = true; }
void Start() { loot = Resources.Load <RandomWeapon>("Loot"); // loot = GameObject.Find("DONOTREMOVE"); }