private void OnTriggerStay2D(Collider2D other) { if (other.tag == "Player" && nextDamage < Time.time) { playerhealth actualhealth = other.gameObject.GetComponent <playerhealth>(); actualhealth.addamage(damage); nextDamage = Time.time + damageweight; } pushback(other.transform); }
private void RpcCollision() { ScoreCounter fruitscore = FindObjectOfType <ScoreCounter>(); fruitscore.FruitPoints(); playerhealth Playerhealth = GameObject.FindObjectOfType <playerhealth>(); Playerhealth.health++; if (FindObjectsOfType <kersTimer>().Length == 1) { kersTimer timerAnimation = FindObjectOfType <kersTimer>(); timerAnimation.KersTimer(); } PlayerOnline[] Players = FindObjectsOfType <PlayerOnline>(); foreach (PlayerOnline player in Players) { player.AddToGridList((int)gameObject.transform.localPosition.x, (int)gameObject.transform.localPosition.z); } Destroy(gameObject); }
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader) { int id = 0; if (extraMessageReader != null) { Debug.Log("we"); var i = extraMessageReader.ReadMessage <IntegerMessage>(); id = i.value; } Debug.Log("disacks"); // Transform chosenSpawnPoint = NetworkManager.singleton.startPositions[Random.Range(0, NetworkManager.singleton.startPositions.Count)]; TeamRed spawn = GetComponent <TeamRed>(); playerhealth spawns = GetComponent <playerhealth>(); Team tele = GetComponent <Team>(); if (characterSelected == 0) { GameObject player = Instantiate(characterPrefabs[id], redspawnpoints[1].position, redspawnpoints[1].rotation) as GameObject; NetworkServer.AddPlayerForConnection(conn, player, playerControllerID); Debug.Log("t44444try"); player.GetComponent <Team>().CmdTele(player); } else { GameObject player = Instantiate(characterPrefabs[id], greenspawnpoints[0].position, greenspawnpoints[0].rotation) as GameObject; NetworkServer.AddPlayerForConnection(conn, player, playerControllerID); Debug.Log("destory53"); player.GetComponent <Team>().CmdTele(player); Debug.Log("destory53"); //Object.Destroy(player); spawns.SelectSpawnPoint(); } }
private void RpcDeathSequence(GameObject Ghost) { GameObject fx = Instantiate(DeathFX, transform.position, Quaternion.identity); fx.transform.parent = parent; if (gameObject.tag == "Player") { // Checken welke UI en vuurwerk kleur moeten gebruiken als pacman door een geestje dood gaat switch (Ghost.GetComponent <Movement>().name) { case "Blue": KillText("Blue"); Instantiate(FireWorks[0]); break; case "Red": KillText("Red"); Instantiate(FireWorks[1]); break; case "Pink": KillText("Pink"); Instantiate(FireWorks[2]); break; case "Orange": KillText("Orange"); Instantiate(FireWorks[3]); break; } playerhealth Health = FindObjectOfType <playerhealth>(); Health.DecreaseHealth(); SendMessage("StartDeathSequence"); } else //Dit is wat er moet gebeuren als de decoy een geest raakt { Destroy(gameObject); } }
// public int tee = GetComponent<player_controler>().TeamIde; //dimples void OnCollisionEnter(Collision collision) { // collision for dimples GameObject hit = collision.gameObject; Debug.Log(hit); Collider coli = hit.GetComponent <Collider>(); playerhealth health = hit.GetComponent <playerhealth>(); Debug.Log(health); // collision for cyborg GameObject hit2 = collision.gameObject; Player_health health2 = hit.GetComponent <Player_health>(); Team mytm = this.GetComponent <Team>(); Team tm = hit.GetComponent <Team>(); //int help = GetComponent<player_controler>().TeamIde; // help = tee; //|| tm.TeamId != mytm.TeamId TeamRed red = GetComponent <TeamRed>(); TeamGreen green = GetComponent <TeamGreen>(); try { Debug.Log("haha1"); bool yesred = hit.GetComponent <TeamRed>().red; // bool yesgreen= hit.GetComponent<TeamGreen>().green; if (yesred == true) { if (coli.CompareTag("Dimples") || hit.CompareTag("Dimples")) { try { TeamRed red4 = GetComponent <TeamRed>(); Debug.Log(red4); if (yesred == true && red4 == null) { if (health != null) { Debug.Log("green1"); Debug.Log("12"); health.TakeDamage(10); } if (health2 != null) { health2.DeductHealth(10); } ////TeamRed green4 = GetComponent<TeamRed>(); Debug.Log("green7779"); return; } else { //TeamRed green4 = GetComponent<TeamRed>(); Debug.Log("green5389"); return; } } catch (NullReferenceException) { if (health != null) { Debug.Log("green1"); Debug.Log("12"); health.TakeDamage(10); } if (health2 != null) { health2.DeductHealth(10); } Debug.Log("green89"); } return; } } } catch (NullReferenceException) { if (health != null) { try { bool yesgreen = hit.GetComponent <TeamGreen>().green; TeamRed myred = GetComponent <TeamRed>(); if (yesgreen == true && myred == false) { Debug.Log("green0"); return; } else { if (health != null) { Debug.Log("green1"); Debug.Log("12"); health.TakeDamage(10); } if (health2 != null) { health2.DeductHealth(10); } } } catch (NullReferenceException) { if (health != null) { Debug.Log("green2"); Debug.Log("dse 13 555"); health.TakeDamage(10); } if (health2 != null) { health2.DeductHealth(10); } } } if (health2 != null) { health2.DeductHealth(10); } } if (tm == null || tm.TeamId != mytm.TeamId) { Debug.Log("haha2"); Debug.Log("are you coming here4"); Debug.Log("dse are here"); Debug.Log("dse are 444"); health.TakeDamage(10); if (health != null) { Debug.Log("dse are 555"); health.TakeDamage(10); } if (health2 != null) { health2.DeductHealth(10); } Destroy(gameObject); } }
void Start() { target = FindObjectOfType <playerhealth>(); }