Exemplo n.º 1
0
    public override void _Ready()
    {
        base._Ready();
        bouncer_data = bouncers[ObjectID.y];
        if (bouncer_data.deadly)
        {
            OrganicEnemy = true;
        }

        if (bouncer_data.jump_trigger)
        {
            // Connect to each Juni
            Juni.Connect("Jumped", this, "juniJumped");
        }
    }
Exemplo n.º 2
0
        // takes the current placed levelObjects and serializes it into the levelData format
        public static LevelData CreateLevelData()
        {
            if (LevelPlacer.generatedLevel != null && editLevel != null)
            {
                print("CreateLevelData");
                LevelDataMono level = LevelPlacer.generatedLevel;
                LevelData     l     = new LevelData(level.levelData.id);

                // save level info
                l.author     = level.levelData.author;
                l.id         = level.levelData.id;
                l.presetTime = DoubleToTwoDecimals(level.levelData.presetTime);
                l.title      = level.levelData.title;
                l.custom     = level.levelData.custom;

                // save moveArea mesh
                Vector3[]   verts    = level.moveArea.meshFilter.mesh.vertices;
                Position2[] posVerts = new Position2[verts.Length];
                for (int i = 0; i < verts.Length; i++)
                {
                    posVerts[i] = new Position2(verts[i].x, verts[i].y);
                }
                if (!posVerts.Equals(editLevel.moveVerticies))
                {
                    Debug.Log("Different Vertices");
                }
                l.moveVerticies = posVerts;
                l.moveTriangles = level.moveArea.meshFilter.mesh.triangles;

                // save spawn
                Vector3 spawnPos = level.spawn.transform.localPosition;
                l.objectData.spawnPosition = new Position2(spawnPos.x, spawnPos.y);

                // save finish
                Vector3 finishPos = level.finish.transform.localPosition;
                l.objectData.finishPosition = new Position2(finishPos.x, finishPos.y);

                // save turrets
                foreach (Turret t in level.turrets)
                {
                    Position2  turretPosition = new Position2(t.transform.localPosition.x, t.transform.localPosition.y);
                    TurretData td             = new TurretData(turretPosition);
                    td.rotation     = new Position3(t.transform.rotation.eulerAngles.x, t.transform.rotation.eulerAngles.y, t.transform.rotation.eulerAngles.z);
                    td.shotDelay    = FloatToTwoDecimals(t.shotDelay);
                    td.shotSpeed    = FloatToTwoDecimals(t.shotSpeed);
                    td.startupDelay = FloatToTwoDecimals(t.startupDelay);
                    td.constantFire = t.constantFire;
                    l.objectData.turretData.Add(td);
                }

                // save attractors
                foreach (Attractor a in level.attractors)
                {
                    Position2     aPosition = new Position2(a.transform.localPosition.x, a.transform.localPosition.y);
                    AttractorData ad        = new AttractorData(aPosition);
                    ad.pullStrength = (int)a.maxPullForce;
                    ad.radius       = (int)a.pullRadius;
                    l.objectData.attractorData.Add(ad);
                }

                // save portals
                foreach (Portal p in level.portals)
                {
                    Position2  pPosition = new Position2(p.transform.localPosition.x, p.transform.localPosition.y);
                    PortalData pd        = new PortalData(pPosition, p.portalID);
                    pd.portalID       = p.portalID;
                    pd.linkedPortalID = p.linkedPortalID;
                    l.objectData.portalData.Add(pd);
                }

                // save speedstrips
                foreach (SpeedStrip s in level.speedStrips)
                {
                    Position2      pPosition = new Position2(s.transform.localPosition.x, s.transform.localPosition.y);
                    SpeedStripData sd        = new SpeedStripData(pPosition);
                    sd.rotation     = new Position3(s.transform.rotation.eulerAngles.x, s.transform.rotation.eulerAngles.y, s.transform.rotation.eulerAngles.z);
                    sd.pushStrength = (int)s.accelSpeed;
                    l.objectData.speedStripData.Add(sd);
                }

                foreach (Bouncer b in level.bouncers)
                {
                    Position2   bPosition = new Position2(b.transform.localPosition.x, b.transform.localPosition.y);
                    BouncerData bd        = new BouncerData(bPosition);
                    bd.rotation   = new Position3(b.transform.rotation.eulerAngles.x, b.transform.rotation.eulerAngles.y, b.transform.rotation.eulerAngles.z);
                    bd.bounciness = b.bounciness;
                    bd.width      = b.width;
                    l.objectData.bouncerData.Add(bd);
                }

                return(l);
            }
            return(null);
        }