public void Upgrade(int turretnum) { NetPlayer.CmdDestroy(turret.GetComponent <NetworkIdentity>().netId); NetPlayer.CmdUpgrade(gameObject.GetComponent <NetworkIdentity>().netId, turretnum, GetBuildPosition()); Player.Money -= turretBlueprint.UpgradeCost; int NewCost = turretBlueprint.cost + turretBlueprint.UpgradeCost; turretBlueprint = new Blueprint(NewCost); }
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); } } } }