TEST

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Test : MonoBehaviour { public string nameEnemy ; public int myAttack ; public int enemyHp ; public int minAttack; public int maxAttack; bool gameOver = false; void Start () { print(nameEnemy+" Appear ! ! !"); print(nameEnemy+" have "+enemyHp+" HP"); } void Update () { if(Input.GetKeyDown(KeyCode.Space) && gameOver == true) { } else if(Input.GetKeyDown(KeyCode.Space) && Criticals() == true ) { Critical (); } else if(Input.GetKeyDown(KeyCode.Space)) { Attack (); } } void Attack() { myAttack = Randomdamage() ; print("SHOOT "+myAttack+" Damage for "+nameEnemy); enemyHp = enemyHp - myAttack; print(nameEnemy+" have "+enemyHp+" HP"); if(enemyHp <= 0) { gameOver = true; print("the game is over"); } } void Critical() { print("CRITICAL"); myAttack = maxAttack*2 ; print("SHOOT "+myAttack+" Damage for "+nameEnemy); enemyHp = enemyHp - myAttack; print(nameEnemy+" have "+enemyHp+" HP"); if(enemyHp <= 0) { gameOver = true; print("the game is over"); } } int Randomdamage () { int ran = Random.Range (minAttack,maxAttack+1); return ran; } bool Criticals() { int rancri = Random.Range (0,11); return rancri == 1 || rancri == 2; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.