Beispiel #1
0
        /// <summary>
        /// Initialize a new instance of the KryptonSeparator class.
        /// </summary>
        public KryptonSeparator()
        {
            // The label cannot take the focus
            SetStyle(ControlStyles.Selectable, false);

            // Create the palette storage
            StateCommon = new PaletteSplitContainerRedirect(Redirector, PaletteBackStyle.PanelClient,
                                                            PaletteBorderStyle.ControlClient, PaletteBackStyle.SeparatorHighProfile,
                                                            PaletteBorderStyle.SeparatorHighProfile, NeedPaintDelegate)
            {
                BorderRedirect = { OverrideBorderToFalse = true }
            };

            // Never draw the border around the background

            StateDisabled = new PaletteSplitContainer(StateCommon, StateCommon.Separator, StateCommon.Separator, NeedPaintDelegate);
            StateNormal   = new PaletteSplitContainer(StateCommon, StateCommon.Separator, StateCommon.Separator, NeedPaintDelegate);
            StateTracking = new PaletteSeparatorPadding(StateCommon.Separator, StateCommon.Separator, NeedPaintDelegate);
            StatePressed  = new PaletteSeparatorPadding(StateCommon.Separator, StateCommon.Separator, NeedPaintDelegate);

            // Our view contains just a simple canvas that covers entire client area and a separator view
            _drawSeparator = new ViewDrawSeparator(StateDisabled.Separator, StateNormal.Separator, StateTracking, StatePressed,
                                                   StateDisabled.Separator, StateNormal.Separator, StateTracking, StatePressed,
                                                   PaletteMetricPadding.SeparatorPaddingLowProfile, Orientation.Vertical);

            // Get the separator to fill the entire client area
            _drawDocker = new ViewDrawDocker(StateNormal.Back, StateNormal.Border)
            {
                IgnoreAllBorderAndPadding = true
            };
            _drawDocker.Add(_drawSeparator, ViewDockStyle.Fill);

            // Create a separator controller to handle separator style behaviour
            _separatorController = new SeparatorController(this, _drawSeparator, true, true, NeedPaintDelegate);

            // Assign the controller to the view element to treat as a separator
            _drawSeparator.MouseController  = _separatorController;
            _drawSeparator.KeyController    = _separatorController;
            _drawSeparator.SourceController = _separatorController;

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawDocker);

            // Use timer to redraw after windows messages are processed
            _redrawTimer = new System.Windows.Forms.Timer
            {
                Interval = 1
            };
            _redrawTimer.Tick += OnRedrawTick;

            // Set other internal starting values
            _style             = SeparatorStyle.HighProfile;
            _orientation       = Orientation.Vertical;
            AllowMove          = true;
            SplitterIncrements = 1;
            _splitterWidth     = 5;
        }
Beispiel #2
0
    public void InitializeMap()
    {
        calculateOffsets();
        GameObject      firstSep   = Instantiate(separatorPrefab);
        PolarCalculator firstSepPc = firstSep.GetComponent <PolarCalculator>();

        firstSepPc.radius     = mapRadius;
        firstSepPc.startAngle = offset;
        firstSepPc.Initialize(mapRadius, offset, movementRange);
        firstSepPc.MoveToStart();

        GameObject         player              = Instantiate(playerPrefab);
        PolarCalculator    playerPc            = player.GetComponent <PolarCalculator> ();
        AstroScoreListener playerScoreListener = player.GetComponent <AstroScoreListener>();

        playerPc.Initialize(mapRadius, 0, movementRange);
        playerPc.MoveToStart();
        playerScoreListener.SetScoreAreaRange(offset);

        for (int i = 1; i < numPlayers; i++)
        {
            GameObject      nextSep = Instantiate(separatorPrefab);
            PolarCalculator sepPc   = nextSep.GetComponent <PolarCalculator>();
            sepPc.Initialize(mapRadius, i * separation + offset, 0);
            sepPc.MoveToStart();

            GameObject          enemy               = Instantiate(enemyPrefab);
            PolarCalculator     enemyPc             = enemy.GetComponent <PolarCalculator>();
            AstroScoreListener  enemyScoreListener  = enemy.GetComponent <AstroScoreListener>();
            SeparatorController separatorController = enemy.GetComponent <SeparatorController>();
            separatorController.associatedSeparator = nextSep;
            enemyPc.Initialize(mapRadius, i * separation, movementRange);
            enemyPc.MoveToStart();
            enemyScoreListener.SetScoreAreaRange(offset);
        }
    }