void Start() { if (UIFade.instance == null) { UIFade.instance = Instantiate(UIScreen).GetComponent <UIFade>(); } if (characterScript.instance == null) { characterScript clone = Instantiate(player).GetComponent <characterScript>(); characterScript.instance = clone; } if (GameManager.instance == null) { GameManager.instance = Instantiate(gameManager).GetComponent <GameManager>(); } }
public void useWeapon(enemyClass enemy, characterScript character) { //improve character attributes if (userAddition == "mag") { character.mag = character.mag + userAdditionValue; } if (userAddition == "pDef") { character.pDef = character.pDef + userAdditionValue; } if (userAddition == "spd") { character.spd = character.spd + userAdditionValue; } if (userAddition == "dex") { character.dex = character.dex + userAdditionValue; } if (userAddition == "mdef") { character.mDef = character.mDef + userAdditionValue; } if (userAddition == "atk") { character.atk = character.atk + userAdditionValue; } character.status = characterStatusChange; //shows current addition to status "Magic UP + 5" System.Random r = new System.Random(); float num = r.Next(0, 1); //critical attack chance if (num == this.criticalHitChance) { this.attackDamage = attackDamage * 5; } //character attack is added with weapon attack and enemies health is decreased character.atk = character.atk + attackDamage; enemy.hp = enemy.hp - character.atk; //checking the repair status of weapon float newNum = r.Next(0, 20); if (newNum == 3) { this.weaponHealth -= 20; } if (this.weaponHealth == 100) { this.weaponStatus = "Perfect Health!"; } if (this.weaponHealth < 100 && this.weaponHealth >= 30) { this.weaponStatus = "Average Health!"; } if (this.weaponHealth < 30) { this.weaponStatus = "Repair Soon!"; } if (this.weaponHealth <= 0) { this.weaponHealth = 0; this.weaponStatus = "Broken!"; this.attackDamage = 0; } }