コード例 #1
0
    private void BulletFlowen(NPC npc, GunModel model, GameObject bullet)
    {
        Destroy(bullet);

        if (npc == null || !npcs.Contains(npc))
        {
            return;
        }

        npc.model.HP -= model.Damage;

        if (npc.model.HP <= 0)
        {
            // дистанция
            var startPosition  = Tower.Instance.bulletStartPlace.transform.position;
            var fullDistance   = Vector3.Distance(Spawner.Instance.StartPoint.position, startPosition);
            var distance       = Vector3.Distance(npc.transform.position, startPosition);
            var distancePassed = distance / fullDistance;

            var variationStat = new VariationStats(distancePassed, npc.DamageDealt);

            variationStats.Add(variationStat);
            npcs.RemoveAt(0);
            npc.Kill();
            if (npcs.Count == 0)
            {
                GeneticsController.Instance.OnVariationDied(variationStats.ToArray());
                StartWave();
            }
        }
    }
コード例 #2
0
ファイル: GunManager.cs プロジェクト: negionion/MRgun-Scripts
    private void OnSelect(object sender, GunType gunType)
    {
        gunMain.fire(false);
        gunMain.gameObject.SetActive(false);
        switch (gunType)
        {
        case GunType.AR:
            gunMain = gunAR;
            break;

        case GunType.RF:
            gunMain = gunRF;
            break;

        case GunType.SG:
            gunMain = gunSG;
            break;

        default:
            gunMain = gunAR;
            break;
        }
        //initial
        gunMain.gameObject.SetActive(true);
        gunMain.select();
    }
コード例 #3
0
        public static string GetGunAmmunitionType(WeaponHash weapon)
        {
            // Get the ammunition type given a weapon
            GunModel gunModel = Constants.GUN_LIST.Where(gun => weapon == gun.weapon).FirstOrDefault();

            return(gunModel == null ? string.Empty : gunModel.ammunition);
        }
コード例 #4
0
 public static Gun Convert(GunModel gun)
 {
     return(new Gun()
     {
         Id = gun.Id, Name = gun.GunName
     });
 }
コード例 #5
0
 public void Initialize()
 {
     playerBase = new PlayerModel();
     gun        = new GunModel();
     settings   = FindObjectOfType <UserSettings>();
     settings.Init(playerBase, gun);
 }
コード例 #6
0
        public static int GetGunAmmunitionCapacity(WeaponHash weapon)
        {
            // Get the capacity from a weapons's clip magazine
            GunModel gunModel = Constants.GUN_LIST.Where(gun => weapon == gun.weapon).FirstOrDefault();

            return(gunModel == null ? 0 : gunModel.capacity);
        }
コード例 #7
0
    public void Setup(EnemyModel model, GunModel gunModel)
    {
        enemyModel = model;
        enemyModel.setConfig(enemyConfig);

        this.gunModel = gunModel;
    }
コード例 #8
0
 void Awake()
 {
     ammo    = gameObject.GetComponent <Ammo>();
     barrel  = gameObject.GetComponent <Barrel>();
     grip    = gameObject.GetComponent <Grip>();
     model   = gameObject.GetComponentInParent <GunModel>();
     swapper = GameObject.Find("Gun Swapper").GetComponent <SwappingGunModel>();
 }
コード例 #9
0
 void Start()
 {
     gunModel       = FindObjectOfType <GunModel>();
     weapon         = GameObject.FindWithTag("Gun").GetComponent <Weapon>();
     scoreManager   = FindObjectOfType <ScoreManager>();
     scoreText      = FindObjectOfType <ButtonManager>().scoreCanvas.transform.GetChild(0).GetComponent <Text>();
     scoreText.text = "";
 }
コード例 #10
0
 void SetGunDelayTime(float delayTime)
 {
     for (int i = 0; i < Guns.Length; i++)
     {
         GunModel currentGun = Guns [i];
         currentGun.ShootingDelay = delayTime;
     }
 }
コード例 #11
0
 void SetBulletSpeed(Vector2 bulletSpeed)
 {
     for (int i = 0; i < Guns.Length; i++)
     {
         GunModel currentGun = Guns [i];
         currentGun.BulletSpeed = new Vector2(currentGun.BulletSpeed.x, bulletSpeed.y);
     }
 }
コード例 #12
0
    private IEnumerator MakeAssignments()
    {
        yield return(new WaitForSeconds(.5f));

        weaponUI = FindObjectOfType <ButtonManager>().gunStatCanvas;
        if (myGun == null)
        {
            myGun = FindObjectOfType <GunModel>();
        }
    }
コード例 #13
0
        public PlayerControllerPresenter Init(Entity.PlayerEntity playerEntity)
        {
            _playerModel = new PlayerModel(playerEntity);
            _gunModel    = new GunModel(playerEntity.BulletEntity);

            Bind();
            DebugInit();

            return(this);
        }
コード例 #14
0
    void OnBulletBoostEvent(BulletBoostPowerEvent eve)
    {
        // add to all gun
        for (int i = 0; i < Guns.Length; i++)
        {
            GunModel currentGunModel = Guns [i];

            currentGunModel.BoostDelay = eve.BoostDelay;
            currentGunModel.BoostTime  = eve.BoostTime;
        }
    }
コード例 #15
0
    public void StartShooting()
    {
        // reset previous routines
        StopShooting();

        for (int i = 0; i < Guns.Length; i++)
        {
            GunModel  currentGun   = Guns [i];
            Coroutine shootRoutine = StartCoroutine(UpdateShoot(currentGun));
            _ShootingRoutine.Add(shootRoutine);
        }
    }
コード例 #16
0
 void SetGunActive(string GunID, bool isActive)
 {
     for (int i = 0; i < Guns.Length; i++)
     {
         GunModel currentGun = Guns [i];
         if (Guns[i].Gun_Id == GunID)
         {
             currentGun.Active = isActive;
             return;
         }
     }
 }
コード例 #17
0
 public void Init(PlayerModel model, GunModel gunModel)
 {
     this.model                   = model;
     this.gunModel                = gunModel;
     AvailableSkills.text         = model.skillPoints.ToString();
     MaxHealthSlider.value        = model.MaxHealth;
     MaxHealthSlider.OnAddButton += MaxHealthSlider_OnAddButton;
     FireRateSlider.value         = gunModel.fireRate;
     FireRateSlider.OnAddButton  += FireRateSlider_OnAddButton;
     RegenSlider.value            = model.RegenPerSecond;
     RegenSlider.OnAddButton     += RegenSlider_OnAddButton;
     DamageSlider.value           = gunModel.Damage;
     DamageSlider.OnAddButton    += DamageSlider_OnAddButton;
 }
コード例 #18
0
    void Shoot(GunModel gunModel)
    {
        GameObject bullet = BulletPool.Get();

        if (bullet != null)
        {
            bullet.transform.position = gunModel.GunPosition.position;

            BulletController bc = bullet.GetComponent <BulletController> ();
            if (bc != null)
            {
                bc.Speed = gunModel.BulletSpeed;
            }

            bullet.SetActive(true);
        }
    }
コード例 #19
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            if (worldModel)
            {
                weaponUI.gameObject.SetActive(true);

                if (myGun == null)
                {
                    myGun = FindObjectOfType <GunModel>();
                }

                myGun.SetPiece(this);
            }
        }
    }
コード例 #20
0
    public void StartShooting()
    {
        BulletPool = PoolManager.Instance.GetPool("EnemyBulletPool");

        // reset previous routines
        for (int i = 0; i < _ShootingRoutine.Count; i++)
        {
            StopCoroutine(_ShootingRoutine [i]);
        }

        for (int i = 0; i < Guns.Length; i++)
        {
            GunModel currentGun = Guns [i];

            Coroutine shootRoutine = StartCoroutine(UpdateShoot(currentGun));
            _ShootingRoutine.Add(shootRoutine);
        }
    }
コード例 #21
0
    IEnumerator UpdateShoot(GunModel currentGunModel)
    {
        yield return(null);

        while (true)
        {
            Shoot(currentGunModel);

            float shootingDelay = currentGunModel.ShootingDelay;

            if (Blackboard.Instance.BulletSpawnSpeedMultiplier > 0)
            {
                shootingDelay = currentGunModel.ShootingDelay / Blackboard.Instance.BulletSpawnSpeedMultiplier;
                yield return(new WaitForSeconds(shootingDelay));
            }
            yield return(null);
        }
    }
コード例 #22
0
ファイル: Player.cs プロジェクト: clifordunique/LastBullet
    private void Start()
    {
        _instance = this;
        PlayerController pc = this.GetComponent <PlayerController>();

        if (pc)
        {
            Debug.Log("PlayerController Found!");

            GameObject instance = Instantiate(Resources.Load("player/weapons/GunModel_Wilson", typeof(GameObject))) as GameObject;
            instance.transform.position = transform.position;
            instance.transform.parent   = transform;
            activeGun = instance.GetComponent <GunModel>();

            pc.gunModel    = activeGun;
            pc.playerModel = transform.GetComponentInChildren <PlayerModel>();
        }

        SoundManager.SetGlobalVolume(.5f);
    }
コード例 #23
0
ファイル: PickupScan.cs プロジェクト: negionion/MRgun-Scripts
    // Update is called once per frame
    void Update()
    {
        foreach (Collider item in Physics.OverlapBox(this.transform.position, scanSize, Quaternion.identity))
        {
            switch (item.tag)
            {
            case "HPBox":
                item.GetComponent <HPBox>().pickupAction((health) => { player.recvDamage(-health); });
                break;

            case "BulletBox":
                item.GetComponent <BulletBox>().pickupAction((bulletAddVal) =>
                {
                    GunModel gun   = SingleObj <GunManager> .obj.gunMain;
                    gun.bulletMax += (int)(gun.bulletStandSize * bulletAddVal);
                });
                break;
            }
        }
    }
コード例 #24
0
    public void Damage(GunModel model)
    {
        if (npcs.Count == 0)
        {
            Debug.LogError("WrongDamage");
            return;
        }

        var bullet = Instantiate(Bullet);

        bullet.transform.position = Tower.Instance.bulletStartPlace.position;
        var npc            = npcs[0];
        var distanceBullet = Vector3.Distance(bullet.transform.position, npc.transform.position);
        var angle          = Vector3.Angle(bullet.transform.position, npc.transform.position);

        bullet.transform.GetChild(0).localEulerAngles = new Vector3(0, 0, Math.Abs(angle) + 45f);
        LeanTween.move(bullet, npc.transform.position, distanceBullet / bulletSpeed)
        .setOnComplete(() =>
        {
            BulletFlowen(npc, model, bullet);
        });
    }
コード例 #25
0
    void Shoot(GunModel gunModel)
    {
        if (!gunModel.Active)
        {
            return;
        }

        GameObject bullet = BulletPool.Get();

        if (bullet != null)
        {
            bullet.transform.position = gunModel.GunPosition.position;

            BulletController bc = bullet.GetComponent <BulletController> ();
            if (bc != null)
            {
                bc.Speed  = gunModel.BulletSpeed;
                bc.Damage = _BulletDamage * _PurchasedBulletDamageMultiplier;
            }

            bullet.SetActive(true);
        }
    }
コード例 #26
0
    IEnumerator UpdateShoot(GunModel currentGunModel)
    {
        yield return(null);

        while (true)
        {
            // shooting boost
            if (currentGunModel.BoostTime > 0)
            {
                float elapsedTime = Time.realtimeSinceStartup;
                while (currentGunModel.BoostTime > 0)
                {
                    elapsedTime = Time.realtimeSinceStartup;
                    Shoot(currentGunModel);
                    yield return(new WaitForSeconds(currentGunModel.BoostDelay));

                    currentGunModel.BoostTime -= Time.realtimeSinceStartup - elapsedTime;
                }
            }

            Shoot(currentGunModel);
            yield return(new WaitForSeconds(currentGunModel.ShootingDelay));
        }
    }
コード例 #27
0
 public void Setup(PlayerModel model, GunModel gunModel)
 {
     playerModel = model;
     playerModel.setConfig(playerConfig);
     this.gunModel = gunModel;
 }
コード例 #28
0
    private static VariationStats CalcStats(Variation variation, float spawnTime, float atackTime, GunModel gun, out float killTime)
    {
        killTime = Mathf.Ceil(variation.HPValue / gun.Damage) * gun.fireRate;
        var runTime      = 1 / variation.SpeedValue + spawnTime;
        var lifetime     = atackTime + killTime;
        var npcFightTime = lifetime - runTime;
        var damage       = npcFightTime > 0? Mathf.FloorToInt(npcFightTime * variation.FireRateValue) * variation.DamageValue: 0;
        //var distance = atackTime + killTime >= runTime ? 1 : 1 / variation.SpeedValue / (1 / variation.SpeedValue - Mathf.Abs(((runTime) - (atackTime + killTime))));
        var distance = Mathf.Max(spawnTime, atackTime) + killTime < runTime ? ((1 / variation.SpeedValue) - (runTime - (Mathf.Max(spawnTime, atackTime) + killTime))) / (1 / variation.SpeedValue) : 1;

        return(new VariationStats(distance, damage));
    }
コード例 #29
0
 public Gun(GunModel model)
 {
     this.Model = model;
     Uid        = RandomGenerator.RandomString(10);
     PB2Map.MapObjects.Add(this);
 }
コード例 #30
0
    // Update is called once per frame
    void Update()
    {
        gun = SingleObj <GunManager> .obj.gunMain;

        bullet.text = string.Format("{0}/{1}", gun.bullet, gun.bulletMax);
    }