vendredi 29 avril 2016

random list object and instantiate gameObject

I will use Pokemon as an example: I have a list of 10 elements, each element contains: string name, GameObject, int hp and mana int, int rarity.

I need after every click or tap, is made a random, even so good, but imagine that these 10 Pokemons, 2 of them are very rare.

after the random, will check out common or rare pokemon. if common, it will be made another radom and will choose only 1. if rare pokemon, choose one of two available. I believe it is very confusing.

the problem and I'm not managing to make the random list not instantiate the object. currently my code this as follows ..

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Linq;

public class Pokemons : MonoBehaviour {

[Serializable]
public class ListPokemons
{
    public string name;
    public GameObject componentObjc;
    public int hp;
    public int mana;
    public int rarity;

}

public ListPokemons[] pokeAtributs;

// Use this for initialization
void Start () {
    List<ListPokemons> list = pokeAtributs.ToList ();

    //ListPokemons pokemon = list.FirstOrDefault (r => r.componentObjc != null);

    }

}

I'm using Unity 5. I am Portuguese and all the text has been translated using google translate. you can add me to skype: morenito-green-eyes@hotmail.com.

thank you. I'll be here to answer all ....




Aucun commentaire:

Enregistrer un commentaire