public WeaponAction(int id, WeaponConfig weaponConfig, Entity targetEntity, Vector3 targetPosition) { ID = id; WeaponConfig = weaponConfig; TargetEntity = targetEntity; TargetPosition = targetPosition; }
void LoadLootWeapon(XmlReader reader, WeaponConfig weaponConf) { LootConfig lootConf = new LootConfig(); if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { if (reader.Name == "giveAtWave") { lootConf.giveAtWave = int.Parse(reader.Value); } else if (reader.Name == "fromWave") { lootConf.fromWave = int.Parse(reader.Value); } else if (reader.Name == "toWave") { lootConf.toWave = int.Parse(reader.Value); } else if (reader.Name == "lootRate") { lootConf.rate = float.Parse(reader.Value); } else if (reader.Name == "increaseRate") { lootConf.increaseRate = float.Parse(reader.Value); } } } weaponConf.lootConf = lootConf; }
public void RestoreState(object state) { string weaponName = (string)state; WeaponConfig weapon = Resources.Load <WeaponConfig>(weaponName); EquipWeapon(weapon); }
private void SaveScriptableObject(out WeaponConfig newConfig) { newConfig = CreateInstance <WeaponConfig>(); newConfig.Name = _weaponName; newConfig.QualityLevel = _weaponQualityLevel; newConfig.Damage = _weaponDamage; newConfig.Recoil = _weaponRecoil; newConfig.Mesh = _weaponMesh; newConfig.Material = _weaponMaterial; if (!Directory.Exists(_soPath)) { Debug.LogError("SO Path does not exist!"); newConfig = null; return; } string assetPathAndName = _soPath + "/" + _weaponName + ".asset"; AssetDatabase.CreateAsset(newConfig, assetPathAndName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
private void Start() { timeSinceLastAttack = 0; WeaponConfig wp = Resources.Load <WeaponConfig>(defaultWeaponName); EquipWeapon(wp); }
public void EquipWeapon(WeaponConfig wp) { currentWeapon = wp; Animator anim = GetComponent <Animator>(); wp.Spawn(rightHand, leftHand, anim); }
public override void OnTriggerEnter2D(Collider2D collision) { base.OnTriggerEnter2D(collision); if (collision.CompareTag("Enemy")) { Debug.Log(photonView.Owner.ActorNumber); // ActorModel.Model.SetEngery(ActorModel.Model.GetCurrentWeapon().回复能量); if (photonView.Owner.ActorNumber == collision.GetComponent <NetkActorController>().photonView.Owner.ActorNumber) { return; } if (attack_type == HitType.击飞) { Camera.main.GetComponent <Cinemachine.CinemachineImpulseSource>().GenerateImpulse(); } bool isCrit = false; var weapon = WeaponConfig.Get(model.GetPlayerEquipment(EquipmentType.武器)); var hurt_value = model.GetPlayerAttribute(PlayerAttribute.攻击力); if (Random.value <= model.GetPlayerAttribute(PlayerAttribute.暴击率) * 0.01f) { isCrit = true; hurt_value = model.GetPlayerAttribute(PlayerAttribute.暴击伤害); } collision.GetComponent <NetkActorController>().GetHurt(new AttackData(hurt_value, isCrit, transform.position, this.attack_type)); } }
public InventoryItem(WeaponConfig weaponConfig, int ammoCount, bool unlimitedAmmo, int selectOrder) { this.weaponConfig = weaponConfig; ammo = ammoCount; this.unlimitedAmmo = unlimitedAmmo; this.selectOrder = selectOrder; }
public bool Use(int index, GameObject user) { //Checks we have an item in this slot if (_dockedItems.ContainsKey(index)) { //If the item is an action item ActionItem action = _dockedItems[index].item as ActionItem; if (action) { action.Use(user, index); if (action.IsConsumable) { RemoveItems(index, 1); } return(true); } //if the item is an armor item ArmorConfig armor = _dockedItems[index].item as ArmorConfig; if (armor) { armor.Use(gameObject, index); RemoveItems(index, 1); } //if the item is a weapon WeaponConfig weapon = _dockedItems[index].item as WeaponConfig; if (weapon) { weapon.Use(gameObject, index); } } return(false); }
//restoura estado public void RestoreState(object state) { string wN = (string)state; WeaponConfig w = Resources.Load <WeaponConfig>(wN); EquipWeapon(w); }
public WeaponConfig GetRandomWC() { Adj = (TextAsset)Resources.Load("Adj"); Noun = (TextAsset)Resources.Load("Noun"); WC = ScriptableObject.CreateInstance <WeaponConfig>(); WC.Name = GetRandomName(); WC.Damage = Mathf.Round(Random.Range(2f, 10f) * 10f) / 10f; WC.Accuracy = Mathf.Round(Random.Range(96f, 100f) * 10f) / 10f; WC.RPM = Mathf.Round(Random.Range(600f, 1500f) / 10f) * 10f; WC.MagSize = Random.Range(8, 61); WC.Velocity = 100f; WC.Range = 100f; WC.RecoilAmount = 1f; WC.Force = 100f; WC.ReloadTime = 2f; WC.Bullets = 1; WC.Automatic = (Random.value > 0.5f); WC.Value = CalculateValue(); return(WC); }
public WeaponAllConfigs(WeaponConfig weaponConfig) { InitWeaponAllConfig = weaponConfig; InitAbstractBehavior = weaponConfig.WeaponBehavior; S_DefualtBehavior = weaponConfig.WeaponBehavior as DefaultWeaponBehaviorConfig; if (null != S_DefualtBehavior) { InitAbstractLogicConfig = S_DefualtBehavior.FireLogic; S_DefaultFireLogicCfg = InitAbstractLogicConfig as DefaultFireLogicConfig; if (null != S_DefaultFireLogicCfg) { HasLogicConfig = true; S_CommonFireCfg = S_DefaultFireLogicCfg.Basic; S_RifleFireCounterCfg = S_DefaultFireLogicCfg.FireCounter as RifleFireCounterConfig; S_BulletCfg = S_DefaultFireLogicCfg.Bullet; ProcessAccuracy(S_DefaultFireLogicCfg); ProcessShake(S_DefaultFireLogicCfg); ProcessSpread(S_DefaultFireLogicCfg); ProcessFireMode(S_DefaultFireLogicCfg); } return; // detailDefaultWeaponLogicConfig = new ExpandWeaponLogicConfig(OriginWeaponLogicConfig); } S_TacticBehvior = weaponConfig.WeaponBehavior as TacticWeaponBehaviorConfig; if (S_TacticBehvior == null) { S_DoubleBehavior = weaponConfig.WeaponBehavior as DoubleWeaponBehaviorConfig; } }
//public void CallAttackRPGTarget(GameObject _target) //{ // bIsMeleeingEnemy = true; // if (AttackRPGTarget != null) AttackRPGTarget(_target); //} //public void CallStopAttackingRPGTarget() //{ // bIsMeleeingEnemy = false; // if (StopAttackingRPGTarget != null) StopAttackingRPGTarget(); //} public void CallPutRPGWeaponInHand(WeaponConfig _weapon) { if (PutRPGWeaponInHand != null) { PutRPGWeaponInHand(_weapon); } }
private void Awake() { //inicializa variaveis mov = GetComponent <Move>(); weaponConfig = weaponD; WeaponC = new LazyValue <Weapon>(SetupDefault); }
public static Image GetWeaponImage(int id, int width, int height) { WeaponConfig weaponConfig = ConfigData.GetWeaponConfig(id); string fname = string.Format("Weapon/{0}{1}x{2}", weaponConfig.Icon, width, height); if (!ImageManager.HasImage(fname)) { Image image = PicLoader.Read("Weapon", string.Format("{0}.JPG", weaponConfig.Icon)); if (image == null) { NLog.Error(string.Format("GetWeaponImage {0} {1} not found", id, fname)); return(null); } #if DEBUG if (weaponConfig.Remark.Contains("未完成")) { Graphics g = Graphics.FromImage(image); var icon = PicLoader.Read("System", "NotFinish.PNG"); g.DrawImage(icon, 0, 0, 180, 180); g.Save(); } #endif if (image.Width != width || image.Height != height) { image = image.GetThumbnailImage(width, height, null, new IntPtr(0)); } ImageManager.AddImage(fname, image); } return(ImageManager.GetImage(fname)); }
public void Equip(WeaponConfig weaponConfig) { Destroy(spawnedWeapon); this.weaponConfig = weaponConfig; spawnedWeapon = Instantiate(this.weaponConfig.weaponPrefab, attachPoint_Hand_Right.transform); onEquipWeapon.Invoke(this); }
protected Character(CharacterSO other) { // name displayName = other.displayName; // stats attributes = other.attributes; elementAttack = other.elementAttack; elementDefense = other.elementDefense; combatStats = other.combatStats; // level and class level = other.level; charClass = other.charClass; // create armor and weapon configs from class rules mWeaponConfig = charClass.CreateWeaponConfig(); mArmorConfig = charClass.CreateArmorConfig(); for (int i=0; i < other.weapons.Length; i++) { mWeaponConfig.EquipWeapon(other.weapons[i], i); } // TODO, this should be tightly coupled with SO implementation // for (int i=0; i < other.weapons.Length; i++) { // mArmorConfig.EquipArmor(other.armors[i], i); // } curHP = maxHP; }
public void testFireDelay() { WeaponConfig config = new WeaponConfig(); config.projectilePrefab = RuntimeTestHelpers.CreatePrefabWithComponent<ProjectileBehaviour>(); config.fireInterval = 1f; config.sprayAngle = 0f; Weapon weapon = new Weapon(config); // can fire immediately Assert.IsTrue(weapon.CanFire, "Weapon cannot fire upon creation"); // fire weapon Assert.IsTrue(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon didn't fire"); // can't re-fire immediately Assert.IsFalse(weapon.CanFire, "Weapon can fire without any delay"); Assert.IsFalse(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon fired without any delay"); // wait part of delay time weapon.UpdateTimer(0.25f); // can't re-fire after partial delay Assert.IsFalse(weapon.CanFire, "Weapon can fire without full delay"); Assert.IsFalse(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon fired without full delay"); // wait rest of delay time weapon.UpdateTimer(0.75f); // weapon fires again after rest of delay Assert.IsTrue(weapon.CanFire, "Weapon cannot fire after delay"); Assert.IsTrue(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon didn't fire after delay"); }
public void testFireDelay() { WeaponConfig config = new WeaponConfig(); config.projectilePrefab = RuntimeTestHelpers.CreatePrefabWithComponent <ProjectileBehaviour>(); config.fireInterval = 1f; config.sprayAngle = 0f; Weapon weapon = new Weapon(config); // can fire immediately Assert.IsTrue(weapon.CanFire, "Weapon cannot fire upon creation"); // fire weapon Assert.IsTrue(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon didn't fire"); // can't re-fire immediately Assert.IsFalse(weapon.CanFire, "Weapon can fire without any delay"); Assert.IsFalse(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon fired without any delay"); // wait part of delay time weapon.UpdateTimer(0.25f); // can't re-fire after partial delay Assert.IsFalse(weapon.CanFire, "Weapon can fire without full delay"); Assert.IsFalse(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon fired without full delay"); // wait rest of delay time weapon.UpdateTimer(0.75f); // weapon fires again after rest of delay Assert.IsTrue(weapon.CanFire, "Weapon cannot fire after delay"); Assert.IsTrue(weapon.FireWeapon(Vector3.zero, Vector3.up, DamageDealer.Default), "Weapon didn't fire after delay"); }
public void LoadPreset(int index) { WeaponConfig preset = configPresets[index]; for (int i = 0; i < colorPalettes.Count; i++) { if (colorPalettes[i].gradient.Equals(preset.colorGradient)) { colorDropdown.value = i; } } trailLengthSlider.value = preset.trailLength; trailWidthSlider.value = preset.trailWidth; projectileCountSlider.value = preset.projectileCount; distanceXField.text = preset.distance.x.ToString(CultureInfo.InvariantCulture); distanceYField.text = preset.distance.y.ToString(CultureInfo.InvariantCulture); angleField.text = preset.angle.ToString(CultureInfo.InvariantCulture); burstSpreadSlider.value = preset.burstSpread; novaToggle.isOn = preset.nova; randomOrderToggle.isOn = preset.randomOrder; speedSlider.value = preset.speed; durationSlider.value = preset.duration; fireRateSlider.value = preset.rateMulti; behaviourDropdown.value = preset.behaviour == WeaponConfig.ProjectileBehaviour.Straight ? 0 : 1; ApplySettings(); }
public override void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Enemy") { ActorModel.Model.SetEngery(ActorModel.Model.GetCurrentWeapon().回复能量); View.CurrentScene.GetView <GameInfoView>().HitCount++; if (attack_type == HitType.击飞) { Camera.main.GetComponent <Cinemachine.CinemachineImpulseSource>().GenerateImpulse(); if (View.CurrentScene is GameScene) { TimeModel.SetTimeScale(0.2f, true, 0.2f); } } bool isCrit = false; var weapon = WeaponConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.武器)); var hurt_value = ActorModel.Model.GetPlayerAttribute(PlayerAttribute.攻击力); if (Random.value <= ActorModel.Model.GetPlayerAttribute(PlayerAttribute.暴击率) * 0.01f) { isCrit = true; hurt_value = ActorModel.Model.GetPlayerAttribute(PlayerAttribute.暴击伤害); } collision.gameObject.GetComponent <IHurt>().GetHurt( new AttackData(hurt_value, isCrit, ActorController.Controller.transform.position, attack_type) ); } }
public void Equip() { if (!CurretnSelect.icon.gameObject.activeSelf) { return; } switch (CurretnSelect.data.itemtype) { case ItemType.武器: var config = WeaponConfig.Get(CurretnSelect.data.config_id); if (config.需要等级 > ActorModel.Model.GetLevel()) { View.CurrentScene.OpenView <TipView>().SetContent("等级不够 需要等级: " + DreamerTool.Util.DreamerUtil.GetColorRichText(config.需要等级.ToString(), Color.red)); return; } Equip(config, WeaponConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.武器)), EquipmentType.武器); break; case ItemType.肩膀: var arm_config = ArmConfig.Get(CurretnSelect.data.config_id); Equip(arm_config, ArmConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.肩膀左)), EquipmentType.肩膀左); break; case ItemType.衣: var torso_config = TorsoConfig.Get(CurretnSelect.data.config_id); Equip(torso_config, TorsoConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.衣)), EquipmentType.衣); break; case ItemType.手链: var sleeve_config = SleeveConfig.Get(CurretnSelect.data.config_id); Equip(sleeve_config, SleeveConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.手链)), EquipmentType.手链); break; case ItemType.裤子: var pelvis_config = PelvisConfig.Get(CurretnSelect.data.config_id); Equip(pelvis_config, PelvisConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.裤子)), EquipmentType.裤子); break; case ItemType.鞋子: var foot_config = FootConfig.Get(CurretnSelect.data.config_id); Equip(foot_config, FootConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.鞋子)), EquipmentType.鞋子); break; case ItemType.消耗品: GameStaticMethod.ExecuteCommond(ConsumablesConfig.Get(CurretnSelect.data.config_id).function); ActorModel.Model.bag_items.Remove(CurretnSelect.data); CurretnSelect.icon.gameObject.SetActive(false); ItemUITip.gameObject.SetActive(false); break; case ItemType.盾牌: var shield_config = ShieldConfig.Get(CurretnSelect.data.config_id); Equip(shield_config, ShieldConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.盾牌)), EquipmentType.盾牌); break; default: break; } }
public void ShowWeapon(EWeaponId pWeapon) { currentWeaponConfig = brainiacs.ItemManager.GetWeaponConfig(pWeapon); weaponUp.sprite = currentWeaponConfig.VisualInfo.PlayerSpriteUp; weaponRight.sprite = currentWeaponConfig.VisualInfo.PlayerSpriteRight; weaponDown.sprite = currentWeaponConfig.VisualInfo.playerSpriteDown; weaponLeft.sprite = currentWeaponConfig.VisualInfo.PlayerSpriteLeft; }
public WeaponState(WeaponConfig config) { name = config.id; cooldown = config.coolDownSeconds; elapsedSinceLastShot = float.MaxValue; currentDispersionDegrees = config.dispersionDegrees; defaultDispersionDegrees = config.dispersionDegrees; }
public void testConfigValidationNoPrefab() { WeaponConfig config = new WeaponConfig(); config.projectilePrefab = null; config.fireInterval = 1f; config.sprayAngle = 1f; Assert.IsFalse(config.Validate(), "Valid despite null projectile"); }
public void testConfigValidationBadSprayAngle() { WeaponConfig config = new WeaponConfig(); config.projectilePrefab = RuntimeTestHelpers.CreatePrefabWithComponent<ProjectileBehaviour>(); config.fireInterval = 1f; config.sprayAngle = -1f; Assert.IsFalse(config.Validate(), "Valid despite negative spray angle"); }
public override void Initiate(WeaponConfig weaponConfig, GameObject shooter, Movement movementScript)//, // bool enableRenderer = true, bool undying = false) { // base.undying = undying; base.velocity = weaponConfig.velocity; base.shooterTag = shooter.tag; base.targetPosition = movementScript.fireTarget; }
/// <summary> /// Fires a projectile after a set delay, used for burst spread /// </summary> /// <param name="weapon">Weapon config</param> /// <param name="pos">Projectile starting position</param> /// <param name="angle">Projectile starting angle</param> /// <param name="delay">Delay in seconds</param> /// <returns>Coroutine delay enumerator</returns> private IEnumerator InitProjectileDelayed(WeaponConfig weapon, Vector3 pos, float angle, float delay) { yield return(new WaitForSeconds(delay)); Projectile projectile = projectileManager.Get(); projectile.Init(weapon, gameObject, transform.position + pos, angle); }
private void CharacterPickupWeapon(Character character, WeaponConfig weaponConfig) { if (!character.photonView.IsMine) { return; } character.CharacterModel.PickupWeapon(weaponConfig); }
public void ReleaseWeapon(WeaponBase obj) { WeaponConfig cfg = Config.WeaponCfg[obj.ID - 1]; obj.OnDetach(); obj.OnUninit(); ReleasePrefab(cfg.prefab, obj.gameObject); }
public void Init(InventoryItem item) { transform.SetParent(GameManager.main.WorldParent); gameConfig = ConfigManager.main.GetConfig("GameConfig") as GameConfig; config = item.WeaponConfig; item.Weapon = this; this.item = item; }
public void Initialise(WeaponConfig weaponConfig) { _id = int.Parse($"{DateTime.Now.Hour}{DateTime.Now.Minute}{DateTime.Now.Second}{DateTime.Now.Millisecond}"); _weaponConfig = weaponConfig; _pointReticleObject = Instantiate(_pointReticlePrefab, Vector3.up * 1000, Quaternion.identity); _entityReticleObject = Instantiate(_entityReticlePrefab, Vector3.up * 1000, Quaternion.identity); }
public virtual void OnInit() { m_Config = Config.WeaponCfg[ID - 1]; HasShell = m_Config.shell > 0; if (HasShell) { m_Shells = new List <ShellBase>(); } }
public void EquipWeapon(GameObject updateWeapon) { weapon = updateWeapon; currentWeaponConfig = updateWeapon.GetComponent <WeaponConfig>(); if (audioSource) { audioSource.clip = currentWeaponConfig.audioClip; } }
public void testSprayAngle() { WeaponConfig config = new WeaponConfig(); config.projectilePrefab = RuntimeTestHelpers.CreatePrefabWithComponent<ProjectileBehaviour>(); config.fireInterval = 1f; config.sprayAngle = 10f; Weapon weapon = new Weapon(config); // randomly test 10,000 random angles // not deterministic, but also difficult to test deterministically without deeper understanding of Quaternion implementation for (int i = 0; i < 10000; i++) { testAngle(Random.onUnitSphere, Random.Range(1f, 90f)); } }
public Weapon(int id) { WeaponConfig = ConfigData.GetWeaponConfig(id); Dura = (int)(WeaponConfig.Dura*1.67); Range = WeaponConfig.Range; Def = WeaponConfig.Def; Spd = WeaponConfig.Spd; Mag = WeaponConfig.Mag; Luk = WeaponConfig.Luk; Hit = WeaponConfig.Hit; Dhit = WeaponConfig.Dhit; Crt = WeaponConfig.Crt; Mov = WeaponConfig.Mov; UpgradeToLevel1(); }
public Weapon(WeaponConfig config) { this.config = config; fireIntervalRemaining = 0f; }