• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Jermainek369 · May 09, 2016 at 09:51 AM · arrayrandomclassweapongenerator

How to create Random Stats matching the weapons?

using UnityEngine; using System.Collections;

public class RandomScript : MonoBehaviour {

 int weaponDamage;
 int weaponSpeed;

 string weaponName;

 public string weaponStrength;
 public string weaponType;
 public int weaponDmge;
 public int weaponSpd;
 public bool classSpecific;
 public string myClass;


 string[] weaponTypes = new string[35];
 string[] weaponStrengths = new string[16];
 string[] classTypes = new string[3];



 void Start ()
 {
     weaponTypes[0] = "Sword";
     weaponTypes [1] = "Mace";
     weaponTypes [2] = "Spear";
     weaponTypes [3] = "Dagger";
     weaponTypes [4] = "Short Bow";
     weaponTypes [5] = "Compisite Bow";
     weaponTypes [6] = "Long Bow";
     weaponTypes [7] = "Stick";
     weaponTypes [8] = "Wand";
     weaponTypes [9] = "Staff";
     weaponTypes [10] = "Long Sword";
     weaponTypes [11] = "Claymore";
     weaponTypes [12] = "Rapier";
     weaponTypes [13] = "Twin Blades";
     weaponTypes [14] = "GreatSword";
     weaponTypes [15] = "Shield";
     weaponTypes [16] = "Claw";
     weaponTypes [17] = "Katana";
     weaponTypes [18] = "Spear";
     weaponTypes [19] = "Scythe";
     weaponTypes [20] = "Axe";
     weaponTypes [21] = "Great Axe";
     weaponTypes [22] = "Hammer";
     weaponTypes [23] = "Falchion";
     weaponTypes [24] = "Caestus";
     weaponTypes [25] = "Halberds";
     weaponTypes [26] = "Whip";
     weaponTypes [27] = "Great Bow";
     weaponTypes [28] = "Crossbow";
     weaponTypes [29] = "Talisman";
     weaponTypes [30] = "Pike";


     weaponStrengths[0] = "Strong";
     weaponStrengths [1] = "";
     weaponStrengths [2] = "Weak";
     weaponStrengths [3] = "Ultra";
     weaponStrengths [4] = "Broken";
     weaponStrengths [5] = "Great";
     weaponStrengths [6] = "Awsome";
     weaponStrengths [7] = "Deamon";
     weaponStrengths [8] = "Vampyric";
     weaponStrengths [9] = "Holy";
     weaponStrengths [10] = "Magical";
     weaponStrengths [11] = "Cool";
     weaponStrengths [12] = "Fire";
     weaponStrengths [13] = "Ice";
     weaponStrengths [14] = "Lightning";
     weaponStrengths [15] = "Godly";


     classTypes[0] = "Warrior";
     classTypes [1] = "Wizard";
     classTypes [2] = "Hunter";




     GenerateWeaponClass ();

 }



 void Update ()
 {


 }

 void GenerateWeaponClass(){

     int strRnd = 1;
     int typeRnd = Random.Range (0, 31);
     weaponType = weaponTypes [typeRnd];
     
     int Rnd = 1;
     int trnd = Random.Range (0, 16);
     weaponStrength = weaponStrengths [trnd];

     int tDam;
     int tSpd;

     if (strRnd == 0) {
         tDam = Random.Range (50, 250);
         tSpd = Random.Range (50, 75);
     }



         

} }

This is what i have, so far i can generate a random weapon and saying how strong it is, but i also want to give it a strength stat and speed stat, as well as giving it a class eg: Wand for Wizard and Sword for Warrior and Hunter. I am not sure how to perform this however and later i want to give descriptions to the weapons as well.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Random texture changer (problem with array) 2 Answers

"Null Reference Error" when using a custom class as an array 1 Answer

Spawning GameObjects with help of classes --- Attaching classes to GameObjects 1 Answer

Making an Array of Animations Play at Random With No Repeats 3 Answers

Select from an array based on values 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges