internal void AdicionaVariavel(string name) { TradeSystem ts = tsC.tradeSystem; ts.vm.GetVariavel(name, "", 0, 0, 0); UpdateUI(); }
public TradePrices(ScrollsPost.Mod mod, TradeSystem trade) { this.mod = mod; this.trade = trade; new Thread(new ThreadStart(CheckData)).Start(); }
public virtual void UpdateValuesFromUI() { if (selectedTS < 0) { return; } TradeSystem ts = holder.GetTS(selectedTS); ts.name = frmPrincipal.Text("txtNameTs"); ts.condicaoEntradaC = frmPrincipal.Text("txtCondEntrC"); //ts.condicaoEntradaC.descricao = frmPrincipal.txtCondEntrCDesc.Text; ts.condicaoSaidaC = frmPrincipal.Text("txtCondSaidaC"); //ts.condicaoSaidaC.descricao = frmPrincipal.txtCondSaidaCDesc.Text; ts.condicaoEntradaV = frmPrincipal.Text("txtCondEntrV"); // ts.condicaoEntradaV.descricao = frmPrincipal.txtCondEntrVDesc.Text; ts.condicaoSaidaV = frmPrincipal.Text("txtCondSaidaV"); //ts.condicaoSaidaV.descricao = frmPrincipal.txtCondSaidaVDesc.Text; ts.stopMovelC = frmPrincipal.Text("txtStopMovelCompra"); ts.stopMovelV = frmPrincipal.Text("txtStopMovelVenda"); ts.stopInicialC = frmPrincipal.Text("txtStopInicialCompra"); ts.stopInicialV = frmPrincipal.Text("txtStopInicialVenda"); vc.ChangeSelectedVariavel(0); }
private void DescreveFormulas(RichTextBox txt, TradeSystem ts, Config config) { if (config.flagCompra) { AddTitle(txt, "CONDIÇÕES COMPRA"); AddText(txt, "Cond.Entrada", ClarificaFormula(ts.condicaoEntradaC)); AddText(txt, "Cond.Saida", ClarificaFormula(ts.condicaoSaidaC)); AddText(txt, "Target Saida", ClarificaFormula(ts.targetSaida)); AddText(txt, "Sizing Compra", ClarificaFormula(ts.sizingCompra)); AddText(txt, "Stop Inicial Compra", ClarificaFormula(ts.stopInicialC)); if (ts.usaStopMovel) { AddText(txt, "Stop Movel Compra", ClarificaFormula(ts.stopMovelC)); } } if (config.flagVenda) { AddTitle(txt, "CONDIÇÕES VENDA"); AddText(txt, "Cond.Entrada", ClarificaFormula(ts.condicaoEntradaV)); AddText(txt, "Cond.Saida", ClarificaFormula(ts.condicaoSaidaV)); AddText(txt, "Target Saida", ClarificaFormula(ts.targetSaida)); AddText(txt, "Sizing Venda", ClarificaFormula(ts.sizingCompra)); AddText(txt, "Stop Inicial Venda", ClarificaFormula(ts.stopInicialV)); if (ts.usaStopMovel) { AddText(txt, "Stop Movel Venda", ClarificaFormula(ts.stopMovelC)); } } }
public bool VerificaCondicao(ativos.Candle candle, TradeSystem ts) { bool ret = true; bool firstLoop = true; foreach (ICondicao cond in condicoes) { bool b = cond.VerificaCondicao(candle, ts); if (firstLoop) { ret = b; firstLoop = false; } if (nodeType == ConstsComuns.BOOLEAN_TYPE.AND || nodeType == ConstsComuns.BOOLEAN_TYPE.NOT) { ret = ret && b; } if (nodeType == ConstsComuns.BOOLEAN_TYPE.OR) { ret = ret || b; } } if (nodeType == ConstsComuns.BOOLEAN_TYPE.NOT) { ret = !ret; } return(ret); }
public Carteira SingleRunValidaSolution(string name = "Single Run Validate") { //gpRunner.SingleRun(); TradeSystem ts = solutionToTest.tradeSystem; int loops = configController.config.CountValidationLoops; Carteira carteira = null; Estatistica stat = null; for (int i = 0; i < loops; i++) { carteira = configController.RunSingle(loopCount, ts, name, backend.Consts.TIPO_CARGA_ATIVOS.VALIDA_CANDIDATO); if (stat != null) { stat.MergeWith(carteira.estatistica); } else { stat = carteira.estatistica; } loopCount++; } CandidatoManager cm = CandidatoManager.LoadSaved(configController.config.tipoPeriodo); cm.AddTradeSystem(ts, stat, configController.config.tipoPeriodo); return(carteira); }
public override void PrepareSolution(GPSolution solution) { TradeSystem ts = new TradeSystem(config); ts.name = solution.name; foreach (string var in listVariaveis) { if (config.IsGPVarDefined(var)) { ts.vm.SetVariavel(var, config.GetGPVarValue(var)); } else { ts.vm.SetVariavel(var, solution.GetValueAsNumber(var)); } } ts.targetSaida = solution.GetValueAsString(PROP_COND_TARGET_SAIDA); if (config.flagCompra) { ts.condicaoEntradaC = solution.GetValueAsString(PROP_COND_ENTRADA_C); ts.condicaoSaidaC = solution.GetValueAsString(PROP_COND_SAIDA_C); ts.stopMovelC = solution.GetValueAsString(PROP_COND_STOP_MOVEL_C); ts.stopInicialC = solution.GetValueAsString(PROP_COND_STOP_INICIAL_C); ts.sizingCompra = solution.GetValueAsString(PROP_SIZING_C); } if (config.flagVenda) { ts.condicaoEntradaV = solution.GetValueAsString(PROP_COND_ENTRADA_V); ts.condicaoSaidaV = solution.GetValueAsString(PROP_COND_SAIDA_V); ts.stopMovelV = solution.GetValueAsString(PROP_COND_STOP_MOVEL_V); ts.stopInicialV = solution.GetValueAsString(PROP_COND_STOP_INICIAL_V); ts.sizingVenda = solution.GetValueAsString(PROP_SIZING_V); } solution.SetPropriedade(ConstsComuns.OBJ_TRADESYSTEM, ts); }
public override void RunSolution(GPSolution solution) { TradeSystem ts = solution.GetPropriedade(ConstsComuns.OBJ_TRADESYSTEM) as TradeSystem; ts.name = solution.name; Carteira carteira = gpController.RunBackTester(ts, solution.name); carteira.monteCarlo.properties = solution; float dif = carteira.GetCapital() - carteira.capitalInicial; if (dif > 0) { float?vExist = solution.GetPropriedade(ConstsComuns.OBJ_TOTAL_PROFIT) as float?; float v = vExist == null ? 0 : (float)vExist; v += dif; solution.SetPropriedade(ConstsComuns.OBJ_TOTAL_PROFIT, v); } else { float?vExist = solution.GetPropriedade(ConstsComuns.OBJ_TOTAL_LOSS) as float?; float v = vExist == null ? 0 : (float)vExist; v += dif; solution.SetPropriedade(ConstsComuns.OBJ_TOTAL_LOSS, v); } solution.iterations++; solution.SetPropriedade(ConstsComuns.OBJ_ITERATIONS, solution.iterations); solution.fitnessResult = carteira.monteCarlo.CalcFitness(); }
internal bool Run(TradeSystem ts) { contaTestes = 0; facade.LoadAtivos(config, 0, config.tipoPeriodo, Consts.TIPO_CARGA_ATIVOS.GERA_CANDIDATOS); frmPrincipal.ClearRows("dataGridRuns"); //facade.RunSingleTS(); return(facade.Run(this, config, ts) != null); }
public Stop(TradeSystem tradeSystem, int sentido, float stopInicial) { this.tradeSystem = tradeSystem; this.sentido = sentido; stopAtual = 0; this.stopInicial = stopInicial; stopAtual = stopInicial; }
internal void AdicionaTS() { TradeSystem ts = new TradeSystem(configController.config); ts.name = "TradeSystem Novo..." + holder.Count; holder.AddTS(ts); selectedTS = holder.Count - 1; UpdateUI(); }
/// <summary> /// Initializes a new instance of the TradeSystemChromosome class. /// </summary> /// <param name="tradeSystem">The trade system the chromosome represents.</param> /// <param name="indicatorHelper">The indicator helper for randomizing the chromosome.</param> /// <param name="size">Chromosome size.</param> public TradeSystemChromosome(TradeSystem tradeSystem, IndicatorHelper indicatorHelper, int size) { TradeSystem temp = new TradeSystem(); temp.BuyCondition = new TradeCondition(); this.size = size; this.ChromosomeValue = temp; this.indicatorHelper = indicatorHelper; }
public int AddTradeSystem(TradeSystem ts, Estatistica stat, Consts.PERIODO_ACAO periodo) { if (!RankingContains(ts, stat.capitalFinal)) { ranking.Add(new CandidatoData(ts, stat, stat.capitalFinal)); } SortRanking(); SaveToFile(periodo); return(GetRanking(ts)); }
public void UpdateWindowInfo () { TradeSystem player = null; GameObject[] objects = GameObject.FindGameObjectsWithTag ("Player"); foreach (var obj in objects) { if (obj.GetComponent<TradeSystem> () != null) { player = obj.GetComponent<TradeSystem> (); } } InfoLabel.text = "Cargo: " + player.TotalCurrentWeight + "/" + player.TotalMaxWeight + " $" + player.Money; }
private bool RankingContains(TradeSystem ts, float finalScore) { if (ranking.FirstOrDefault(x => x.tradeSystem == ts) != null) { return(true); } //se tem a mesma posição então eu desconsidero. É variação do mesmo TS. return(ranking.FirstOrDefault(x => x.finalScore == finalScore) != null); }
public int GetRanking(TradeSystem ts) { for (int i = 0; i < ranking.Count; i++) { if (ranking[i].tradeSystem == ts) { return(i); } } return(ranking.Count); }
private void btnRodaSingle_Click(object sender, System.EventArgs e) { if (cbTradeSystem.SelectedIndex >= 0) { TradeSystem ts = tsController.GetTS(cbTradeSystem.SelectedItem.ToString()); if (txtVarsDebug.Text != "") { ts.vm.LoadVars(txtVarsDebug.Text); } configController.RunSingle(0, ts, "Roda Single", backend.Consts.TIPO_CARGA_ATIVOS.GERA_CANDIDATOS); } }
public BackTester(FacadeBacktester facade, Periodo periodoInicial, Config config, TradeSystem tradeSystem) { this.facade = facade; this.ativoManager = facade.dh; this.ativos = facade.dh.GetAtivos(); this.config = config; this.tradeSystem = tradeSystem; this.periodoInicial = periodoInicial; // monteCarlo = new List<MonteCarlo>(); Init(new MonteCarlo("single")); }
void CreateTradePost() { CargoModule cargoModule = gameObject.AddComponent <CargoModule> (); cargoModule.InitialMaxWeight = 9000; cargoModule.InitializeFromPlanet(); gameObject.AddComponent <CargoSystem> (); TradeSystem tradeSystem = gameObject.AddComponent <TradeSystem> (); tradeSystem.InitialMoney = 900000; gameObject.AddComponent <SystemManager> (); }
private void Analyze_Click(object sender, EventArgs e) { TradeSystem analyze = new TradeSystem(condition); TradeHelper newAnalysis = new TradeHelper(analyze); newAnalysis.RunBacktest(testData, TDD); List <DateTime> results = newAnalysis.occuranceCount; for (int i = 0; i < results.Count; i++) { this.ResultsBox.AppendText(results[i].ToString() + "\n"); } }
private void UpdateList() { frmPrincipal.ClearList("listTSVars"); TradeSystem ts = tsC.tradeSystem; if (ts != null) { foreach (Variavel v in ts.vm.variaveis) { frmPrincipal.AddItem("listTSVars", v); } } }
public virtual bool VerificaCondicao(Candle candle, TradeSystem ts) { //Se cond1 e cond2 forem null é porque é uma condição pai, logo não há o que verificar (apenas os filhos) if ((cond1 == null) && (cond2 == null)) { return(true); } float c1 = candle.GetValor(ts.vm.ReplaceVariavel(cond1)); float c2 = candle.GetValor(ts.vm.ReplaceVariavel(cond2)); return(VerificaCondicao(c1, c2)); }
private void DescreveCaracteristicas(RichTextBox txt, TradeSystem ts) { AddTitle(txt, "CARACTERÍSTICAS"); txt.SelectionBullet = true; AddText(txt, ts.usaMultiplasEntradas ? "Usa Múltiplas Entradas" : "Não usa Múltiplas Entradas"); AddText(txt, ts.usaStopMovel ? "Usa Stop Móvel" : "Não Usa Stop Móvel"); AddText(txt, "Risco por trade", Utils.FormatCurrency(ts.riscoTrade) + "%"); AddText(txt, "Risco Global", Utils.FormatCurrency(ts.riscoGlobal) + "%"); AddText(txt, "Gap Stop Inicial", Utils.FormatCurrency(ts.stopGapPerc) + "%"); AddText(txt, "% capital máximo por trade", Utils.FormatCurrency(ts.percTrade) + "%"); AddText(txt, "Capital máximo por trade", "$ " + Utils.FormatCurrency(ts.maxCapitalTrade)); AddText(txt, "Stop Mensal", Utils.FormatCurrency(ts.stopMensal) + "%"); txt.SelectionBullet = false; }
public void TestValidaCandidato() { MockReferView rv = new MockReferView(); ConfigController configController = new ConfigController(rv); GeneticProgrammingController gpc = new GeneticProgrammingController(rv, configController); gpc.gpRunner.gpConfig.poolSize = 2; gpc.InitPool(); gpc.solutionToTest = new GPSolutionProxy(); gpc.solutionToTest.tradeSystem = new TradeSystem(configController.config); Assert.IsNotNull(gpc.solutionToTest.tradeSystem); Carteira carteira = gpc.SingleRunValidaSolution("teste Validation"); Assert.IsTrue(carteira.estatistica.capitalFinal != carteira.estatistica.capitalInicial); Assert.IsNotNull(carteira); Assert.IsTrue(carteira.posicoesAbertas.Count == 0); Assert.IsTrue(carteira.posicoesFechadas.Count > 0); Assert.IsTrue(configController.facadeValidation.dh.ativos.Count > 0); //adicionar o resultado da carteira em algum objeto persistido, ordenando pelo resultado final CandidatoManager cm = CandidatoManager.LoadSaved(configController.config.tipoPeriodo); CandidatoManager cm2 = CandidatoManager.LoadSaved(configController.config.tipoPeriodo); Assert.IsTrue(cm == cm2); Estatistica stat = new Estatistica(10000); CandidatoManager cmTest = new CandidatoManager(); TradeSystem ts1 = new TradeSystem(configController.config); TradeSystem ts2 = new TradeSystem(configController.config); TradeSystem ts3 = new TradeSystem(configController.config); stat.capitalFinal = 1000; cmTest.AddTradeSystem(ts1, stat, configController.config.tipoPeriodo); Assert.IsTrue(cmTest.GetRanking(ts1) == 0); stat.capitalFinal = 2000; cmTest.AddTradeSystem(ts2, stat, configController.config.tipoPeriodo); Assert.IsTrue(cmTest.GetRanking(ts1) == 1); Assert.IsTrue(cmTest.GetRanking(ts2) == 0); stat.capitalFinal = 3000; cmTest.AddTradeSystem(ts3, stat, configController.config.tipoPeriodo); Assert.IsTrue(cmTest.GetRanking(ts1) == 2); Assert.IsTrue(cmTest.GetRanking(ts2) == 1); Assert.IsTrue(cmTest.GetRanking(ts3) == 0); }
internal Carteira RunSingle(int loop, TradeSystem ts, string name, Consts.TIPO_CARGA_ATIVOS tipoCarga) { if (tipoCarga == Consts.TIPO_CARGA_ATIVOS.VALIDA_CANDIDATO) { //valido com todos os papeis disponíveis config.qtdPercPapeis = 100; facadeValidation.LoadAtivos(config, loop, config.tipoPeriodo, tipoCarga); return(facadeValidation.RunValidation(this, config, ts, name)); } else { facade.LoadAtivos(config, loop, config.tipoPeriodo, tipoCarga); return(facade.RunSingle(name, this, config, ts)); } }
public void TestTradeSystem() { facade = new FacadeBacktester(); Config config = new Config(); TradeSystem tradeSystem = new TradeSystem(config); MonteCarlo mc = new MonteCarlo("teste"); float valorInicial = 100000; Carteira carteira = new Carteira(facade, valorInicial, config, tradeSystem, mc); config.custoOperacao = 20f; tradeSystem.condicaoEntradaC = "GREATER(MME(C,9),MME(C,3))"; tradeSystem.condicaoSaidaC = "LOWER(MME(C,9),MME(C,3))"; tradeSystem.condicaoEntradaV = "LOWER(MME(C,9),MME(C,3))"; Periodo periodo = new Periodo("01-01-2017"); Ativo ativo = new Ativo(facade, "TESTE", 100); Candle candle = new Candle(periodo, ativo); ativo.firstCandle = candle; candle.SetValor("MME(C,9)", 10); candle.SetValor("MME(C,3)", 5); candle.SetValor("SUBTRACT(L,MULTIPLY(STD(C,10),2))", 2); candle.SetValor("H", 10); candle.SetValor(tradeSystem.stopInicialC, 5); Formula formulaGreater = facade.formulaManager.GetFormula(tradeSystem.condicaoEntradaC); float value = formulaGreater.Calc(candle); Assert.IsTrue(value > 0, value + "<=0"); Formula formulaLower = facade.formulaManager.GetFormula(tradeSystem.condicaoEntradaV); value = formulaLower.Calc(candle); Assert.IsTrue(value == 0, value + ">0"); float result = tradeSystem.checaCondicaoEntrada(candle, config); Assert.IsTrue(result > 0, "result:" + result); candle.SetValor("MME(C,9)", 2); candle.SetValor("C", 2); candle.RemoveValor(tradeSystem.condicaoEntradaC); result = tradeSystem.checaCondicaoEntrada(candle, config); Assert.IsTrue(result == 0, "result:" + result); }
public void TestCondicaoComplexa() { facade.LoadAtivo("PETR4", 100, Consts.PERIODO_ACAO.DIARIO, "dados/petr4-diario.js"); Ativo ativo = facade.GetAtivo("PETR4"); Config config = new Config(); TradeSystem ts = new TradeSystem(config); /* * Exemplos: * C>O * * !C>O * * C>O||C<REF(C,1) * * (C>O||C<REF(C,1))&&RSI(C,9)>7 * * */ string strFormulaA = "MME(C,9)"; string strFormulaB = "MMS(C,9)"; string strFormulaC = "MMS(C,3)"; ICondicao cond1 = new CondicaoComplexa(config, strFormulaA + ">" + strFormulaB); FormulaManager fm = facade.formulaManager; Candle candle = ativo.firstCandle; candle.SetValor(strFormulaA, 10); candle.SetValor(strFormulaB, 20); candle.SetValor(strFormulaC, 5); Assert.IsFalse(cond1.VerificaCondicao(candle, ts)); candle.SetValor(strFormulaA, 30); Assert.IsTrue(cond1.VerificaCondicao(candle, ts)); ICondicao cond2 = new CondicaoComplexa(config, strFormulaA + ">" + strFormulaB + "&&" + strFormulaB + ">" + strFormulaC); Assert.IsTrue(cond2.VerificaCondicao(candle, ts)); candle.SetValor(strFormulaC, 30); Assert.IsFalse(cond2.VerificaCondicao(candle, ts)); candle.SetValor(strFormulaC, 5); Assert.IsTrue(cond2.VerificaCondicao(candle, ts)); candle.SetValor(strFormulaA, 10); Assert.IsFalse(cond2.VerificaCondicao(candle, ts)); }
public void Describe(RichTextBox txt, CandidatoData candidatoData, Config config) { txt.Text = ""; TradeSystem ts = candidatoData.tradeSystem; AddTitle(txt, ts.name); AddQuebraLinha(txt); Clarify clarify = new Clarify(); DescreveCaracteristicas(txt, ts); AddQuebraLinha(txt); DescreveFormulas(txt, ts, config); AddQuebraLinha(txt); AddQuebraLinha(txt); AddTitle(txt, "ESTATÍSTICAS"); Estatistica stat = candidatoData.estatistica; AddText(txt, "Max.Capital", Utils.FormatCurrency(stat.maxCapital)); AddText(txt, "Min.Capital", Utils.FormatCurrency(stat.minCapital)); AddQuebraLinha(txt); txt.SelectionIndent += 10; if (config.flagCompra) { AddTitle(txt, "Ponta Comprada"); SubDado dado = stat.geral.getCompras(); DescreveDado(txt, dado); } if (config.flagVenda) { AddTitle(txt, "Ponta Vendida"); SubDado dado = stat.geral.getVendas(); DescreveDado(txt, dado); } txt.SelectionIndent -= 10; AddQuebraLinha(txt); AddTitle(txt, "MENSAGENS"); foreach (string msg in candidatoData.tradeSystem.mensagens) { AddText(txt, msg); } }
public void TestNode() { facade.LoadAtivo("PETR4", 100, Consts.PERIODO_ACAO.DIARIO, "dados/petr4-diario.js"); Ativo ativo = facade.GetAtivo("PETR4"); Config config = new Config(); TradeSystem ts = new TradeSystem(config); Candle candle = ativo.firstCandle; candle.SetValor("A", 10); candle.SetValor("B", 20); candle.SetValor("C", 10); Condicao cond1 = new Condicao(config, "A>B"); Condicao cond2 = new Condicao(config, "B>C"); Node nodeOR = new Node(ConstsComuns.BOOLEAN_TYPE.OR); Node nodeAND = new Node(ConstsComuns.BOOLEAN_TYPE.AND); Node nodeNOT = new Node(ConstsComuns.BOOLEAN_TYPE.NOT); nodeOR.AddCondicao(cond1); nodeAND.AddCondicao(cond1); nodeNOT.AddCondicao(cond1); Assert.IsFalse(nodeOR.VerificaCondicao(candle, ts)); Assert.IsFalse(nodeAND.VerificaCondicao(candle, ts)); Assert.IsTrue(nodeNOT.VerificaCondicao(candle, ts)); candle.SetValor("A", 30); Assert.IsTrue(nodeOR.VerificaCondicao(candle, ts)); Assert.IsTrue(nodeAND.VerificaCondicao(candle, ts)); Assert.IsFalse(nodeNOT.VerificaCondicao(candle, ts)); candle.SetValor("A", 10); nodeOR.AddCondicao(cond2); nodeAND.AddCondicao(cond2); nodeNOT.AddCondicao(cond2); Assert.IsTrue(nodeOR.VerificaCondicao(candle, ts)); Assert.IsFalse(nodeAND.VerificaCondicao(candle, ts)); Assert.IsTrue(nodeNOT.VerificaCondicao(candle, ts)); }
void Awake() { systems = GetComponentsInChildren <ShipSystem> (); autoWeaponSystem = GetComponentInChildren <AutoWeaponSystem> (); flightSystem = GetComponentInChildren <FlightSystem> (); detectionSystem = GetComponentInChildren <DetectionSystem> (); cargoSystem = GetComponentInChildren <CargoSystem> (); tradeSystem = GetComponentInChildren <TradeSystem> (); if (flightSystem != null) { flightSystem.MyBody = GetComponent <Rigidbody> (); // Ужас! } if (detectionSystem != null && autoWeaponSystem != null) { autoWeaponSystem.SubscribeToDetectionSystem(detectionSystem); } if (tradeSystem != null && cargoSystem != null) { tradeSystem.SubscribeToCargoSystem(cargoSystem); } }
//int candleWidth private void DrawCandle(Operacao oper, TradeSystem tradeSystem, Candle candle, bool atual) { float cw = candleWidth() * 0.8f; float x = GetWidthForPeriodo(contaPers) - cw / 2; float dif = Math.Abs(candle.GetValor(FormulaManager.OPEN) - candle.GetValor(FormulaManager.CLOSE)); float y = GetYPosition(candle.GetValor(FormulaManager.OPEN)); float w = cw; float h = GetHeightValueAbs(dif); Color cor = atual ? Color.Green : Color.White; if (candle.GetValor(FormulaManager.OPEN) < candle.GetValor(FormulaManager.CLOSE)) { cor = atual ? Color.Red : Color.Black; y -= h; } //stop float vlrStop = oper.stop.CalcStop(candle); DrawLine(x, GetYPosition(vlrStop), x + cw, GetYPosition(vlrStop), Color.Red); //target float vlrTarget = oper.CalcAlvo(candle); DrawLine(x, GetYPosition(vlrTarget), x + cw, GetYPosition(vlrTarget), Color.Green); RectangleShape corpo = new RectangleShape((int)x, (int)y, (int)w, (int)h); corpo.FillColor = cor; corpo.FillStyle = FillStyle.Solid; corpo.BorderColor = Color.Black; shapes.Add(corpo); corpo.Parent = canvas; DrawLine(x + cw / 2, GetYPosition(candle.GetValor(FormulaManager.LOW)), x + cw / 2, GetYPosition(candle.GetValor(FormulaManager.HIGH)), Color.Black); //DrawLine(x-cw/2, GetYPosition(candle.GetValor(FormulaManager.LOW)), x + cw/2, GetYPosition(candle.GetValor(FormulaManager.LOW)), Color.Blue); //DrawLine(x - cw / 2, GetYPosition(candle.GetValor(FormulaManager.HIGH)), x + cw / 2, GetYPosition(candle.GetValor(FormulaManager.HIGH)), Color.Blue); }
public override void AfterInvoke (InvocationInfo info, ref object returnValue) //public override bool BeforeInvoke(InvocationInfo info, out object returnValue) { if (info.target is ChatUI && info.targetMethod.Equals("AdjustToResolution"))//get style { this.chatLogStyle = new GUIStyle((GUIStyle)chatMsgStylefield.GetValue(info.target)); this.chatButtonSkin = (GUISkin)chatButtonSkinfield.GetValue(info.target); //Console.WriteLine("AdjustToResolution"); } if (info.target is Store && info.targetMethod.Equals("Start"))//update rects in store { this.menueheight = (float)Screen.width / 25.6f; selfsearchstring = ""; this.store = (Store)info.target; this.sellFrame = (CardListPopup)typeof(Store).GetField("sellFrame", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target); Rect sellrect = new Rect((float)Screen.width * 0.01f, (float)Screen.height * 0.18f, (float)Screen.height * 0.5f, (float)Screen.height * 0.7f); Rect searchFieldRect = new Rect(-10, -10, 1, 1); float BOTTOM_MARGIN_EXTRA = (float)Screen.height * 0.047f; float num = 0.005f * (float)Screen.width; Vector4 margins = new Vector4(0f, 0f, 0f, 0f + BOTTOM_MARGIN_EXTRA); float num2 = BOTTOM_MARGIN_EXTRA - 0.01f * (float)Screen.height; float num3 = num2 * 1.28f; Rect outerRect = new Rect((Rect)outerRectfield.GetValue(sellFrame)); Rect innerBGRect = new Rect((Rect)innerBGRectfield.GetValue(sellFrame)); Rect innerRect = new Rect((Rect)innerRectfield.GetValue(sellFrame)); innerBGRect.height = innerBGRect.height + num3; innerRect.height = innerRect.height + num3; searchFieldRectfield.SetValue(sellFrame, searchFieldRect); innerBGRectfield.SetValue(sellFrame, innerBGRect); innerRectfield.SetValue(sellFrame, innerRect); this.p1cf = CardFilter.from(""); this.p1rectsearchmenu = new Rect(outerRect.x, sellrect.y + sellrect.height + num, (float)Screen.width / 2, this.menueheight); this.p1searchrect = new Rect(p1rectsearchmenu.x + num+2, p1rectsearchmenu.y + num + 2, sellrect.width / 2, p1rectsearchmenu.height - 2f * num - 4); this.p1growthrect = new Rect(p1searchrect.x + p1searchrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1orderrect = new Rect(p1growthrect.x + p1growthrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1energyrect = new Rect(p1orderrect.x + p1orderrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1decayrect = new Rect(p1energyrect.x + p1energyrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1commonrect = new Rect(p1decayrect.x + p1decayrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1uncommonrect = new Rect(p1commonrect.x + p1commonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1rarerect = new Rect(p1uncommonrect.x + p1uncommonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1mt3rect = new Rect(p1rarerect.x + p1rarerect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1clearrect = new Rect(p1mt3rect.x + p1mt3rect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1rectsearchmenu.width = p1clearrect.x + p1clearrect.width + num +2 - p1rectsearchmenu.x; this.orgicardsPlayer1.Clear(); } if (info.target is Store && info.targetMethod.Equals("handleMessage"))// update orginal cards! { Message msg = (Message)info.arguments[0]; if (msg is LibraryViewMessage) { if (!(((LibraryViewMessage)msg).profileId==123)) { this.selfsearchstring = ""; p1growthbool = true; p1orderbool = true; p1energybool = true; p1decaybool = true; p1commonbool = true; p1uncommonbool = true; p1rarebool = true; p1mt3bool = false; this.orgicardsPlayer1.Clear(); this.orgicardsPlayer1.AddRange(((LibraryViewMessage)msg).cards); this.p1moddedlist.Clear(); this.p1moddedlist.AddRange(this.orgicardsPlayer1); } } } if (info.target is Store && info.targetMethod.Equals("OnGUI"))//draw menu { float offset = 0f; if (sellFrame != null) { float offX = (float)offxInfo.GetValue(sellFrame); offset = offX; } if (true) { sliderectsp1(offset); //outerFrame1.Draw(); GUI.color = new Color(1f, 1f, 1f, 1f); GUI.skin = this.chatButtonSkin; GUI.Box(this.p1rectsearchmenu, string.Empty); Color dblack = new Color(1f, 1f, 1f, 0.2f); GUI.color = new Color(1f, 1f, 1f, 0.6f); GUI.skin = this.chatButtonSkin; GUI.Box(this.p1searchrect, string.Empty); GUI.color = Color.white; string selfcopy = this.selfsearchstring; this.selfsearchstring = GUI.TextField(this.p1searchrect, this.selfsearchstring, this.chatLogStyle); GUI.contentColor = Color.white; GUI.color = Color.white; if (!p1growthbool) { GUI.color = dblack; } bool p1growthclick = GUI.Button(p1growthrect, growthres); GUI.color = Color.white; if (!p1orderbool) { GUI.color = dblack; } bool p1orderclick = GUI.Button(p1orderrect, orderres); GUI.color = Color.white; if (!p1energybool) { GUI.color = dblack; } bool p1energyclick = GUI.Button(p1energyrect, energyres); GUI.color = Color.white; if (!p1decaybool) { GUI.color = dblack; } bool p1decayclick = GUI.Button(p1decayrect, decayres); GUI.color = Color.white; if (!p1commonbool) { GUI.color = dblack; } GUI.contentColor = Color.gray; bool p1commonclick = GUI.Button(p1commonrect, "C"); GUI.color = Color.white; if (!p1uncommonbool) { GUI.color = dblack; } GUI.contentColor = Color.white; bool p1uncommonclick = GUI.Button(p1uncommonrect, "U"); GUI.color = Color.white; if (!p1rarebool) { GUI.color = dblack; } GUI.contentColor = Color.yellow; bool p1rareclick = GUI.Button(p1rarerect, "R"); GUI.contentColor = Color.white; GUI.color = Color.white; if (!p1mt3bool) { GUI.color = dblack; } bool p1mt3click = GUI.Button(p1mt3rect, ">3"); GUI.color = Color.white; GUI.contentColor = Color.red; bool p1closeclick = GUI.Button(p1clearrect, "X"); if (p1growthclick) { p1growthbool = !p1growthbool; }; if (p1orderclick) { p1orderbool = !p1orderbool; } if (p1energyclick) { p1energybool = !p1energybool; }; if (p1decayclick) { p1decaybool = !p1decaybool; } if (p1commonclick) { p1commonbool = !p1commonbool; }; if (p1uncommonclick) { p1uncommonbool = !p1uncommonbool; } if (p1rareclick) { p1rarebool = !p1rarebool; }; if (p1mt3click) { p1mt3bool = !p1mt3bool; } if (p1closeclick) { this.selfsearchstring = ""; this.p1cf = CardFilter.from(""); p1growthbool = true; p1orderbool = true; p1energybool = true; p1decaybool = true; p1commonbool = true; p1uncommonbool = true; p1rarebool = true; p1mt3bool = false; } //clear p1moddedlist only if necessary if (selfcopy != this.selfsearchstring || p1closeclick || (p1growthclick && p1growthbool) || (p1orderclick && p1orderbool) || (p1energyclick && p1energybool) || (p1decayclick && p1decaybool) || (p1commonclick && p1commonbool) || (p1uncommonclick && p1uncommonbool) || (p1rareclick && p1rarebool) || p1mt3click) { //Console.WriteLine("delete dings####"); this.p1moddedlist.Clear(); this.p1moddedlist.AddRange(this.orgicardsPlayer1); string[] res = { "", "", "", "" }; if (p1decaybool) { res[0] = "decay"; }; if (p1energybool) { res[1] = "energy"; }; if (p1growthbool) { res[2] = "growth"; }; if (p1orderbool) { res[3] = "order"; }; int[] rare = { -1, -1, -1 }; if (p1rarebool) { rare[2] = 2; }; if (p1uncommonbool) { rare[1] = 1; }; if (p1commonbool) { rare[0] = 0; }; if (this.p1mt3bool) { this.searchmorethan3(); } //this.onlytradeableself(); this.p1cf = CardFilter.from(""); if (this.selfsearchstring != "") { this.p1cf = CardFilter.from(this.selfsearchstring); this.containsname(this.selfsearchstring); } this.searchforownenergy(res); this.searchforownrarity(rare); this.updatestoreself(); } else { if (selfcopy != this.selfsearchstring) { this.p1cf = CardFilter.from(""); if (this.selfsearchstring != "") { this.p1cf = CardFilter.from(this.selfsearchstring); this.containsname(this.selfsearchstring); this.updatestoreself(); } } if (p1growthclick || p1orderclick || p1energyclick || p1decayclick) { string[] res = { "", "", "", "" }; if (p1decaybool) { res[0] = "decay"; }; if (p1energybool) { res[1] = "energy"; }; if (p1growthbool) { res[2] = "growth"; }; if (p1orderbool) { res[3] = "order"; }; this.searchforownenergy(res); this.updatestoreself(); } if (p1commonclick || p1uncommonclick || p1rareclick) { int[] rare = { -1, -1, -1 }; if (p1rarebool) { rare[2] = 2; }; if (p1uncommonbool) { rare[1] = 1; }; if (p1commonbool) { rare[0] = 0; }; this.searchforownrarity(rare); this.updatestoreself(); } } sliderectsp1(-1*offset); } } if (info.target is TradeSystem && info.targetMethod.Equals("Init"))//update rects { Rect searchFieldRect= new Rect(-10,-10,1,1); //Console.WriteLine("INIT "); this.menueheight = (float)Screen.width / 25.6f; Rect outerArea1 = (Rect)outerArea1field.GetValue(info.target); Rect outerArea2 = (Rect)outerArea2field.GetValue(info.target); Rect innerArea = (Rect)innerAreafield.GetValue(info.target); Rect rectInvP1 = (Rect)rectInvP1field.GetValue(info.target); Rect rectOfferP1 = (Rect)rectOfferP1field.GetValue(info.target); Rect rectInvP2 = (Rect)rectInvP2field.GetValue(info.target); Rect rectOfferP2 = (Rect)rectOfferP2field.GetValue(info.target); outerArea1.height = outerArea1.height - this.menueheight; outerArea2.height = outerArea2.height - this.menueheight; innerArea.height = innerArea.height - this.menueheight; rectInvP1.height = rectInvP1.height - this.menueheight; rectOfferP1.height = rectOfferP1.height - this.menueheight; rectInvP2.height = rectInvP2.height - this.menueheight; rectOfferP2.height = rectOfferP2.height - this.menueheight; this.p1cf = CardFilter.from(""); this.p2cf = CardFilter.from(""); outerArea1field.SetValue(info.target, outerArea1); outerArea2field.SetValue(info.target, outerArea2); innerAreafield.SetValue(info.target, innerArea); rectInvP1field.SetValue(info.target, rectInvP1); rectOfferP1field.SetValue(info.target, rectOfferP1); rectInvP2field.SetValue(info.target, rectInvP2); rectOfferP2field.SetValue(info.target, rectOfferP2); CardListPopup clInventoryP1 = (CardListPopup)clInventoryP1field.GetValue(info.target); CardListPopup clOfferP1 = (CardListPopup)clOfferP1field.GetValue(info.target); CardListPopup clInventoryP2 = (CardListPopup)clInventoryP2field.GetValue(info.target); CardListPopup clOfferP2 = (CardListPopup)clOfferP2field.GetValue(info.target); float BOTTOM_MARGIN_EXTRA = (float)Screen.height * 0.047f; float num = 0.005f * (float)Screen.width; Vector4 margins = new Vector4(0f, 0f, 0f, 0f + BOTTOM_MARGIN_EXTRA); float num2 = BOTTOM_MARGIN_EXTRA - 0.01f * (float)Screen.height; //update clinventoryp1 (same calculation of the rect like in CardListPopup.Init(...)) Rect outerRect = rectInvP1; Rect innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w)); Rect innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num); Rect buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); Rect buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); outerRectfield.SetValue(clInventoryP1, outerRect); innerBGRectfield.SetValue(clInventoryP1, innerBGRect); innerRectfield.SetValue(clInventoryP1, innerRect); buttonLeftRectfield.SetValue(clInventoryP1, buttonLeftRect); buttonRightRectfield.SetValue(clInventoryP1, buttonRightRect); searchFieldRectfield.SetValue(clInventoryP1, searchFieldRect); //update clinventoryp2 outerRect = rectInvP2; innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w)); innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num); buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); outerRectfield.SetValue(clInventoryP2, outerRect); innerBGRectfield.SetValue(clInventoryP2, innerBGRect); innerRectfield.SetValue(clInventoryP2, innerRect); buttonLeftRectfield.SetValue(clInventoryP2, buttonLeftRect); buttonRightRectfield.SetValue(clInventoryP2, buttonRightRect); searchFieldRectfield.SetValue(clInventoryP2, searchFieldRect); //update clOfferP1 outerRect = rectOfferP1; innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w)); innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num); buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); outerRectfield.SetValue(clOfferP1, outerRect); innerBGRectfield.SetValue(clOfferP1, innerBGRect); innerRectfield.SetValue(clOfferP1, innerRect); buttonLeftRectfield.SetValue(clOfferP1, buttonLeftRect); buttonRightRectfield.SetValue(clOfferP1, buttonRightRect); searchFieldRectfield.SetValue(clOfferP1, searchFieldRect); //update clOfferP2 outerRect = rectOfferP2; innerBGRect = new Rect(outerRect.x + margins.x, outerRect.y + margins.y, outerRect.width - (margins.x + margins.z), outerRect.height - (margins.y + margins.w)); innerRect = new Rect(innerBGRect.x + num, innerBGRect.y + num, innerBGRect.width - 2f * num, innerBGRect.height - 2f * num); buttonLeftRect = new Rect(innerRect.x + innerRect.width * 0.03f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); buttonRightRect = new Rect(innerRect.xMax - innerRect.width * 0.48f, innerBGRect.yMax + num2 * 0.28f, innerRect.width * 0.45f, num2); outerRectfield.SetValue(clOfferP2, outerRect); innerBGRectfield.SetValue(clOfferP2, innerBGRect); innerRectfield.SetValue(clOfferP2, innerRect); buttonLeftRectfield.SetValue(clOfferP2, buttonLeftRect); buttonRightRectfield.SetValue(clOfferP2, buttonRightRect); searchFieldRectfield.SetValue(clOfferP2, searchFieldRect); this.p1rectsearchmenu = new Rect(outerArea1.x, outerArea1.y + outerArea1.height, outerArea1.width, this.menueheight); this.p2rectsearchmenu = new Rect(outerArea2.x, outerArea2.y + outerArea2.height, outerArea2.width, this.menueheight); this.p1searchrect = new Rect(p1rectsearchmenu.x + 5*num, p1rectsearchmenu.y + num+2, outerArea1.width/3, p1rectsearchmenu.height - 2f*num-4); this.p2searchrect = new Rect(p2rectsearchmenu.x + 5*num, p2rectsearchmenu.y + num+2, outerArea2.width / 3, p2rectsearchmenu.height - 2f*num-4); this.outerFrame1 = new ScrollsFrame(this.p1rectsearchmenu).AddNinePatch(ScrollsFrame.Border.DARK_CURVED, NinePatch.Patches.TOP | NinePatch.Patches.TOP_RIGHT | NinePatch.Patches.CENTER | NinePatch.Patches.RIGHT | NinePatch.Patches.BOTTOM | NinePatch.Patches.BOTTOM_RIGHT).AddNinePatch(ScrollsFrame.Border.DARK_SHARP, NinePatch.Patches.TOP_LEFT | NinePatch.Patches.LEFT | NinePatch.Patches.CENTER | NinePatch.Patches.BOTTOM_LEFT); this.outerFrame2 = new ScrollsFrame(this.p2rectsearchmenu).AddNinePatch(ScrollsFrame.Border.DARK_CURVED, NinePatch.Patches.TOP_LEFT | NinePatch.Patches.TOP | NinePatch.Patches.LEFT | NinePatch.Patches.CENTER | NinePatch.Patches.BOTTOM_LEFT | NinePatch.Patches.BOTTOM).AddNinePatch(ScrollsFrame.Border.DARK_SHARP, NinePatch.Patches.TOP_RIGHT | NinePatch.Patches.CENTER | NinePatch.Patches.RIGHT | NinePatch.Patches.BOTTOM_RIGHT); this.p1growthrect = new Rect(p1searchrect.x + p1searchrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1orderrect = new Rect(p1growthrect.x + p1growthrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1energyrect = new Rect(p1orderrect.x + p1orderrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1decayrect = new Rect(p1energyrect.x + p1energyrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1commonrect = new Rect(p1decayrect.x + p1decayrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1uncommonrect = new Rect(p1commonrect.x + p1commonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1rarerect = new Rect(p1uncommonrect.x + p1uncommonrect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1mt3rect = new Rect(p1rarerect.x + p1rarerect.width + 3, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p1clearrect = new Rect(p1rectsearchmenu.x + p1rectsearchmenu.width - p1rectsearchmenu.height-num, p1rectsearchmenu.y + num + 2, p1rectsearchmenu.height - 2f * num - 4, p1rectsearchmenu.height - 2f * num - 4); this.p2growthrect = new Rect(p2searchrect.x + p2searchrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2orderrect = new Rect(p2growthrect.x + p2growthrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2energyrect = new Rect(p2orderrect.x + p2orderrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2decayrect = new Rect(p2energyrect.x + p2energyrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2commonrect = new Rect(p2decayrect.x + p2decayrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2uncommonrect = new Rect(p2commonrect.x + p2commonrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2rarerect = new Rect(p2uncommonrect.x + p2uncommonrect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2mt3rect = new Rect(p2rarerect.x + p2rarerect.width + 3, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); this.p2clearrect = new Rect(p2rectsearchmenu.x + p2rectsearchmenu.width - p2rectsearchmenu.height-num, p2rectsearchmenu.y + num + 2, p2rectsearchmenu.height - 2f * num - 4, p2rectsearchmenu.height - 2f * num - 4); } if (info.target is TradeSystem && info.targetMethod.Equals("OnGUI"))//draw menu { //int state = (int)typeof(TradeSystem).GetField("state", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target); if (trading) { outerFrame1.Draw(); outerFrame2.Draw(); Color dblack = new Color(1f, 1f, 1f, 0.2f); GUI.color = new Color(1f, 1f, 1f, 0.6f); GUI.skin = this.chatButtonSkin; GUI.Box(this.p1searchrect, string.Empty); GUI.Box(this.p2searchrect, string.Empty); GUI.color = Color.white; string selfcopy = this.selfsearchstring; string oppocopy = this.opposearchstring; this.selfsearchstring = GUI.TextField(this.p1searchrect, this.selfsearchstring, this.chatLogStyle); this.opposearchstring = GUI.TextField(this.p2searchrect, this.opposearchstring, this.chatLogStyle); GUI.contentColor = Color.white; GUI.color = Color.white; if (!p1growthbool) { GUI.color = dblack; } bool p1growthclick = GUI.Button(p1growthrect, growthres); GUI.color = Color.white; if (!p1orderbool) { GUI.color = dblack; } bool p1orderclick = GUI.Button(p1orderrect, orderres); GUI.color = Color.white; if (!p1energybool) { GUI.color = dblack; } bool p1energyclick = GUI.Button(p1energyrect, energyres); GUI.color = Color.white; if (!p1decaybool) { GUI.color = dblack; } bool p1decayclick = GUI.Button(p1decayrect, decayres); GUI.color = Color.white; if (!p1commonbool) { GUI.color = dblack; } GUI.contentColor = Color.gray; bool p1commonclick = GUI.Button(p1commonrect,"C"); GUI.color = Color.white; if (!p1uncommonbool) { GUI.color = dblack; } GUI.contentColor = Color.white; bool p1uncommonclick = GUI.Button(p1uncommonrect, "U"); GUI.color = Color.white; if (!p1rarebool) { GUI.color = dblack; } GUI.contentColor = Color.yellow; bool p1rareclick = GUI.Button(p1rarerect, "R"); GUI.contentColor = Color.white; GUI.color = Color.white; if (!p1mt3bool) { GUI.color = dblack; } bool p1mt3click = GUI.Button(p1mt3rect, ">3"); GUI.color = Color.white; GUI.contentColor = Color.red; bool p1closeclick = GUI.Button(p1clearrect, "X"); if (p1growthclick) { p1growthbool = !p1growthbool; }; if (p1orderclick) { p1orderbool = !p1orderbool; } if (p1energyclick) { p1energybool = !p1energybool; }; if (p1decayclick) { p1decaybool = !p1decaybool; } if (p1commonclick) { p1commonbool = !p1commonbool; }; if (p1uncommonclick) { p1uncommonbool = !p1uncommonbool; } if (p1rareclick) { p1rarebool = !p1rarebool; }; if (p1mt3click) { p1mt3bool = !p1mt3bool; } if (p1closeclick) { this.selfsearchstring = ""; this.p1cf = CardFilter.from(""); p1growthbool = true; p1orderbool = true; p1energybool = true; p1decaybool = true; p1commonbool = true; p1uncommonbool = true; p1rarebool = true; p1mt3bool = false; } //clear p1moddedlist only if necessary if (selfcopy != this.selfsearchstring || p1closeclick || (p1growthclick && p1growthbool) || (p1orderclick && p1orderbool) || (p1energyclick && p1energybool) || (p1decayclick && p1decaybool) || (p1commonclick && p1commonbool) || (p1uncommonclick && p1uncommonbool) || (p1rareclick && p1rarebool) || p1mt3click) { //Console.WriteLine("delete dings####"); this.p1moddedlist.Clear(); this.p1moddedlist.AddRange(this.orgicardsPlayer1); string[] res = { "", "", "", "" }; if (p1decaybool) { res[0] = "decay"; }; if (p1energybool) { res[1] = "energy"; }; if (p1growthbool) { res[2] = "growth"; }; if (p1orderbool) { res[3] = "order"; }; int[] rare = { -1, -1, -1 }; if (p1rarebool) { rare[2] = 2; }; if (p1uncommonbool) { rare[1] = 1; }; if (p1commonbool) { rare[0] = 0; }; if (this.p1mt3bool) { this.searchmorethan3(); } this.onlytradeableself(); this.p1cf = CardFilter.from(""); if (this.selfsearchstring != "") { this.p1cf = CardFilter.from(this.selfsearchstring); this.containsname(this.selfsearchstring); } this.searchforownenergy(res); this.searchforownrarity(rare); this.updatetradeself(); } else { if (selfcopy != this.selfsearchstring ) { this.p1cf = CardFilter.from(""); if (this.selfsearchstring != "") { this.p1cf = CardFilter.from(this.selfsearchstring); this.containsname(this.selfsearchstring); this.updatetradeself(); } } if (p1growthclick || p1orderclick || p1energyclick || p1decayclick ) { string[] res = { "", "", "", "" }; if (p1decaybool) { res[0] = "decay"; }; if (p1energybool) { res[1] = "energy"; }; if (p1growthbool) { res[2] = "growth"; }; if (p1orderbool) { res[3] = "order"; }; this.searchforownenergy(res); this.updatetradeself(); } if (p1commonclick || p1uncommonclick || p1rareclick) { int[] rare = { -1, -1, -1 }; if (p1rarebool) { rare[2] = 2; }; if (p1uncommonbool) { rare[1] = 1; }; if (p1commonbool) { rare[0] = 0; }; this.searchforownrarity(rare); this.updatetradeself(); } } GUI.contentColor = Color.white; GUI.color = Color.white; if (!p2growthbool) { GUI.color = dblack; } bool p2growthclick = GUI.Button(p2growthrect, growthres ); GUI.color = Color.white; if (!p2orderbool) { GUI.color = dblack; } bool p2orderclick = GUI.Button(p2orderrect, orderres); GUI.color = Color.white; if (!p2energybool) { GUI.color = dblack; } bool p2energyclick = GUI.Button(p2energyrect, energyres); GUI.color = Color.white; if (!p2decaybool) { GUI.color = dblack; } bool p2decayclick = GUI.Button(p2decayrect, decayres); GUI.color = Color.white; if (!p2commonbool) { GUI.color = dblack; } GUI.contentColor = Color.gray; bool p2commonclick = GUI.Button(p2commonrect, "C"); GUI.color = Color.white; if (!p2uncommonbool) { GUI.color = dblack; } GUI.contentColor = Color.white; bool p2uncommonclick = GUI.Button(p2uncommonrect, "U"); GUI.color = Color.white; if (!p2rarebool) { GUI.color = dblack; } GUI.contentColor = Color.yellow; bool p2rareclick = GUI.Button(p2rarerect, "R"); GUI.contentColor = Color.white; GUI.color = Color.white; if (!p2mt3bool) { GUI.color = dblack; } bool p2mt3click = GUI.Button(p2mt3rect, ">3"); GUI.color = Color.white; GUI.contentColor = Color.red; bool p2closeclick = GUI.Button(p2clearrect, "X"); if (p2growthclick) { p2growthbool = !p2growthbool; }; if (p2orderclick) { p2orderbool = !p2orderbool; } if (p2energyclick) { p2energybool = !p2energybool; }; if (p2decayclick) { p2decaybool = !p2decaybool; } if (p2commonclick) { p2commonbool = !p2commonbool; }; if (p2uncommonclick) { p2uncommonbool = !p2uncommonbool; } if (p2rareclick) { p2rarebool = !p2rarebool; }; if (p2mt3click) { p2mt3bool = !p2mt3bool; } if (p2closeclick) { this.opposearchstring = ""; this.p2cf = CardFilter.from(""); p2growthbool = true; p2orderbool = true; p2energybool = true; p2decaybool = true; p2commonbool = true; p2uncommonbool = true; p2rarebool = true; p2mt3bool = false; } //clear p1moddedlist only if necessary if (oppocopy != this.opposearchstring || p2closeclick || (p2growthclick && p2growthbool) || (p2orderclick && p2orderbool) || (p2energyclick && p2energybool) || (p2decayclick && p2decaybool) || (p2commonclick && p2commonbool) || (p2uncommonclick && p2uncommonbool) || (p2rareclick && p2rarebool) || p2mt3click) { //Console.WriteLine("delete dings####"); this.p2moddedlist.Clear(); this.p2moddedlist.AddRange(this.orgicardsPlayer2); string[] res = { "", "", "", "" }; if (p2decaybool) { res[0] = "decay"; }; if (p2energybool) { res[1] = "energy"; }; if (p2growthbool) { res[2] = "growth"; }; if (p2orderbool) { res[3] = "order"; }; int[] rare = { -1, -1, -1 }; if (p2rarebool) { rare[2] = 2; }; if (p2uncommonbool) { rare[1] = 1; }; if (p2commonbool) { rare[0] = 0; }; this.onlytradeableoppo(); this.p2cf = CardFilter.from(""); if (this.opposearchstring != "") { this.p2cf = CardFilter.from(this.opposearchstring); this.containsopponentname(this.opposearchstring); } this.searchforoppoenergy(res); this.searchforopporarity(rare); if (this.p2mt3bool) { this.searchmorethan3oppo(); } this.updatetradeoppo(); } else { if (oppocopy != this.opposearchstring) { this.p2cf = CardFilter.from(""); if (this.opposearchstring != "") { this.p2cf = CardFilter.from(this.opposearchstring); this.containsopponentname(this.opposearchstring); this.updatetradeoppo(); } } if (p2growthclick || p2orderclick || p2energyclick || p2decayclick) { string[] res = { "", "", "", "" }; if (p2decaybool) { res[0] = "decay"; }; if (p2energybool) { res[1] = "energy"; }; if (p2growthbool) { res[2] = "growth"; }; if (p2orderbool) { res[3] = "order"; }; this.searchforoppoenergy(res); this.updatetradeoppo(); } if (p2commonclick || p2uncommonclick || p2rareclick) { int[] rare = { -1, -1, -1 }; if (p2rarebool) { rare[2] = 2; }; if (p2uncommonbool) { rare[1] = 1; }; if (p2commonbool) { rare[0] = 0; }; this.searchforopporarity(rare); this.updatetradeoppo(); } } /* if (oppocopy != this.opposearchstring || p2growthclick || p2orderclick || p2energyclick || p2decayclick || p2commonclick || p2uncommonclick || p2rareclick || p2mt3click || p2closeclick) { this.p2moddedlist.Clear(); this.p2moddedlist.AddRange(this.orgicardsPlayer2); string[] res = { "", "", "", "" }; if (p2decaybool) { res[0] = "decay"; }; if (p2energybool) { res[1] = "energy"; }; if (p2growthbool) { res[2] = "growth"; }; if (p2orderbool) { res[3] = "order"; }; int[] rare = { -1, -1, -1 }; if (p2rarebool) { rare[2] = 2; }; if (p2uncommonbool) { rare[1] = 1; }; if (p2commonbool) { rare[0] = 0; }; this.onlytradeableoppo(); if (this.opposearchstring != "") { this.containsopponentname(this.opposearchstring); } this.searchforoppoenergy(res); this.searchforopporarity(rare); if (this.p2mt3bool) { this.searchmorethan3oppo(); } this.updatetrade(); }*/ } } if (info.target is Lobby && info.targetMethod.Equals("Start")) { //Console.WriteLine("startlobby"); if (lby == null) { lby = (Lobby)info.target; lbyinfo = info; this.p1cards = (List<Card>)cardsPlayer1field.GetValue(lbyinfo.target); this.p2cards = (List<Card>)cardsPlayer2field.GetValue(lbyinfo.target); anzupdates = 0; this.searchedself = false; this.searchedoppo = false; } } if (info.target is TradeSystem && info.targetMethod.Equals("SetTradeRoomName")) { this.traderoomname = (string)info.arguments[0]; } if (info.target is TradeSystem && info.targetMethod.Equals("StartTrade")) { //Console.WriteLine("STARTTRAD2E"); if (ts == null) { trading = true; ts = (TradeSystem)info.target; this.p1moddedlist.Clear(); this.p2moddedlist.Clear(); this.orginalp1name = (string)info.arguments[2]; this.orginalp2name = (string)info.arguments[3]; this.orginalint = (int)info.arguments[4]; this.selfsearchstring = ""; this.opposearchstring = ""; } } if (info.target is TradeSystem && info.targetMethod.Equals("UpdateView")) { //Console.WriteLine("updateview"+anzupdates.ToString()); if ((Boolean)info.arguments[0] == false && this.anzupdates<=1) { this.orgicardsPlayer1.Clear(); this.orgicardsPlayer2.Clear(); this.orgicardsPlayer1.AddRange(p1cards); this.orgicardsPlayer2.AddRange(p2cards); this.p1moddedlist.Clear(); this.p2moddedlist.Clear(); this.p1moddedlist.AddRange(this.orgicardsPlayer1); this.p2moddedlist.AddRange(this.orgicardsPlayer2); //Console.WriteLine("cards"); //foreach (Card c in this.orgicardsPlayer1) { Console.WriteLine(c.getName()); }; //foreach (Card c in this.orgicardsPlayer2) { Console.WriteLine(c.getName()); }; //Rect outerArea1 = (Rect)typeof(Lobby).GetField("outerArea1", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(lbyinfo.target); //Console.WriteLine("outer area" + outerArea1.height); if (anzupdates == 1) // only show at the second time (first time you get own cards, second time you get opponent cards) { this.onlytradeable(); this.updatetrade(); } } anzupdates++; //collect tradeview changes: if ((Boolean)info.arguments[0] == true) { this.player1 = (TradeInfo)info.arguments[1]; this.player2 = (TradeInfo)info.arguments[2]; this.updatetrade(); } } if (info.target is TradeSystem && info.targetMethod.Equals("CloseTrade")) { ts = null; lby = null; player1 = new TradeInfo(); player2 = new TradeInfo(); trading = false; this.traderoomname = ""; } return; }