Пример #1
0
        /*
         *      this method reads spike data from a json file and converts it to multiple attribute-value tuples, before returning it
         *      it is called in DataReader.Initiate(), after ModelData.Initiate()
         */
        public SpikesData Initiate()
        {
            //string path = Application.dataPath + "/JsonData/spikestest.json";
            string     path       = Application.dataPath + "/JsonData/spikes_VMDG_0.json";
            string     jsonString = File.ReadAllText(path);
            SpikesData sd         = JsonConvert.DeserializeObject <SpikesData>(jsonString);

            return(sd);
        }
Пример #2
0
    // ----------------------------------------------------------------
    //  Start
    // ----------------------------------------------------------------
    public void Initialize(Room _myRoom, SpikesData data)
    {
        base.InitializeAsProp(_myRoom, data);
        Size             = data.size;
        bodySprite.color = Colors.Spikes(WorldIndex);

        if (data.onOffer.durOff > 0)
        {
            AddOnOffer(data.onOffer);
        }
    }
Пример #3
0
    // ----------------------------------------------------------------
    //  Serializing
    // ----------------------------------------------------------------
    override public PropData ToData()
    {
        SpikesData data = new SpikesData {
            pos        = pos,
            size       = Size,
            rotation   = rotation,
            onOffer    = new OnOfferData(onOffer),
            travelMind = new TravelMindData(travelMind),
        };

        return(data);
    }
 private void AddPropSprites()
 {
     foreach (PropData propData in myRD.allPropDatas)
     {
         // -- Batteries --
         if (propData.GetType() == typeof(BatteryData))
         {
             BatteryData pd = propData as BatteryData;
             AddSpriteRenderer("Battery", rh.s_battery, go_props, pd.pos, BatteryIconSize, 10, Color.white);
         }
         // -- Grounds --
         else if (propData.GetType() == typeof(GroundData))
         {
             GroundData pd = propData as GroundData;
             groundDatas.Add(pd);                                                                                  // also add it to my ref list!
             srs_grounds.Add(AddSpriteRenderer("Ground", rh.s_ground, go_props, pd.pos, pd.size, 1, Color.white)); //WHY POSITION? why not center?
         }
         // -- DispGrounds --
         else if (propData.GetType() == typeof(DispGroundData))
         {
             DispGroundData pd    = propData as DispGroundData;
             Color          color = DispGround.GetBodyColor(pd);
             color = new Color(color.r, color.g, color.b, color.a * 0.6f); // alpha it out a bit, to taste.
             AddSpriteRenderer("DispGround", rh.s_ground, go_props, pd.pos, pd.size, 1, color);
         }
         // -- Gems --
         else if (propData.GetType() == typeof(GemData))
         {
             GemData pd     = propData as GemData;
             Sprite  sprite = rh.GetGemSprite(pd.type);
             AddSpriteRenderer("Gem", sprite, go_props, pd.pos, GemIconSize, 10, Color.white);
         }
         // -- Snacks --
         else if (propData.GetType() == typeof(SnackData))
         {
             SnackData pd    = propData as SnackData;
             Color     color = PlayerBody.GetBodyColorNeutral(PlayerTypeHelper.TypeFromString(pd.playerType));
             AddSpriteRenderer("Snack", rh.s_snack, go_props, pd.pos, SnackIconSize, 10, color);
         }
         // -- Spikes --
         else if (propData.GetType() == typeof(SpikesData))
         {
             SpikesData     spikesData = propData as SpikesData;
             Color          color      = Colors.Spikes(myRD.WorldIndex);// new Color(0.7f,0.1f,0f, 0.6f);
             SpriteRenderer newSprite  = AddSpriteRenderer("Spikes", rh.s_spikes, go_props, spikesData.pos, Vector2.one, 0, color);
             newSprite.drawMode = SpriteDrawMode.Tiled;
             newSprite.size     = spikesData.size;
             newSprite.transform.localEulerAngles = new Vector3(0, 0, spikesData.rotation);
         }
     }
 }
Пример #5
0
    /*
     *      this method instantiates the parameter, model, spikes and program data, the label lists and the dictionaries and then calls all the other methods
     *      it is called in Controlla.cs, before anything else
     */
    public void Initiate()
    {
        myPD  = new ParamData().Initiate();
        myMD  = new ModelData().Initiate();
        mySD  = new SpikesData().Initiate();
        myPrD = new ProgramData().Initiate();
        //ActivityHC = new List<List<Spike>>();
        myStop             = new List <float>();
        myNames            = new List <string>();
        myStart            = new List <float>();
        phase              = new Dictionary <int, List <int> >();
        phaseDeactivation  = new Dictionary <int, List <int> >();
        basketDeactivation = new Dictionary <int, List <int> >();
        basketphase        = new Dictionary <int, List <int> >();

        ReformateData();
        SetValues();
        CreatePhaseList();

        //File.WriteAllText(@"./id_e_rec.json", JsonConvert.SerializeObject(e_rec_MC));
        //File.WriteAllText(@"./id_i_pop.json", JsonConvert.SerializeObject(i_pop_HC));
        //File.WriteAllText(@"./eSource.json", JsonConvert.SerializeObject(e_src));
    }
Пример #6
0
        private void AddPropImages()
        {
            int snackIndex = 0; // for determining which Snacks we gots!

            foreach (PropData propData in myRD.allPropDatas)
            {
                // -- Spikes --
                if (propData.GetType() == typeof(SpikesData))
                {
                    SpikesData spikesData = propData as SpikesData;
                    Color      color      = Colors.Spikes(myRD.WorldIndex);// new Color(0.7f,0.1f,0f, 0.6f);
                    Image      newObj     = AddImage("Spikes", rh.s_spikes, rt_props, spikesData.pos, spikesData.size, color);
                    newObj.transform.localEulerAngles = new Vector3(0, 0, spikesData.rotation);
                    newObj.type = Image.Type.Tiled;
                    newObj.transform.localScale     = Vector3.one / 100f; // kinda hacky-ish.
                    newObj.rectTransform.sizeDelta *= 100f;
                    newObj.transform.SetAsFirstSibling();                 // put spikes BEHIND everything else.
                }
                // -- Grounds --
                else if (propData.GetType() == typeof(GroundData))
                {
                    GroundData pd    = propData as GroundData;
                    Color      color = new Color255(100, 130, 90).ToColor();//Ground.GetBodyColor(pd, myRD.WorldIndex);
                    AddImage("Ground", rh.s_ground, rt_props, pd.pos, pd.size, color);
                }
                // -- DispGrounds --
                else if (propData.GetType() == typeof(DispGroundData))
                {
                    DispGroundData pd    = propData as DispGroundData;
                    Color          color = DispGround.GetBodyColor(pd);
                    color = new Color(color.r, color.g, color.b, color.a * 0.6f); // alpha it out a bit, to taste.
                    AddImage("DispGround", rh.s_ground, rt_props, pd.pos, pd.size, color);
                }
                // -- Batteries --
                else if (propData.GetType() == typeof(BatteryData))
                {
                    BatteryData pd = propData as BatteryData;
                    AddImage("Battery", rh.s_battery, rt_props, pd.pos, BatteryIconSize, Color.white);
                }
                // -- Gems --
                else if (propData.GetType() == typeof(GemData))
                {
                    GemData pd     = propData as GemData;
                    Sprite  sprite = rh.GetGemSprite(pd.type);
                    AddImage("Gem", sprite, rt_props, pd.pos, GemIconSize, Color.white);
                }
                // -- Snacks --
                else if (propData.GetType() == typeof(SnackData))
                {
                    SnackData pd = propData as SnackData;
                    Color     color;
                    bool      didEatSnack = SaveStorage.GetBool(SaveKeys.DidEatSnack(myRD, snackIndex));
                    if (didEatSnack)
                    {
                        color = new Color(0, 0, 0, 0.2f);
                    }
                    else
                    {
                        color = PlayerBody.GetBodyColorNeutral(PlayerTypeHelper.TypeFromString(pd.playerType));
                    }
                    AddImage("Snack", rh.s_snack, rt_props, pd.pos, SnackIconSize, color);
                    snackIndex++;
                }
            }
        }
Пример #7
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);
    }