public void PlayerHit(PlayerControllerComponent player, uint netId, bool sentFromClient = false) { if (!isServer) { return; } // Add new hit for new bomb netId if (!detectedHits.ContainsKey(netId)) { var stat = new List<PlayerHitStat>(); stat.Add(new PlayerHitStat { slot = player.slot, hitOnServer = !sentFromClient, hitOnClient = (player.isLocalPlayer || sentFromClient), addedTime = Time.time }); detectedHits.Add(netId, stat); } else { // Add hit on existing hit if (detectedHits[netId].Where(x => x.slot == player.slot).Count() > 0) detectedHits[netId].Where(x => x.slot == player.slot).ToList().ForEach(x => { if (!x.hitOnServer) x.hitOnServer = !sentFromClient; if (!x.hitOnClient) x.hitOnClient = (player.isLocalPlayer || sentFromClient); }); else detectedHits[netId].Add(new PlayerHitStat { slot = player.slot, hitOnServer = !sentFromClient, hitOnClient = (player.isLocalPlayer || sentFromClient), addedTime = Time.time }); } }
private void Awake() { _player = FindObjectOfType <PlayerControllerComponent>(); _initialMiningDamage = _player.MiningDamage; _player.MiningDamage *= 2; Destroy(gameObject, 30.0f); }
public void onTargetLateUpdate() { if (playerController.currentTarget) { // TODO: update UI components to match the targeted player PlayerControllerComponent pcc = playerController.currentTarget.GetComponent <PlayerControllerComponent>(); if (pcc) { targetName.text = pcc.name; targetHealthText.text = pcc.currentHealth.ToString() + "/" + pcc.totalHealth.ToString(); // TODO: animate the bar lowering down. targetHealthBar.fillAmount = (float)pcc.currentHealth / (float)pcc.totalHealth; targetManaBar.fillAmount = (float)pcc.currentMana / (float)pcc.totalMana; targetPannel.SetActive(true); } } else { // no target targetPannel.SetActive(false); } }
private void OnTriggerEnter2D(Collider2D other) { var player = other.GetComponentInParent <PlayerControllerComponent>(); if (!player) { return; } _isAiming = true; _player = player; }
public TestOldMan(int playerNumber = 0) { mPlayerNumber = playerNumber; mPosition = new PositionComponent(this, 100, 100); mRotation = new RotationComponent(this); //mRenderable = new RenderableComponent(this); mPhysics = new PhysicsComponent(this); mAnimated = new AnimatedComponent(this); mInput = new InputComponent(this); mController = new PlayerControllerComponent(this); mHealth = new HealthComponent(this, 100.0f); }
void LateUpdate() { if (!playerController) { if (!PlayerComponent.localPlayer) { Debug.LogWarning("no local player yet..."); return; } playerController = PlayerComponent.localPlayer.GetComponent <PlayerControllerComponent>(); if (!playerController) { Debug.LogError("no targetingComponent !"); return; } } onTargetLateUpdate(); onPortraitLateUpdate(); }
public TestNess(int playerNumber = 0) { mPlayerNumber = playerNumber; mPosition = new PositionComponent(this, 100, 100); mRotation = new RotationComponent(this); //mRenderable = new RenderableComponent(this); mPhysics = new PhysicsComponent(this); mAnimated = new AnimatedComponent(this); mInput = new InputComponent(this); mController = new PlayerControllerComponent(this); //switch (mPlayerNumber) //{ // case 0: // // Player 0 means no human control. // break; // case 1: // mInput.PlayerIndex = PlayerIndex.One; // break; // case 2: // mInput.PlayerIndex = PlayerIndex.Two; // break; // case 3: // mInput.PlayerIndex = PlayerIndex.Three; // break; // case 4: // mInput.PlayerIndex = PlayerIndex.Four; // break; //} mHealth = new HealthComponent(this, 100.0f); }
private void PlayerDead(PlayerControllerComponent player) { if (_isGameOver) return; SpawnUpgradeInRandomLocation(UpgradeType.Bomb, player.maxNumBombs - 1); SpawnUpgradeInRandomLocation(UpgradeType.Laser, player.bombParams.radius - 2); SpawnUpgradeInRandomLocation(UpgradeType.Kick, player.bombKick); SpawnUpgradeInRandomLocation(UpgradeType.Line, player.bombLine); (LobbyManager.instance.lobbySlots.Where(x => x.slot == player.slot).First() as LobbyPlayer).isAlive = false; if (!_isGameOver) { Invoke("CheckIfGameOver", 2); NetworkServer.Destroy(player.gameObject); } }
void Start() { _animator = gameObject.GetComponent<Animator>(); _player = gameObject.GetComponentInParent<PlayerControllerComponent>(); _isLocalPlayer = _player.isLocalPlayer; _dPad = gameObject.GetComponentInParent<PlayerControllerComponent>().dPad; }
private void Awake() { _ui = FindObjectOfType <UIComponent>(); _player = FindObjectOfType <PlayerControllerComponent>(); _title.text = _item; }
void Start() { Instance = this; _animator = GetComponent <Animator>(); }