예제 #1
0
            public Gun(GunData data)
            {
                _data = data;

                _damage     = _data.Damage;
                _reloadTime = _data.ReloadTime;
            }
예제 #2
0
    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();*/
        }
예제 #4
0
    public void AddWeapon()
    {
        GunData Weapon = new GunData();

        Weapon.attackGun = 1;
        gunDatas.Add(Weapon);
    }
예제 #5
0
    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);
    }
예제 #6
0
    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;
        }
    }
예제 #7
0
    public GunBase(GunData data, GameObject player)
    {
        gun = new GunRuntimeData(data);

        transform = player.transform;
        box       = player.GetComponent <BoxCollider2D>();
    }
예제 #8
0
    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];
 }
예제 #10
0
        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;
                }
            }
        }
예제 #11
0
    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;
            }
        }
    }
예제 #12
0
    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);
    }
예제 #13
0
        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 ();
            });
        }
예제 #14
0
        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
                });
            }
        }
예제 #15
0
 public virtual void SetNewGunData(GunData newData)
 {
     data = newData ?? null;
     if (gunSprite)
     {
         gunSprite.sprite = data?.gunSprite ?? null;
     }
 }
예제 #16
0
 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();
     }
 }
예제 #17
0
    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;
    }
예제 #18
0
 public Guns(GunData gun, int slot)
 {
     this.gun              = gun;
     this.slot             = slot;
     this.bulletsInChamber = 0;
     this.reloading        = false;
     this.gunDurability    = gun.weaponDurability;
 }
예제 #19
0
 // 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;
 }
예제 #20
0
    public void Init(PlayerReferences playerReferences, GunData specialGun)
    {
        _playerReferences = playerReferences;

        CurrentGun = specialGun;
        Ammo       = (int)CurrentGun.Magazine.CurrentLevel.Value;

        Progress?.Invoke(1);
    }
예제 #21
0
 public void SetData(GunData gunData)
 {
     lastFire         = 0f;
     Empty            = false;
     GunData          = gunData;
     shootSoundy.clip = gunData.FireSound;
     model            = GunManager.Current.GetModel(gunData);
     animator         = model.GetComponent <Animator>();
 }
예제 #22
0
 // 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;
 }
예제 #23
0
 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();
     }
 }
예제 #24
0
파일: Bullet.cs 프로젝트: pitfon/1
    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);
    }
예제 #25
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();
    }
예제 #27
0
 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());
     }
 }
예제 #28
0
    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());
    }
예제 #29
0
    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());
    }
예제 #30
0
    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;
    }
예제 #31
0
    /*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);
    }
예제 #32
0
 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;
 }
예제 #33
0
	// 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);
	}
예제 #34
0
 public GunRuntimeData(GunData data) {
     this.data = data;
 }
예제 #35
0
    public GunBase(GunData data, GameObject player) {
        gun = new GunRuntimeData(data);

        transform = player.transform;
        box = player.GetComponent<BoxCollider2D>();
    }
예제 #36
0
 public StraightGun(GunData data, GameObject player) : base(data, player) { }
예제 #37
0
 public HelixGun(GunData data, GameObject player) : base(data, player) { }
예제 #38
0
 public SideGun(GunData data, GameObject player) : base(data, player) { }
예제 #39
0
 public CardinalGun(GunData data, GameObject player) : base(data, player) { }
예제 #40
0
    public void TakeGun(GunData data)
    {
        
        
       

        gunData = data;

        firetype = gunData.firetype;
        
        ammo = gunData.maxammo;
        ammospend = gunData.ammospend;
    }