コード例 #1
0
            /// <summary>
            /// Check if Item's Pos is fully within the board posiiton, assuming Upper Left alignment
            /// </summary>
            /// <param name="Pos"></param>
            /// <param name="di"></param>
            /// <returns></returns>
            private bool m_PositionFitBoard(Vector2Int Pos, DecorationItem di, BaseBuildingGrid bbg)
            {
                int row    = di.OccupySize.GetLength(0);
                int column = di.OccupySize.GetLength(1);

                for (int i = 0; i < row; i++)
                {
                    for (int j = 0; j < column; j++)
                    {
                        if (Pos.x + i > bbg.RowNum - 1)
                        {
                            return(false);
                        }
                        if (Pos.x + i < 0)
                        {
                            return(false);
                        }
                        if (Pos.y + j > bbg.ColumnNum - 1)
                        {
                            return(false);
                        }
                        if (Pos.y + j < 0)
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
コード例 #2
0
            private void m_Place(Vector2Int Pos, DecorationItem di, BaseBuildingGrid bbg)
            {
                int row    = di.OccupySize.GetLength(0);
                int column = di.OccupySize.GetLength(1);

                for (int i = 0; i < row; i++)
                {
                    for (int j = 0; j < column; j++)
                    {
                        bbg.Grids[Pos.x + i, Pos.y + j].GridState = GridState.Occupied;
                    }
                }
            }
コード例 #3
0
            public override void OnEnter()
            {
                base.OnEnter();
                Context.InventoryPanel.gameObject.SetActive(false);
                Context.m_SelectionCursor.SetActive(false);
                Context.InventoryInfoPanel.gameObject.SetActive(false);

                Context.ClinicGrid.SetActive(true);
                BuildPosition    = new Vector2Int();
                BaseBuildingGrid = Context.ClinicGrid.GetComponent <BaseBuildingGrid>();
                DecorationItem   = Context.m_DecorationItem;
                m_FitPosition(BuildPosition);
                // Make Camera Follow this
                Camera.main.GetComponent <CameraManager>().Character = Context.m_CurrentInstantiatedObject;
            }
コード例 #4
0
            /// <summary>
            /// Check if can place
            /// </summary>
            /// <param name="Pos"></param>
            /// <param name="di"></param>
            /// <param name="bbg"></param>
            /// <returns></returns>
            private bool m_CanPlace(Vector2Int Pos, DecorationItem di, BaseBuildingGrid bbg)
            {
                int row    = di.OccupySize.GetLength(0);
                int column = di.OccupySize.GetLength(1);

                for (int i = 0; i < row; i++)
                {
                    for (int j = 0; j < column; j++)
                    {
                        if (bbg.Grids[Pos.x + i, Pos.y + j].GridState != GridState.CanPlace &&
                            bbg.Grids[Pos.x + i, Pos.y + j].GridState != GridState.Empty)
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }