protected virtual void HandlePlayerCreate(ZMPlayerInfoEventArgs args) { if (_playerInfo == args.info) { _playerController = args.info.GetComponent <ZMPlayerController>(); } }
private void KillOpponent(ZMPlayerController playerController) { if (playerController.IsAbleToDie()) { var playerArgs = new ZMPlayerControllerEventArgs(this); playerController.KillSelf(this); Notifier.SendEventNotification(OnPlayerKill, playerArgs); // add the stat ZMStatTracker.Kills.Add(_playerInfo); } }
private void KillSelf(ZMPlayerController killer) { GameObject body; var infoArgs = new ZMPlayerInfoEventArgs(_playerInfo); _moveModState = MoveModState.RESPAWN; _controlModState = ControlModState.NEUTRAL; _controlMoveState = ControlMoveState.NEUTRAL; Notifier.SendEventNotification(OnPlayerDeath, infoArgs); Utilities.StopDelayRoutine(_endLungeCoroutine); Utilities.StopDelayRoutine(_resetControlModCoroutine); Utilities.StopDelayRoutine(_enablePlayerCoroutine); // Handle death visuals here _material.color = Color.red; _light.enabled = false; _spriteRenderer.enabled = false; // load and instantiate the body's upper half body = GameObject.Instantiate(_upperBodyTemplate) as GameObject; body.transform.position = transform.position; ZMAddForce upperBody = body.GetComponent <ZMAddForce>(); upperBody.ParticleColor = _light.color; upperBody.AddForce(new Vector2(killer.runSpeed / 12, 0)); // load and instantiate the body's lower half body = GameObject.Instantiate(_lowerBodyTemplate) as GameObject; body.transform.position = transform.position; ZMAddForce lowerBody = body.GetComponent <ZMAddForce>(); lowerBody.ParticleColor = _light.color; lowerBody.AddForce(new Vector2(killer.runSpeed / 12, 0)); // Set player states _playerInPath = false; ClearInputEvents(); _audio.PlayOneShot(_audioGore[Random.Range(0, _audioGore.Length)]); _audio.PlayOneShot(_audioHurt[Random.Range(0, _audioHurt.Length)]); _audio.PlayOneShot(_audioKill[Random.Range(0, _audioKill.Length)]); _goreEmitter.Play(); }
protected ZMPlayerController CreatePlayer(int id) { var player = ZMPlayerController.Instantiate(playerTemplate) as ZMPlayerController; var score = player.GetComponent <ZMScoreController>(); var input = player.GetComponent <ZMPlayerInputController>(); player.ConfigureItemWithID(transform, id); _players[player.PlayerInfo.ID] = player; _players[player.PlayerInfo.ID].transform.position = _playerStartPoints[player.PlayerInfo.ID].position; _scores[player.PlayerInfo.ID] = score; score.ConfigureItemWithID(player.PlayerInfo.ID); input.ConfigureItemWithID(player.PlayerInfo.ID); _latestJoinIndex = id; return(player); }
public virtual void ConfigureItemWithID(Transform parent, int id) { _playerInfo = GetComponent <ZMPlayerInfo>(); _playerInfo.ID = id; _playerInfo.standardColor = Configuration.PlayerColors[id]; _playerInfo.lightColor = Configuration.PlayerLightColors[id]; if (_playerController == null) { _playerController = ZMPlayerManager.Instance.Players[_playerInfo.ID]; } if (parent != null) { transform.SetParent(parent); } ConfigureHierarchyColor(); }
public ZMPlayerControllerEventArgs(ZMPlayerController playerController) { controller = playerController; }
public ZMPlayerControllerFloatEventArgs(ZMPlayerController playerController, float valueParam) { controller = playerController; value = valueParam; }
private void HandlePlayerKillEvent(ZMPlayerController killer) { Settings.LobbyKillcount.value[killer.PlayerInfo.ID] += 1; }
void onControllerCollider(RaycastHit2D hit) { if (hit.collider.gameObject.layer == LayerMask.NameToLayer(LayerMaskNames.kGroundLayerMaskName)) { if (Mathf.Abs(hit.normal.x) > 0) { if (_moveModState == MoveModState.RESPAWN) { if (Mathf.Abs(runSpeed) > FRICTION) { runSpeed *= -0.9f; _audio.PlayOneShot(_audioBash[Random.Range(0, _audioBash.Length)], runSpeed / RUN_SPEED_MAX); } } } } if (hit.collider.gameObject.layer == LayerMask.NameToLayer(LayerMaskNames.kSpecialInteractiblesLayerMaskName)) { if (hit.normal.y == 1.0f) { if (hit.collider.CompareTag(Tags.kPlayerTag)) { ZMPlayerController otherPlayer = hit.collider.GetComponent <ZMPlayerController>(); if (IsPlunging()) { KillOpponent(otherPlayer); } } else if (hit.collider.CompareTag(Tags.kBreakable)) { if (IsPlunging()) { hit.collider.GetComponent <ZMBreakable>().HandleCollision(_playerInfo); } } } if (hit.normal.x == -1.0f || hit.normal.x == 1.0f) { // See if we hit a player. if (IsLunging()) { if (hit.collider.CompareTag(Tags.kPlayerTag)) { ZMPlayerController otherPlayer = hit.collider.GetComponent <ZMPlayerController>(); if (_playerInPath && otherPlayer._playerInPath) { if (_movementDirection != otherPlayer._movementDirection) { Utilities.StopDelayRoutine(_endLungeCoroutine); _moveModState = MoveModState.RECOIL; } } else if (otherPlayer._moveModState == MoveModState.PARRY_FACING && IsOpposingDirection(otherPlayer)) { if (otherPlayer._canStun) { _moveModState = MoveModState.STUN; _audio.PlayOneShot(_audioRecoil); } else { _moveModState = MoveModState.RECOIL; _audio.PlayOneShot(_audioSword[Random.Range(0, _audioSword.Length)], 1.0f); } } else if (otherPlayer._moveModState == MoveModState.PARRY_AOE) { _moveModState = MoveModState.RECOIL; } else { _playerInPath = false; KillOpponent(otherPlayer); } } else if (hit.collider.CompareTag("Breakable")) { hit.collider.GetComponent <ZMBreakable>().HandleCollision(_playerInfo); } } } // Check for collision with volume. if (hit.collider.CompareTag(Tags.kWarpVolume)) { GetComponent <ZMWarpController>().OnTriggerEnterCC2D(hit.collider); } } }
private bool IsOpposingDirection(ZMPlayerController otherPlayer) { return(_movementDirection != otherPlayer._movementDirection); }
protected virtual void SpawnPlayer(ZMPlayerController playerController) { playerController.Respawn(GetFarthestSpawnPosition()); }
protected override void SpawnPlayer(ZMPlayerController playerController) { playerController.Respawn(GetPlayerSpawnPosition(playerController.PlayerInfo)); }