public Gun(GunData data) { _data = data; _damage = _data.Damage; _reloadTime = _data.ReloadTime; }
public void OnPickupWeapon(PickupWeaponContext context) { bool hasEmptySlot = false; for (int i = 0; i < HeldGuns.Length; i++) { if (HeldGuns[i].Empty) { hasEmptySlot = true; HeldGuns[i].SetData(context.pickup.gunData); if (CurrentGun == i) { GunManager.Current.GetModel(context.pickup.gunData).SetActive(true); } break; } } if (hasEmptySlot) { Destroy(context.pickup.gameObject); } else { GunManager.Current.GetModel(context.pickup.gunData).SetActive(true); GunData swapGun = HeldGuns[CurrentGun].GunData; HeldGuns[CurrentGun].SetData(context.pickup.gunData); context.pickup.gunData = swapGun; GunManager.Current.GetModel(context.pickup.gunData).SetActive(false); } }
public Magazine(GunData data) { _Data = data; _RemainingBullet = new ReactiveProperty <uint> (_Data.ReminingBulletCount); _BulletList = new List <IShootable> (); _ReadOnlyRemaningBullet = _RemainingBullet.ToReadOnlyReactiveProperty(); DefineDebugCommand(); Observable.FromCoroutine <GameObject> (_ => InstantiateBullet(_)) .Subscribe(bullet => { _BulletList.Add(UnityEngine.Object.Instantiate(bullet).GetComponent <IShootable> ()); }); //1フレーム中にデストロイを集中させないためにコルーチンモドキを外部に生成 /*Observable.EveryUpdate () //多分いらない * .SkipUntil (GameManager.Player.OnDestroyAsObservable ()) * .TakeWhile(_ => _BulletList.Count > 0) * .Subscribe (_ => * { * var bullet = _BulletList * .Where (b => !b.IsActive) * .FirstOrDefault (); * if (bullet != null) * { * _BulletList.Remove (bullet); * bullet.Destroy (); * } * }).AddTo();*/ }
public void AddWeapon() { GunData Weapon = new GunData(); Weapon.attackGun = 1; gunDatas.Add(Weapon); }
public void InitCharGunObject(string gunId) { if (charaData.IsDead || string.IsNullOrEmpty(gunId)) { return; } GunData gunData = GunDataTableObject.Instance.GetParams(gunId); _gunObject = ((GameObject)Instantiate((GameObject)Resources.Load("Prefabs/Items/Guns/" + gunData.GunPrefab))).GetComponent <GunObject>(); _gunObject.Owner = gameObject; //ソードを持ってる手のgameObjectを取得 if (weaponPosObj == null) { weaponPosObj = Utils.getChildGameObject(gameObject, "weapon"); } _gunObject.transform.SetParent(weaponPosObj.transform); _gunObject.transform.localPosition = Vector3.zero; //ポジションとレンダーオーダーを整える。 _gunObject.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 90.0f)); _gunObject.GetComponent <SpriteRenderer> ().sortingLayerName = GetSortingLayerName(); _gunObject.GetComponent <SpriteRenderer> ().sortingOrder = 59; _gunObject.CopyParamsFrom(gunId); //gunをdisable _gunObject.DisplaySprite(false); }
public void UpdateCharacterParam() { //プレイヤーのExpPoint表示 UnusedExpPoint.text = "Unused ExpPoint: " + PlayerData.unusedExpPoints; //キャラクタレベル情報 CharLevel.text = "Lv: " + _charData.Level; CharExpPoint.text = "Exp: " + _charData.CurrentExp; CharAtkPoint.text = "Atk: " + _charData.CrntAtk(); CharGunAtkPoint.text = "GUN: Not Equiped"; if (!string.IsNullOrEmpty(_charData.GunID)) { // GunData gunData = GunDataTableObject.Instance.Table.All.FirstOrDefault (tmpData => tmpData.ID == _charData.GunID); GunData gunData = GunDataTableObject.Instance.GetParams(_charData.GunID); CharGunAtkPoint.text = "GUN: x" + gunData.Damage; } CharSwdAtkPoint.text = "SWD: Not Equiped"; if (!string.IsNullOrEmpty(_charData.SwordID)) { SwordData swordData = SwordDataTableObject.Instance.Table.All.FirstOrDefault(tmpData => tmpData.ID == _charData.SwordID); CharSwdAtkPoint.text = "SWD: x" + swordData.Damage; } }
public GunBase(GunData data, GameObject player) { gun = new GunRuntimeData(data); transform = player.transform; box = player.GetComponent <BoxCollider2D>(); }
public override void InitialiseItemData() { base.InitialiseItemData(); if (itemData != null) { GunData gunData = (GunData)itemData; damage = gunData.damage; automatic = gunData.automatic; roundsPerSecond = gunData.roundsPerSecond; fireDelay = 1 / roundsPerSecond; maxMagazineSize = gunData.maxMagazineSize; magazineSize = maxMagazineSize; reloadTime = gunData.reloadTime; fastReloadSuccessFraction = gunData.fastReloadSuccessFraction; canFastReload = gunData.canFastReload; fastReloadFailTimeMultiplier = gunData.fastReloadFailMultiplier; fireConeStartAngle = gunData.fireConeStartAngle; fireConeEndAngle = gunData.fireConeEndAngle; fireConeAngle = fireConeStartAngle; aimTime = gunData.aimTime; fireConeAnglePunchOnShot = gunData.fireConeAnglePunchOnShot; traumaValueOnFire = gunData.traumaValueOnFire; fireConeDelayOnShot = gunData.fireConeDelayOnShot; gunData.valid = true; } }
public void SetUp() { guns = new GunData[gunsSize]; outfits = new OutfitData[outfitsSize]; medKits = new MedKitData[medKitsSize]; ammoData = new AmmoData[ammoSize]; }
public void Execute(TriggerEvent triggerEvent) { if (playerGroup.HasComponent(triggerEvent.EntityA)) { if (pickupGroup.HasComponent(triggerEvent.EntityB)) { PickupTag pickup = pickupGroup[triggerEvent.EntityB]; switch (pickup.type) { case 0: HealthData health = healthGroup[triggerEvent.EntityA]; health.health += 50; if (health.health > 100) { health.health = 100; } health.damageCoolDown = .3f; healthGroup[triggerEvent.EntityA] = health; break; case 1: GunData gun = gunGroup[triggerEvent.EntityB]; gunGroup[triggerEvent.EntityA] = gun; break; default: break; } pickup.destroy = true; pickupGroup[triggerEvent.EntityB] = pickup; } } }
private void Awake() { container = InGameManager.Instance.PlayerDataContainer_readonly; characterData = GameManager.Instance.CharacterSheet_readonly.m_data[GameManager.Instance.selectedPlayableUnit.index]; Hp = characterData.hp; IsShield = true; MoveSpeed = characterData.move.moveSpeed; Bomb = 0; Pearl = 0; gunSheet = GameManager.Instance.gunSheet_readonly; for (int count = 0; count < gunSheet.m_data.Count; count++) { if (gunSheet.m_data[count].name == characterData.firstGunName) { Debug.Log(gunSheet.m_data[count].name + count + characterData.firstGunName); gunData = gunSheet.m_data[count]; break; } } }
IEnumerator ReloadGun(Gun gun, GunData gunData, AmmoCategory category, int availableAmmo, float reloadTime) { PlayAudio(startReloadAudio); animator.SetTrigger("IsReload"); // Start playing audio x seconds before full reload time where x is the length of the end reload audio length yield return(new WaitForSeconds(reloadTime - endReloadAudioLength)); PlayAudio(endReloadAudio); yield return(new WaitForSeconds(endReloadAudioLength)); // round magazine size to highest int and ensure magazine can hold at least 1 bullet after modifiers int magazineSizeAdjusted = (int)Mathf.Ceil(gunData.MagazineSize * gunData.MagazineSizeMultiplier.Value); magazineSizeAdjusted = Mathf.Max(1, magazineSizeAdjusted); int maximumReloadAmount = Mathf.Min(availableAmmo, magazineSizeAdjusted - gun.BulletsInMagazine); // maximum amount should never exceed magazine size gun.IncreaseMagazine(maximumReloadAmount); gun.PlayerAmmoStorage.ReduceAmmoAmount(category, maximumReloadAmount); reloadCoroutine = null; onReload?.Invoke(gun); }
public PlayerGun(GunData data) { _ShotArgs = new _ShotArgsTuple(); _ReLoadObserver = new Subject <Unit> (); _ShotOrderObserver = new Subject <_ShotArgsTuple> (); _ShotObserver = new Subject <Unit> (); _Resource = new Magazine(data); _GunData = data; _ShotOrderObserver .Where(_ => !_Reloading) .Where(_ => _CanShot) .Subscribe(tuple => { IShootable bullet; if (_Resource.Load(out bullet)) { bullet.Shoot(tuple.Position, tuple.Direction); _ShotObserver.OnNext(Unit.Default); Observable.FromCoroutine <Unit> (observer => DeltaTimer(observer)) .Subscribe(time => { }); return; } //_ReloadAuto (); }); }
protected virtual void ProcessHit(RaycastHit hit) { var ent = Entity.Game.EntityManager.FindEntity(hit.collider.gameObject); if (ent == null && !Entity.Game.IsHost) { ImpactEffect(hit); return; } if (ent is IDamageable dmg) { var hb = hit.collider.GetComponent <HitboxBehaviour>(); var dmgMultiplier = hb ? GunData.GetDamageMultiplier(hb.Area) : 1f; var dmgAmount = (int)(GunData.BaseDamage * dmgMultiplier); dmg.Damage(new DamageInfo() { Amount = dmgAmount, HitPoint = hit.point, HitNormal = hit.normal, DamageType = DamageType.Bullet, HitArea = hb != null ? hb.Area : HitboxArea.None, WeaponId = Entity.EntityId, AttackerEntityId = Equippable.HumanId, VictimEntityId = ent.EntityId }); } }
public virtual void SetNewGunData(GunData newData) { data = newData ?? null; if (gunSprite) { gunSprite.sprite = data?.gunSprite ?? null; } }
private void HandleOnStopLaser(GunData gun) { //if the cannon (Transform) that stopped firing is on the same GameObject which this Laser is attached to, it stops too if (gun.cannon == beamOrigin) { EndMyself(); } }
protected void EquipGun(GunData gunData, GunComponent gunComponent, GameobjectComponent gameobjectComponent) { gunComponent.gunData = gunData; var sprite = Resources.Load <Sprite>(gunData.spritePath); Debug.Log(gameobjectComponent); gameobjectComponent.spriteRenderer.sprite = sprite; }
public Guns(GunData gun, int slot) { this.gun = gun; this.slot = slot; this.bulletsInChamber = 0; this.reloading = false; this.gunDurability = gun.weaponDurability; }
// Use this for initialization public override void StartFire(eUnitType findType) { m_findType = findType; m_GunData = new GunData(); m_bulletData = new BulletData(); m_fireCount = m_GunData.m_repeatCount; //newBullet.Fire (); m_isFire = true; }
public void Init(PlayerReferences playerReferences, GunData specialGun) { _playerReferences = playerReferences; CurrentGun = specialGun; Ammo = (int)CurrentGun.Magazine.CurrentLevel.Value; Progress?.Invoke(1); }
public void SetData(GunData gunData) { lastFire = 0f; Empty = false; GunData = gunData; shootSoundy.clip = gunData.FireSound; model = GunManager.Current.GetModel(gunData); animator = model.GetComponent <Animator>(); }
// Use this for initialization public override void StartFire( eUnitType findType) { m_findType = findType; m_GunData = new GunData (); m_bulletData = new BulletData (); m_fireCount = m_GunData.m_repeatCount; //newBullet.Fire (); m_isFire = true; }
void HandleOnStopFiring(GunData gun) { //if the cannon (Transform) that stopped firing is on the same GameObject which this oscillator is attached to, it stops too if (gun.cannon == transform) { mustOscillate = false; ResetAngle(); } }
public virtual void Init(PlayerReferences playerReferences, GunData gun) { PlayerReferences = playerReferences; _gun = gun; _speed = gun.BulletSpeed; _direction = playerReferences.PlayerController.direction; transform.rotation = Quaternion.Euler(90, 0, 0); }
public Gun Deserialize(GunData gunData) { var gun = new Gun(gunData.gunType, gunData.fireRate, gunData.damage, gunData.ammoCount, gunData.ammoLimit); var itemUiDataTransfer = new ItemUiDataTransfer(); itemUiDataTransfer.SetItemUiSlotIndex(gunData.slotUiIndex); gun.SetItemUi(itemUiDataTransfer); return(gun); }
public override void Init() { GunData tempData = weaponData as GunData; volleyTime = tempData.VolleyTime; noOfShots = tempData.NoOfShots; angle = tempData.Angle; base.Init(); }
void HandleOnStartFiring(GunData gun) { //if the cannon (Transform) that starts firing is on the same GameObject which this oscillator is attached to, it starts too if (gun.cannon == transform) { mustOscillate = true; StopAllCoroutines(); StartCoroutine(CoOscillate()); } }
public void Shoot(GunData _gunData, Transform newTransform) { gunData = _gunData; gameObject.transform.rotation = newTransform.rotation; gameObject.transform.position = newTransform.position; isActive = true; journeyTime = gunData.range / gunData.bulletSpeed; disabling = StartCoroutine(Disable()); }
public void Shoot(GunData _gunData, Vector3 position, Vector3 angle) { gunData = _gunData; gameObject.transform.eulerAngles = angle; gameObject.transform.position = position; isActive = true; journeyTime = gunData.range / gunData.bulletSpeed; disabling = StartCoroutine(Disable()); }
void CreateNewGunData(GameObject projectilePrefab) { GunData newGunData = CreateInstance(typeof(GunData)) as GunData; newGunData.InitialiseGunData(fireMode, ammoCategory, projectilePrefab, damage, magazineSize, roundsPerMinute, baseSpreadRadius, baseCritChance, baseCritMultiplier, baseStunChance); AssetDatabase.CreateAsset(newGunData, gunPrefabPath + gunName + "Data.asset"); AssetDatabase.SaveAssets(); selectedGunData = newGunData; }
/*void Update(){ * if(Input.GetKeyDown("1")){ * SetCurrentGun(gunSlot1); * } else if(Input.GetKeyDown("2")){ * SetCurrentGun(gunSlot2); * } * * if(state == GunState.Idle){ * if(Input.GetMouseButton(0) && currentGun.currentAmmo > 0){ * fireTimer.Start(); * state = GunState.Firing; * * audioSource.clip = currentGun.fireSound; * audioSource.Play(); * * animstate = AnimationState.Firing; * animationTimer.Start(); * * GetComponent<FPSComponent>().CmdFireGun(); * * currentGun.currentAmmo--; * } * * if(Input.GetMouseButtonDown(0) && currentGun.currentAmmo == 0 && !audioSource.isPlaying){ * audioSource.clip = emptyGunSound; * audioSource.Play(); * } * } else if(state == GunState.Firing){ * if(fireTimer.Finished()){ * if(currentGun.automatic){ * state = GunState.Idle; * } else { * state = GunState.Waiting; * } * } * } else if(state == GunState.Waiting){ * if(!Input.GetMouseButton(0)){ * state = GunState.Idle; * } * } * * if(state != GunState.Reloading && state != GunState.Firing && Input.GetKey("r") && currentGun.currentAmmo < currentGun.magazineAmmo){ * state = GunState.Reloading; * reloadTimer.Start(); * * audioSource.clip = reloadSoundA; * audioSource.Play(); * } else if(state == GunState.Reloading && reloadTimer.Finished()){ * state = GunState.Idle; * currentGun.currentAmmo = currentGun.magazineAmmo; * * audioSource.clip = reloadSoundB; * audioSource.Play(); * } * * if(animstate == AnimationState.Firing && animationTimer.Finished()){ * animstate = AnimationState.Cocking; * animationTimer.Start(); * } else if(animstate == AnimationState.Cocking && animationTimer.Finished()){ * animstate = AnimationState.Idle; * } * }*/ void SetCurrentGun(GunData newgun) { currentGun = newgun; state = GunState.Idle; animstate = AnimationState.Idle; fireTimer.SetDuration(newgun.fireTime); reloadTimer.SetDuration(newgun.reloadTime); animationTimer.SetDuration(newgun.fireTime / 2.0f); }
public static GunBase Build(GunData data, GameObject player) { switch (data.type) { case GunType.Straight: return new StraightGun(data, player); case GunType.Helixing: return new HelixGun(data, player); case GunType.SideShooting: return new SideGun(data, player); case GunType.Cardinal: return new CardinalGun(data, player); } return null; }
// Use this for initialization void Start () { instance = this; weaponSlot = (GunData)GameBase.findObjectByName(init_weaponSlot); items = new ItemData[100]; for(int i = 0; i < init_inventory.Length; i++) { items[i] = GameBase.findObjectByName(init_inventory[i]); } controlAtk.TakeGun(weaponSlot); }
public GunRuntimeData(GunData data) { this.data = data; }
public GunBase(GunData data, GameObject player) { gun = new GunRuntimeData(data); transform = player.transform; box = player.GetComponent<BoxCollider2D>(); }
public StraightGun(GunData data, GameObject player) : base(data, player) { }
public HelixGun(GunData data, GameObject player) : base(data, player) { }
public SideGun(GunData data, GameObject player) : base(data, player) { }
public CardinalGun(GunData data, GameObject player) : base(data, player) { }
public void TakeGun(GunData data) { gunData = data; firetype = gunData.firetype; ammo = gunData.maxammo; ammospend = gunData.ammospend; }