Exemple #1
0
        internal static void rep_castleblock(Building b, CastleBlockBuildingSkin skin)
        {
            CastleBlock cb = b.gameObject.GetComponent <CastleBlock>();

            if (skin.Adjacent != null)
            {
                cb.Adjacent = skin.Adjacent.transform;
            }
            if (skin.Single != null)
            {
                cb.Single = skin.Single.transform;
            }
            if (skin.Opposite != null)
            {
                cb.Opposite = skin.Opposite.transform;
            }
            if (skin.Threeside != null)
            {
                cb.Threeside = skin.Threeside.transform;
            }
            if (skin.doorPrefab != null)
            {
                cb.doorPrefab = skin.doorPrefab;
            }
            if (skin.Closed != null)
            {
                cb.Closed = skin.Closed.transform;
            }
            if (skin.Open != null)
            {
                cb.Open = skin.Open.transform;
            }
        }
Exemple #2
0
        static void Prefix(CastleBlock __instance, ref Vector3 position, ref Vector3 faceDirection)
        {
            CellMark mark = ElevationManager.GetCellMark(__instance.GetComponent <Building>().GetCell());

            if (mark != null)
            {
                position.y      = __instance.transform.localPosition.y - mark.Elevation;
                faceDirection.y = 0f;
            }
        }
Exemple #3
0
        internal static void rp_castleblock(Building b)
        {
            CastleBlock cb = b.gameObject.GetComponent <CastleBlock>();

            cb.Adjacent.GetComponent <MeshFilter>().mesh  = null;
            cb.Single.GetComponent <MeshFilter>().mesh    = null;
            cb.Opposite.GetComponent <MeshFilter>().mesh  = null;
            cb.Threeside.GetComponent <MeshFilter>().mesh = null;
            cb.doorPrefab = null;
            cb.Closed.GetComponent <MeshFilter>().mesh = null;
            cb.Open.GetComponent <MeshFilter>().mesh   = null;
        }
        internal static void rep_woodcastleblock(Building b, WoodCastleBlockBuildingModelInfo modelInfo)
        {
            CastleBlock cb = b.gameObject.GetComponent <CastleBlock>();

            cb.Adjacent   = modelInfo.Adjacent.transform;
            cb.Single     = modelInfo.Single.transform;
            cb.Opposite   = modelInfo.Opposite.transform;
            cb.Threeside  = modelInfo.Threeside.transform;
            cb.doorPrefab = modelInfo.doorPrefab;
            cb.Closed     = modelInfo.Closed.transform;
            cb.Open       = modelInfo.Open.transform;
        }
        internal static void rp_woodcastleblock(Building b)
        {
            CastleBlock cb = b.gameObject.GetComponent <CastleBlock>();

            cb.Adjacent   = null;
            cb.Single     = null;
            cb.Opposite   = null;
            cb.Threeside  = null;
            cb.doorPrefab = null;
            cb.Closed     = null;
            cb.Open       = null;
        }
Exemple #6
0
        static void Postfix(CastleBlock __instance)
        {
            Cell     c    = __instance.GetComponent <Building>().GetCell();
            CellMark mark = ElevationManager.GetCellMark(c);

            if (mark != null)
            {
                Cell[] neighborCells = new Cell[4];

                Building b = __instance.GetComponent <Building>();
                World.inst.GetNeighborCells(c, ref neighborCells);


                int idx = -1;
                for (int n = 0; n < c.OccupyingStructure.Count; n++)
                {
                    if (c.OccupyingStructure[n] == b)
                    {
                        idx = n;
                        break;
                    }
                }

                float selfHeight = BuildingPlacePatch.GetAbsoluteStackHeightOfBuildingAtIndex(c, idx);
                DebugExt.dLog(" -- " + idx.ToString() + " -- ");
                DebugExt.dLog(selfHeight.ToString());

                typeof(CastleBlock).GetMethod("ClearDoors", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { });
                for (int m = 0; m < neighborCells.Length; m++)
                {
                    float otherHeight = BuildingPlacePatch.GetAbsoluteStackHeightTotal(neighborCells[m]);

                    if (otherHeight > 0f)
                    {
                        DebugExt.dLog(otherHeight.ToString());
                    }

                    Cell cell = neighborCells[m];
                    if (cell != null)
                    {
                        if (Mathf.Approximately(selfHeight - 0.5f, otherHeight) && otherHeight > 0)
                        {
                            DebugExt.dLog("Connection!");
                            typeof(CastleBlock).GetMethod("VisibleDoors", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { true });
                        }
                    }
                }
            }
        }
Exemple #7
0
 private Block FindBlock(Color c)
 {
     if (c == StandardGroundBlock.GetColor())
     {
         return(new StandardGroundBlock());
     }
     else if (c == DarkGroundBlock.GetColor())
     {
         return(new DarkGroundBlock());
     }
     else if (c == StandardAirBlock.GetColor())
     {
         return(new StandardAirBlock());
     }
     else if (c == DarkAirBlock.GetColor())
     {
         return(new DarkAirBlock());
     }
     else if (c == CoinBoxBlock.GetColor())
     {
         return(new CoinBoxBlock());
     }
     else if (c == PowerUpgradeBoxBlock.GetColor())
     {
         return(new PowerUpgradeBoxBlock());
     }
     else if (c == EmptyBoxBlock.GetColor())
     {
         return(new EmptyBoxBlock());
     }
     else if (c == StandardHillBlock.GetColor())
     {
         return(new StandardHillBlock());
     }
     else if (c == DarkHillBlock.GetColor())
     {
         return(new DarkHillBlock());
     }
     else if (c == PipeBlock.GetColor())
     {
         return(new PipeBlock());
     }
     else if (c == CastleBlock.GetColor())
     {
         return(new CastleBlock());
     }
     else if (c == CrazyCoinBoxBlock.GetColor())
     {
         return(new CrazyCoinBoxBlock());
     }
     else if (c == EndlessCrazyCoinBoxBlock.GetColor())
     {
         return(new EndlessCrazyCoinBoxBlock());
     }
     else if (c == StandardCeilingBlock.GetColor())
     {
         return(new StandardCeilingBlock());
     }
     else if (c == DarkCeilingBlock.GetColor())
     {
         return(new DarkCeilingBlock());
     }
     else if (c == StandardPillarBlock.GetColor())
     {
         return(new StandardPillarBlock());
     }
     else if (c == MushroomPlatformBlock.GetColor())
     {
         return(new MushroomPlatformBlock());
     }
     else if (c == CastleGroundBlock.GetColor())
     {
         return(new CastleGroundBlock());
     }
     else if (c == LavaBlock.GetColor())
     {
         return(new LavaBlock());
     }
     else if (c == FireBoxBlock.GetColor())
     {
         return(new FireBoxBlock());
     }
     else if (c == SolidCloudBlock.GetColor())
     {
         return(new SolidCloudBlock());
     }
     else if (c == BeanStalkBoxBlock.GetColor())
     {
         return(new BeanStalkBoxBlock());
     }
     else if (c == UnderwaterGroundBlock.GetColor())
     {
         return(new UnderwaterGroundBlock());
     }
     else if (c == WaterBlock.GetColor())
     {
         return(new WaterBlock());
     }
     else if (c == BillBlasterBlock.GetColor())
     {
         return(new BillBlasterBlock());
     }
     else
     {
         return(null);
     }
 }