Exemplo n.º 1
0
        private void TimeTick(SimulationEvent e)
        {
            Dictionary <string, string> objAttributes = new Dictionary <string, string>();

            time = ((IntegerValue)e["Time"]).value;

            LocationValue lv;

            if (v3 != null)
            {
                foreach (string id in objectProxies.Keys)
                {
                    string type     = objectProxies[id].GetObjectType();
                    bool   isWeapon = ((BooleanValue)objectProxies[id]["IsWeapon"].GetDataValue()).value;

                    if (isWeapon)
                    {
                        type = "Munition";
                    }
                    objAttributes.Clear();
                    lv = (LocationValue)objectProxies[id]["Location"].GetDataValue();
                    switch (type)
                    {
                    case "AirObject":

                        objAttributes.Add("comment", time.ToString());
                        objAttributes.Add("WorldLocation", String.Format("<X>{0}</X><Y>{1}</Y><Z>{2}</Z>", lv.X, lv.Y, lv.Z));
                        v3.UpdateObjectAttributes(id, _aircraft, objAttributes, time.ToString());
                        break;

                    case "SeaObject":
                        objAttributes.Add("comment", time.ToString());
                        objAttributes.Add("WorldLocation", String.Format("<X>{0}</X><Y>{1}</Y><Z>{2}</Z>", lv.X, lv.Y, lv.Z));
                        v3.UpdateObjectAttributes(id, _seaSurface, objAttributes, time.ToString());
                        break;

                    case "LandObject":
                        objAttributes.Add("comment", time.ToString());
                        objAttributes.Add("WorldLocation", String.Format("<X>{0}</X><Y>{1}</Y><Z>{2}</Z>", lv.X, lv.Y, lv.Z));
                        v3.UpdateObjectAttributes(id, _landUnit, objAttributes, time.ToString());
                        break;

                    case "Munition":
                        objAttributes.Add("comment", time.ToString());
                        objAttributes.Add("WorldLocation", String.Format("<X>{0}</X><Y>{1}</Y><Z>{2}</Z>", lv.X, lv.Y, lv.Z));
                        v3.UpdateObjectAttributes(id, _munition, objAttributes, time.ToString());
                        break;

                    default:
                        Console.WriteLine("ExternalCommunicationSim: On TimeTick, object type \"" + type + "\" not found for object " + id);
                        break;
                    }
                }
                v3.Tick();
            }
        }