private void Sv0vtSetUp(string param, IUbrzanoTijeloModel tijelo)
        {
            FizVel1        = FizikalneVeličine.VNulaBrzina;
            FizVel2        = FizikalneVeličine.Brzina;
            FizVel3        = FizikalneVeličine.Vrijeme;
            FizVelRjesenje = FizikalneVeličine.Put;

            if (tijelo.VeličinaMjerneJedinice == "km, s")
            {
                Vrijednost1        = 0;
                Vrijednost2        = Math.Round(tijelo.BrzinaVrijednost / 3.6, 2);
                Vrijednost3        = tijelo.VrijemeVrijednost;
                VrijednostRješenje = Formule.Sv0vtFormula(Vrijednost1, Vrijednost2, Vrijednost3);
                DicVrijednosti     = dicVrijednosti.FzikalneMjerneJediniceRiječnik("m, s");
            }
            else
            {
                Vrijednost1        = 0;
                Vrijednost2        = tijelo.BrzinaVrijednost;
                Vrijednost3        = tijelo.VrijemeVrijednost;
                VrijednostRješenje = Formule.Sv0vtFormula(Vrijednost1, Vrijednost2, Vrijednost3);
                DicVrijednosti     = dicVrijednosti.FzikalneMjerneJediniceRiječnik("m, s");
            }

            MJ1        = dicVrijednosti.NazivMJ(FizVel1);
            MJ2        = dicVrijednosti.NazivMJ(FizVel2);
            MJ3        = dicVrijednosti.NazivMJ(FizVel3);
            MJRješenje = dicVrijednosti.NazivMJ(FizVelRjesenje);

            FormulaImage = RječnikSlika.ImageSource(param);
        }
예제 #2
0
파일: Program.cs 프로젝트: Orkad/Formule
    static void Main()
    {
        Var P  = new Var(Grec.Beta, 15);
        Var E  = new Var("E", 0.5);
        Var R  = new Var("R", 200);
        Var Ro = new Var("Ro", 250);
        Var t  = new Var("t", 20);

        F_S_A13_2(P, E, R, t).ToConsole();
        F_S_A13_2bis(P, E, Ro, t).ToConsole();

        Var a = new Var("a", 1);
        Var b = new Var("b", 2);

        Formule c = a + b;

        c.ToConsole();


        Var xs   = new Var("xs", 56);
        Var vt   = new Var("vt", 0.5);
        Var Kst  = new Var("Kst", 57);//, , , ,
        Var Ds   = new Var("Ds", 11);
        Var Do   = new Var("Do", 3);
        Var vs   = new Var("vs", 0.3);//, ,
        Var rhos = new Var(Grec.rho + "s", 34);
        Var J    = new Var("J", 60);
        Var Dj   = new Var("Dj", 58);
        Var Ps   = new Var("Ps", 59);


        Console.ReadKey();
    }
 public List <PlayerMgr> GetRangePlayers(int dist)
 {
     try
     {
         List <PlayerMgr> Players = new List <PlayerMgr>();
         lock (Helpers.Manager.clients)
         {
             for (int i = 0; i < Helpers.Manager.clients.Count; i++)
             {
                 PlayerMgr s = Helpers.Manager.clients[i];
                 //double distance = Formule.gamedistance((float)x, (float)y, s.Character.Position.x, s.Character.Position.y);
                 double distance = Formule.gamedistance(this, s.Character.Position);
                 if (distance <= dist)
                 {
                     Players.Add(s);
                 }
             }
             return(Players);
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
     return(null);
 }
        private void Svv0aSetUp(string param, IUbrzanoTijeloModel tijelo)
        {
            // stavljamo vrijednost VNula na nulu. jer u početnom trenutku miruje
            FizVel1        = FizikalneVeličine.Brzina;
            FizVel2        = FizikalneVeličine.VNulaBrzina;
            FizVel3        = FizikalneVeličine.Akceleracija;
            FizVelRjesenje = FizikalneVeličine.Put;

            // ako je brzina tijela u kilometrima akceleracija je u metrima i time sve vrijednosti spuštamo na metre
            if (tijelo.VeličinaMjerneJedinice == "km, s")
            {
                Vrijednost1        = Math.Round(tijelo.BrzinaVrijednost / 3.6, 2);
                Vrijednost2        = 0;
                Vrijednost3        = tijelo.AkceleracijaVrijednost;
                VrijednostRješenje = Formule.Svv0aFormula(Vrijednost1, Vrijednost2, Vrijednost3);
                DicVrijednosti     = dicVrijednosti.FzikalneMjerneJediniceRiječnik("m, s");
            }
            else
            {
                Vrijednost1        = tijelo.BrzinaVrijednost;
                Vrijednost2        = 0;
                Vrijednost3        = tijelo.AkceleracijaVrijednost;
                VrijednostRješenje = Formule.Svv0aFormula(Vrijednost1, Vrijednost2, Vrijednost3);
            }

            MJ1          = dicVrijednosti.NazivMJ(FizVel1);
            MJ2          = dicVrijednosti.NazivMJ(FizVel2);
            MJ3          = dicVrijednosti.NazivMJ(FizVel3);
            MJRješenje   = dicVrijednosti.NazivMJ(FizVelRjesenje);
            FormulaImage = RječnikSlika.ImageSource(param);
        }
예제 #5
0
        //----------------------------------------------------------------------
        public CResultAErreur Eval(CContexteEvaluationExpression ctxEval, params object[] parametres)
        {
            if (Formule == null)
            {
                return(null);
            }
            int nParametre = 0;
            CContexteEvaluationExpression ctxCopie = new CContexteEvaluationExpression(ctxEval.ObjetSource);

            foreach (CParametreFonctionDynamique parametre in Parametres)
            {
                CDefinitionProprieteDynamiqueVariableFormule def = new CDefinitionProprieteDynamiqueVariableFormule(
                    parametre.Nom,
                    parametre.TypeResultatExpression,
                    true);
                ctxCopie.AddVariable(def);
                if (nParametre < parametres.Length)
                {
                    ctxCopie.SetValeurVariable(def, parametres[nParametre]);
                }
                else
                {
                    ctxCopie.SetValeurVariable(def, null);
                }
                nParametre++;
            }
            CResultAErreur result = Formule.Eval(ctxCopie);

            if (!result)
            {
                result.EmpileErreur(I.T("Error while evaluating method @1|20127"));
            }
            return(result);
        }
예제 #6
0
 public KostOfBaat(Analyse a, int id, KOBEnum kobEnum, Formule formule)
 {
     VraagId        = id;
     KostOfBaatEnum = kobEnum;
     Resultaat      = 0;
     Rijen          = new List <KOBRij>();
     Formule        = formule;
 }
예제 #7
0
        public void Test_Psp_UHX13()
        {
            Formule Psp = ASME.UHX13.F_Psp_UHX13(56, 0.5, 57, 11, 3, 0.3, 34, 60, 58, 59);

            Assert.AreEqual(230.804434697856, Psp.Resultat, 0.00001);
            Assert.AreEqual("(xs+2*(1-xs)*vt+2/Kst*(Ds/Do)²*vs-(ρs²-1)/(J*Kst)-(1-J)/(2*J*Kst)*(Dj²-Ds²)/Do²)*Ps", Psp.Litterale);
            Assert.AreEqual("(56+2*(1-56)*0,5+2/57*(11/3)²*0,3-(34²-1)/(60*57)-(1-60)/(2*60*57)*(58²-11²)/3²)*59", Psp.Numerique);
        }
예제 #8
0
    public void VerifFormule()
    {
        iField = focusHandler.getCurrentFormule();
        output = focusHandler.getCurrentVerif();

        if (string.IsNullOrEmpty(iField.text))
        {
            return;
        }
        try
        {
            Formule     formule = FormuleFactory.parse(iField.text);
            Jardin      jardin  = terrainHandler.getJardin();
            Communicate comm    = new Communicate(SCRIPT_PYTHON, jardin);
            foreach (Element el in jardin.GetElements())
            {
                Debug.Log(el);
            }


            //lance le script
            comm.GetSource().Execute(comm.GetScope());
            object pythonForm = comm.HandleForm(formule);
            Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form");
            var res = unity_eval_one_form(pythonJardin, pythonForm);
            Debug.Log("res=" + res);

            //Affiche résultat
            if ((bool)res == true)
            {
                output.color = Color.green;
                output.text  = "Vrai";
            }
            else
            {
                output.color = Color.red;
                output.text  = "Faux";
            }
        }
        catch (ParserLogException)
        {
            output.color = Color.red;
            output.text  = "Erreur";
            Debug.Log("Erreur formule");
        }
        catch (ValueErrorException)
        {
            output.color = new Color32(255, 128, 0, 255);
            output.text  = "Var libre";
        }
        catch (Exception)
        {
            output.color = Color.red;
            output.text  = "Erreur imprévue";
        }
    }
        public void GotoPlayer(character Player, double distance)
        {
            try
            {
                StopMovement();

                float farkx = Player.Position.x + 1; // later have to modify
                float farky = Player.Position.y + 1;
                //Systems.aRound(ref Player.aRound, ref farkx, ref farky);

                xSec = (byte)((farkx / 192) + 135);
                ySec = (byte)((farky / 192) + 92);

                //don't follow the player into the town.
                bool inTown = ObjData.Manager.safeZone.Exists(
                    delegate(ObjData.region r)
                {
                    if (r.SecX == xSec && r.SecY == ySec)
                    {
                        return(true);
                    }
                    return(false);
                });

                Send(Client.Packet.Movement(new ObjData.vektor(UniqueID,
                                                               (float)Formule.packetx((float)farkx, Player.Position.xSec),
                                                               (float)Player.Position.z,
                                                               (float)Formule.packety((float)farky, Player.Position.ySec),
                                                               xSec,
                                                               ySec)));

                if (inTown)
                {
                    AttackStop();
                    Attacking = false;

                    GetDie = true;
                    Die    = true;
                    DeSpawnMe();

                    return;
                }

                // Keep track of the current position of the mob.
                wx = farkx - x;
                wy = farky - y;
                // Calc for time if mob follows initalise speed info Run
                WalkingTime  = (distance / (RunningSpeed * 0.0768)) * 1000.0;
                RecordedTime = WalkingTime;

                StartMovement((int)(WalkingTime / 10));
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        private void btnMethodeAnonyme_Click(object sender, EventArgs e)
        {
            Formule Emc2 = delegate(double pV, double pM)
            {
                return(pM * Math.Pow(pV, 2));
            };

            txtEnergie.Text = Emc2(double.Parse(txtVitesse.Text), double.Parse(txtMasseKg.Text)).ToString();
        }
예제 #11
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Formule formule = await _applicationDbContext.Formules.FindAsync(id);

            _applicationDbContext.Formules.Remove(formule);
            await _applicationDbContext.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #12
0
 public static FormuleModel formuleToFormuleModel(Formule f)
 {
     return(new FormuleModel()
     {
         IdFormule = f.IdFormule,
         Nom = f.Nom,
         Description = f.Description,
         Prix = f.Prix,
         DateDebut = f.DateDebut,
         DateFin = f.DateFin
     });
 }
        //-------------------------------------------------------------------
        public object[] GetValues(CChartSetup chart)
        {
            List <object>         lstValeurs = new List <object>();
            CParametreSourceChart p          = chart.ParametresDonnees.GetSourceFV(SourceId);

            if (p != null)
            {
                CEasyQuery query = p.GetSource(chart) as CEasyQuery;
                if (query != null)
                {
                    //trouve la table
                    DataTable table = query.GetTable(TableName);
                    if (table != null)
                    {
                        DataColumn col = table.Columns[ColumnName];
                        if (col != null)
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                object val = row[col];
                                if (val == DBNull.Value)
                                {
                                    lstValeurs.Add(null);
                                }
                                else
                                {
                                    lstValeurs.Add(val);
                                }
                            }
                        }
                        else if (Formule != null)
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                CDynamicDataTableRow          dr  = new CDynamicDataTableRow(row);
                                CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(dr);
                                CResultAErreur result             = Formule.Eval(ctx);
                                if (result)
                                {
                                    lstValeurs.Add(result.Data);
                                }
                                else
                                {
                                    lstValeurs.Add(null);
                                }
                            }
                        }
                    }
                }
            }
            return(lstValeurs.ToArray());
        }
예제 #14
0
 //-----------------------------------------------
 public void OnChangeFormule(CRepresentationExpressionGraphique exp)
 {
     foreach (KeyValuePair <int, string> kv in m_dicParametresGraphiques)
     {
         if (kv.Value == exp.Id)
         {
             if (Formule != null)
             {
                 Formule.SetParametre(kv.Key, exp.FormuleFinale);
             }
         }
     }
 }
예제 #15
0
        private void HarmonyBuff_callback(object e)
        {
            try
            {
                foreach (int p in Spawn)
                {
                    PlayerMgr s = Helpers.GetInformation.GetPlayer(p);

                    //double distance = Formule.gamedistance((float)x, (float)y, s.Character.Position.x, s.Character.Position.y);
                    double distance = Formule.gamedistance(this, s.Character.Position);
                    if (distance <= Radius && !s.Character.Action.Buff.InfiniteBuffs.ContainsKey(Name))
                    {
                        byte slot = s.SkillBuffGetFreeSlot();
                        if (slot == 255)
                        {
                            return;
                        }

                        //add properties
                        foreach (KeyValuePair <string, int> a in ObjData.Manager.SkillBase[ID].Properties1)
                        {
                            if (s.SkillAdd_Properties(s, a.Key, true, slot))
                            {
                                return;
                            }
                            ;
                        }

                        s.Character.Action.Buff.SkillID[slot] = ID;
                        s.Character.Action.Buff.OverID[slot]  = s.Character.Ids.GetBuffID();
                        s.Character.Action.Buff.slot          = slot;
                        s.Character.Action.Buff.count++;

                        s.Send(s.Character.Spawn, Client.Packet.SkillIconPacket(s.Character.Information.UniqueID, ID, s.Character.Action.Buff.OverID[s.Character.Action.Buff.slot], false));
                        s.Character.Action.Buff.InfiniteBuffs.Add(Name, s.Character.Action.Buff.slot);

                        Inside.Add(s.Character.Information.UniqueID);
                    }
                    else if (distance >= Radius && s.Character.Action.Buff.InfiniteBuffs.ContainsKey(Name))
                    {
                        if (Inside.Contains(s.Character.Information.UniqueID))
                        {
                            s.SkillBuffEnd(s.Character.Action.Buff.InfiniteBuffs[Name]);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
예제 #16
0
        public async Task <ActionResult> Edit([Bind(Include = "FormuleId,FormuleNom,DebutValidite,FinValidite,IsActive,Tarif,ActiviteId")] Formule formule)
        {
            if (ModelState.IsValid)
            {
                _applicationDbContext.Entry(formule).State = EntityState.Modified;
                await _applicationDbContext.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            var activites = GetListActivitesWithLieu();

            ViewBag.ActiviteId = new SelectList(activites, formule.ActiviteId);
            return(View(formule));
        }
예제 #17
0
        // GET: Formules/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Formule formule = await _applicationDbContext.Formules.FindAsync(id);

            if (formule == null)
            {
                return(HttpNotFound());
            }
            return(View(formule));
        }
예제 #18
0
        private void FntSetUp(string param, IKružnoTijeloModel tijelo)
        {
            FizVel1        = FizikalneVeličine.BrojOkretaja;
            FizVel2        = FizikalneVeličine.Vrijeme;
            FizVelRjesenje = FizikalneVeličine.Frekvencija;

            Vrijednost1        = tijelo.BrojOkretajaVrijednost;
            Vrijednost2        = tijelo.VrijemeVrijednost;
            VrijednostRješenje = Formule.FntFormula(Vrijednost1, Vrijednost2);

            MJ1          = dicFizVeličina.NazivMJ(FizVel1);
            MJ2          = dicFizVeličina.NazivMJ(FizVel2);
            MJRješenje   = dicFizVeličina.NazivMJ(FizVelRjesenje);
            FormulaImage = RječnikSlika.ImageSource(param);
        }
예제 #19
0
        private void OmegaPiVT(string param, IKružnoTijeloModel tijelo)
        {
            FizVel1        = FizikalneVeličine.Pi;
            FizVel2        = FizikalneVeličine.VrijemePeriod;
            FizVelRjesenje = FizikalneVeličine.KutnaBrzina;

            Vrijednost1        = 3.14;
            Vrijednost2        = tijelo.VrijemePeriodVrijednost;
            VrijednostRješenje = Formule.OmegaPiVTFormula(Vrijednost1, Vrijednost2);

            MJ1          = dicFizVeličina.NazivMJ(FizVel1);
            MJ2          = dicFizVeličina.NazivMJ(FizVel2);
            MJRješenje   = dicFizVeličina.NazivMJ(FizVelRjesenje);
            FormulaImage = RječnikSlika.ImageSource(param);
        }
예제 #20
0
        public void TestPerfOperation()
        {
            int      it     = 100000;
            Var      a      = new Var("a", 2.4);
            Var      b      = new Var("b", 6.8);
            TimeSpan ts_Add = PerformanceTest(it, () => { Formule f = a + b + a + b + a + b; });
            TimeSpan ts_Sub = PerformanceTest(it, () => { Formule f = a - b - a - b - a - b; });
            TimeSpan ts_Mul = PerformanceTest(it, () => { Formule f = a * b * a * b * a * b; });
            TimeSpan ts_Div = PerformanceTest(it, () => { Formule f = a / b / a / b / a / b; });

            Console.WriteLine("Addition ={0}ms", ts_Add.TotalMilliseconds);
            Console.WriteLine("Soustraction ={0}ms", ts_Sub.TotalMilliseconds);
            Console.WriteLine("Multiplication ={0}ms", ts_Mul.TotalMilliseconds);
            Console.WriteLine("Division ={0}ms", ts_Div.TotalMilliseconds);
        }
        public void SvtSetUp(string param, IPravocrtnoTijeloModel tijelo)
        {
            FizVel1 = FizikalneVeličine.Brzina;
            FizVel2 = FizikalneVeličine.Vrijeme;
            FizVelRjesenje = FizikalneVeličine.Put;

            Vrijednost1 = tijelo.BrzinaVrijednost;
            Vrijednost2 = tijelo.VrijemeVrijednost;
            VrijednostRješenje = Formule.SvtFormula(Vrijednost1, Vrijednost2);

            MJ1 = dicFizVeličina.NazivMJ(FizVel1);
            MJ2 = dicFizVeličina.NazivMJ(FizVel2);
            MJRješenje = dicFizVeličina.NazivMJ(FizVelRjesenje);
            FormulaImage = RječnikSlika.ImageSource(param);
        }
예제 #22
0
        public async Task <ActionResult> Create([Bind(Include = "FormuleId,FormuleNom,IsActive,Tarif,ActiviteId")] Formule formule)
        {
            if (ModelState.IsValid)
            {
                _applicationDbContext.Formules.Add(formule);
                await _applicationDbContext.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            var activites = GetListActivitesWithLieu();

            ViewBag.ActiviteId = new SelectList(activites, formule.ActiviteId);
            return(View(formule));
        }
예제 #23
0
 //----------------------------------------------------------------------
 internal void ExtractOids(HashSet <string> strOids)
 {
     if (Formule != null)
     {
         ArrayList lstChamps = Formule.ExtractExpressionsType(typeof(C2iExpressionChamp));
         foreach (C2iExpressionChamp champ in lstChamps)
         {
             CDefinitionProprieteDynamiqueOID defOID = champ.DefinitionPropriete as CDefinitionProprieteDynamiqueOID;
             if (defOID != null)
             {
                 strOids.Add(defOID.NomProprieteSansCleTypeChamp.Replace("_", "."));
             }
         }
     }
 }
        void walkcallback(object e)
        {
            try
            {
                if (this != null)
                {
                    if (RecordedTime <= 0)
                    {
                        Runing = false;
                        //if (Attacking) AttackHim();
                        StopMovement();
                        if (!Attacking)
                        {
                            StartRunTimer(Rnd.Next(1, 5) * 1000);
                        }
                    }
                    else
                    {
                        // only 40% left from the movement and attacking
                        if (RecordedTime <= WalkingTime * 0.50 && Attacking && AgressiveDMG != null)
                        {
                            PlayerMgr sys      = (PlayerMgr)GetTarget();
                            double    distance = Formule.gamedistance((float)x, (float)y, sys.Character.Position.x, sys.Character.Position.y);
                            if (distance > 3 && distance < 19)
                            {
                                StopMovement();
                                GotoPlayer(sys.Character, distance);
                            }
                        }

                        x            += wx * 0.1f;
                        y            += wy * 0.1f;
                        RecordedTime -= (WalkingTime * 0.1);
                    }
                    //CheckEveryOne();
                    if (SpawnWatch.ElapsedMilliseconds >= 1000)
                    {
                        //Console.Write("StopWatch şuan {0} ms", SpawnWatch.ElapsedMilliseconds);
                        CheckEveryOne();
                        SpawnWatch.Restart();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
예제 #25
0
        private void DoAddToCart()
        {
            MenuDataLayer layer      = new MenuDataLayer();
            Formule       form       = layer.GetOne(_menu.Type);
            Menu          ChosenMenu = new Menu()
            {
                Boisson = _menu.Boisson,
                Dessert = _menu.Dessert,
                Plat    = _menu.Plat,
                Price   = form.Prix,
                Name    = $"Formule {form.Label} à {form.Prix} euros"
            };

            Session.Instance().Panier.Add(ChosenMenu);
            RedirectEvent?.Invoke(new ChoixMenu());
        }
예제 #26
0
        // GET: Formules/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Formule formule = await _applicationDbContext.Formules.FindAsync(id);

            if (formule == null)
            {
                return(HttpNotFound());
            }
            var activites = GetListActivitesWithLieu();

            ViewBag.ActiviteId = new SelectList(activites, formule.ActiviteId);
            return(View(formule));
        }
        public static byte[] ObjectSpawn(WorldMgr.spez_obj so)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            Writer.DWord(0xFFFFFFFF);                                              //Static
            Writer.DWord(so.spezType);                                             //Type
            Writer.DWord(so.ID);                                                   //skillid
            Writer.DWord(so.UniqueID);                                             //UniqueID of spawn
            Writer.Byte(so.xSec);                                                  //XSec
            Writer.Byte(so.ySec);                                                  //Ysec
            Writer.Float(Formule.packetx((float)so.x, so.xSec));                   //X
            Writer.Float(so.z);                                                    //Z
            Writer.Float(Formule.packety((float)so.y, so.ySec));                   //Y
            Writer.Word(0);                                                        //Angle
            Writer.Byte(1);                                                        //Static
            return(Writer.GetBytes());
        }
        public void CalculateNewPosition()
        {
            //int FoundCount = FoundPosition();
            int CAngle = 0;

            /* if (FoundCount >= 0)
             * {*/
            int   AngleIndex = Rnd.Next(0, 360);
            float INC        = Rnd.Next(0, 3) * (float)Rnd.NextDouble(),
                  MinRadius  = 0.85f,
                  MaxRadius  = 8.85f;
            float  AddX      = (INC * ObjData.Manager.AngleCos[AngleIndex]);
            float  AddY      = (INC * ObjData.Manager.AngleSin[AngleIndex]);
            double distance  = Formule.gamedistance(x + AddX, y + AddY, x, y);

            if (distance >= MinRadius && distance <= MaxRadius)
            {
                x     += AddX;
                y     += AddY;
                CAngle = Convert.ToInt32(Math.Atan2(x, y) * 10430.38208);
                if (CAngle >= 32000)
                {
                    Log.Exception("Angle Hatası:" + CAngle);
                }
                else
                {
                    Angle = (short)CAngle;
                }
            }
            else
            {
                // Recalc
                CalculateNewPosition();
            }

            // CalculateNewPosition();

            /* }
             * else
             * {
             *   // İtem'in şimdiki pozisyonu iyi.
             *   // TODO:Bu algoritmanın geliştirilmesi gerekiyor.
             * }*/
        }
        public void ObjeSleepCallBack(object e)
        {
            try
            {
                State  = 3;
                bSleep = false;

                Send(Packet.Movement(new ObjData.vektor(UniqueID,
                                                        (float)Formule.packetx((float)x, xSec),
                                                        (float)z,
                                                        (float)Formule.packety((float)y, ySec),
                                                        xSec,
                                                        ySec)));
                objeSleep.Dispose();
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        public static byte[] SpawnPortal(WorldMgr.Monsters o, WorldMgr.character c, int itemid)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            Writer.DWord(o.ID);
            Writer.DWord(o.UniqueID);
            Writer.Byte(o.xSec);
            Writer.Byte(o.ySec);
            Writer.Float(Formule.packetx((float)o.x, o.xSec));
            Writer.Float(o.z);
            Writer.Float(Formule.packety((float)o.y, o.ySec));
            Writer.Word(0);
            Writer.Byte(1);
            Writer.Byte(0);
            Writer.Byte(1);
            Writer.Byte(6);
            Writer.Text(c.Information.Name);
            Writer.DWord(itemid);
            Writer.Byte(1);
            return(Writer.GetBytes());
        }
예제 #31
0
    /*
     * Récupère récursivement les classes python correspondants aux différents éléments de la formule
     * Le cas d'arrêt est le fait de ne plus avoir d'éléments dans la liste Args ce qui signifie qu'on
     * a atteint les feuilles de l'ast.
     * Retourne un objet correspondant à une formule python
     */
    public object HandleForm(Formule f)
    {
        object pythonForm = null;
        object[] sub = new object[3];
        int i = 0;

        //Debug.Log(f.ToString());
        if (f.getArgs() != null)
        {
            foreach (Formule form in f.getArgs())
            {
               /* Debug.Log("i: " + i + "type " + form.getType() );
                if (form.getArgs() != null)
                    Debug.Log("i: " + i + "args = " + form.getArgs().Count());
                else
                    Debug.Log("i: " + i + "args = 0");*/
                sub[i] = HandleForm(form);
                i++;
            }
        }

        Formule.Formule_Type type = f.getType();
        switch (type)
        {
            case Formule.Formule_Type.constante:
                if (!jardin.GetConstantes().Contains(f.getNom()))
                    throw new CommException("Error: La constante " + f.getNom() + " n'existe pas dans le jardin.");
                if (f.getArgs() == null)
                    sub[0] = pythonEmptyArray();
                pythonForm = pythonBinaire("Cons_term", f.getNom(), sub[0]);
               // Debug.Log(" Constante " + f.getNom());
                break;
            case Formule.Formule_Type.variable:
               pythonForm = pythonUnaire("Var_term", f.getNom());
                //Debug.Log(" Variable " + f.getNom());
                break;
           case Formule.Formule_Type.predicat:
                object array = pythonCreateArray(sub[0]);
                for (int j = 1; j < i; j++)
                    array = pythonAddInArray(array, sub[j]);
                pythonForm = pythonBinaire("F1_Atom", f.getNom(), array);
               // Debug.Log(" predicat " + f.getNom());
                break;
           case Formule.Formule_Type.neg:
                pythonForm = pythonUnaire("F1_Neg", sub[0]);
               // Debug.Log(" neg");
                break;
           case Formule.Formule_Type.and:
                pythonForm = pythonBinaire("F1_And", sub[0], sub[1]);
               // Debug.Log("and");
                break;
           case Formule.Formule_Type.or:
                pythonForm = pythonBinaire("F1_Or", sub[0], sub[1]);
               // Debug.Log("or");
                break;
           case Formule.Formule_Type.impl:
                pythonForm = pythonBinaire("F1_Impl", sub[0], sub[1]);
               // Debug.Log("impl");
                break;
           case Formule.Formule_Type.forall:
                pythonForm = pythonBinaire("F1_Forall", f.getArgs().First().getNom(), sub[1]);
               // Debug.Log("forall");
                break;
           case Formule.Formule_Type.exists:
                pythonForm = pythonBinaire("F1_Exists", f.getArgs().First().getNom(), sub[1]);
               // Debug.Log("exists");
                break;
            default:
                Debug.Log("Error");
                break;
        }

        return pythonForm;
    }