Exemple #1
0
        //Preferential when calculate
        private int Preferential(obj o)
        {
            switch (o.t)
            {
            case type.function:
                return(4);
            }
            switch (o.name)
            {
            case "^":
                return(3);

            case "*":
                return(2);

            case "/":
                return(2);

            case "+":
                return(1);

            case "-":
                return(1);
            }
            return(-1);
        }
Exemple #2
0
        //Use obj transform to triangles
        public mesh(obj obj, Vector3 _position, int _color, Quaternion _rotation, float multiplier, float _absorption = 1, float _refraction = 0)
        {
            position = _position;
            color    = _color;
            rotation = _rotation;
            rotation.Normalize();
            absorption = _absorption;
            refraction = _refraction;

            shape    = new triangle[obj.shape.Length];
            vertices = new Vector3[obj.vertex.Length];

            for (int i = 0; i < vertices.Length; ++i)
            {
                vertices[i]  = obj.vertex[i];
                vertices[i] *= multiplier;
                vertices[i]  = rotation * vertices[i];
                vertices[i] += position;
            }

            for (int i = 0; i < shape.Length; i++)
            {
                shape[i] = new triangle(obj.shape[i].vertices[0], obj.shape[i].vertices[1], obj.shape[i].vertices[2], _color, _absorption);
            }
        }
Exemple #3
0
        //Replace variable by value x
        private ArrayList Not_Variable(double x)
        {
            ArrayList array = new ArrayList();

            for (int i = 0; i < Postfix_Exp.Count; i++)
            {
                array.Add(Postfix_Exp[i]);
            }
            obj o1 = new obj();

            o1.name  = x.ToString();
            o1.t     = type.number;
            o1.value = x;
            for (int i = 0; i < array.Count; i++)
            {
                if (((obj)array[i]).t == type.variable)
                {
                    if (((obj)array[i]).name != "x")
                    {
                        return(new ArrayList());
                    }
                    array[i] = o1;
                }
            }
            return(array);
        }
 public void ClientCallback_SendObjectData(int x, int y, obj otmp, int cmdtype, int where, int tile_height, ulong oflags)
 {
     lock (_gamePageLock)
     {
         _gamePage.AddObjectData(x, y, otmp, cmdtype, where, tile_height, oflags);
     }
 }
Exemple #5
0
        /// <summary>
        ///   把标识符放进table,只要传入标识符类型,然后方法根据全局变量录入符号。
        /// </summary>
        /// <param name="k"></param>
        public void enter(obj k)
        {
            tx             = tx + 1;
            Table[tx].name = id;
            Table[tx].kind = k;
            switch (k)
            {
            case obj.constant:
                if (num > Int32.MaxValue)
                {
                    error(31);
                    num = 0;
                }
                Table[tx].val = num;
                break;

            case obj.variable:
                Table[tx].level = lev;
                Table[tx].adr   = dx;
                dx++;
                break;

            case obj.procedur:
                Table[tx].level = lev;
                break;
            }
        }
Exemple #6
0
        private void createMons()
        {
            int rlocate = r.Next(1, 4);

            m1 = new obj("monster");
            m2 = new obj("monster");
            m3 = new obj("monster");

            if (rlocate == 1)
            {
                m1.Icon.Location = new Point(570, 120);
                m2.Icon.Location = new Point(250, 280);
                m3.Icon.Location = new Point(300, 550);
            }
            else if (rlocate == 2)
            {
                m1.Icon.Location = new Point(570, 150);
                m2.Icon.Location = new Point(150, 70);
                m3.Icon.Location = new Point(300, 300);
            }
            else if (rlocate == 3)
            {
                m1.Icon.Location = new Point(100, 550);
                m2.Icon.Location = new Point(480, 500);
                m3.Icon.Location = new Point(550, 300);
            }
            game.Controls.Add(m1.Icon);
            game.Controls.Add(m2.Icon);
            game.Controls.Add(m3.Icon);
        }
        static void Main(string[] args)
        {
            obj adder = new obj();

            Console.WriteLine(adder.myFunc(value1: 1, value3: 1));
            Console.ReadLine();
        }
Exemple #8
0
 private void dialogBox(obj npc)
 {
     box           = new Label();
     box.BackColor = Color.White;
     box.Size      = new Size(200, 50);
     box.Location  = new Point(npc.Icon.Left + npc.Icon.Width, npc.Icon.Top);
     game.Controls.Add(box);
 }
Exemple #9
0
        public obj Get()
        {
            var obj = new obj();

            obj.RequestId = "123";
            obj.Nmae      = "navi";
            obj.UserId    = 1234;
            return(obj);
        }
 public void addObject(obj _object)
 {
     oldObj.name                      = objects[_object.index].name;
     oldObj.img                       = objects[_object.index].img;
     oldObj.theIndex                  = objects[_object.index].theIndex;
     objects[_object.index].name      = _object.name;
     objects[_object.index].img       = _object.img;
     objects[_object.index].theIndex  = _object.theIndex;
     spritesObj[_object.index].sprite = _object.img;
 }
    public override bool Equals(obj other)
    {
        var person = other as Person;

        if (person == null)
        {
            return(false);
        }
        return(person.Id == this.Id);
    }
Exemple #12
0
        public void synch(obj o)
        {
            this.jsonEditor.Text  = o.json;
            this.keySelector.Text = o.key;

            this.regionCheckbox.Checked = o.region;
            this.widthBox.Text          = o.w.ToString();
            this.heightBox.Text         = o.h.ToString();
            this.selected = o;
        }
Exemple #13
0
        public static object[] read(Object obj, string filename)
        {
            XmlSerializer sr          = new XmlSerializer(Type.GetType(obj));
            FileStream    fs          = new FileStream(filename, FileMode.OpenOrCreate);
            XmlReader     reader      = XmlReader.Create(fs);
            obj           ObjectArray =
                writer.Close();

            return(ObjectArray[]);
        }
Exemple #14
0
 private void startGameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     player = new obj("player");
     createNPC();
     game.Show();
     game.Controls.Add(player.Icon);
     tdialog.Tick += Tdialog_Tick;
     temote.Tick  += Temote_Tick;
     tmove.Tick   += Tmove_Tick;
     this.KeyDown += MainForm_KeyDown;
 }
Exemple #15
0
 public objeditor()
 {
     InitializeComponent();
     this.keySelector.SelectedIndex = 0;
     this.selected = null;
     this.keySelector.TextChanged       += KeySelector_TextChanged;
     this.jsonEditor.TextChanged        += JsonEditor_TextChanged;
     this.widthBox.TextChanged          += WidthBox_TextChanged;
     this.heightBox.TextChanged         += HeightBox_TextChanged;
     this.regionCheckbox.CheckedChanged += RegionCheckbox_CheckedChanged;
 }
Exemple #16
0
 private void Start()
 {
     //scrap buttons
     //this for loop loads all the buttons with the right item.
     for(int i = 0; i <RefinerButtonItem.Count; i++)
     {
         obj item = new obj(findId(i),i);
         //Debug.Log(item.id + "\n"+item.pos);
         RefinerButtonItem[i].onClick.AddListener(delegate { changeItem(item); });
     }
     ofMenu.onClick.AddListener(onClose);
 }
Exemple #17
0
        public JsonResult Select2AjaxTable(string PageName, string colname, List <inputParameter> Parameters)
        {
            Page Info = PDAL.FindPage(PageName);

            ConvertNullToEmpty(Parameters);

            column Pp = null;

            for (int k = 0; k < Info.tables[0].columns.Count; k++)
            {
                if (Info.tables[0].columns[k].name == colname)
                {
                    Pp = Info.tables[0].columns[k];
                }
            }

            for (int k = 0; k < Pp.DBSelectCommandParameters.Count; k++)
            {
                if (Pp.DBSelectCommandParameters[k].source == "Session")
                {
                    inputParameter i = new inputParameter();
                    i.key   = Pp.DBSelectCommandParameters[k].name;
                    i.value = PDAL.GetSession(Pp.DBSelectCommandParameters[k].Parameter);
                    Parameters.Add(i);
                }
            }


            DataTable   Dt = PDAL.ReadRecords(ref Pp.DBSelect2Command, Parameters);
            List <item> it = new List <item>();

            for (int k = 0; k < Pp.options.Count; k++)
            {
                item i = new item();
                i.id   = Pp.options[k].value;
                i.text = Pp.options[k].text;
                it.Add(i);
            }
            for (int k = 0; k < Dt.Rows.Count; k++)
            {
                item i = new item();
                i.id   = Dt.Rows[k][Pp.codeColumn].ToString();
                i.text = Dt.Rows[k][Pp.textColumn].ToString();
                it.Add(i);
            }

            obj o = new obj();

            o.results = it.ToArray();
            return(Json(o));
        }
        public async Task <JsonResult> doFoto(string id)
        {
            var rm                   = RegistryManager.CreateFromConnectionString(_configuration["IoTHubConnectionString"]);
            var bytes                = Encoding.UTF8.GetBytes("scattafoto");
            var message              = new Microsoft.Azure.Devices.Message(bytes);
            var deviceId             = _configuration["deviceId"];
            var authenticationMethod = new DeviceAuthenticationWithRegistrySymmetricKey(deviceId, _configuration["deviceKey"]);
            var transportType        = Microsoft.Azure.Devices.Client.TransportType.Mqtt;

            if (!string.IsNullOrWhiteSpace(_configuration["transportType"]))
            {
                transportType = (Microsoft.Azure.Devices.Client.TransportType)Enum.Parse(typeof(Microsoft.Azure.Devices.Client.TransportType), _configuration["transportType"], true);
            }
            var client        = DeviceClient.Create(_configuration["hostName"], authenticationMethod, transportType);
            var serviceClient =
                ServiceClient.CreateFromConnectionString(
                    _configuration["IoTHubConnectionString"]);
            var x = new obj();

            try
            {
                await serviceClient.SendAsync(id, message);

                var twin = await client.GetTwinAsync();

                while (true)
                {
                    var msg = await client.ReceiveAsync();

                    if (msg == null)
                    {
                        continue;
                    }

                    var bts = msg.GetBytes();
                    if (bts == null)
                    {
                        continue;
                    }

                    var text = Encoding.UTF8.GetString(bts);
                    x.img = text;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Scrivi: scattafoto");
            }
            return(Json(x));
        }
Exemple #19
0
        private void createNPC()
        {
            npc1 = new obj("npc1");
            npc2 = new obj("npc2");
            npc3 = new obj("npc3");

            npc1.Icon.Location = new Point(120, 200);
            npc2.Icon.Location = new Point(440, 50);
            npc3.Icon.Location = new Point(600, 400);

            game.Controls.Add(npc1.Icon);
            game.Controls.Add(npc2.Icon);
            game.Controls.Add(npc3.Icon);
        }
Exemple #20
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if ((mask & 1 << other.gameObject.layer) == 1 << other.gameObject.layer) //Test it against our collision layer mask
     {
         var rb = other.gameObject.GetComponent <Rigidbody2D>();
         if (rb)
         {
             var o = new obj(rb);
             objects.Add(o);
             var cont = other.gameObject.GetComponent <CharacterController2D>();
             if (cont)
             {
                 cont.setIsOnConveyor(true);
             }
         }
     }
 }
Exemple #21
0
 public void sendMessage(string name, dynamic command)
 {
     if (connected == true)
     {
         obj    JsonObj   = new obj(name, command, "N/A");
         string JasonText = JsonConvert.SerializeObject(JsonObj) + ';';
         Byte[] data      = System.Text.Encoding.UTF8.GetBytes(JasonText);
         //Byte[] data = System.Text.Encoding.UTF8.GetBytes(command.ToString());
         try { stream.Write(data, 0, data.Length); }
         catch (System.IO.IOException)
         {
             MessageBox.Show("Connection Failed", "Send ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
             connected = false;
         }
         //if (command == 128) { connected = false; }
     }
 }
Exemple #22
0
        public async Task <IActionResult> TestName([FromBody] obj obj)
        {
            string ques = await Task.FromResult(context.Questions.AsEnumerable()
                                                .Where(que => que.Text == obj.tex).Select(que => que.Answer).FirstOrDefault());

            string quesWithoutAccents    = RemoveAccents(ques);
            string obj_ansWithoutAccents = RemoveAccents(obj.ans);

            if (quesWithoutAccents.Equals(obj_ansWithoutAccents, StringComparison.CurrentCultureIgnoreCase))
            {
                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }
Exemple #23
0
        static void Main(string[] args)
        {
            var i = 1;
            var j = 2;
            var k = i == 1 ? i : j;

            Console.WriteLine(j);
            Console.WriteLine(k);
            Console.WriteLine("----------------------");

            object a = 3;
            var    b = new obj("abc");
            object x = a ?? b;

            Console.WriteLine(b.ToString());
            Console.WriteLine(x);
            Console.ReadKey();
        }
Exemple #24
0
 private void goForrest()
 {
     if (player.Icon.Top >= game.Height - player.Icon.Height &&
         (player.Icon.Left >= 350 && player.Icon.Left <= 500))
     {
         game.Controls.Remove(npc1.Icon);
         game.Controls.Remove(npc2.Icon);
         game.Controls.Remove(npc3.Icon);
         npc1 = null;
         npc2 = null;
         npc3 = null;
         game.BackgroundImage = Image.FromFile("map/forrest.png");
         player.Icon.Location = new Point(100, 100);
         createChest();
         createMons();
         moveMons();
     }
 }
Exemple #25
0
    public override Equals(obj o)
    {
        if (ReferenceEquals(null, o))
        {
            return(false);
        }
        if (ReferenceEquals(this, o))
        {
            return(true);
        }
        if (o.GetType() != typeof(MyValue))
        {
            return(false);
        }
        var v2 = o as MyValue;

        return(Equals(v2.Property1, this.Property1));
        // if you want to compare more than one property use && and Equals on them all
    }
Exemple #26
0
        public IActionResult Get()
        {
            obj result = new obj()
            {
                id      = "test1",
                title   = "test1",
                comment = "test1",
                status  = true
            };

            //for(int i = 0; i < 10; i++)
            //{
            //    result[i].id = "_test" + i;
            //    result[i].title = "_test" + i;
            //    result[i].comment = "_test" + i;
            //    result[i].status = true;
            //}

            return(Ok(result));
        }
Exemple #27
0
 private void UpdateValve(obj Object, Valve valve)
 {
     if (Object.Value == "Open")
     {
         valve.Open();
     }
     else if (Object.Value == "Close")
     {
         valve.Close();
     }
     //update feedback
     if (Object.Feedback == "Nom")
     {
         valve.Feedback = Valve.State.Nominal;
     }
     else if (Object.Feedback == "Fail")
     {
         valve.Feedback = Valve.State.Failure;
     }
     else
     {
         valve.Feedback = Valve.State.Unknown;
     }
 }
Exemple #28
0
 TYPE_FUNCTION => ToIshtarObject(new IshtarLayerFunction(obj, frame).Name),
 private void comboBox3_SelectedIndexChanged(obj sender, System.EventArgs e)
 {
     int[] price = {30, 45, 60};
      roadsidePrice = price[comboBox3.SelectedIndex];
      total = stereoPrice + powerPrice + roadsidePrice;
      label2.Text = "Option package = " +
     total.ToString("C");
 }
Exemple #30
0
        public string ToJson()
        {
            var obj = new json_dat();
            obj.width = Width; obj.height = Height;
            List<loc> locs = new List<loc>();
            MemoryStream ms = new MemoryStream();
            using (PacketWriter wtr = new PacketWriter(ms))
                for (int y = 0; y < obj.height; y++)
                    for (int x = 0; x < obj.width; x++)
                    {
                        var loc = new loc();
                        loc.ground = Tiles[x][y] != -1 ? GetTileId((ushort)Tiles[x][y]) : null;
                        loc.objs = new obj[Entities[x][y].Length];
                        for (int i = 0; i < loc.objs.Length; i++)
                        {
                            var en = Entities[x][y][i];
                            obj o = new obj()
                            {
                                id = GetEntityId(en.ObjectType)
                            };
                            string s = "";
                            Dictionary<StatsType, object> vals = new Dictionary<StatsType, object>();
                            foreach (var z in en.Status.Data) vals.Add(z.Id, z.IsStringData() ? (object)z.StringValue : (object)z.IntValue);
                            if (vals.ContainsKey(StatsType.Name))
                                s += ";name:" + vals[StatsType.Name];
                            if (vals.ContainsKey(StatsType.Size))
                                s += ";size:" + vals[StatsType.Size];
                            if (vals.ContainsKey(StatsType.ObjectConnection))
                                s += ";conn:0x" + ((int)vals[StatsType.ObjectConnection]).ToString("X8");
                            if (vals.ContainsKey(StatsType.MerchandiseType))
                                s += ";mtype:" + vals[StatsType.MerchandiseType];
                            if (vals.ContainsKey(StatsType.MerchandiseRemainingCount))
                                s += ";mcount:" + vals[StatsType.MerchandiseRemainingCount];
                            if (vals.ContainsKey(StatsType.MerchandiseRemainingMinutes))
                                s += ";mtime:" + vals[StatsType.MerchandiseRemainingMinutes];
                            if (vals.ContainsKey(StatsType.RankRequired))
                                s += ";nstar:" + vals[StatsType.RankRequired];
                            o.name = s.Trim(';');
                            loc.objs[i] = o;
                        }

                        int ix = -1;
                        for (int i = 0; i < locs.Count; i++)
                        {
                            if (locs[i].ground != loc.ground) continue;
                            if (!((locs[i].objs != null && loc.objs != null) ||
                              (locs[i].objs == null && loc.objs == null))) continue;
                            if (locs[i].objs != null)
                            {
                                if (locs[i].objs.Length != loc.objs.Length) continue;
                                bool b = false;
                                for (int j = 0; j < loc.objs.Length; j++)
                                    if (locs[i].objs[j].id != loc.objs[j].id ||
                                        locs[i].objs[j].name != loc.objs[j].name)
                                    {
                                        b = true;
                                        break;
                                    }
                                if (b)
                                    continue;
                            }
                            ix = i;
                            break;
                        }
                        if (ix == -1)
                        {
                            ix = locs.Count;
                            locs.Add(loc);
                        }
                        wtr.Write((short)ix);
                    }
            obj.data = ZlibStream.CompressBuffer(ms.ToArray());
            obj.dict = locs.ToArray();
            var settings = new JsonSerializerSettings();
            settings.NullValueHandling = NullValueHandling.Ignore;
            return JsonConvert.SerializeObject(obj, settings);
        }
Exemple #31
0
 return (Iterator<Object>) it.execute(obj, null);
Exemple #32
0
        /////////////////////////////////////////////////////////////////////////////
        // Load objects
        /////////////////////////////////////////////////////////////////////////////
        public static void LoadObject()
        {
            //Junk ........ ugh
            TxtFile.ReadFromFile(@"\data\npcpos.txt", '\t');
            string Spawninfo = Systems.Rate.Spawns.ToString();
            string s = null;
            int count = TxtFile.amountLine;
            uint index = 0;
            int npcamount = Convert.ToInt16(Spawninfo);
            int countme = 0;
            for (int l = 0; l <= TxtFile.amountLine - 1; l++)
            {
                s = TxtFile.lines[l].ToString();
                TxtFile.commands = s.Split('\t');
                int ID = Convert.ToInt32(TxtFile.commands[0]);
                string namecheck = Data.ObjectBase[ID].Name;

                if (namecheck.Contains("MOB_"))
                {
                    countme += 1;

                    //Should redo this , if static non moving monster , set AROUND , random location from source location.
                    if (ID == 1979 || ID == 2101 || ID == 2124 || ID == 2111 || ID == 2112)
                        npcamount = 1;

                    for (int i = 1; i <= npcamount; i++)
                    {
                        obj o = new obj();
                        index++;
                        short AREA = short.Parse(TxtFile.commands[1]);
                        float x = Convert.ToInt32(TxtFile.commands[2]);
                        float z = Convert.ToInt32(TxtFile.commands[3]);
                        float y = Convert.ToInt32(TxtFile.commands[4]);

                        //:S localtype not needed just set state speed information
                        if (ID == 1979 || ID == 2101 || ID == 2124 || ID == 2111 || ID == 2112)
                        {
                            o.AutoMovement = false;
                            o.LocalType = Data.ObjectBase[ID].Type;
                        }
                        else
                        {
                            o.AutoMovement = true;
                            o.LocalType = Data.ObjectBase[ID].Type;
                        }

                        o.OrgMovement = o.AutoMovement;
                        if (o.AutoMovement)
                            o.StartRunTimer(Global.RandomID.GetRandom(5000, 8000));
                        o.ID = ID;
                        o.Ids = new Global.ID(Global.ID.IDS.Object);
                        o.UniqueID = o.Ids.GetUniqueID;

                        o.xSec = Convert.ToByte((AREA).ToString("X4").Substring(2, 2), 16);
                        o.ySec = Convert.ToByte((AREA).ToString("X4").Substring(0, 2), 16);
                        o.x = (o.xSec - 135) * 192 + (x) / 10;
                        o.z = z;
                        o.y = (o.ySec - 92) * 192 + (y) / 10;

                        o.oX = o.x;
                        o.oY = o.y;
                        Systems.aRound(ref o.oX, ref o.oY, 9);
                        o.State = 1;
                        o.Move = 1;
                        o.AutoSpawn = true;
                        o.State = 2;
                        o.HP = Data.ObjectBase[ID].HP;
                        o.Kat = 1;
                        o.Agro = new List<_agro>();
                        o.SpeedWalk = Data.ObjectBase[o.ID].SpeedWalk;
                        o.SpeedRun = Data.ObjectBase[o.ID].SpeedRun;
                        o.SpeedZerk = Data.ObjectBase[o.ID].SpeedZerk;
                        o.oldAgresif = o.Agresif;
                        if (o.Type == 1) o.Agresif = 1;
                        //if (o.Type == 0) o.Agresif = 0;
                        o.spawnOran = 20;
                        if (ID == 1979 || ID == 2101 || ID == 2124 || ID == 2111 || ID == 2112) o.AutoMovement = false;
                        o.OrgMovement = o.AutoMovement;

                        if (o.AutoMovement) o.StartRunTimer(Global.RandomID.GetRandom(5000, 8000));

                        if (Data.ObjectBase[ID].ObjectType != 3)
                        {
                            o.Type = Systems.RandomType(Data.ObjectBase[ID].Level, ref o.Kat, false, ref o.Agresif);
                            o.HP *= o.Kat;
                            if (o.Type == 1)
                                o.Agresif = 1;
                            Systems.Objects.Add(o);

                        }
                        else
                        {
                            o.AutoSpawn = false;
                            o.Type = Data.ObjectBase[ID].ObjectType; GlobalUnique.AddObject(o);

                        }
                        if (namecheck.Contains("CH")) Data.ObjectBase[ID].Race = 0;
                        if (namecheck.Contains("EU")) Data.ObjectBase[ID].Race = 1;
                        if (!namecheck.Contains("CH") && (!namecheck.Contains("EU"))) Data.ObjectBase[ID].Race = 2;
                    }
                }
            }
            Console.WriteLine("[INFO] Loaded " + TxtFile.amountLine + " monsters");
        }
Exemple #33
0
        /////////////////////////////////////////////////////////////////////////////
        // Load npcs
        /////////////////////////////////////////////////////////////////////////////
        public static void LoadNpcs()
        {
            TxtFile.ReadFromFile(@"\data\npcpos.txt", '\t');
            string input = null;
            string s = null;
            string[] npcangle1;
            int count = TxtFile.amountLine;
            uint index = 0;
            int countme = 0;
            for (int l = 0; l <= TxtFile.amountLine - 1; l++)
            {
                s = TxtFile.lines[l].ToString();
                TxtFile.commands = s.Split('\t');
                int ID = Convert.ToInt32(TxtFile.commands[0]);
                byte race = Data.ObjectBase[ID].Type;
                string namecheck = Data.ObjectBase[ID].Name;

                if (namecheck.Contains("NPC_"))
                {
                    countme += 1;
                    TextReader Npcangle = new StreamReader(Environment.CurrentDirectory + @"\data\NpcAngles.txt");
                    obj o = new obj();
                    index++;
                    short AREA = short.Parse(TxtFile.commands[1]);
                    double x = Convert.ToDouble(TxtFile.commands[2].Replace('.', ','));
                    double z = Convert.ToDouble(TxtFile.commands[3].Replace('.', ','));
                    double y = Convert.ToDouble(TxtFile.commands[4].Replace('.', ','));

                    byte movement = 0;
                    o.Agresif = movement;
                    o.AutoMovement = true;
                    o.ID = ID;
                    o.Ids = new Global.ID(Global.ID.IDS.Object);
                    o.UniqueID = o.Ids.GetUniqueID;
                    o.area = AREA;
                    o.xSec = Convert.ToByte((AREA).ToString("X4").Substring(2, 2), 16);
                    o.ySec = Convert.ToByte((AREA).ToString("X4").Substring(0, 2), 16);
                    o.x = (o.xSec - 135) * 192 + (x) / 10;
                    o.z = z;
                    o.y = (o.ySec - 92) * 192 + (y) / 10;
                    o.oX = o.x;
                    o.oY = o.y;
                    o.State = 1;
                    o.Move = 1;
                    o.LocalType = 2;
                    o.AutoSpawn = true;
                    o.State = 2;
                    o.HP = Data.ObjectBase[ID].HP;
                    o.Kat = 1;
                    o.Agro = new List<_agro>();
                    o.spawnOran = 20;
                    o.OrgMovement = o.AutoMovement;

                    while ((input = Npcangle.ReadLine()) != null)
                    {
                        npcangle1 = input.Split(',');
                        if (ID == int.Parse(npcangle1[0]) && AREA == int.Parse(npcangle1[2]))
                        {
                            o.rotation = Int32.Parse(npcangle1[1]);
                            break;
                        }
                    }
                    Npcangle.Close();

                    if (Data.ObjectBase[ID].ObjectType != 3)
                    {
                        o.Type = Systems.RandomType(Data.ObjectBase[ID].Level, ref o.Kat, false, ref o.Agresif);
                        o.HP *= o.Kat;
                        if (o.Type == 1) o.Agresif = 1;
                        Systems.Objects.Add(o);
                    }
                    else
                    {
                        o.AutoSpawn = false;
                        o.Type = Data.ObjectBase[ID].ObjectType;
                        GlobalUnique.AddObject(o);
                    }
                }
            }
            Console.WriteLine("[INFO] Loaded " + TxtFile.amountLine + " npc's");
        }
Exemple #34
0
        /////////////////////////////////////////////////////////////////////////////
        // Teleports
        /////////////////////////////////////////////////////////////////////////////
        public static void TeleportBuilding()
        {
            TxtFile.ReadFromFile(@"\data\teleportbuilding.txt", '\t');

            string s = null;

            for (int l = 0; l <= TxtFile.amountLine - 1; l++)
            {
                s = TxtFile.lines[l].ToString();
                TxtFile.commands = s.Split('\t');

                if (!(short.Parse(TxtFile.commands[41]) == 0))
                {
                    obj o = new obj();
                    int ID = Convert.ToInt32(TxtFile.commands[1]);
                    short AREA = short.Parse(TxtFile.commands[41]);
                    double x = Convert.ToDouble(TxtFile.commands[43]);
                    double z = Convert.ToDouble(TxtFile.commands[44]);
                    double y = Convert.ToDouble(TxtFile.commands[45]);
                    o.Ids = new Global.ID(Global.ID.IDS.Object);
                    o.UniqueID = o.Ids.GetUniqueID;
                    objectdata os = new objectdata();
                    os.Name = TxtFile.commands[2];
                    Data.ObjectBase[ID] = os;
                    o.ID = ID;
                    o.area = AREA;
                    o.xSec = Convert.ToByte((AREA).ToString("X4").Substring(2, 2), 16);
                    o.ySec = Convert.ToByte((AREA).ToString("X4").Substring(0, 2), 16);
                    o.x = (o.xSec - 135) * 192 + (x) / 10;
                    o.z = z;
                    o.y = (o.ySec - 92) * 192 + (y) / 10;
                    o.HP = 0x000000C0;
                    o.LocalType = 3;
                    Data.ObjectBase[o.ID].Object_type = Global.objectdata.NamdedType.TELEPORT;
                    Systems.Objects.Add(o);
                }
            }
            Console.WriteLine("[INFO] Loaded " + TxtFile.amountLine + " teleport buildings");
            TeleportData();
        }
        public string ToJson()
        {
            var obj = new json_dat();
            obj.width = Width;
            obj.height = Height;
            var locs = new List<loc>();
            var ms = new MemoryStream();
            using (var wtr = new NWriter(ms))
                for (int y = 0; y < obj.height; y++)
                    for (int x = 0; x < obj.width; x++)
                    {
                        var loc = new loc();
                        loc.ground = dat.TileTypeToId[(byte) Tiles[x][y]];
                        loc.objs = new obj[Entities[x][y].Length];
                        for (int i = 0; i < loc.objs.Length; i++)
                        {
                            ObjectDef en = Entities[x][y][i];
                            var o = new obj
                            {
                                id = dat.ObjectTypeToId[en.ObjectType]
                            };
                            string s = "";
                            var vals = new Dictionary<StatsType, object>();
                            foreach (var z in en.Stats.Stats) vals.Add(z.Key, z.Value);
                            if (vals.ContainsKey(StatsType.Name))
                                s += ";name:" + vals[StatsType.Name];
                            if (vals.ContainsKey(StatsType.Size))
                                s += ";size:" + vals[StatsType.Size];
                            if (vals.ContainsKey(StatsType.ObjectConnection))
                                s += ";conn:0x" + ((int) vals[StatsType.ObjectConnection]).ToString("X8");
                            if (vals.ContainsKey(StatsType.MerchantMerchandiseType))
                                s += ";mtype:" + vals[StatsType.MerchantMerchandiseType];
                            if (vals.ContainsKey(StatsType.MerchantRemainingCount))
                                s += ";mcount:" + vals[StatsType.MerchantRemainingCount];
                            if (vals.ContainsKey(StatsType.MerchantRemainingMinute))
                                s += ";mtime:" + vals[StatsType.MerchantRemainingMinute];
                            if (vals.ContainsKey(StatsType.NameChangerStar))
                                s += ";nstar:" + vals[StatsType.NameChangerStar];
                            o.name = s.Trim(';');
                            loc.objs[i] = o;
                        }

                        int ix = -1;
                        for (int i = 0; i < locs.Count; i++)
                        {
                            if (locs[i].ground != loc.ground) continue;
                            if (!((locs[i].objs != null && loc.objs != null) ||
                                  (locs[i].objs == null && loc.objs == null))) continue;
                            if (locs[i].objs != null)
                            {
                                if (locs[i].objs.Length != loc.objs.Length) continue;
                                bool b = false;
                                for (int j = 0; j < loc.objs.Length; j++)
                                    if (locs[i].objs[j].id != loc.objs[j].id ||
                                        locs[i].objs[j].name != loc.objs[j].name)
                                    {
                                        b = true;
                                        break;
                                    }
                                if (b)
                                    continue;
                            }
                            ix = i;
                            break;
                        }
                        if (ix == -1)
                        {
                            ix = locs.Count;
                            locs.Add(loc);
                        }
                        wtr.Write((short) ix);
                    }
            obj.data = ZlibStream.CompressBuffer(ms.ToArray());
            obj.dict = locs.ToArray();
            return JsonConvert.SerializeObject(obj);
        }
Exemple #36
0
		void parseline (string s) {
			if (!s.StartsWith ("trace:"))
				return;

			s = s.Replace ("~", "dtor_");
			
			List<Frame> tmpstack = new List<Frame>();
			string[] act = s.Substring (6, s.IndexOf (";") - 6).Split ('|');
			string[] frames = s.Substring(s.IndexOf (";")+1).Split (';');
			int ptr = 0;
			string prev = "";
			
			action a = new action ();
			a.name = act[0];
			a.type = act[1];
			a.refcount = int.Parse (act[2]);

			foreach (string frame in frames) {
				string[] parts = frame.Split ('|');
				if (parts.Length != 3)
					break;
				if (prev == parts[2])
					continue;
				Frame f = new Frame ();
				if (!int.TryParse (parts[0], out f.type)) {
					Console.WriteLine (frame);
					continue;
				}
				f.ptr = int.Parse (parts[1], NumberStyles.AllowHexSpecifier);
				if (ptr == 0)
					ptr = f.ptr;
				if (f.type == 1)
					if (parts[2].IndexOf("_ref") > 0 || parts[2].IndexOf("_unref") > 0)
						f.name = parts[2];
					else
						f.name = parts[2];//.Substring (0, parts[2].IndexOf ("_"));
				else
					f.name = parts[2];

				if (f.name.IndexOf ("Track") > 0)
					continue;
				f.name = Regex.Replace (f.name, "[:(),.-/&`]", "_");
				f.name = f.name.Replace (" ", "_");
				f.name = f.name.Replace ("-", "_");
				
				prev = f.name;				
				tmpstack.Add (f);
			}
			a.frames = tmpstack;
			a.ptr = ptr;
			if (!objects.ContainsKey (ptr)) {
				objects[ptr] = new obj (ptr);
			} else if (objects[ptr].type == null && a.type != "")
				objects[ptr].type = a.type;

			objects[ptr].actions.Add (a);
		}
 return(new CustomProducerMachine(obj, location, tile));
Exemple #38
0
 return(obj.Name.Contains("Pufferfish Egg") ? (IAutomatable) new CustomProducerMachine(obj, location, tile) : (IAutomatable)null);
Exemple #39
0
    public int[] trackSort(int n, int[] best, int[] a)
    {
        int m = best.Length;

        int j = 0;
        int[] nbest = new int[n - best.Length];
        for (int i = 1; i <= n; i++)
        {
            bool found = false;
            for (int k = 0; k < m; k++)
            {
                if (best[k] == i)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                nbest[j++] = i;
            }
        }
        Array.Sort(nbest);

        obj[] slots = new obj[n];
        for (int i = 0; i < n; i++)
        {
            slots[i] = new obj();
            slots[i].i = i;
        }
        for (int i = 0; i < a.Length; i++)
        {
            slots[a[i] - 1].f++;
        }
        Array.Sort(slots, delegate (obj x, obj y) {
            if (y.f != x.f)
                return y.f - x.f;
            return y.i - x.i;
        });

        obj[] bslots = new obj[best.Length];
        obj[] nslots = new obj[n - best.Length];
        for (int i = 0; i < n; i++)
        {
            if (i < best.Length)
                bslots[i] = slots[i];
            else
                nslots[i-best.Length] = slots[i];
        }
        Array.Sort(bslots, delegate(obj x, obj y)
        {
            return x.i - y.i;
        });
        int[] s = new int[n];
        Array.Sort(best);
        for (int i = 0; i < bslots.Length; i++)
        {
            s[bslots[i].i] = best[i];
        }

        Array.Sort(nslots, delegate(obj x, obj y)
        {
            return x.i - y.i;
        });
        for (int i = 0; i < nslots.Length; i++)
        {
            s[nslots[i].i] = nbest[i];
        }

        return s;
    }