Esempio n. 1
0
    // вызывается из потока событий unity
    static private PacketTransformReady transform(PacketHeader packet)
    {
        PacketTransform transform = UnityEngine.JsonUtility.FromJson <PacketTransform>(packet.json_data);

        if (!idnames.ContainsKey(transform.idname))
        {
            return(new PacketTransformReady(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
        }

        int id = idnames[transform.idname];

        if (things.ContainsKey(id))
        {
            thing thing = (thing)things[id];
            List <UnityEngine.Vector3> pos = thing.GetPos();
            return(new PacketTransformReady(1, pos[0].x, pos[0].y, pos[0].z, pos[1].x, pos[1].y, pos[1].z, pos[2].x, pos[2].y, pos[2].z, pos[3].x));
        }

        if (tables.ContainsKey(id))
        {
            table table = (table)tables[id];
            List <UnityEngine.Vector3> pos = table.GetPos();
            return(new PacketTransformReady(1, pos[0].x, pos[0].y, pos[0].z, pos[1].x, pos[1].y, pos[1].z, pos[2].x, pos[2].y, pos[2].z, pos[3].x));
        }

        return(new PacketTransformReady(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
    }
Esempio n. 2
0
    private void OnCaught(thing thing_)
    {
        if (!IsGripped() || thing != null)
        {
            return;
        }

        thing = thing_;
        thing.joint.Config(capture.GetClamp(), thing.gameObject, true, JointPhysics.Fixed);
        chassis.GetComponent <chassismanipulator2>().thing = thing;
    }
Esempio n. 3
0
    public void SetGripper(bool gripped)
    {
        for (int i = 0; i < fingers.Count; i++)
        {
            fingers[i].Clench(gripped);
        }

        if (!gripped && thing != null)
        {
            chassis.GetComponent <chassismanipulator2>().thing = null;
            thing.joint.Break();
            thing.gameObject.GetComponent <Rigidbody>().isKinematic = false;
            thing.gameObject.GetComponent <Rigidbody>().useGravity  = true;
            thing.StartTimer();
            thing = null;
        }
    }
    public void addObject(GameObject toAdd)
    {
        int nameIndex = checkForName(things, toAdd.tag);

        if (nameIndex >= 0)
        {
            things [nameIndex].count++;
        }
        else
        {
            thing tInst = new thing();
            tInst.name = toAdd.tag;
            tInst.gO   = GameObject.Instantiate(toAdd);
            tInst.gO.SetActive(false);
            tInst.count = 1;
            things.Add(tInst);
        }
    }
Esempio n. 5
0
    private void OnTriggerEnter(Collider other, int index)
    {
        thing thing = other.gameObject.GetComponent <thing>();

        if (thing == null)
        {
            return;
        }

        if (!isclenched)
        {
            return;
        }

        if (index <= caught)
        {
            return;
        }

        caught = index;

        // переустановить лимиты, задать целевые углы
        for (int i = 0; i < config.SectionCount; i++)
        {
            if (i <= index)
            {
                sections[i].SetPos(sections[i].GetCurrent0());
            }
            else
            {
                float angle1 = 30;//угол доводки секции, который лучше выглядит
                sections[i].SetLimits(config.SectionAngle0, angle1);
                sections[i].SetPos(angle1);
            }
        }

        if (oncaught != null)
        {
            oncaught(thing);
        }
    }
Esempio n. 6
0
        static void Main(string[] args)
        {
            thing t1  = new thing("Laptop", 600);
            thing t2  = new thing("Książka1", 400);
            thing t3  = new thing("Książka2", 300);
            thing t4  = new thing("Sok", 250);
            thing t5  = new thing("Telefon", 80);
            thing t6  = new thing("Batonik", 40);
            thing t7  = new thing("Dokumenty", 15);
            thing t8  = new thing("Długopis1", 10);
            thing t9  = new thing("Długopis2", 10);
            thing t10 = new thing("Długopis3", 10);
            thing t11 = new thing("Długopis4", 10);
            thing t12 = new thing("Spinka", 7);

            thing[] things = { t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12 };
            Max_capacity(things, 1200);


            Console.ReadKey();
        }
Esempio n. 7
0
 public void AddThing(thing t)
 {
     t->next = gThings;
     gThings = t;
 }
Esempio n. 8
0
 private static object tryGetCommonField(ref Memories MemoryHaystack, String KeyS, KeyWord KeyK, thing.Parts.Memory.MemoryComponents InPart, thing.Parts.Memory.MemoryComponents OutPart)
 {
     thing.Parts.Memory MemoryNeedle = new thing.Parts.Memory(KeyS, KeyK, String.Empty);
     foreach (thing.Parts.Memory Memory in MemoryHaystack)
     {
         switch (InPart)
         {
             case thing.Parts.Memory.MemoryComponents.KEY:
                 if (!Object.Equals(null, KeyK))
                 {
                     if (KeyK != KeyWord.NIL)
                     {
                         if (compare(Memory, MemoryNeedle, InPart))
                         {
                             return get(Memory, OutPart);
                         }
                     }
                 }
                 if (!Object.Equals(null, KeyS))
                 {
                     if (KeyS != String.Empty)
                     {
                         if (compare(Memory, MemoryNeedle, InPart))
                         {
                             return get(Memory, OutPart);
                         }
                     }
                 }
                 break;
             case thing.Parts.Memory.MemoryComponents.NAME:
                 if (!Object.Equals(null, KeyK))
                 {
                     if (KeyK != KeyWord.NIL)
                     {
                         if (compare(Memory, MemoryNeedle, InPart))
                         {
                             return get(Memory, OutPart);
                         }
                     }
                 }
                 if (!Object.Equals(null, KeyS))
                 {
                     if (KeyS != String.Empty)
                     {
                         if (compare(Memory, MemoryNeedle, InPart))
                         {
                             return get(Memory, OutPart);
                         }
                     }
                 }
                 break;
         }
     }
     return null;
 }
Esempio n. 9
0
 private static object get(thing.Parts.Memory m, thing.Parts.Memory.MemoryComponents Part)
 {
     switch (Part)
     {
         case thing.Parts.Memory.MemoryComponents.KEY:
             return m.Key;
         case thing.Parts.Memory.MemoryComponents.NAME:
             return m.Name;
         case thing.Parts.Memory.MemoryComponents.VALUE:
             return m.Value;
         default:
             return null;
     }
 }
Esempio n. 10
0
 private static bool compare(thing.Parts.Memory a, thing.Parts.Memory b, thing.Parts.Memory.MemoryComponents Part)
 {
     switch (Part)
     {
         case thing.Parts.Memory.MemoryComponents.KEY:
             if (a.Key == b.Key)
                 return true;
             else
                 return false;
         case thing.Parts.Memory.MemoryComponents.NAME:
             if (a.Name == b.Name)
                 return true;
             else
                 return false;
         case thing.Parts.Memory.MemoryComponents.VALUE:
             if (a.Value == b.Value)
                 return true;
             else
                 return false;
         default:
             return false;
     }
 }
Esempio n. 11
0
        public static bool tryGetCommonField(ref Memories Memories, String KeyS, KeyWord KeyK, System.Type OutValueType, thing.Parts.Memory.MemoryComponents InPart, thing.Parts.Memory.MemoryComponents OutPart, ref object outVar)
        {
            try
            {
                //lock (Memories)
                //{
                    String TYPE_STRING = typeof(System.String).ToString();
                    String TYPE_INT = typeof(System.Int32).ToString();
                    String TYPE_BOOL = typeof(System.Boolean).ToString();
                    String TYPE_KEYWORD = typeof(thing.KeyWord).ToString();
                    String OUT_VALUE_TYPE = OutValueType.ToString();

                    Object o = null;
                   // lock (Memories)
                   // {
                        o = tryGetCommonField(ref Memories, KeyS, KeyK, InPart, OutPart);
                   // }

                    string s = String.Empty;
                    if (object.Equals(null, o))
                    {
                        return false;
                    }
                    if (OUT_VALUE_TYPE == TYPE_STRING)
                    {
                        s = (String)o;
                        outVar = s;
                        return true;
                    }
                    else if (OUT_VALUE_TYPE == TYPE_BOOL)
                    {
                        s = (String)o;
                        if (s != String.Empty)
                        {
                            outVar = Boolean.Parse(s);
                            return true;
                        }
                        else
                        {
                            outVar = false;
                            return false;
                        }
                    }
                    else if (OUT_VALUE_TYPE == TYPE_INT)
                    {
                        s = (String)o;
                        if (s != String.Empty)
                        {
                            outVar = System.Int32.Parse(s);
                            return true;
                        }
                        else
                        {
                            outVar = 0;
                            return false;
                        }
                    }
                    else if (OUT_VALUE_TYPE == TYPE_KEYWORD)
                    {
                        outVar = (thing.KeyWord)o;
                        return true;
                    }
                    else
                    {
                        outVar = null;
                        return false;
                    }
                //}
            }
            catch //(Exception e)
            {
               // _Log(e.ToString());
                return false;
            }
        }
Esempio n. 12
0
 Also, you JSON buffs (really, who would admit to being a JSON buff...) might also notice from my feature list that this thing isn't exactly to specifications. Here is where it differs: 
 public static bool HasAandB(this thing t)
 {
     return(t.propA.HasValue && t.propB.HasValue);
 }