本文整理汇总了C#中WeaponType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# WeaponType.ToString方法的具体用法?C# WeaponType.ToString怎么用?C# WeaponType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeaponType
的用法示例。
在下文中一共展示了WeaponType.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWeaponPrefab
public static Weapon GetWeaponPrefab(WeaponType type)
{
/*switch (type) {
case WeaponType.Spear1:
return Resources.Load("Weapons/Spear1");
break;
case WeaponType.Sword1:
break;
default:
Debug.Log("Weapon type '" + type + "' is not implemented");
break;
}*/
GameObject prefab = Resources.Load ("Weapons/" + type.ToString ()) as GameObject;
GameObject instance = Instantiate (prefab) as GameObject;
return instance.GetComponent<Weapon> ();
}
示例2: LoadClips
/// <summary>
/// Loads all animations for given weapon type and gender. The clips are saved to Animation/{gender}/{weapon}/clips/{action}.anim
/// Used only in editor to generate prefabs
/// </summary>
/// <param name="skeleton"></param>
/// <param name="weapon"></param>
/// <param name="gender"></param>
/// <returns></returns>
public void LoadClips(GameObject skeleton, ZMD zmd, WeaponType weapon, GenderType gender)
{
List<AnimationClip> clips = new List<AnimationClip>();
foreach (ActionType action in Enum.GetValues(typeof(ActionType)))
{
string zmoPath = Utils.FixPath(ResourceManager.Instance.GetZMOPath(weapon, action, gender)); // Assets/3ddata path
string unityPath = "Assets/Resources/Animation/" + gender.ToString() + "/" + weapon.ToString() + "/clips/" + action.ToString() + ".anim";
AnimationClip clip = new ZMO("Assets/" + zmoPath).buildAnimationClip(zmd);
clip.name = action.ToString();
clip.legacy = true;
clip = (AnimationClip)Utils.SaveReloadAsset(clip, unityPath, ".anim");
clips.Add(clip);
}
Animation animation = skeleton.AddComponent<Animation> ();
AnimationUtility.SetAnimationClips(animation, clips.ToArray());
}
示例3: GenerateAnimationAsset
/// <summary>
/// Generate an animation prefab for the given gender and weapon
/// </summary>
/// <param name="gender"></param>
/// <param name="weapon"></param>
public void GenerateAnimationAsset(GenderType gender, WeaponType weapon)
{
GameObject skeleton = new GameObject("skeleton");
bool male = (gender == GenderType.MALE);
ZMD zmd = new ZMD( male ? "Assets/3DData/Avatar/MALE.ZMD" : "Assets/3DData/Avatar/FEMALE.ZMD");
zmd.buildSkeleton(skeleton);
BindPoses poses = ScriptableObject.CreateInstance<BindPoses> ();
poses.bindPoses = zmd.bindposes;
poses.boneNames = getBoneNames (zmd.boneTransforms);
poses.boneTransforms = zmd.boneTransforms;
LoadClips(skeleton, zmd, weapon, gender);
string path = "Assets/Resources/Animation/" + gender.ToString() + "/" + weapon.ToString() + "/skeleton.prefab";
AssetDatabase.CreateAsset(poses, path.Replace("skeleton.prefab", "bindPoses.asset"));
AssetDatabase.SaveAssets();
PrefabUtility.CreatePrefab(path, skeleton);
}
示例4: loadSkeleton
/// <summary>
/// Load a skeleton game object from resources prefab
/// </summary>
/// <param name="gender"></param>
/// <param name="weapon"></param>
/// <returns></returns>
public GameObject loadSkeleton(GenderType gender, WeaponType weapon)
{
var prefab = Resources.Load ("Animation/" + gender.ToString () + "/" + weapon.ToString () + "/skeleton");
var clone = GameObject.Instantiate ( prefab );
return clone as GameObject;
}
示例5: loadBindPoses
/// <summary>
/// Load bindposes and bones matrices from resources scriptable object
/// </summary>
/// <param name="gender"></param>
/// <param name="weapon"></param>
/// <returns></returns>
public BindPoses loadBindPoses(GameObject skeleton, GenderType gender, WeaponType weapon)
{
BindPoses poses = ScriptableObject.Instantiate<BindPoses>((BindPoses)Resources.Load ("Animation/" + gender.ToString () + "/" + weapon.ToString () + "/bindPoses"));
for (int i = 0; i < poses.boneNames.Length; i++) {
poses.boneTransforms[i] = Utils.findChild(skeleton, poses.boneNames[i]);
}
return poses;
}
示例6: Weapon
// Create a weapon
public Weapon(string itemName, WeaponType itemType, Sprite itemIcon, int attack, int cost)
: base(itemName, itemType.ToString(), itemIcon, attack, 0, 0, 0, cost)
{
// Leave empty
}
示例7: InvalidWeaponException
public InvalidWeaponException(WeaponType weaponType)
: base("Invalid weapon type: " + weaponType.ToString())
{
}
示例8: CreateWeapon
public static Weapon CreateWeapon(WeaponType type, WeaponQuality quality = WeaponQuality.Factory)
{
var weapon = new Weapon()
{
Guid = Guid.NewGuid(),
Type = type,
Quality = quality
};
var values = Enum.GetValues(typeof(WeaponType)).Cast<int>();
var index = Enum.GetNames(typeof(WeaponType)).ToList().IndexOf(type.ToString()); // ugh
var price = values.ElementAt(index);
values = Enum.GetValues(typeof(WeaponQuality)).Cast<int>();
index = Enum.GetNames(typeof(WeaponQuality)).ToList().IndexOf(quality.ToString()); // ugh
price *= values.ElementAt(index);
weapon.Price = price;
weapon.Name = type.ToString();
return weapon;
}