コード例 #1
0
    void LoadObject(DObject o, GameObject parent)
    {
        if (parent == null)
        {
            return;
        }
        GameObject ingameObject = new GameObject(o.name, typeof(IngameObject));

        ingameObject.hideFlags        = HideFlags.DontSave;
        ingameObject.transform.parent = parent.transform;
        Vector2 v = MapPosToUPos(o.x, o.y);

        ingameObject.transform.position = ingameObject.transform.position + new Vector3(v.x, v.y, 0);

        IngameObject incomp = ingameObject.GetComponent <IngameObject>();

        incomp.ObjectData = o;

        _objects.Add(o.name, ingameObject);
    }
コード例 #2
0
ファイル: IngameObject.cs プロジェクト: romibi/stalnias
    private void teleport(Collider2D collision, string v)
    {
        GameObject target = GameObject.Find(v);

        if (target == null)
        {
            return;
        }

        PlayerMovement player = collision.GetComponent <PlayerMovement>();

        if (player == null)
        {
            return;
        }

        IngameObject targetObject = target.GetComponent <IngameObject>();

        if (targetObject != null)
        {
            targetObject.ignoreTriggerOnce.Add(collision);
            player.teleportTo(targetObject.getGroundCenterCoordinates());
        }
    }
コード例 #3
0
        public static IngameObject MakeObject(BinaryReader reader, int type, Dictionary <uint, string> listfile, int x, int y, List <uint> offsets, List <string> filenames, Dictionary <string, uint> filelist, Dictionary <uint, List <Toolbox.IngameObject> > IG_Obj)
        {
            // 0 = wmo; 1 = m2; 2 = wmo map
            IngameObject n          = new IngameObject();
            float        posx       = 0;
            float        posy       = 0;
            float        posz       = 0;
            uint         filedataid = 0;
            uint         uniqueId   = 0;
            uint         flags      = 0;

            if (type == 1)
            {
                filedataid = reader.ReadUInt32();
                uniqueId   = reader.ReadUInt32();
                posx       = reader.ReadSingle();
                posy       = reader.ReadSingle();
                posz       = reader.ReadSingle();
                float[] rotation = new float[3];
                rotation[0] = reader.ReadSingle();
                rotation[1] = reader.ReadSingle();
                rotation[2] = reader.ReadSingle();
                ushort scale = reader.ReadUInt16();
                flags = reader.ReadUInt16();
            }
            else
            {
                filedataid = reader.ReadUInt32();
                uniqueId   = reader.ReadUInt32();
                posx       = reader.ReadSingle();
                posy       = reader.ReadSingle();
                posz       = reader.ReadSingle();

                float[] rotation = new float[3];
                rotation[0] = reader.ReadSingle();
                rotation[1] = reader.ReadSingle();
                rotation[2] = reader.ReadSingle();
                float[] min = new float[3];
                min[0] = reader.ReadSingle();
                min[1] = reader.ReadSingle();
                min[2] = reader.ReadSingle();
                float[] max = new float[3];
                max[0] = reader.ReadSingle();
                max[1] = reader.ReadSingle();
                max[2] = reader.ReadSingle();
                flags  = reader.ReadUInt16();
                ushort doodadSet = reader.ReadUInt16();
                ushort nameSet   = reader.ReadUInt16();
                ushort scale     = reader.ReadUInt16();
            }
            n.filedataid = filedataid;
            n.uniqueId   = uniqueId;
            n.x          = x;
            n.y          = y;
            n.type       = type;
            n.posx       = posx / 533 * 256;
            n.posy       = posy;
            n.posz       = posz / 533 * 256;

            if (type == 1)   // m2
            {
                if ((flags & 64) == 64)
                {
                    string name = "";
                    if (listfile.TryGetValue(n.filedataid, out name))
                    {
                        n.name = name;
                    }
                    else
                    {
                        n.name = n.filedataid.ToString();
                    }
                }
                else
                {
                    n.name       = filenames[(int)filedataid];
                    n.name       = n.name.ToLower();
                    n.name       = n.name.Replace("\\", "/");
                    n.filedataid = filelist[n.name];
                }
            }
            else if (type == 0)   // wmo
            {
                if ((flags & 8) == 8)
                {
                    string name = "";
                    if (listfile.TryGetValue(n.filedataid, out name))
                    {
                        n.name = name;
                    }
                    else
                    {
                        n.name = n.filedataid.ToString();
                    }
                }
                else
                {
                    n.name       = filenames[(int)filedataid];
                    n.name       = n.name.ToLower();
                    n.name       = n.name.Replace("\\", "/");
                    n.filedataid = filelist[n.name];
                }
            }
            else if (type == 2)  //wmo map
            {
                if ((flags & 8) == 8)
                {
                    string name = "";
                    if (listfile.TryGetValue(n.filedataid, out name))
                    {
                        n.name = name;
                    }
                    else
                    {
                        n.name = n.filedataid.ToString();
                    }
                }
                else
                {
                    n.name       = filenames[(int)filedataid];
                    n.name       = n.name.ToLower();
                    n.name       = n.name.Replace("\\", "/");
                    n.filedataid = filelist[n.name];
                }
            }
            if (!IG_Obj.ContainsKey(n.filedataid))
            {
                IG_Obj.Add(n.filedataid, new List <Toolbox.IngameObject>());
            }
            IG_Obj[n.filedataid].Add(n);

            return(n);
        }
コード例 #4
0
 public void DestroyObject(IngameObject toDestroy)
 {
     CreatedObjectsAsGameObjects.Remove(toDestroy.get());
     CreatedObjects.Remove(toDestroy);
     DestroyImmediate(toDestroy.get());
 }