void OnCollisionEnter(Collision col) { collisionTag = col.gameObject.tag; if (collisionTag != "Water" || collisionTag != "Ivy") { Destroy(this.gameObject); } if (collisionTag == "Brick") { col.gameObject.GetComponent <BrickScript>().Explode(); } else if (collisionTag == "EnemyTank") { EnemyTankScript enemyTankScript = col.gameObject.GetComponent <EnemyTankScript>(); enemyTankScript.Explode(); EnemyTankScript.setNextID(enemyTankScript.getID()); mapGO.GetComponent <MapScript>().createEnemyTank(); } else if (collisionTag == "Player") { col.gameObject.GetComponent <PlayerTankScript>().gotHit(); } else if (collisionTag == "HeartBase") { Destroy(col.gameObject); GameObject.Find("GameManager").GetComponent <GameManagerSc>().gameOver(); } }
void OnCollisionEnter(Collision hit) { if (networkView.isMine) { if (hit.gameObject.name == "Enemy(Clone)") { EnemyScript script = hit.gameObject.GetComponent("EnemyScript") as EnemyScript; script.GetHit(ap, sp); } else if (hit.gameObject.name == "Tank(Clone)") { EnemyTankScript script = hit.gameObject.GetComponent("EnemyTankScript") as EnemyTankScript; script.GetHit(20000, 20000); } else if (hit.gameObject.tag == "Bullet" || hit.gameObject.tag == "EnemyBullet") { } else { GetHit(5000, 1000); } } }
void Start() { // enemyScript\ mapElements = new string[size, size]; EnemyTankScript.restartLives(); generateMap(); setNavMeshSize(); surface.BuildNavMesh(); }
public void createEnemyTank() { Vector3?position = EnemyTankScript.canCreateTank(); if (position != null) { StartCoroutine(Wait(3f, position.GetValueOrDefault())); } else if (EnemyTankScript.getLives() < -1) { GameObject.Find("GameManager").GetComponent <GameManagerSc>().gameWon(); } }
//bullet hits something void OnCollisionEnter(Collision hit) { if (networkView.isMine) { if (hit.transform.gameObject.name == "Enemy(Clone)") { EnemyScript script = hit.gameObject.GetComponent("EnemyScript") as EnemyScript; script.rpcGetHit(ad, sd); } if (hit.transform.gameObject.name == "EnemyTank(Clone)") { EnemyTankScript script = hit.gameObject.GetComponent("EnemyTankScript") as EnemyTankScript; script.rpcGetHit(ad, sd); } if (hit.transform.gameObject.name == "EnemyBomber") { EnemyBomberScript script = hit.gameObject.GetComponent("EnemyBomberScript") as EnemyBomberScript; script.rpcGetHit(ad, sd); } destroy(); } }
// Update is called once per frame void Update() { if (life > 0) { life -= Time.deltaTime; //check if bullet will hit anything in front of it because bullet moves too fast RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, checkahead)) { if (hit.transform.gameObject.tag == "Objective") { Debug.Log("objective hit"); } if (hit.transform.gameObject.name == "Enemy(Clone)") { EnemyScript script = hit.transform.gameObject.GetComponent("EnemyScript") as EnemyScript; script.rpcGetHit(ad, sd); } if (hit.transform.gameObject.name == "EnemyTank(Clone)") { EnemyTankScript script = hit.transform.gameObject.GetComponent("EnemyTankScript") as EnemyTankScript; script.rpcGetHit(ad, sd); } if (hit.transform.gameObject.name == "EnemyBomber") { EnemyBomberScript script = hit.transform.gameObject.GetComponent("EnemyBomberScript") as EnemyBomberScript; script.rpcGetHit(ad, sd); } destroy(); } } else { destroy(); } }