Exemplo n.º 1
0
    public static GameObject buildEnemy(PlayerTemplate enemyTemplate)
    {
        GameObject enemyClone = null;

        //Añadimos las habilidades del enemigo sin necesidad de usar botones físicos
        if (enemyTemplate != null)
        {
            Vector3 posicionPlayer = new Vector3(-7f, -2.5f, 0f);
            Vector3 posicionEnemy  = new Vector3(-posicionPlayer.x, posicionPlayer.y, posicionPlayer.z);
            enemyClone = Instantiate(Resources.Load("Prefabs/Players/enemy1") as GameObject, posicionEnemy, new Quaternion());
            GameObject habilidades = new GameObject("habilidades");
            GameObject.Destroy(habilidades);
            habilidades = Instantiate(habilidades, enemyClone.transform);
            habilidades.transform.localPosition = new Vector3(0, 0, 0);
            habilidades.transform.localScale    = new Vector3(1, 1, 1);
            habilitiesEnemy = new List <WeaponInterface>();
            foreach (HabilidadTemplate hab in enemyTemplate.getHabilidadesConjunto1())
            {
                if (hab != null)
                {
                    GameObject hab1 = Resources.Load("Prefabs/Habilidades/" + hab.nombre) as GameObject;
                    hab1 = Instantiate(hab1, habilidades.transform);

                    WeaponScript script = hab1.GetComponent <WeaponScript>();
                    script.setMaxProximity(hab.maxProximity);
                    script.setCoolDown(hab.cooldown);
                    script.setDamage(hab.damage);
                    script.prioridad = hab.prioridad;
                    if (script is CuraScript)
                    {
                        (script as CuraScript).setCuracion(hab.curacion);
                    }

                    GameObject   enemyButton = new GameObject("Button" + hab.nombre);
                    ButtonScript buttonEnem  = enemyButton.AddComponent <ButtonScript>() as ButtonScript;
                    script.setButtonScript(buttonEnem);

                    habilitiesEnemy.Add(script);
                }
            }
            foreach (ItemTemplate item in enemyTemplate.itemConjunto1)
            {
                item.itemMaestro = UtilsItems.getItemMaestro(item.identificador);

                if (item.itemMaestro != null)
                {
                    enemyClone.GetComponent <PlayerScript>().setSpriteTo(item);
                }
            }
        }
        else
        {
            Vector3 posicionPlayer = new Vector3(-7f, -2.5f, 0f);
            Vector3 posicionEnemy  = new Vector3(-posicionPlayer.x, posicionPlayer.y, posicionPlayer.z);
            enemyClone = Instantiate(Resources.Load("Prefabs/Players/enemy1") as GameObject, posicionEnemy, new Quaternion());
        }

        return(enemyClone);
    }
Exemplo n.º 2
0
    public void setWeaponTemplate(WeaponTemplate weaponTemplate)
    {
        weaponTemp = weaponTemplate;
        //item.itemPrefab.sprite;

        // Sprite myFruit = Resources.Load("fruits_1", typeof(Sprite)) as Sprite;
        if (weaponTemp.weaponMaestro != null)
        {
            sprite = UtilsItems.getSpriteWeapon(weaponTemp.weaponMaestro.sprite);
            GetComponent <Image>().sprite = sprite;
        }
    }
Exemplo n.º 3
0
    public void setItemTemplate(ItemTemplate itemTemp)
    {
        item = itemTemp;
        //item.itemPrefab.sprite;

        // Sprite myFruit = Resources.Load("fruits_1", typeof(Sprite)) as Sprite;
        if (item.itemMaestro != null)
        {
            sprite = UtilsItems.getSprite(item.itemMaestro.sprite);
            GetComponent <Image>().sprite = sprite;
        }
    }
Exemplo n.º 4
0
    public List <WeaponTemplate> buildPanelWeapon(List <WeaponTemplate> weapons)
    {
        GameObject single = Resources.Load("Prefabs/UI/btSingleWeap") as GameObject;

        //Ordena los botones alfabeticamente
        //items.Sort((x, y) => x.nombre.CompareTo(y.nombre));
        if (weapons != null)
        {
            foreach (WeaponTemplate weap in weapons)
            {
                weap.weaponMaestro = UtilsItems.getWeaponMaestro(weap.identificador);
                GameObject singleClone = Instantiate(single);
                singleClone.transform.SetParent(
                    gridPaneWeapons.transform);

                singleClone.transform.localPosition = new Vector3(0, 0, 0);
                singleClone.AddComponent <WeaponSingle>();
                singleClone.GetComponent <WeaponSingle>().setWeaponTemplate(weap);
            }
        }

        return(weapons);
    }
Exemplo n.º 5
0
    public List <ItemTemplate> buildPanelItems(List <ItemTemplate> items)
    {
        GameObject single = Resources.Load("Prefabs/UI/btSingleItem") as GameObject;

        //Ordena los botones alfabeticamente
        //items.Sort((x, y) => x.nombre.CompareTo(y.nombre));
        if (items != null)
        {
            foreach (ItemTemplate item in items)
            {
                item.itemMaestro = UtilsItems.getItemMaestro(item.identificador);
                GameObject singleClone = Instantiate(single);
                singleClone.transform.SetParent(
                    gridPaneItems.transform);

                singleClone.transform.localPosition = new Vector3(0, 0, 0);

                singleClone.GetComponent <ItemSingle>().setItemTemplate(item);
            }
        }

        return(items);
    }
Exemplo n.º 6
0
    public void setSpriteTo(ItemTemplate item)
    {
        int zone = item.itemMaestro.posicion;

        switch (zone)
        {
        case 1:
            headGO.GetComponent <SpriteRenderer>().sprite =
                UtilsItems.getSprite(item.itemMaestro.sprite);
            temHead = item;
            break;

        case 2:
            troncoGO.GetComponent <SpriteRenderer>().sprite = UtilsItems.getSprite(item.itemMaestro.sprite);
            temTronco = item;
            break;

        case 3:
            List <SpriteRenderer> spritesRend = new List <SpriteRenderer>(piesGO.GetComponentsInChildren <SpriteRenderer>());
            spritesRend.ForEach(h => h.sprite = UtilsItems.getSprite(item.itemMaestro.sprite));
            temPies = item;
            break;
        }
    }
Exemplo n.º 7
0
 public void setWeaponTo(WeaponTemplate weap)
 {
     weaponTemplate    = weap;
     weaponRightSprite = UtilsItems.getSpriteWeapon(weap.weaponMaestro.sprite);
     rightHandGO.GetComponent <SpriteRenderer>().sprite = weaponRightSprite;
 }
Exemplo n.º 8
0
    public static GameObject buildPlayer(PlayerTemplate playerTempl)
    {
        GameObject player = null;

        //Añadimos las habilidades del enemigo sin necesidad de usar botones físicos
        if (playerTempl != null)
        {
            player = Resources.Load("Prefabs/Players/player") as GameObject;

            // Creacion de la carpteta de habilidades
            GameObject habilidades = new GameObject("habilidades");
            GameObject.Destroy(habilidades);
            habilidades = Instantiate(habilidades, player.transform);
            habilidades.transform.localPosition = new Vector3(0, 0, 0);
            habilidades.transform.localScale    = new Vector3(1, 1, 1);

            // Creacion de la carpteta de habilidad basica del arma
            GameObject habilidadWeap = new GameObject("habilidadBasica");
            GameObject.Destroy(habilidadWeap);
            habilidadWeap = Instantiate(habilidadWeap, player.transform);
            habilidadWeap.transform.localPosition = new Vector3(0, 0, 0);
            habilidadWeap.transform.localScale    = new Vector3(1, 1, 1);

            foreach (HabilidadTemplate hab in playerTempl.getHabilidadesConjunto1())
            {
                if (hab != null)
                {
                    GameObject hab1 = Resources.Load("Prefabs/Habilidades/" + hab.nombre) as GameObject;
                    hab1 = Instantiate(hab1, habilidades.transform);

                    WeaponScript script = hab1.GetComponent <WeaponScript>();
                    script.setMaxProximity(hab.maxProximity);
                    script.setCoolDown(hab.cooldown);
                    script.setDamage(hab.damage);
                    script.prioridad = hab.prioridad;
                    if (script is CuraScript)
                    {
                        (script as CuraScript).setCuracion(hab.curacion);
                    }
                }
            }

            foreach (ItemTemplate item in playerTempl.itemConjunto1)
            {
                item.itemMaestro = UtilsItems.getItemMaestro(item.identificador);
                if (item.itemMaestro != null)
                {
                    player.GetComponent <PlayerScript>().setSpriteTo(item);
                }
            }

            if (playerTempl.getWeaponConjunto1() != null)
            {
                WeaponTemplate weap = playerTempl.getWeaponConjunto1();

                weap.weaponMaestro = UtilsItems.getWeaponMaestro(weap.identificador);

                if (weap.identificador != null)
                {
                    player.GetComponent <PlayerScript>().setWeaponTo(weap);

                    string     habilidadW = UtilsWeapon.getWeaponHab(weap.weaponMaestro.tipoHabilidadBasica);
                    GameObject habW       = Resources.Load("Prefabs/Habilidades/basicas/" + habilidadW) as GameObject;

                    habW = Instantiate(habW, habilidadWeap.transform);

                    WeaponScript script = habW.GetComponent <WeaponScript>();
                    script.setMaxProximity(5);
                    script.setCoolDown(weap.weaponMaestro.velocidad);
                    script.setDamage(weap.weaponMaestro.damage);
                    script.setAlcance(weap.weaponMaestro.alcance);
                    print(weap.weaponMaestro.alcance);

                    script.prioridad = 0;
                }
            }
            //Insertamos las habilidades básicas de las armas.
        }
        else
        {
            Vector3 posicionPlayer = new Vector3(-7f, -2.5f, 0f);
            player = Instantiate(Resources.Load("Prefabs/Players/player") as GameObject, posicionPlayer, new Quaternion());
        }

        return(player);
    }