Exemple #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);
            }
Exemple #2
0
 public void OnUseDecoration(DecorationItem di)
 {
     if (m_InventoryFSM.CurrentState.GetType().Equals(typeof(InventoryOpenState)))
     {
         m_DecorationItem = di;
         m_InventoryFSM.TransitionTo <InventoryBuildState>();
     }
 }
Exemple #3
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;
                    }
                }
            }
            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;
            }
Exemple #5
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);
            }
Exemple #6
0
 public void OnSave(Vector2Int buildPosition, Clinic.DecorationItem decorationItem)
 {
     m_HomeDatabase.SaveDecortaion(buildPosition, decorationItem);
     OnSave();
 }