Esempio n. 1
0
 public FactoryNeighbors(GridObject obj, Direction facing)
 {
     _north  = obj.NorthNeighbor != null ? obj.NorthNeighbor.FactoryObject : null;
     _east   = obj.EastNeighbor != null ? obj.EastNeighbor.FactoryObject : null;
     _south  = obj.SouthNeighbor != null ? obj.SouthNeighbor.FactoryObject : null;
     _west   = obj.WestNeighbor != null ? obj.WestNeighbor.FactoryObject : null;
     _facing = facing;
 }
Esempio n. 2
0
 public FactoryNeighbors(GridObject north, GridObject east, GridObject south, GridObject west, Direction facing)
 {
     _north  = north != null ? north.FactoryObject : null;
     _east   = east != null ? east.FactoryObject : null;
     _south  = south != null ? south.FactoryObject : null;
     _west   = west != null ? west.FactoryObject : null;
     _facing = facing;
 }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            GUILayout.Label("Current Selected : " + _current);

            FactoryObject factoryObject = (FactoryObject)target;
            int           rows          = (int)Mathf.Sqrt(factoryObject.GridObjects.Count);

            GUILayout.BeginVertical();
            for (int r = rows - 1; r >= 0; r--)
            {
                GUILayout.BeginHorizontal();
                for (int c = 0; c < rows; c++)
                {
                    if (GUILayout.Button(_textureHolder[factoryObject.GridObjects[r + (rows * c)]], GUILayout.Width(50), GUILayout.Height(50)))
                    {
                        factoryObject.GridObjects[r + (rows * c)] = _current;
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            GUILayout.Space(20);
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            int count = 0;

            foreach (KeyValuePair <FactoryElements, Texture> e in _textureHolder)
            {
                count++;
                if (GUILayout.Button(e.Value, GUILayout.Width(50), GUILayout.Height(50)))
                {
                    _current = e.Key;
                }
                if (count % 4 == 0)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }