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);
         }
     }
 }
Example #2
0
    /// Returns TRUE if we can do a far-fall hop or just-ate-happy-hop.
    private bool MayDoAFunHop()
    {
        if (!DoesFunHop)
        {
            return(false);
        }                                  // No, I don't do that sort of thing.
        //if (!IsGrounded()) { return false; } // Not on ground? Can't hop.
        Collidable collOn = myWhiskers.TEMP_GetFloorCollidable();

        if (collOn != null)
        {
            Ground g = collOn as Ground;
            if (g != null && g.PreventHappyHop)
            {
                return(false);
            }                                                   // This Ground specifically says we can't.
            DispGround dg = collOn as DispGround;
            if (dg != null && dg.DieFromPlayerLeave)
            {
                return(false);
            }         // DispGround that'll disappear if we leave it? Don't hop!
        }
        return(true); // Looks good!
    }
Example #3
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++;
                }
            }
        }
Example #4
0
    // ----------------------------------------------------------------
    //	Initialize
    // ----------------------------------------------------------------
    public void Initialize(GameController _gameControllerRef, Transform tf_world, RoomData _roomData)
    {
        gameControllerRef    = _gameControllerRef;
        MyRoomData           = _roomData;
        this.gameObject.name = MyRoomData.RoomKey;

        GameUtils.ParentAndReset(this.gameObject, tf_world);
        this.transform.localPosition = PosGlobal; // Position me!

        // Initialize channels!
        gateChannels = new GateChannel[5];
        for (int i = 0; i < gateChannels.Length; i++)
        {
            gateChannels[i] = new GateChannel(this, i);
        }

        // Instantiate my props!
        RoomData         rd  = MyRoomData;
        ResourcesHandler rh  = ResourcesHandler.Instance;
        int numProgressGates = 0; // for deteriming their indexes.
        int numVeils         = 0; // for determining their indexes.

        foreach (PropData propData in rd.allPropDatas)
        {
            System.Type pt = propData.GetType();
            if (false)
            {
            }
            // Enemies
            else if (pt == typeof(DweebData))
            {
                Dweeb newProp = Instantiate(rh.Dweeb).GetComponent <Dweeb>();
                newProp.Initialize(this, propData as DweebData);
            }
            // Grounds
            else if (pt == typeof(CrateData))
            {
                Crate newProp = Instantiate(rh.Crate).GetComponent <Crate>();
                newProp.Initialize(this, propData as CrateData);
            }
            else if (pt == typeof(DispGroundData))
            {
                DispGround newProp = Instantiate(rh.DispGround).GetComponent <DispGround>();
                newProp.Initialize(this, propData as DispGroundData);
            }
            else if (pt == typeof(GateData))
            {
                Gate newProp = Instantiate(rh.Gate).GetComponent <Gate>();
                newProp.Initialize(this, propData as GateData);
                gateChannels[newProp.ChannelID].AddGate(newProp);
            }
            else if (pt == typeof(ToggleGroundData))
            {
                ToggleGround newProp = Instantiate(rh.ToggleGround).GetComponent <ToggleGround>();
                newProp.Initialize(this, propData as ToggleGroundData);
            }
            else if (pt == typeof(PlatformData))
            {
                Platform newProp = Instantiate(rh.Platform).GetComponent <Platform>();
                newProp.Initialize(this, propData as PlatformData);
            }
            else if (pt == typeof(GroundData))
            {
                Ground newProp = Instantiate(rh.Ground).GetComponent <Ground>();
                newProp.Initialize(this, propData as GroundData);
            }
            // Everything else!
            else if (pt == typeof(BatteryData))
            {
                Battery newProp = Instantiate(rh.Battery).GetComponent <Battery>();
                newProp.Initialize(this, propData as BatteryData);
            }
            else if (pt == typeof(BuzzsawData))
            {
                Buzzsaw newProp = Instantiate(rh.Buzzsaw).GetComponent <Buzzsaw>();
                newProp.Initialize(this, propData as BuzzsawData);
            }
            else if (pt == typeof(CharBarrelData))
            {
                CharBarrel newProp = Instantiate(rh.CharBarrel).GetComponent <CharBarrel>();
                newProp.Initialize(this, propData as CharBarrelData, charBarrels.Count);
                charBarrels.Add(newProp);
            }
            else if (pt == typeof(CharUnlockOrbData))
            {
                CharUnlockOrb newProp = Instantiate(rh.CharUnlockOrb).GetComponent <CharUnlockOrb>();
                newProp.Initialize(this, propData as CharUnlockOrbData);
            }
            else if (pt == typeof(CameraBoundsData))
            {
                CameraBounds newProp = Instantiate(rh.CameraBounds).GetComponent <CameraBounds>();
                newProp.Initialize(this, propData as CameraBoundsData);
            }
            else if (pt == typeof(GateButtonData))
            {
                GateButton newProp = Instantiate(rh.GateButton).GetComponent <GateButton>();
                newProp.Initialize(this, propData as GateButtonData);
                gateChannels[newProp.ChannelID].AddButton(newProp);
            }
            else if (pt == typeof(GemData))
            {
                Gem newProp = Instantiate(rh.Gem).GetComponent <Gem>();
                newProp.Initialize(this, propData as GemData, gems.Count);
                gems.Add(newProp);
            }
            else if (pt == typeof(InfoSignData))
            {
                InfoSign newProp = Instantiate(rh.InfoSign).GetComponent <InfoSign>();
                newProp.Initialize(this, propData as InfoSignData);
            }
            else if (pt == typeof(LaserData))
            {
                Laser newProp = Instantiate(rh.Laser).GetComponent <Laser>();
                newProp.Initialize(this, propData as LaserData);
            }
            else if (pt == typeof(LiftData))
            {
                Lift newProp = Instantiate(rh.Lift).GetComponent <Lift>();
                newProp.Initialize(this, propData as LiftData);
            }
            else if (pt == typeof(PlayerStartData))
            {
                PlayerStart newProp = Instantiate(rh.PlayerStart).GetComponent <PlayerStart>();
                newProp.Initialize(this, propData as PlayerStartData);
            }
            else if (pt == typeof(ProgressGateData))
            {
                ProgressGate newProp = Instantiate(rh.ProgressGate).GetComponent <ProgressGate>();
                newProp.Initialize(this, propData as ProgressGateData, numProgressGates++);
            }
            else if (pt == typeof(RoomDoorData))
            {
                RoomDoor newProp = Instantiate(rh.RoomDoor).GetComponent <RoomDoor>();
                newProp.Initialize(this, propData as RoomDoorData);
            }
            else if (pt == typeof(SnackData))
            {
                Snack newProp = Instantiate(rh.Snack).GetComponent <Snack>();
                newProp.Initialize(this, propData as SnackData, snacks.Count);
                snacks.Add(newProp);
            }
            else if (pt == typeof(SpikesData))
            {
                Spikes newProp = Instantiate(rh.Spikes).GetComponent <Spikes>();
                newProp.Initialize(this, propData as SpikesData);
            }
            else if (pt == typeof(TurretData))
            {
                Turret newProp = Instantiate(rh.Turret).GetComponent <Turret>();
                newProp.Initialize(this, propData as TurretData);
            }
            else if (pt == typeof(VeilData))
            {
                Veil newProp = Instantiate(rh.Veil).GetComponent <Veil>();
                newProp.Initialize(this, propData as VeilData, numVeils++);
            }
            else
            {
                Debug.LogWarning("PropData not recognized: " + propData);
            }
        }

        AddHardcodedRoomElements();

        // For development, add bounds so we don't fall out of unconnected rooms!
        AutoAddInvisibounds();
        roomGizmos.Initialize(this);
        shutters.Initialize(this);
    }