public override void Initialize(WeaponSocket weaponSocket, Weapon weapon, WeaponHud hud, AimOrigin aimOrigin, HitEvent hitEvent) { base.Initialize(weaponSocket, weapon, hud, aimOrigin, hitEvent); m_hitEffect = Instantiate(weapon.HitEffect); m_chargeEffect = Instantiate(weapon.ChargeEffect, WeaponObject.transform, false); m_chargeEffect.transform.localPosition = Weapon.MuzzleFlashOffset; //Get Components to Handle Effects var lineEffects = Instantiate(Weapon.TrailEffect, MuzzleFlash.transform, false); m_lineRender = lineEffects.GetComponent <LineRenderer>(); m_lineRender.transform.localPosition = new Vector3(0, 0, 0); m_lineRender.positionCount = 2; m_lineRender.widthMultiplier = Weapon.RayThickness * 10; m_lineRender.enabled = false; m_lineAnimation = lineEffects.GetComponent <LineAnimation>(); }
private void OnCollisionEnter(Collision collision) { if (_pickedUp) { return; } GameObject gameObject = collision.gameObject; DartBoard dartBoard = gameObject.GetComponentInParent <DartBoard>(); if (dartBoard != null) { _stuckInDartBoard = true; _audioSource.pitch = 1.2f + Random.value * 0.2f; _audioSource.PlayOneShot(HitClip, 1.0f); } HitEvent?.Invoke(this, gameObject); }
public static void HandleHitEvent(HitEvent hitEvent) { switch (hitEvent.EventType) { case 1: PlayerInfo hitPlayer = playerList[hitEvent.PlayerNum]; BulletInfo hitBullet = bulletList[hitEvent.BulletNum]; Debug.Log("hitBullet : " + hitBullet); hitPlayer.playerHealth -= hitBullet.bulletDamage; Destroy(hitBullet.gameObject); break; case 2: Destroy(playerList[hitEvent.PlayerNum].gameObject); break; default: break; } }
private void OnHit(HitEvent hei) { if (GetParent().Name == hei.target.Name) { //Reduce the tanks health with the given amount health -= hei.damage; //Check if the health has gone down to zero CheckHealth(); if (hei.target.IsInGroup("Player")) { //Broadcast the health after it has been modified to anyone who is listening SendHealthEvent shei = new SendHealthEvent(); shei.health = health; shei.target = hei.target; shei.FireEvent(); } } }
/// <summary>Deals Damage to Targets.</summary> private void ApplyDamage(int targetCount, float damage) { for (var i = 0; i < targetCount; i++) { var target = m_hits[i].transform.gameObject; if (!PlayerHelper.ValidateTarget(target)) { continue; } var damageableTarget = target.GetComponent <IDamageable>(); var hitted = damageableTarget.ApplyDamage(damage); if (hitted) { HitEvent.Invoke(); ScriptableTextDisplay.Instance.InitializeScriptableText(0, target.transform.position, damage.ToString()); } } }
private void OnMouseDown() { if (!_isFreezed) { clicksToDestroy--; HitEvent?.Invoke(); if (clicksToDestroy <= 0) { gameProxy.AddScore(score); DieEvent?.Invoke(); explodable.generateFragments(); foreach (var fragment in explodable.fragments) { fragment.AddComponent <ObjectCleaner>(); } gameProxy.AddTime(timeAddedOnDestroy); gameProxy.ExplosionForce.doExplosion(transform.position); explodable.explode(); } } }
void FixedUpdate() { ray = mainCamera.ScreenPointToRay(mainCamera.WorldToScreenPoint(transform.position)); //проверяется пересечение сферы с коллайдерами Physics.SphereCast(ray, _radius, out hit); if (hit.collider != null) { HitEvent?.Invoke(hit); //событие столкновения if (IsSolid) //если сфера "твердая", рассчитываем направление отскока { Vector2 normal = new Vector2(Mathf.Round(hit.normal.x), Mathf.Round(hit.normal.y)); SetVelocity(Vector2.Reflect(velocity, normal).normalized *velocity.magnitude); } } if (velocity.magnitude != 0) //если вектор скорости не нулевой, двигаем сферу { transform.Translate(velocity * Time.fixedDeltaTime); } }
void BubbleHitEvent(HitEvent e) { if (e.eventType == HitEvent.Type.Spawn) { SpawnHit(e.collider, e.bubble); } else { currentBubbles.Remove(e.bubble); currentBubbleConfigs.Remove(e.bubble.GetComponent <Bubble>()); for (int i = 0; i < currentBubbleConfigs.Count; i++) { Transform target = (i > 0) ? currentBubbles[i - 1].transform : transform; currentBubbleConfigs[i].target = target; } Destroy(e.bubble); } }
/// <summary> /// Checks if Weapon is able to Shoot, applies Damage, Reduce ammo, Camera Shake and Push back. /// </summary> public override void Shoot() { if (WeaponCollision.IsColliding() || IsReloading) { IsShooting = false; return; } IsShooting = true; if (Time.time <= CooldownCollapsed) { return; } if (m_target != null && PlayerHelper.ValidateTarget(m_target)) { var hitted = m_target.GetComponent <IDamageable>().ApplyDamage(Weapon.Damage); if (hitted) { HitEvent.Invoke(); ScriptableTextDisplay.Instance.InitializeStackingScriptableText(5, m_target.transform.position, Weapon.Damage.ToString(), m_target.name); } } //PushBack PushBack(); //Ammo ReduceAmmo(); //Camera Shake CameraShake.StartShake(Weapon.ShakeProfile); CooldownCollapsed = Time.time + Weapon.FireRate; }
public void CreateExplosionOnEachTarget(HitEvent evt, WeaponNode weapon) { HitExplosionGraphicsComponent hitExplosionGraphics = weapon.hitExplosionGraphics; Vector3 fireDirectionWorld = new MuzzleVisualAccessor(weapon.muzzlePoint).GetFireDirectionWorld(); foreach (HitTarget target in evt.Targets) { ExplosionEvent eventInstance = new ExplosionEvent { ExplosionOffset = -fireDirectionWorld * hitExplosionGraphics.ExplosionOffset, HitDirection = target.HitDirection, Asset = hitExplosionGraphics.ExplosionAsset, Duration = hitExplosionGraphics.ExplosionDuration, Target = target }; base.ScheduleEvent(eventInstance, target.Entity); } if (evt.StaticHit != null) { Vector3 position = evt.StaticHit.Position - (fireDirectionWorld * hitExplosionGraphics.ExplosionOffset); this.DrawExplosionEffect(position, evt.StaticHit.Normal, hitExplosionGraphics.ExplosionAsset, hitExplosionGraphics.ExplosionDuration, weapon); } }
void spawnStepNote(GameObject ring, Transform spawner, HitEvent hitObject, KeyCode key) { if (hitObject.IsHold()) { int offsetDiff = hitObject.getEndOffset() - hitObject.getOffset(); StopCoroutine(spawnStepHold(ring, spawner, hitObject, offsetDiff, key)); StartCoroutine(spawnStepHold(ring, spawner, hitObject, offsetDiff, key)); } else { var currentRing = Instantiate(ring, spawner.position, spawner.rotation); currentRing.transform.SetParent(noteHolder.transform); currentRing.transform.localScale = ring.transform.localScale; if (hitObject.IsMine()) { currentRing.AddComponent <Mine>().Initialize(spawner.position, hitbox.transform.position, hitObject.getOffset(), scrollDelay, key, hitObject); } else { currentRing.AddComponent <Ring>().Initialize(spawner.position, hitbox.transform.position, hitObject.getOffset(), scrollDelay, key, hitObject); } } }
public void CreateHitSoundEffect(HitEvent evt, HammerHitSoundEffectNode weapon, [JoinAll] SingleNode <SoundListenerBattleStateComponent> soundListener) { List <HitTarget> targets = evt.Targets; HammerHitSoundEffectComponent hammerHitSoundEffect = weapon.hammerHitSoundEffect; if (targets != null) { int count = targets.Count; if (count > 0) { List <HitTarget> differentTargetsByHit = hammerHitSoundEffect.DifferentTargetsByHit; differentTargetsByHit.Clear(); for (int i = 0; i < count; i++) { HitTarget item = targets[i]; if (!differentTargetsByHit.Contains(item)) { differentTargetsByHit.Add(item); } } Vector3 zero = Vector3.zero; int num3 = differentTargetsByHit.Count; for (int j = 0; j < num3; j++) { zero += differentTargetsByHit[j].TargetPosition; } zero /= (float)num3; base.CreateHitExplosionSoundEffect(zero, hammerHitSoundEffect.TargetHitSoundAsset, hammerHitSoundEffect.TargetHitSoundDuration); return; } } if (evt.StaticHit != null) { GameObject staticHitSoundAsset = hammerHitSoundEffect.StaticHitSoundAsset; base.CreateHitExplosionSoundEffect(evt.StaticHit.Position, staticHitSoundAsset, hammerHitSoundEffect.StaticHitSoundDuration); } }
void spawnMemoryNote(GameObject ring, Transform spawner, HitEvent hitObject, KeyCode key) { if (MemoryNoteManager.Instance.currentMemorySequence.Count > 0) { HitEvent memNote = MemoryNoteManager.Instance.currentMemorySequence.Dequeue(); var currentRing = Instantiate(ring, spawner.localPosition, Quaternion.identity); currentRing.transform.SetParent(diamondHolder.transform, false); hitObject.setPlayMode(FetchNotePlayMode(hitObject)); currentRing.GetComponent <DiamondRing>().Initialize(diamondHitbox.transform.localScale, hitObject.getOffset(), scrollDelay, hitObject); if (hitObject.getColorIntArray().Length == 4) { colorIntArray = hitObject.getColorIntArray(); } int intKey = Array.IndexOf(colorIntArray, memNote.getKey()); switch (intKey) { case 0: // LEFT currentRing.GetComponent <DiamondRing>().keyCode = keyLeft; break; case 1: // DOWN currentRing.GetComponent <DiamondRing>().keyCode = keyDown; break; case 2: // UP currentRing.GetComponent <DiamondRing>().keyCode = keyUp; break; case 3: // RIGHT currentRing.GetComponent <DiamondRing>().keyCode = keyRight; break; default: break; } } }
public virtual void Initialize(WeaponSocket weaponSocket, Weapon weapon, WeaponHud hud, AimOrigin aimOrigin, HitEvent hitEvent) { PhotonView = GetComponent<PhotonView>(); m_rigidbody = GetComponent<Rigidbody>(); WeaponAudio = GetComponent<AudioSource>(); m_shield = GetComponent<Shield>(); m_playerMovementModel = GetComponent<PlayerMovementModel>(); HitEvent = hitEvent; m_weaponHud = hud; WeaponSocket = weaponSocket; Weapon = weapon; AimOrigin = aimOrigin; CameraShake = CameraShake.Instance; CreateWeapon(); CreateMuzzleFlash(); WeaponCollision = WeaponObject.GetComponent<WeaponCollision>(); m_currentAmmo = Weapon.AmmoClip; m_weaponHud.SetAmmoAmount(m_currentAmmo, Weapon.AmmoClip); }
void FetchCurrentNote() { while (index < hitEventsList.Count) { //gets latest timing points offsetTime = (AudioSettings.dspTime - startTime) * 1000 + scrollDelay; //Debug.Log("OFFSET TIME: " + offsetTime); if (timingIndex < timingPointsList.Count && offsetTime >= timingPointsList[timingIndex].getOffset()) { scrollDelay = delayHandler.GetComponent <DelayHandler>().UpdateBPM(timingPointsList[timingIndex].getMsPerBeat()); if (timingPointsList[timingIndex].getPlaymode() == 0) // step { baseScore = noteBaseScore; memoryMode = false; invertedMemoryMode = false; } else { baseScore = memoryBaseScore; memoryMode = timingPointsList[timingIndex].getPlaymode() == 1 ? true : false; invertedMemoryMode = timingPointsList[timingIndex].getPlaymode() == -1 ? true : false; } timingIndex++; } noteOffsetTime = (AudioSettings.dspTime - startTime) * 1000; noteOffsetTime += scrollDelay; HitEvent hitObject = hitEventsList[index]; if (noteOffsetTime >= hitObject.getOffset()) { //Debug.Log("Note " + hitObject.getOffset() + " Spawn time: " + offsetTime + "\nNote offset: " + noteOffsetTime); if ((hitObject.IsNote() || hitObject.IsHold()) && !noteFlag) { spawnNotes(hitObject); } noteFlag = true; if (hitObject.isFlashYellow() || hitObject.isFlashGreen() || hitObject.isFlashRed() || hitObject.isFlashBlue()) { HitEvent memoryNote = new HitEvent(); memoryNote.setSequenceStart(isSequenceStart); if (hitObject.isFlashYellow()) { StartCoroutine(FlashMemoryPrompt("yellow", hitObject.IsflashBlack())); memoryNote.setKey("0"); memorySequence.Enqueue(memoryNote); } if (hitObject.isFlashGreen()) { StartCoroutine(FlashMemoryPrompt("green", hitObject.IsflashBlack())); memoryNote.setKey("1"); memorySequence.Enqueue(memoryNote); } if (hitObject.isFlashRed()) { StartCoroutine(FlashMemoryPrompt("red", hitObject.IsflashBlack())); memoryNote.setKey("2"); memorySequence.Enqueue(memoryNote); } if (hitObject.isFlashBlue()) { StartCoroutine(FlashMemoryPrompt("blue", hitObject.IsflashBlack())); memoryNote.setKey("3"); memorySequence.Enqueue(memoryNote); } isSequenceStart = false; } else { isSequenceStart = true; } if (index + 1 < hitEventsList.Count) { HitEvent nextHitObject = hitEventsList[index + 1]; int nextHitMode = FetchNotePlayMode(nextHitObject); // Check if the next note is a memory input corresponding to the start of memory sequence if (memorySequence.Count > 0) { if (nextHitMode != 0 && nextHitObject.IsNote() && memorySequence.Peek().isSequenceStart()) { StopCoroutine(HandleMemoryStart(nextHitObject, nextHitMode)); StartCoroutine(HandleMemoryStart(nextHitObject, nextHitMode)); } } StopCoroutine(HandleMemorySprites(hitObject, FetchNotePlayMode(hitObject))); StartCoroutine(HandleMemorySprites(hitObject, FetchNotePlayMode(hitObject))); } } else // if next hit object doesn't need to be spawned now { break; } noteFlag = false; index++; } }
// Called when the node enters the scene tree for the first time. public override void _Ready() { HitEvent.RegisterListener(OnHit); }
public void spawnNotes(HitEvent hitObject) { switch (hitObject.getKey()) { case 0: // LEFT if (memoryMode || invertedMemoryMode) // Currently in a memory timing section { spawnMemoryNote(diamondRing, diamondRing.transform, hitObject, keyLeft); } else if (hitObject.IsMine()) { spawnStepNote(bigMine, leftSpawnerBig, hitObject, keyLeft); } else { spawnStepNote(bigRing, leftSpawnerBig, hitObject, keyLeft); } break; case 1: // DOWN if (memoryMode || invertedMemoryMode) { spawnMemoryNote(diamondRing, diamondRing.transform, hitObject, keyDown); } else if (hitObject.IsMine()) { spawnStepNote(smallMine, leftSpawnerSmall, hitObject, keyDown); } else { spawnStepNote(smallRing, leftSpawnerSmall, hitObject, keyDown); } break; case 2: // UP if (memoryMode || invertedMemoryMode) { spawnMemoryNote(diamondRing, diamondRing.transform, hitObject, keyUp); } else if (hitObject.IsMine()) { spawnStepNote(smallMine, rightSpawnerSmall, hitObject, keyUp); } else { spawnStepNote(smallRing, rightSpawnerSmall, hitObject, keyUp); } break; case 3: // RIGHT if (memoryMode || invertedMemoryMode) { spawnMemoryNote(diamondRing, diamondRing.transform, hitObject, keyRight); } else if (hitObject.IsMine()) { spawnStepNote(bigMine, rightSpawnerBig, hitObject, keyRight); } else { spawnStepNote(bigRing, rightSpawnerBig, hitObject, keyRight); } break; default: break; } }
public Tile() { OnHit = null; Status = TileStatus.OpenOcean; }
public void Initialize(Vector3 hitboxScale, float beatOfThisNote, float beatsShownInAdvance, HitEvent currentNote) { this.hitboxScale = hitboxScale; this.beatOfThisNote = beatOfThisNote; this.beatsShownInAdvance = beatsShownInAdvance; this.currentNote = currentNote; }
private static void Invoke(HitEvent eve, params GameObject[] obj) { eve.Invoke(obj); }
protected virtual void OnHitEvent(ProjectileHitEventArgs e) { HitEvent?.Invoke(this, e); }
public override void _ExitTree() { HitEvent.UnregisterListener(OnHit); }
public void PlayHitEvent() => HitEvent?.Invoke();
private void Hit(HitEvent hit) { //Play hit sound depending on who hit who }
public void Initialize(Vector3 spawner, Vector3 hitbox, int offset, float scrollDelay, KeyCode key, GameObject startRing, GameObject endRing, HitEvent currentNote) { spawnerPos = spawner; hitboxPos = hitbox; beatOfThisNote = Convert.ToSingle(offset); beatsShownInAdvance = scrollDelay; keyCode = key; this.startRing = startRing; this.endRing = endRing; transform.localScale = new Vector3(startRing.transform.localScale.x, 1f, 1f); this.currentNote = currentNote; }
public void Initialize(Vector3 spawner, Vector3 hitbox, int offset, float scrollDelay, KeyCode key, HitEvent currentNote) { spawnerPos = spawner; hitboxPos = hitbox; beatOfThisNote = Convert.ToSingle(offset); beatsShownInAdvance = scrollDelay; keyCode = key; this.currentNote = currentNote; }
void Result() { HitEvent.FinPlay(); }
public void PrepareImpact(HitEvent evt, ImpactWeakeningNode weapon) { this.PrepareImpactByBaseHitEvent(evt, weapon); }
private static void OnHit() { HitEvent?.Invoke(); }
public void ParseLevel(string filename) { // Read the file and display it line by line. string line; bool timingPointsStart = false; bool hitEventsStart = false; string[] tmp; System.IO.StreamReader file = new System.IO.StreamReader(filename); while ((line = file.ReadLine()) != null) { System.Console.WriteLine(line); line = line.Trim(); if (line.Length == 0 || line[0] == '/') { continue; } //Debug.Log(line); if (line == "[TimingPoints]") { //Debug.Log("TimingPoints start"); hitEventsStart = false; timingPointsStart = true; continue; } if (line == "[HitEvents]") { //Debug.Log("hitobject start"); hitEventsStart = true; timingPointsStart = false; continue; } if (hitEventsStart) { //Debug.Log(line); tmp = line.Split(','); HitEvent hitEvents = new HitEvent(); hitEvents.setKey(tmp[0]); hitEvents.setOffset(tmp[1]); hitEvents.setIsNote(tmp[2]); hitEvents.setIsMine(tmp[2]); hitEvents.setColour(tmp[2]); hitEvents.setFlashBlack(tmp[2]); hitEvents.setIsHold(tmp[2]); if (tmp.Length < 5) { if (tmp.Length == 4) { hitEvents.setColorArray(tmp[3]); } } else { hitEvents.setEndOffset(tmp[3]); hitEvents.setColorArray(tmp[4]); } GameManager.Instance.hitEventsList.Add(hitEvents); } if (timingPointsStart) { tmp = line.Split(','); TimingPoints timingPoints = new TimingPoints(Convert.ToInt32(tmp[0]), Convert.ToSingle(tmp[1]), Convert.ToInt32(tmp[2]), Convert.ToInt32(tmp[3]), Convert.ToInt32(tmp[4])); GameManager.Instance.timingPointsList.Add(timingPoints); } } file.Close(); }