Example #1
0
 public bool PrefabIsDoor()
 {
     if (WallObject == null)
     {
         WallObject = GetComponentInterface <IWallObject>();
     }
     return(WallObject != null && WallObject is DoorController);
 }
 public void Reset()
 {
     _CurrentMode    = Mode.None;
     _SelectedObject = null;
     if (OnReset != null)
     {
         OnReset();
     }
 }
Example #3
0
    //public void ForeachWall(System.Action<WallPoint,WallController> action)
    //{

    //}

    public WallController PrefabSetWall(Manager m, WallPoint point)
    {
        IWallObject    wo = GetComponentInterface <IWallObject>();
        WallController w  = m.House.ReplaceWall(point, this);

        if (wo != null)
        {
            wo.PrefabPrepareWall(m, w);
        }
        return(w);
    }
Example #4
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (_SelectedManager.CurrentMode == ObjectsManager.Mode.None || _SelectedManager.CurrentMode == ObjectsManager.Mode.Vert)
            {
                return;
            }

            var wallObj = _SelectedManager.SelectedObject as WallObject;

            if (wallObj != null)
            {
                _ChosenObject = (WallObject)EditorGUILayout.ObjectField(wallObj, typeof(WallObject), false);
                _SelectedManager.SelectObject(_ChosenObject);
            }
        }
        public void SelectMode(Mode mode)
        {
            _CurrentMode = mode;
            switch (mode)
            {
            case Mode.Doors:
                _SelectedObject = ScriptableObjectUtils.CreateOrGet <Door>("default");
                break;

            case Mode.Windows:
                _SelectedObject = ScriptableObjectUtils.CreateOrGet <Window>("default");
                break;

            case Mode.Vert:
                _SelectedObject = new RoomVert(null, new Vector2());
                break;
            }
            if (OnChangeMode != null)
            {
                OnChangeMode();
            }
        }
Example #6
0
    // returns true if wall has to be destroyed
    public bool EditorUpdateWall()
    {
        if (houseController == null)
        {
            houseController = GetComponentInParent <HouseController>();
        }
        CellController tr = houseController.GetCell(new MapPoint(position.X, position.Y));
        CellController tl = houseController.GetCell(new MapPoint(position.X - 1, position.Y));

        CellController br = houseController.GetCell(new MapPoint(position.X, position.Y - 1));
        CellController bl = houseController.GetCell(new MapPoint(position.X - 1, position.Y - 1));

        if (tr != null && tl != null && br != null && bl != null)
        {
            return(true);
        }
        if (tr == null && tl == null && br == null && bl == null)
        {
            return(true);
        }


        wallSprite.Top    = (tr == null) ^ (tl == null);
        wallSprite.Bottom = (br == null) ^ (bl == null);

        wallSprite.Right = (tr == null) ^ (br == null);
        wallSprite.Left  = (tl == null) ^ (bl == null);

        wallSprite.UpdateWall();

        IWallObject wo = GetComponentInterface <IWallObject>();

        if (wo != null && wo is WindowController)
        {
            (wo as WindowController).EditorUpdateWall(houseController);
        }
        return(false);
    }
Example #7
0
    public bool PrefabValidatePosition(Manager m, WallPoint point)
    {
        IWallObject wo = GetComponentInterface <IWallObject>();

        if (wo != null && wo.PrefabValidatePosition(m, point) == false)
        {
            return(false);
        }

        if (!m.House.IsInsideBuilding(point))
        {
            return(false);
        }
        WallController w = null;

        w = m.House.GetWall(new WallPoint(point.X - 1, point.Y));
        if (w != null && w.WallObject != null)
        {
            return(false);
        }
        w = m.House.GetWall(new WallPoint(point.X + 1, point.Y));
        if (w != null && w.WallObject != null)
        {
            return(false);
        }
        w = m.House.GetWall(new WallPoint(point.X, point.Y - 1));
        if (w != null && w.WallObject != null)
        {
            return(false);
        }
        w = m.House.GetWall(new WallPoint(point.X, point.Y + 1));
        if (w != null && w.WallObject != null)
        {
            return(false);
        }

        return(true);
    }
Example #8
0
 protected override void Awake()
 {
     base.Awake();
     houseController = GetComponentInParent <HouseController>();
     WallObject      = GetComponentInterface <IWallObject>();
 }
 public void SelectObject(IWallObject wallObj)
 {
     _SelectedObject = wallObj;
 }
Example #10
0
	protected override void Awake ()
	{
		base.Awake ();
		houseController = GetComponentInParent<HouseController>();
		WallObject = GetComponentInterface<IWallObject>();
	}
Example #11
0
	public bool PrefabIsDoor()
	{
		if(WallObject==null)
			WallObject = GetComponentInterface<IWallObject>();
		return (WallObject!=null && WallObject is DoorController);
	}