//protected void SetMyRect(Rect r) {
    //    bodySprite.transform.localPosition = r.position;
    //}


    // ----------------------------------------------------------------
    //  Start
    // ----------------------------------------------------------------
    //override protected void Start() {
    //       base.Start();
    //	// TEMP! For room transitioning.
    //	if (bodySprite==null) {
    //		bodySprite = GetComponent<SpriteRenderer>();
    //	}
    //}
    protected void BaseGroundInitialize(Room _myRoom, BaseGroundData data)
    {
        base.InitializeAsProp(_myRoom, data);

        isPlayerRespawn = data.isPlayerRespawn;
        mayPlayerEat    = data.mayPlayerEat;
        preventHappyHop = data.preventHappyHop;
        SetSize(data.size);
    }
Beispiel #2
0
    static private List <string> GetPropPropertyNamesToSave(PropData propData)
    {
        List <string> ps = new List <string>(); // property names!

        // YES travelMind?? Add that!
        if (propData.travelMind.IsUsed)
        {
            ps.Add("travelMind");
        }
        // NO TravelMind?? Add pos!
        else
        {
            ps.Add("pos");
        }
        if (!Mathf.Approximately(propData.rotation, 0))
        {
            ps.Add("rotation");
        }
        // BaseGroundData?
        if (propData is BaseGroundData)
        {
            ps.Add("size");
            BaseGroundData d = propData as BaseGroundData;
            if (!d.mayPlayerEat)
            {
                ps.Add("mayPlayerEat");
            }
            if (d.isPlayerRespawn)
            {
                ps.Add("isPlayerRespawn");
            }
            if (d.preventHappyHop)
            {
                ps.Add("preventHappyHop");
            }
        }

        Type type = propData.GetType();

        if (type == typeof(BatteryData))
        {
        }
        else if (type == typeof(BuzzsawData))
        {
            ps.Add("size");
        }
        else if (type == typeof(CameraBoundsData))
        {
            ps.Add("size");
        }
        else if (type == typeof(CharBarrelData))
        {
            ps.Add("otherCharName");
        }
        else if (type == typeof(CharUnlockOrbData))
        {
            ps.Add("myCharName");
        }
        else if (type == typeof(CrateData))
        {
            ps.Add("hitsUntilBreak"); ps.Add("numCoinsInMe");
        }
        else if (type == typeof(GateData))
        {
            ps.Add("channelID");
        }
        else if (type == typeof(GateButtonData))
        {
            ps.Add("channelID");
        }
        else if (type == typeof(GemData))
        {
            ps.Add("type");
        }
        else if (type == typeof(InfoSignData))
        {
            ps.Add("myText");
        }
        else if (type == typeof(LiftData))
        {
            ps.Add("size"); ps.Add("strength");
        }
        else if (type == typeof(PlayerStartData))
        {
        }
        else if (type == typeof(ProgressGateData))
        {
            ps.Add("numSnacksReq");
        }
        else if (type == typeof(RoomDoorData))
        {
            ps.Add("myID"); ps.Add("worldToIndex"); ps.Add("roomToKey"); ps.Add("doorToID");
        }
        else if (type == typeof(SnackData))
        {
            ps.Add("playerType");
        }
        else if (type == typeof(VeilData))
        {
            ps.Add("size");
        }
        // Enemies
        else if (type == typeof(DweebData))
        {
            ps.Add("speed");
        }
        // Props with optional params
        else if (type == typeof(TurretData))
        {
            TurretData d = propData as TurretData;
            ps.Add("interval");
            ps.Add("speed");
            if (d.startOffset > 0)
            {
                ps.Add("startOffset");
            }
        }
        else if (type == typeof(SpikesData))
        {
            SpikesData d = propData as SpikesData;
            ps.Add("size");
            if (d.onOffer.IsUsed)
            {
                ps.Add("onOffer");
            }
        }
        else if (type == typeof(LaserData))
        {
            LaserData d = propData as LaserData;
            if (d.onOffer.IsUsed)
            {
                ps.Add("onOffer");
            }
        }
        else if (type == typeof(DispGroundData))
        {
            DispGroundData d = propData as DispGroundData;
            ps.Add("doRegen");
            if (d.regenTime != DispGround.RegenTimeDefault)
            {
                ps.Add("regenTime");
            }
            if (d.dieFromBounce)
            {
                ps.Add("dieFromBounce");
            }
            if (d.dieFromPlayerLeave)
            {
                ps.Add("dieFromPlayerLeave");
            }
            if (d.dieFromVel)
            {
                ps.Add("dieFromVel");
            }
        }
        else if (type == typeof(GroundData))
        {
            GroundData d = propData as GroundData;
            if (d.isBouncy)
            {
                ps.Add("isBouncy");
            }
            if (!d.mayBounce)
            {
                ps.Add("mayBounce");
            }
            if (!d.doRechargePlayer)
            {
                ps.Add("doRechargePlayer");
            }
        }
        else if (type == typeof(PlatformData))
        {
            PlatformData d = propData as PlatformData;
            if (!d.canDropThru)
            {
                ps.Add("canDropThru");
            }
        }
        else if (type == typeof(ToggleGroundData))
        {
            ps.Add("startsOn");
            ps.Add("togFromContact");
            ps.Add("togFromAction");
        }
        else
        {
            Debug.LogWarning("Prop in Room not recognized for serialization: " + type);
        }
        return(ps);
    }