示例#1
0
    public void CopyAttr(Dinossauro dino)
    {
        this.custo = dino.custo;

        this.vida                    = dino.vida;
        this.ataque                  = dino.ataque;
        this.velocidadeAtaque        = dino.velocidadeAtaque;
        this.velocidade_deslocamento = dino.velocidade_deslocamento;
        this.alcance_ataque          = dino.alcance_ataque;

        this.custoAttrVida                   = dino.custoAttrVida;
        this.custoAttrAtaque                 = dino.custoAttrAtaque;
        this.custoAttrVelocidadeAtaque       = dino.custoAttrVelocidadeAtaque;
        this.custoAttrVelocidadeDeslocamento = dino.custoAttrVelocidadeDeslocamento;
        this.abilityCost = dino.abilityCost;

        this.dinoType = dino.dinoType;

        this.MAX_VIDA                    = dino.MAX_VIDA;
        this.MAX_ATAQUE                  = dino.MAX_ATAQUE;
        this.MAX_VELOCIDADE_ATAQUE       = dino.MAX_VELOCIDADE_ATAQUE;
        this.MAX_VELOCIDADE_DESLOCAMENTO = dino.MAX_VELOCIDADE_DESLOCAMENTO;
        this.MAX_ALCANCE_ATAQUE          = dino.MAX_ALCANCE_ATAQUE;

        this.habilidadeOn = dino.habilidadeOn;
    }
示例#2
0
    /* gera um grupo com 4 dinotype*/
    private GroupController.DinoType[] gerarGrupo()
    {
        GroupController.DinoType[] arg_dinos;
        int recursos  = this.playerScr.Recursos;
        int indexDino = dinoPrefab [0].GetComponent <Dinossauro> ().Custo;

        if (recursos < indexDino)
        {
            GroupController.DinoType[] arg =
            {
                GroupController.DinoType.NONE,
                GroupController.DinoType.NONE,
                GroupController.DinoType.NONE,
                GroupController.DinoType.NONE
            };
            return(arg);
        }
        arg_dinos = new GroupController.DinoType[4];
        int        custoTotal = 0;
        int        slotsTotal = 4;
        Dinossauro dinoAux, dinoAuxEscolhido;

        GroupController.DinoType aux;
        arg_dinos[0] = decideDinoType();        //randomDino (false);

        //SE O RANDOM NAO FOR NONE
        slotsTotal -= (int)(arg_dinos[0]) != 0? this.dinoPrefab[(int)(arg_dinos[0]) - 1].GetComponent <Dinossauro> ().NSlot: 0;
        custoTotal += (int)(arg_dinos[0]) != 0? this.dinoPrefab[(int)(arg_dinos[0]) - 1].GetComponent <Dinossauro> ().Custo: 0;
        int skip = 0;//(int)(arg_dinos[0])!=0? this.dinoPrefab[ (int)(arg_dinos[0]) -1 ].GetComponent<Dinossauro> ().NSlot-1: -1;

        string debugMSG = ("  0 : " + arg_dinos[0] + " " + custoTotal + "/" + recursos + " " + (4 - slotsTotal) + "/" + 4 + " skip: " + skip + " ; ");

        for (int i = 1; i < 4; i++)
        {
            dinoAuxEscolhido = null;
            //		Debug.Log ("skip: " + skip);
            if (skip-- < 1)
            {
                //	Debug.Log ("2:: skip: " + skip);
                dinoAux = dinoPrefab[(int)decideDinoType() - 1].GetComponent <Dinossauro>();
                if ((dinoAux.NSlot <= slotsTotal) && ((custoTotal + dinoAux.Custo) <= recursos))
                {
                    arg_dinos[i]     = dinoAux.DinoType;
                    dinoAuxEscolhido = dinoAux;
                }
                else
                {
                    for (int j = 0; (j < 6); j++)
                    {
                        dinoAux = this.dinoPrefab[j].GetComponent <Dinossauro>();
                        if ((dinoAux.NSlot <= slotsTotal) && ((custoTotal + dinoAux.Custo) <= recursos))
                        {
                            arg_dinos[i]     = dinoAux.DinoType;
                            dinoAuxEscolhido = dinoAux;
                        }
                    }
                }
            }
            if (dinoAuxEscolhido == null)
            {
                arg_dinos [i] = GroupController.DinoType.NONE;
                debugMSG     += ("  " + i + ": x " + arg_dinos [i] + " " + 0 + "/ " + recursos + "  " + 0 + "/" + 4) + " skip: " + skip + " total slots:" + slotsTotal + ";";
            }
            else
            {
                custoTotal += dinoAuxEscolhido.Custo;
                slotsTotal -= dinoAuxEscolhido.NSlot;
                skip        = 0;//dinoAuxEscolhido.NSlot - 1;
                debugMSG   += ("  " + i + ": x " + dinoAuxEscolhido.DinoType + " " + dinoAuxEscolhido.Custo + "/ " + recursos + "  " + dinoAuxEscolhido.NSlot + "/" + 4) + " skip: " + skip + " total slots:" + slotsTotal + ";";
            }
        }

        //msg += ("=== GRUPO::: " + custoTotal + " slots: " + slotsTotal+" skip: "+skip)+"\n";

        debugMSG += "\n" + arg_dinos [0] + " ; " + arg_dinos [1] + "; " + arg_dinos [2] + "; " + arg_dinos [3] + "; \n";
        //	Debug.LogError(msg+ "=== GRUPO: custo:" + custoTotal+"/"+recursos + " slots: " + slotsTotal);

        this.playerScr.reduzirRecursos(custoTotal);
        return(arg_dinos);
    }
示例#3
0
    // Faz o upgrade.
    //Retorna 1 se ocorreu ok;
    // Retorna -1, se nao tiver recursos suficiente;
    // Retorna -2, se ja esta no nivel maximo.
    // Retorna 2, se ocorreu ok, mas chegou no nivel maximo
    public int Upgrade(GroupController.DinoType dino, Attributes attr)
    {
        if (attr == Attributes.ATK)
        {
            if (reduzirRecursos(goDinos[(int)dino].CustoAttrAtaque))
            {
                if (!goDinos [(int)dino].UpgradeAtaque())
                {
                    incrementarRecursos(goDinos [(int)dino].CustoAttrAtaque);
                    return(-2);
                }
                else if (goDinos [(int)dino].CustoAttrAtaque > goDinos [(int)dino].GET_MAX_ATTR_ATAQUE)
                {
                    return(2);
                }
                logg.msg = "ATK";
            }
            else
            {
                return(-1);
            }
        }
        else if (attr == Attributes.VIDA)
        {
            if (reduzirRecursos(goDinos[(int)dino].CustoAttrVida))
            {
                if (!goDinos [(int)dino].UpgradeVida())
                {
                    incrementarRecursos(goDinos [(int)dino].CustoAttrVida);
                    return(-2);
                }
                else if (goDinos [(int)dino].CustoAttrVida > goDinos [(int)dino].GET_MAX_ATTR_VIDA)
                {
                    return(2);
                }
                logg.msg = "VIDA";
            }
            else
            {
                return(-1);
            }
        }
        else if (attr == Attributes.VEL_ATK)
        {
            if (reduzirRecursos(goDinos[(int)dino].CustoAttrVelocidadeAtaque))
            {
                if (!goDinos [(int)dino].UpgradeVelAtq())
                {
                    incrementarRecursos(goDinos [(int)dino].CustoAttrVelocidadeAtaque);
                    return(-2);
                }
                else if (goDinos [(int)dino].CustoAttrVelocidadeAtaque > goDinos [(int)dino].GET_MAX_ATTR_VEL_ATQ)
                {
                    return(2);
                }
                logg.msg = "VELOCIDADE DE ATAQUE";
            }
            else
            {
                return(-1);
            }
        }
        else if (attr == Attributes.VEL_DES)
        {
            if (reduzirRecursos(goDinos[(int)dino].CustoAttrVelocidadeDeslocamento))
            {
                if (!goDinos [(int)dino].UpgradeVelDes())
                {
                    incrementarRecursos(goDinos [(int)dino].CustoAttrVelocidadeDeslocamento);
                    return(-2);
                }
                else if (goDinos [(int)dino].CustoAttrVelocidadeDeslocamento > goDinos [(int)dino].GET_MAX_ATTR_VEL_DES)
                {
                    return(2);
                }
                logg.msg = "AUMENTANDO VELOCIDADE DE DESLOCAMENTO";
            }
            else
            {
                return(-1);
            }
        }
        else if (attr == Attributes.HAB)
        {
            if (reduzirRecursos(goDinos[(int)dino].AbilityCost))
            {
                if (!goDinos [(int)dino].UpgradeAbility())
                {
                    incrementarRecursos(goDinos [(int)dino].AbilityCost);
                    return(-2);
                }
                else if (goDinos [(int)dino].HabilidadeOn)
                {
                    return(2);
                }
                logg.msg = "DESTRAVANDO HABILIDADE";
            }
            else
            {
                return(-1);
            }
        }

        logg.acao        = "UPGRADE";
        logg.playerID    = playerID;
        logg.attachedObj = goDinos [(int)dino];
        logg.writeLog();
        return(1);
    }