new void Start() { base.Start(); m_bullet = CreateBullet(m_firingDescs[0], m_gunPoint.transform.position) as Bullet; StartCoroutine(EffectShield()); }
public override void onManagedUpdate(float secondsElapsed) { this.CenterX += this.VectorX * this.Speed * secondsElapsed; this.CenterY += this.VectorY * this.Speed * secondsElapsed; this.LifeTime -= secondsElapsed; if (this.LifeTime <= 0 || this.Health <= 0) { for (int i = 0; i < this.FragmetsCount; ++i) { Bullet bullet = new Bullet() { Parent = this.Parent, CenterX = this.CenterX, CenterY = this.CenterY, Width = this.Width * this.FragmetsPart, Height = this.Height * this.FragmetsPart, Angle = (float)(2 * Math.PI * Options.Random.NextDouble()), Speed = this.Speed / this.FragmetsPart, LifeTime = this.LifeTime, Health = this.Health * this.FragmetsPart, }; (this.Parent as Weapon).bullets.Add(bullet); } } if (this.LifeTime <= 0 || this.Health <= 0 || this.Y > Options.CameraHeight || this.Y + this.Height < 0) { (this.Parent as Weapon).bullets.Remove(this); } }
public void AddInactiveBullet( Bullet b ) { if( bullets.Contains( b ) ) { bullets.Remove( b ); } inactive.Enqueue( b ); }
void setupBullet(Bullet b) { b.m_Damage = m_Damage; b.m_Distance = m_Distance; b.m_Speed = m_Speed; b.gameObject.tag = gameObject.tag; }
//struct FishAndOddsMulti //{ // public FishAndOddsMulti(Fish f,int oddMulti) // { // F = f; // OddMulti = oddMulti; // } // public Fish F; // public int OddMulti; //} public static void ProcessHit(Bullet b , Fish f) { switch(f.HittableTypeS) { case "Normal": Process_NormalFish(b,f); break; case "AreaBomb": Process_AreaBomb(b,f); break; case "SameTypeBomb": Process_FishTypeBomb2(b,f); break; case "FreezeBomb": Process_FreezeBomb(b, f); break; case "SameTypeBombEx": Process_FishTypeBombEx(b, f); break; default: if (Evt_HitExtension != null) Evt_HitExtension(b, f); break; } }
protected void HealOnHit(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { Enemy e = target as Enemy; if (e == null) return; e.Heal(amt); }
public void drawBullet(Bullet theBullet) { gameCanvas.Children.Add(theBullet.getBulletShape()); TranslateTransform initialTransform = new TranslateTransform(theBullet.getBulletX(), theBullet.getBulletY()); theBullet.getBulletShape().RenderTransform = initialTransform; }
private void ShootWeapon(Vector2 PlayerCenter) { Bullet newBullet = new Bullet(); newBullet.Shoot(PlayerCenter, new Vector2(Mouse.GetState().X, Mouse.GetState().Y) - Camera._position); _Shoot.Play(); Bullets.Add(newBullet); }
public void AddThreat(Bullet threat, Vector2 collisionPosition, float timeToCollision) { if (!AlreadyHasThisBullet(threat.transform)) { threats.Add(new Threat(threat.transform, collisionPosition, timeToCollision)); } }
public static BulletManager instance; // 다른 곳에서 참조하지 못하도록 static 변수로 선언 void Awake() { instance = this; bullet[0].skillBorder.enabled = true; bullet[1].skillBorder.enabled = false; selected = bullet[0]; }
void OnCollisionEnter(Collision collision) { Debug.Log("Enemy was hit by Collision:" + collision.transform.name); playerBullet = collision.gameObject.GetComponent<Bullet>(); if(playerBullet == null) { playerWeapon = (Weapon)GameConstants.findPlayerInProject().GetComponent<ToonCharacter_Inventory>().getPlayerWeapon(); } if (playerBullet != null) { this.GetComponent<BaseEnemy>().health -= GameConstants.getPlayerAttackDamage(); Destroy(collision.gameObject); } else if (playerWeapon != null) { if (collision.transform.name.Equals(playerWeapon.transform.name)) { //Make Enemy Damage from Melee if (collision.transform.gameObject.GetComponent<Inventory>() is IWeapon) { if (GameConstants.findPlayerInProject().GetComponent<ToonCharacter_DamageEnemyOneTime>().isAttacking) { if (!GameConstants.findPlayerInProject().GetComponent<ToonCharacter_DamageEnemyOneTime>().oneHit) { this.GetComponent<BaseEnemy>().health -= GameConstants.getPlayerAttackDamage(); } //Set Only One Time Damage per Animation GameConstants.findPlayerInProject().GetComponent<ToonCharacter_DamageEnemyOneTime>().oneHit = true; } } } } }
public Gun(GameplayScreen gameplayScreen, GameCharacter owner) : base(gameplayScreen, owner) { _bullet = new Bullet(ImageManager.BulletTexture); coolDownTime = 0.8; coolDownElapsed = 0; }
public void ShouldBeAbleToAddABullet() { var bullet = new Bullet(_battlefield, 20, 21, 180, 2, 5, null); _battlefield.Add(bullet); Assert.That(_battlefield.NewBullets.Count, Is.EqualTo(1)); Assert.That(_battlefield.Bullets.Count, Is.EqualTo(1)); }
void Handle_BulletHit(bool isMiss, Player p, Bullet b, Fish f) { if (!isMiss) { b.SelfDestroy(); } }
public void Init(float power,bool isDamage, IBulletHolder talic) { Init(power); this.talic = talic; cacheGameObject = Resources.Load(WAY_AOETRAP_BULLET, typeof(Bullet)) as Bullet; this.isDamage = isDamage; }
public void RemoveBullet(Bullet toRemove) { if (GameManager.playWithAIs) foreach (AIControls ai in AIs) ai.RemoveThreat(toRemove); bulletMap.Remove(toRemove); }
public void GetHit(Bullet bullet) { life -= bullet.damage; if (life <= 0) { mobKilled(); } }
private void onHit(Vector3 position, Bullet bullet) { bullet.OnHit -= onHit; StartCoroutine(effectCoroutine(explosionsPull, bullet.transform.position, false)); bullet.Rigidbody.velocity = Vector3.zero; bulletsPull.ReleaseObject(bullet); }
void InstantiateBullet(Bullet bullet, int angle) { var obj = Instantiate( bullet, transform.position, Quaternion.AngleAxis(angle - 90, Vector3.forward) ) as Bullet; //Debug.Log ("Obj is " + obj ); obj.transform.parent = Manager.RootBullet.transform; }
void CreateWeb(Bullet b, WebScoreScaleRatio webData,bool isLizi) { GameObject goWebBoom = Instantiate(webData.PrefabWebBoom) as GameObject; goWebBoom.transform.parent = transform; Ef_WebBubble efBubble = goWebBoom.GetComponent<Ef_WebBubble>(); if (efBubble != null) { efBubble.ScaleTarget = webData.BubbleScale; } Ef_WebBoom[] efWebs = goWebBoom.GetComponentsInChildren<Ef_WebBoom>(); foreach (Ef_WebBoom efWeb in efWebs) { efWeb.Prefab_GoSpriteWeb = webData.PrefabWeb; efWeb.NameSprite = webData.NameSprite; //Debug.Log(webData.NameSprite); efWeb.ScaleTarget = webData.Scale; efWeb.transform.localPosition *= webData.PositionScale; if(!isLizi) efWeb.ColorInitialize = Prefab_WebColorNormal.Colors[b.Owner.Idx % Prefab_WebColorNormal.Colors.Length]; } Transform tsWeb = goWebBoom.transform; Transform tsBullet = b.transform; tsWeb.position = new Vector3(tsBullet.position.x, tsBullet.position.y, Defines.GlobleDepth_Web); tsWeb.rotation = tsBullet.rotation; }
public void Init(Bullet bullet){ State = bullet; TweenPost = ActionTarget.AddComponent<TweenPosition> (); TweenPost.duration = bullet.DurationTime; TweenPost.from = bullet.StartPoint; TweenPost.to = bullet.TargetPoint; EventDelegate.Add( TweenPost.onFinished, DeleteSelf); if(bullet.StartSize != Vector3.one){ TweenScal = ActionTarget.AddComponent<TweenScale> (); TweenScal.duration = bullet.DurationTime; TweenScal.from = bullet.StartSize; TweenScal.to = bullet.TargetSize; TweenScal.Play (true); } TweenRota = ActionTarget.AddComponent<TweenRotation>(); TweenRota.to = new Vector3(0.0f, 0.0f, 360.0f); TweenRota.duration = bullet.DurationTime; TweenRota.style = UITweener.Style.Once; EventDelegate.Add(TweenRota.onFinished, _RotationCount); TweenPost.Play (true); TweenRota.Play (true); //Invoke ("DeleteSelf", bullet.DurationTime + 1.0f); }
public void attack() { if (Engine.IsKeyDown(keyMap.attack) && Engine.Timer.Get("coolDown") <= 0) { bullet = new Bullet(direction); if (direction == Bullet.bulletsDirection.RIGHT) { bullet.X = this.X + Sprite.Width; bullet.Y = this.Y + Sprite.Height / 2; } if (direction == Bullet.bulletsDirection.LEFT) { bullet.X = this.X - bullet.Width; bullet.Y = this.Y + Sprite.Height / 2; } if (direction == Bullet.bulletsDirection.UP) { bullet.X = this.X + Sprite.Width / 2 - (bullet.Width / 2); bullet.Y = this.Y - bullet.Height; } if (direction == Bullet.bulletsDirection.DOWN) { bullet.X = this.X + Sprite.Width / 2 - (bullet.Width / 2); bullet.Y = this.Y + Sprite.Height; } bulletsShot.Add(bullet); Engine.SpawnObject("bullet", bullet); bullet.isShoot = true; Engine.Timer.Set("coolDown", 0.5f); } }
/// <summary> /// Gets all necessary references. /// </summary> void Start() { photonView = this.GetComponent<PhotonView>(); myBullet = this.GetComponent<Bullet>(); isMine = photonView.isMine; }
// Use this for initialization void Start () { BS = GameObject.FindGameObjectWithTag ("Bullet").GetComponent<Bullet> (); BM = GameObject.FindGameObjectWithTag ("BulletManager").GetComponent<BulletManager> (); ColSwitch (); // BM.NewRand (); //Code that changes the color of the target itself if (CurrentColor == _Color.Pink) Border.GetComponent<Renderer>().material.color = Color.blue + Color.red + Color.yellow; else if(CurrentColor == _Color.Red) Border.GetComponent<Renderer>().material.color = Color.red; else if(CurrentColor == _Color.Orange) Border.GetComponent<Renderer>().material.color = new Color32(255, 145, 0, 255); else if(CurrentColor == _Color.Yellow) Border.GetComponent<Renderer>().material.color = Color.red + Color.yellow + Color.grey; else if(CurrentColor == _Color.Green) Border.GetComponent<Renderer>().material.color = Color.green; else if(CurrentColor == _Color.Blue) Border.GetComponent<Renderer>().material.color = Color.blue; else if(CurrentColor == _Color.Purple) Border.GetComponent<Renderer>().material.color = Color.magenta; else if(CurrentColor == _Color.Brown) Border.GetComponent<Renderer>().material.color = new Color32(99, 59, 5, 255); else if(CurrentColor == _Color.Black) Border.GetComponent<Renderer>().material.color = Color.grey; }
public static void LoadProjectiles() { Projectiles["20mmAP"] = new Bullet { SpriteId = "bullet_boltsmall", Scale = new Vector2(0.7f, 0.7f), Color = new Color(255,200,100,255), MaxAge = TimeSpan.FromSeconds(1), MuzzleVelocity = 500, Damage = "2d10" }; Projectiles["LaserBeam"] = new Beam { Color = Color.LightYellow, DamagePerSecond = "1d4+18", Range = 800, IntensityFadeInTime = 0.2f, IntensityFadeOutTime = 0.5f, FrameAnimationFps = 20, UseFrameAnimation = true, Scale = new Vector2(1, 0.4f), SpriteId = "crispybeam_0003_Layer-1", Lifetime = 0.5f }; Projectiles["Missile_Sparrow"] = new Missile { Name = "Sparrow", Role = "antiarmor, support", Description = "A standard anti-armor missile with good maneuverability." }; Projectiles["Missile_Shrike"] = new Missile { Name = "Shrike", Role = "barrier-piercing, strike", Description = "Like its avian namesake, the Shrike files to proximity and then impales its targets with saboted shaped-charge spikes capable of damaging armor and hull.", }; Projectiles["Missile_Hornet-S"] = new Missile { Name = "Hornet-S", Description = "A cheap missile built for swarming fire. It has unimpressive performance, but more than makes up for it by its extremely low cost and weight.", Damage = "3d6+1", BlastRadius = 1, }; Projectiles["SpinalRailgunSlug"] = new Bullet { Color = Color.Cyan, Damage = "1d50+100", MuzzleVelocity = 1000, MaxAge = TimeSpan.FromSeconds(3), SpriteId = "bullet_boltsmall", Scale = new Vector2(4,3), }; }
public void fire() { this.bulletsFired += 1; if (this.myBullet == null) { this.myBullet = new Bullet(this.bulletsFired, this.entityCenterX, this.entityCenterY, this.entityHeading, theGameDrawer); } }
public void ShouldBeAbleToRemoveADeadBulletInaTick() { var bullet = new Bullet(_battlefield, 20, 21, 180, 2, 5, null); _battlefield.Add(bullet); bullet.Dead = true; _battlefield.Tick(); Assert.That(_battlefield.Bullets.Count, Is.EqualTo(0)); }
protected virtual Vector3 BulletVelocity(RaycastHit rayHit, Bullet bullet) { // perform the reflection Vector3 normal = BulletNormal(rayHit); normal = new Vector3(normal.x, normal.y, 0).normalized; Vector3 newDir = Vector3.Reflect(bullet.vel, normal); return FixVector3(newDir.normalized*bullet.vel.magnitude); }
void Handle_FishBulletHit(bool isMiss, Player p, Bullet b, Fish f) { if(isMiss) { if (b.IsLockingFish) b.IsLockingFish = false; } }
public void BulletShouldMoveEachTick() { var bullet = new Bullet(_battlefield, 20, 21, 180, 2, 5, null); _battlefield.Add(bullet); _battlefield.Tick(); Assert.That(bullet.X, Is.EqualTo(18.0d)); Assert.That(bullet.Y, Is.EqualTo(21.0d)); }
public Bullet[] TrippleShoot(float speed, uint dmg, Direction dir, Vector2 from, Team team, float rangeBeetwenSidesShot, Bullet prefab = null, Action <Bullet> onDestroy = null) { Bullet[] bullets = new Bullet[3]; Bullet SingleShoot(Direction direction, Vector2 pos) { return(Shoot(speed, dmg, direction, pos, team, prefab, onDestroy)); } Vector2 changer; if (Math.Abs(dir.X) < Math.Abs(dir.Y)) { changer = new Vector2(1, 0); } else { changer = new Vector2(0, 1); } bullets[0] = SingleShoot(dir, from + changer * rangeBeetwenSidesShot); bullets[1] = SingleShoot(dir, from); bullets[2] = SingleShoot(dir, from - changer * rangeBeetwenSidesShot); return(bullets); }
/// <summary> /// 弾道プレファブの追加 /// </summary> /// <param name="bul">生成された弾道</param> public void AddBullet(Bullet bul, Bullet prefab) { Bullets.Add(new MagickBullet(bul, prefab)); }
// 销毁子弹, 所有接口最终经过这里 public void removeBullet(Bullet bulletInst) { allBullets.Remove(bulletInst); Destroy(bulletInst.gameObject); }
//弹幕发射器 public void Launch(BulletParameter BP) { float rotation = analysis(BP.rotation); float speed = analysis(BP.speed); int amount = (int)analysis(BP.amount); float length = analysis(BP.length); float midAngle = analysis(BP.midAngle); float spreadAngle = analysis(BP.spreadAngle); float distance = analysis(BP.distance); float minspeed = analysis(BP.minspeed); float maxspeed = analysis(BP.maxspeed); Vector2 Acc; Acc.x = analysis(BP.AccX); Acc.y = analysis(BP.AccY); float MSpeed = analysis(BP.MSpeed); float RotateSpeed = analysis(BP.RotateSpeed); float RotateAcc = analysis(BP.RotateAcc); float Rotation = analysis(BP.Rotation); float Lifetime = analysis(BP.Lifetime); float JudgeSize = analysis(BP.JudgeSize); float alpha = analysis(BP.alpha); if (BP.laucherType == BulletData.LaucherType.ABullet) { dmk = LaunchABullet(BP.bulletType, rotation, BP.offset, BP.velocity); } if (BP.laucherType == BulletData.LaucherType.Barrier) { dmks = LaunchABarrier(BP.bulletType, BP.offset, speed, amount, midAngle, spreadAngle, distance); } else if (BP.laucherType == BulletData.LaucherType.Random) { dmks = LaunchRandom(BP.bulletType, BP.offset, amount, midAngle, spreadAngle, distance, speed); } else if (BP.laucherType == BulletData.LaucherType.Line) { dmks = LaunchALine(BP.bulletType, BP.offset, amount, midAngle, distance, minspeed, maxspeed); } else if (BP.laucherType == BulletData.LaucherType.Horizon) { dmks = LaunchHorizon(BP.bulletType, BP.offset, amount, midAngle, distance, length, speed); } else { Debug.Log("参数出现问题 未发射"); return; } //给弹幕附加属性 if (BP.laucherType == BulletData.LaucherType.ABullet) { Bullet temp = dmk.GetComponent <Bullet>(); temp.isRemoveable = BP.isRemoveable; temp.IsRemovedOut = BP.IsRemovedOut; temp.isAwake = BP.isAwake; temp.IsForward = BP.IsForward; temp.Acc = Acc; temp.MSpeed = MSpeed; temp.Rotation = Rotation; temp.RotateAcc = RotateAcc; temp.RotateSpeed = RotateSpeed; temp.Lifetime = Lifetime; temp.JudgeSize = JudgeSize; temp.alpha = alpha; temp.Counter = BP.Counter; } else { foreach (GameObject Dmk in dmks) { Bullet temp = Dmk.GetComponent <Bullet>(); temp.isRemoveable = BP.isRemoveable; temp.IsRemovedOut = BP.IsRemovedOut; temp.isAwake = BP.isAwake; temp.IsForward = BP.IsForward; temp.Acc = Acc; temp.MSpeed = MSpeed; temp.Rotation = Rotation; temp.RotateAcc = RotateAcc; temp.RotateSpeed = RotateSpeed; temp.Lifetime = Lifetime; temp.JudgeSize = JudgeSize; temp.alpha = alpha; temp.Counter = BP.Counter; } } }
public bool RegisterBullets() { bulletIncoming = false; Collider2D[] colliders = Physics2D.OverlapCircleAll(aiBase.transform.position, aiBase.mapWidth / 2, aiBase.bulletMask); List <Collider2D> listColliders = new List <Collider2D>(colliders); List <int> indicesToRemove = new List <int>(); for (int i = colliders.Length - 1; i >= 0; i--) { try { Bullet b = colliders[i].GetComponentInParent <Bullet>(); SpriteRenderer sr = colliders[i].GetComponentInParent <SpriteRenderer>(); if (sr.sprite.ToString().Contains("mine")) { listColliders.RemoveAt(i); } else { } } catch (Exception e) { } } foreach (Collider2D collider in listColliders) { Vector2 bulletPosition = collider.transform.position; Vector2 bulletDirection = collider.GetComponent <Bullet>().direction; if (aiMapLogic.AlmostEqual(bulletPosition.x, aiBase.posX, characterColliderWidth)) //bullet above or bellow { if (bulletPosition.y > aiBase.posY) //bullet is above { if (bulletDirection == down) //bullet is aiming down { bulletIncoming = true; bulletFrom = up; } } else //bullet is bellow { if (bulletDirection == up) //bullet is aiming up { bulletIncoming = true; bulletFrom = down; } } } else if (aiMapLogic.AlmostEqual(bulletPosition.y, aiBase.posY, characterColliderHeight)) //bullet is on left or right { if (bulletPosition.x > aiBase.posX) //bullet is on right { if (bulletDirection == left) //bullet is aiming left { bulletIncoming = true; bulletFrom = right; } } else //bullet on left { if (bulletDirection == right) //bullet is aiming right { bulletIncoming = true; bulletFrom = left; } } } } return(bulletIncoming); }
public override void Update() { base.Update(); if (!this._pin) { this._timer -= 0.01f; } if (this._timer < 0.5f && this.owner == null && !this._didBonus) { this._didBonus = true; if (Recorder.currentRecording != null) { Recorder.currentRecording.LogBonus(); } } if (!this._localDidExplode && this._timer < 0f) { if (this._explodeFrames < 0) { //this.CreateExplosion(this.position); this._explodeFrames = 4; } else { this._explodeFrames--; if (this._explodeFrames == 0) { float cx = base.x; float cy = base.y - 2f; //Graphics.FlashScreen(); if (base.isServerForObject) { for (int i = 0; i < 20; i++) { float dir = (float)i * 18f - 5f + Rando.Float(10f); ATShrapnel shrap = new ATShrapnel(); shrap.range = 60f + Rando.Float(18f); Bullet bullet = new Bullet(cx + (float)(System.Math.Cos((double)Maths.DegToRad(dir)) * 6.0), cy - (float)(System.Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true); bullet.firedFrom = this; this.firedBullets.Add(bullet); Level.Add(bullet); } System.Collections.Generic.IEnumerable <Window> windows = Level.CheckCircleAll <Window>(this.position, 40f); foreach (Window w in windows) { if (Level.CheckLine <Block>(this.position, w.position, w) == null) { w.Destroy(new DTImpact(this)); } } this.bulletFireIndex += 20; if (Network.isActive) { NMFireGun gunEvent = new NMFireGun(this, this.firedBullets, this.bulletFireIndex, false, 4, false); Send.Message(gunEvent, NetMessagePriority.ReliableOrdered, null); this.firedBullets.Clear(); } } Level.Remove(this); base._destroyed = true; this._explodeFrames = -1; } } } if (base.prevOwner != null && this._cookThrower == null) { this._cookThrower = (base.prevOwner as Duck); this._cookTimeOnThrow = this._timer; } this._sprite.frame = (this._pin ? 0 : 1); }
public MultiplyingBullet(Bullet bullet) : base(bullet) { }
public void AddPoolBullet(Bullet _bullet) { bulletPool.Add(_bullet); }
public static void ClearNonSimpleBullets() { Bullet.ClearAll(); }
//Set weapon to the firs Bullet in the _bullets list (Happens when player dies) void ResetWeapon() { _currentBullet = 1; this._bullet = this._bullets[1]; }
/// <summary> /// Increases a bullet's damage /// </summary> /// <param name="bullet">The bullet to increase damage for</param> public override void OnShoot(Bullet bullet) { bullet.damage.AddModifier(percentageChange); }
private void Awake() { bullet = GetComponent <Bullet>(); movingProjectile = GetComponentInChildren <MovingProjectile>().transform; }
private void Awake() { bullet = GetComponent <Bullet>(); }
public Bullet Shoot(float speed, uint dmg, Direction dir, Vector2 from, Team team, Bullet prefab = null, Action <Bullet> onDestroy = null) { if (prefab == null) { prefab = team == Team.Good ? DefaultBullet : EnemyBullet; } Bullet instance = Instantiate(prefab); instance.Team = team; instance.Speed = speed; instance.Direction = dir; instance.transform.position = from; instance.Dmg = dmg; if (onDestroy != null) { instance.OnDestroy += (s, e) => onDestroy(e.Value); } return(instance); }
public void Activate(Bullet lastBullet) { this.Active = true; this.PrevBullet = lastBullet.thisPosition; list[this.PrevBullet].NextBullet = this.thisPosition; }
// Update is called once per frame public new void Update() { //Set UI healthSlider.value = health / healthMax * 100; healthText.text = health + " / " + healthMax; //Dying if (health <= 0) { gameObject.SetActive(false); } //Set Target to player if (target == null) { target = GameObject.FindGameObjectWithTag("Player"); } //Only do stuff when not kinematic if (rb.isKinematic) { myAnimator.speed = 0; } else { myAnimator.speed = 1; if (!HitState()) { if (myState == states.walking) { applyRootMotion = false; if (target != null) { navMeshAgent.SetDestination(target.transform.position); } myAnimator.Play("Walk"); if (!isRanged) { if (Vector3.Distance(transform.position, target.transform.position) < 1) { myState = states.attackingMelee; } } else { if (Vector3.Distance(transform.position, target.transform.position) < 10) { myState = states.attackingRange; } } } if (myState == states.attackingMelee) { if (!attackStarted) { attackTimer = myAnimClips[attackCounter].length; currentAttackLength = myAnimClips[attackCounter].length; applyRootMotion = true; myAnimator.Play(myAnimClips[attackCounter].name); MeleeProperties.instance.GetProperties(myAnimClips[attackCounter].name, GetComponent <BaseCharacter>(), false); attackStarted = true; if (attackCounter < myAnimClips.Length - 1) { attackCounter += 1; } else { attackCounter = 0; } } else { attackTimer -= Time.deltaTime; if (attackTimer <= 0) { attackStarted = false; if (!(Vector3.Distance(transform.position, target.transform.position) < 1)) { myState = states.walking; } } } } if (myState == states.attackingRange) { if (!rangedAttackStarted) { if (Physics.Raycast(transform.position + Vector3.up, transform.forward, 1000, 1 << 11)) { Bullet bullet = Instantiate(bulletPrefab, transform.position + Vector3.up + transform.forward, Quaternion.identity).GetComponent <Bullet>(); bullet.transform.localScale = bullet.transform.localScale * bulletSize; bullet.myVelocity = transform.forward * bulletSpeed; rangedAttackStarted = true; rangedAttackTimer = 2; myAnimator.Play("PistolShooting"); } } else { rangedAttackTimer -= Time.deltaTime; if (rangedAttackTimer <= 0) { rangedAttackStarted = false; myAnimator.Play("Idle"); } } } } else { applyRootMotion = false; } } }
public abstract void BulletLogicUpdate(Bullet bullet, float deltaTime);
public abstract void OnBulletDestroyed(Bullet bullet);
public static void Update(Bullet bullet, double x, double y, string victimName, bool isActive) { bulletHelper.update(bullet, x, y, victimName, isActive); }
void Awake() { bullet = GetComponent <Bullet>(); data = new Data(); }
public abstract void OnBulletSpawned(Bullet bullet);
void InstantiateBullet() { GameObject BulletGo = GameObject.Instantiate(bulletPrefab, posStartBullet, Quaternion.identity) as GameObject; bullet = BulletGo.GetComponent <Bullet>(); }
private void fire(Vector3 mouseDir) { if (damageDone >= 5 || reloadDelay <= 0.2F) { levelOfWeapon++; damageDone = Math.Max(1, damageDone / 2); reloadDelay = Mathf.Min(0.5F, reloadDelay + 0.15F); } Bullet b = Instantiate(bullet); b.transform.position = transform.position; b.damage = (int)(damageDone * Mathf.Pow(2.3F, levelOfWeapon)); b.shoot(bulletSpeed, mouseDir); /*int centralShot = levelOfWeapon % 2; * int pairLevelOfWeapon = levelOfWeapon-centralShot; * if (1 == centralShot) * { * Bullet b = Instantiate(bullet); * b.transform.position = transform.position; * b.damage = (int)(damageDone * Mathf.Pow(2.3F, levelOfWeapon)); * b.shoot(bulletSpeed, mouseDir); * }*/ // Generate a collision bug where entities are killed twice or more instead of just one... /* * for (int i = 1; i <= pairLevelOfWeapon/2; i++) * { * Bullet b = Instantiate(bullet); * b.transform.position = transform.position; * b.damage = (int)(damageDone * Mathf.Pow(2.3F, levelOfWeapon)); * Vector3 dirrectionBullet = mouseDir; * if ((mouseDir.x > 0 && mouseDir.z > 0) || (mouseDir.x <= 0 && mouseDir.z <= 0)) * { * dirrectionBullet.x += -i; * dirrectionBullet.z += i; * } * else * { * dirrectionBullet.x += i; * dirrectionBullet.z += i; * } * b.shoot(bulletSpeed, dirrectionBullet); * * Bullet b2 = Instantiate(bullet); * b2.transform.position = transform.position; * b2.damage = (int)(damageDone * Mathf.Pow(2.3F, levelOfWeapon)); * dirrectionBullet = mouseDir; * if ((mouseDir.x > 0 && mouseDir.z > 0) || (mouseDir.x <= 0 && mouseDir.z <= 0)) * { * dirrectionBullet.x += i; * dirrectionBullet.z += -i; * } * else * { * dirrectionBullet.x += -i; * dirrectionBullet.z += -i; * } * b2.shoot(bulletSpeed, dirrectionBullet); * } */ GetComponent <AudioSource>().PlayOneShot(BulletShoot, 0.5f); reloadTimer = reloadDelay; }
public void AddToPool(Bullet bulletToAdd) { bulletToAdd.gameObject.SetActive(false); bulletToAdd.transform.position = transform.position; bulletPool.Enqueue(bulletToAdd); }
public void TestCreate() { var bullet = new Bullet(null, null, TargetType.None); }
public BulletRigidBody(Bullet bullet) { this.bullet = bullet; }
public override void Init(Bullet b) { bullet = b; smoke = Instantiate(b.smokePrefab, transform.position, transform.rotation) as GameObject; }
public void TestGetDrawingAction() { var texture = new Bullet(null, null, TargetType.None).GetDrawingAction(); }
public void TestGetTextureFileName() { var textureFileName = new Bullet(null, null, TargetType.None).GetTextureFileName(); Assert.IsTrue(string.IsNullOrEmpty(textureFileName) || textureFileName.ToLower().EndsWith(".png")); }
void setBulletDamage(Bullet bullet) { bullet.setBulletDamage(bulletDamage); }