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(); } } }
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(); }
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); }
public static Gun Convert(GunModel gun) { return(new Gun() { Id = gun.Id, Name = gun.GunName }); }
public void Initialize() { playerBase = new PlayerModel(); gun = new GunModel(); settings = FindObjectOfType <UserSettings>(); settings.Init(playerBase, gun); }
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); }
public void Setup(EnemyModel model, GunModel gunModel) { enemyModel = model; enemyModel.setConfig(enemyConfig); this.gunModel = gunModel; }
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>(); }
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 = ""; }
void SetGunDelayTime(float delayTime) { for (int i = 0; i < Guns.Length; i++) { GunModel currentGun = Guns [i]; currentGun.ShootingDelay = delayTime; } }
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); } }
private IEnumerator MakeAssignments() { yield return(new WaitForSeconds(.5f)); weaponUI = FindObjectOfType <ButtonManager>().gunStatCanvas; if (myGun == null) { myGun = FindObjectOfType <GunModel>(); } }
public PlayerControllerPresenter Init(Entity.PlayerEntity playerEntity) { _playerModel = new PlayerModel(playerEntity); _gunModel = new GunModel(playerEntity.BulletEntity); Bind(); DebugInit(); return(this); }
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; } }
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); } }
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; } } }
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; }
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); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { if (worldModel) { weaponUI.gameObject.SetActive(true); if (myGun == null) { myGun = FindObjectOfType <GunModel>(); } myGun.SetPiece(this); } } }
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); } }
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); } }
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); }
// 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; } } }
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); }); }
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); } }
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)); } }
public void Setup(PlayerModel model, GunModel gunModel) { playerModel = model; playerModel.setConfig(playerConfig); this.gunModel = gunModel; }
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)); }
public Gun(GunModel model) { this.Model = model; Uid = RandomGenerator.RandomString(10); PB2Map.MapObjects.Add(this); }
// Update is called once per frame void Update() { gun = SingleObj <GunManager> .obj.gunMain; bullet.text = string.Format("{0}/{1}", gun.bullet, gun.bulletMax); }