IEnumerator Checkoff(Vector3 PreviousPos30, Vector3 PreviousPos20) { Vector3 PreviousPos; if (this.GetComponent <AIPath>().maxSpeed >= 10) { yield return(new WaitForSeconds(2f)); PreviousPos = PreviousPos20; } else { yield return(new WaitForSeconds(3f)); PreviousPos = PreviousPos30; } Debug.Log("STARTCHECK"); Collider2D[] colliders = Physics2D.OverlapCircleAll(PreviousPos, 6f); foreach (Collider2D col in colliders) { if (GameObject.ReferenceEquals(col.gameObject, gameObject)) { PlayerOff player = GameObject.FindGameObjectsWithTag("HostHealth")[0].GetComponent <PlayerOff>(); player.GetDamage(); Debug.Log("Finddd!!!!"); } } }
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "HostHealth") { if (!isOffline & isServer) { Player player = col.gameObject.GetComponent <Player>(); if (CanDoubleDamage) { Debug.Log(col.gameObject); NetPlayer.CmdDecideDoubleDamage(col.gameObject.GetComponent <NetworkIdentity>().netId); } else { player.GetDamage(); } NetworkServer.Destroy(gameObject); } if (isOffline) { PlayerOff player = col.gameObject.GetComponent <PlayerOff>(); player.GetDamage(); Destroy(gameObject); } } if (col.gameObject.tag == "ClientHealth") { if (!isOffline & !isServer) { Player player = col.gameObject.GetComponent <Player>(); if (CanDoubleDamage) { NetPlayer.CmdDecideDoubleDamage(col.gameObject.GetComponent <NetworkIdentity>().netId); } else { player.GetDamage(); } Debug.Log("DEstroy" + gameObject); NetPlayer.CmdDestroy(gameObject.GetComponent <NetworkIdentity>().netId); } if (isOffline) { if (CanDoubleDamage) { float Rate = Random.Range(0f, 100f); PlayerOff player = col.gameObject.GetComponent <PlayerOff>(); EnemySpawnOff SpawnManager = FindObjectsOfType <EnemySpawnOff>()[0].GetComponent <EnemySpawnOff>(); Debug.Log(Rate); Debug.Log(SpawnManager.DoubleDamageRate); if (Rate <= SpawnManager.DoubleDamageRate) { Debug.Log("Double"); player.Lives -= 2; player.UpdateLive(); // player.gameObject.GetComponent<AudioSource>().Play(); if (player.Lives <= 0) { FindObjectsOfType <GameManageNewOff>()[0].GetComponent <GameManageNewOff>().DefineWinLose(player); } Destroy(gameObject); } else { player = col.gameObject.GetComponent <PlayerOff>(); player.GetDamage(); Destroy(gameObject); } } else { PlayerOff player2 = col.gameObject.GetComponent <PlayerOff>(); player2.GetDamage(); Destroy(gameObject); } } } }