Ejemplo n.º 1
0
        public override void Execute(Dispatcher service)
        {
            Console.Write("Altering version for Project " + Project);

            var search = MainDirectory;

            if (Directory.Exists(Path.Combine(MainDirectory, Project)))
            {
                search = Path.Combine(MainDirectory, Project);
            }
            string[] files = Directory.GetFiles(search, "*" + Project + ".csproj", SearchOption.AllDirectories);
            foreach (string path in files)
            {
                ProjectFile f = new ProjectFile(path, new PhysicalFileReader());
                f.SetVersion(this);
                f.Save();
            }
            service.GotoColumn(7);
            using (ColorSetter.Set(ConsoleColor.Cyan))
            {
                Console.Write("-> v" + LongVersion + "\t");
            }
            using (ColorSetter.Set(ConsoleColor.Green))
            {
                Console.Write("SUCCESS");
            }

            Console.WriteLine();
        }
Ejemplo n.º 2
0
    public void Spawn(Vector2 speedVector, Vector2 initSpeed, int attackerIndex = -1)
    {
        this.attackerIndex = attackerIndex;

        if (speedVector == Vector2.zero && initSpeed == Vector2.zero)
        {
            ChangeLayerToRestState();
        }
        else
        {
            ChangeLayerToMotionState();
        }

        _rb          = gameObject.GetComponent <Rigidbody2D>();
        _rb.velocity = initSpeed + speedVector * LAUNCH_FORCE;
        _rb.AddForce(speedVector * LAUNCH_FORCE, ForceMode2D.Impulse);
        _col         = GetComponent <Collider2D>();
        _col.enabled = false;
        Invoke("EnableCollision", 0.05f);

        _forceFlag       = true;
        _lastSpeedVector = speedVector * 0.5f;
        Invoke("DisableForce", 0.15f);

        ColorSetter.UpdateModelColor(gameObject, mineTypeColor);
    }
Ejemplo n.º 3
0
    public static IEnumerator PingPongColor(ColorSetter colorSetter,
                                            Color startValue, Color endValue,
                                            float period, bool useGameTime = false,
                                            AnimationCurve animationCurve  = null)
    {
        animationCurve              = animationCurve ?? AnimationCurve.Linear(0.0f, 0.0f, 1.0f, 1.0f);
        animationCurve.preWrapMode  = WrapMode.PingPong;
        animationCurve.postWrapMode = WrapMode.PingPong;
        float startTime   = Time.realtimeSinceStartup;
        float timeElapsed = 0.0f;
        float progress    = 0.0f;

        colorSetter(startValue);
        float duration = period / 2;

        while (true)
        {
            timeElapsed = UpdateTimeElapsed(timeElapsed, startTime, useGameTime);
            progress    = timeElapsed / duration;
            float scaledProgress = ScaleProgress(progress, 0.0f, 1.0f, animationCurve);
            Color newColor       = Color.Lerp(startValue, endValue, scaledProgress);
            colorSetter(newColor);
            yield return(null);
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// This is called by every event handler for compat reasons -- see DDB #136924
        /// However it will skip after the first call
        /// </summary>
        private void InitializeBaseConsoleLogger()
        {
            if (_consoleLogger == null)
            {
                bool useMPLogger         = false;
                bool disableConsoleColor = false;
                if (!string.IsNullOrEmpty(_parameters))
                {
                    string[] parameterComponents = _parameters.Split(BaseConsoleLogger.parameterDelimiters);
                    for (int param = 0; param < parameterComponents.Length; param++)
                    {
                        if (parameterComponents[param].Length > 0)
                        {
                            if (0 == String.Compare(parameterComponents[param], "ENABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = true;
                            }
                            if (0 == String.Compare(parameterComponents[param], "DISABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = false;
                            }
                            if (0 == String.Compare(parameterComponents[param], "DISABLECONSOLECOLOR", StringComparison.OrdinalIgnoreCase))
                            {
                                disableConsoleColor = true;
                            }
                        }
                    }
                }

                if (disableConsoleColor)
                {
                    _colorSet   = new ColorSetter(BaseConsoleLogger.DontSetColor);
                    _colorReset = new ColorResetter(BaseConsoleLogger.DontResetColor);
                }

                if (_numberOfProcessors == 1 && !useMPLogger)
                {
                    _consoleLogger = new SerialConsoleLogger(_verbosity, _write, _colorSet, _colorReset);
                }
                else
                {
                    _consoleLogger = new ParallelConsoleLogger(_verbosity, _write, _colorSet, _colorReset);
                }

                if (!string.IsNullOrEmpty(_parameters))
                {
                    _consoleLogger.Parameters = _parameters;
                    _parameters = null;
                }

                if (_showSummary != null)
                {
                    _consoleLogger.ShowSummary = (bool)_showSummary;
                }

                _consoleLogger.SkipProjectStartedText = _skipProjectStartedText;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <owner>t-jeffv, sumedhk</owner>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public SerialConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     InitializeConsoleMethods(verbosity, write, colorSet, colorReset);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <owner>t-jeffv, sumedhk</owner>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public SerialConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     InitializeConsoleMethods(verbosity, write, colorSet, colorReset);
 }
Ejemplo n.º 7
0
    public static IEnumerator LerpAlpha(ColorSetter colorSetter,
                                        float startOpacity, float endOpacity,
                                        float duration, bool useGameTime = false,
                                        Color?maybeTint = null)
    {
        Color tint       = maybeTint ?? Color.black;
        Color startColor = new Color(tint.r, tint.g, tint.b, startOpacity);
        Color endColor   = new Color(tint.r, tint.g, tint.b, endOpacity);

        yield return(TransitionUtility.instance.StartCoroutine(
                         LerpColor(colorSetter, startColor, endColor, duration, useGameTime)));
    }
Ejemplo n.º 8
0
 private void Awake()
 {
     #region Singleton
     if (instance == null)
     {
         instance = this;
     }
     else if (instance == this)
     {
         Destroy(gameObject);
     }
     #endregion
 }
        /// <summary>
        /// Creates a default black and white bitmap from the HGT file, black being lowest or missing, white being highest.
        /// </summary>
        /// <returns>Black and white Bitmap.</returns>
        public System.Drawing.Bitmap ToBitmap()
        {
            ColorSetter setter = (lowest, highest, height) =>
            {
                if (height == short.MinValue)
                {
                    return(System.Drawing.Color.Black);
                }
                return(System.Drawing.Color.FromArgb((height - lowest) * 255 / (highest - lowest), (height - lowest) * 255 / (highest - lowest), (height - lowest) * 255 / (highest - lowest)));
            };

            return(ToBitmap(setter));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public ConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     _verbosity  = verbosity;
     _write      = write;
     _colorSet   = colorSet;
     _colorReset = colorReset;
 }
Ejemplo n.º 11
0
		public ConsoleLogger (LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
		{
			if (write == null)
				throw new ArgumentNullException ("write");
			if (colorSet == null)
				throw new ArgumentNullException ("colorSet");
			if (colorReset == null)
				throw new ArgumentNullException ("colorReset");
			Verbosity = verbosity;
			this.write = write;
			set_color = colorSet;
			reset_color = colorReset;
		}
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public ConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     ErrorUtilities.VerifyThrowArgumentNull(write, "write");
     _verbosity  = verbosity;
     _write      = write;
     _colorSet   = colorSet;
     _colorReset = colorReset;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public ConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     ErrorUtilities.VerifyThrowArgumentNull(write, nameof(write));
     this.verbosity  = verbosity;
     this.write      = write;
     this.colorSet   = colorSet;
     this.colorReset = colorReset;
 }
        /// <summary>
        /// Creates a bitmap from the HGT file, where each height corresponds to a color set by the setter.
        /// </summary>
        /// <param name="setter">Maps the (lowest, highest) interval with short.MinValue for missing height value into RGB colorspace.</param>
        /// <returns>Bitmap created using the setter.</returns>
        public System.Drawing.Bitmap ToBitmap(ColorSetter setter)
        {
            int size = (int)Math.Sqrt(data.Length);
            var bmp  = new System.Drawing.Bitmap(size, size);

            using (var k = new LockBitmap.LockBitmap(bmp))
            {
                for (int i = 0; i < data.Length; i++)
                {
                    k.SetPixel(i % size, i / size, setter(Lowest, Highest, data[i]));
                }
            }
            return(bmp);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 新しいベクトル描画マネージャを作成します。
        /// </summary>
        /// <param name="g">グラフィックデバイス</param>
        /// <param name="arrow">矢印の設定オブジェクト</param>
        /// <param name="MaxValue">データの最大値</param>
        public ArrowDrawer( Graphics g, VectorSetting arrow, double MaxValue, double MinValue )
        {
            this.Arrow = arrow;
            this.G = g;

            this.maxValue = MaxValue;
            this.minValue = MinValue;
            this.refValue = arrow.ReferredLength;
            this.unitLength = 500/20.0;
            this.magnitude = this.Arrow.Length/100.0/this.refValue*this.unitLength*2;
            this.tipMagnitude = this.Arrow.TipLength/100.0*this.magnitude;
            this.halfTipAngle = arrow.TipAngle/180.0*Math.PI/2.0;
            this.tan_halfTipAngle = Math.Tan( this.halfTipAngle );
            this.linePen = new Pen( arrow.LineColor, arrow.LineWidth );
            this.innerBrush = new SolidBrush( arrow.InnerColor );

            switch( arrow.TipType )
            {
                case TipType.FillTriangle:
                    this.arrowDrawer = this.drawTrAnglArrow;
                    break;
                case TipType.LineTip:
                    this.arrowDrawer = this.drawLineArrow;
                    break;
                default:
                    throw new NotImplementedException();
            }
            if( arrow.FixTipSize )
            {
                this.pointCalculator = this.calcFixPoints;
            }
            else
            {
                this.pointCalculator = this.calcVarPoints;
            }
            if( arrow.Colorful )
            {
                this.lineColorSetter = this.setColorfulColor;
                this.innerColorSetter = this.setColorfulColor;
            }
            else
            {
                this.lineColorSetter = this.setFixedPenColor;
                this.innerColorSetter = this.setFixedBrushColor;
            }
        }
Ejemplo n.º 16
0
    public static IEnumerator LerpColorSequence(ColorSetter colorSetter,
                                                List <Color> stops,
                                                List <float> durations)
    {
        int i = 0;

        while (i < stops.Count - 1)
        {
            Color startColor = stops[i];
            Color endColor   = stops[i + 1];
            float duration   = durations[i];
            yield return(TransitionUtility.instance.StartCoroutine(
                             LerpColor(colorSetter, startColor, endColor, duration)));

            ++i;
        }
    }
Ejemplo n.º 17
0
    public static IEnumerator LerpColor(ColorSetter colorSetter,
                                        Color startColor, Color endColor,
                                        float duration, bool useGameTime = false)
    {
        float startTime   = Time.realtimeSinceStartup;
        float timeElapsed = 0.0f;
        float progress    = 0.0f;

        colorSetter(startColor);
        while (timeElapsed < duration)
        {
            timeElapsed = UpdateTimeElapsed(timeElapsed, startTime, useGameTime);
            progress    = timeElapsed / duration;
            Color newColor = Color.Lerp(startColor, endColor, progress);
            colorSetter(newColor);
            yield return(null);
        }
        colorSetter(endColor);
    }
Ejemplo n.º 18
0
 public ConsoleLogger(LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
 {
     if (write == null)
     {
         throw new ArgumentNullException("write");
     }
     if (colorSet == null)
     {
         throw new ArgumentNullException("colorSet");
     }
     if (colorReset == null)
     {
         throw new ArgumentNullException("colorReset");
     }
     Verbosity   = verbosity;
     this.write  = write;
     set_color   = colorSet;
     reset_color = colorReset;
 }
Ejemplo n.º 19
0
    public void Init(int index, InputManager controls, Color color)
    {
        _rb          = GetComponent <Rigidbody2D>();
        _initMass    = _rb.mass;
        _initDrag    = _rb.drag;
        _input       = controls;
        _playerIndex = index;
        _shipColor   = color;

        ColorSetter.UpdateModelColor(BodyModel, _shipColor);

        SpeedIndicator = Instantiate(SpeedIndicator, new Vector3(0, 0, 0), Quaternion.identity, null);
        SpeedIndicator.transform.parent        = gameObject.transform;
        SpeedIndicator.transform.localPosition = new Vector3(0, -0.3f, 0);

        EventManager.Subscribe <Event_PlayerMineCollect>(this, OnMineCollect);
        EventManager.Subscribe <Event_MaximumMinesCount_Change>(this, OnMineMaxCountChange);
        EventManager.Subscribe <Event_ControlsLockState_Change>(this, OnControlsLockStateChange);
    }
Ejemplo n.º 20
0
    void OnGUI()
    {
        GUI.Label(new Rect(200, 200, 100, 20), $"Health: {playerdata.health}"); //Displays player health
        if (GUI.Button(new Rect(300, 200, 80, 20), "Health +"))                 // + to health
        {
            playerdata.health += 1;
        }
        if (GUI.Button(new Rect(390, 200, 80, 20), "Health -")) // - from health
        {
            playerdata.health -= 1;
        }
        GUI.Label(new Rect(200, 220, 100, 20), $"Level: {playerdata.level}"); // Display player lvl
        if (GUI.Button(new Rect(300, 220, 80, 20), "Level +"))                // + to level
        {
            playerdata.level += 1;
        }
        if (GUI.Button(new Rect(390, 220, 80, 20), "Level -")) // - to level
        {
            playerdata.level -= 1;
        }
        if (GUI.Button(new Rect(300, 240, 80, 20), "Save")) // call SavePlayer() function in player script
        {
            playerdata.SavePlayer();
        }
        if (GUI.Button(new Rect(390, 240, 80, 20), "Load")) // call LoadPlayer() function in player script
        {
            playerdata.LoadPlayer();
            Color color = new Color(playerdata.sphereMat.r, playerdata.sphereMat.g, playerdata.sphereMat.b, playerdata.sphereMat.a);
            ColorSetter.SetObjectColor(sphere, color);               // Calls SetObjectColor in ColorSetterScript to change color
        }
        if (GUI.Button(new Rect(300, 260, 120, 20), "Change Color")) // Button to change color of sphere obj material
        {
            playerdata.sphereMat.r = Random.Range(0.1f, 1f);         // Randomize the Color change with rgba vals
            playerdata.sphereMat.g = Random.Range(0.1f, 1f);
            playerdata.sphereMat.b = Random.Range(0.1f, 1f);
            playerdata.sphereMat.a = Random.Range(0.1f, 1f);

            Color color = new Color(playerdata.sphereMat.r, playerdata.sphereMat.g, playerdata.sphereMat.b, playerdata.sphereMat.a); // Create a color with those values

            ColorSetter.SetObjectColor(sphere, color);                                                                               // Calls SetObjectColor in ColorSetterScript to change color
        }
    }
Ejemplo n.º 21
0
    private void Start()
    {
        gameManager = FindObjectOfType <GameManager>();

        colorSetter = FindObjectOfType <ColorSetter>();

        inputStates = new InputState[4];

        for (int i = 0; i < 4; i++)
        {
            inputStates[i] = new InputState();
        }

        colorInputs = new InputState[4];

        for (int i = 0; i < 4; i++)
        {
            colorInputs[i] = new InputState();
        }
    }
Ejemplo n.º 22
0
    private void SetAttributes(GameObject tank, Material mat, string tag, GameObject enemy)
    {
        TankMovementAgent tankMovementAgent = tank.GetComponent <TankMovementAgent>();

        tankMovementAgent.battleArenaManager = this;
        tankMovementAgent.target             = enemy;
        tankMovementAgent.Search             = tag;

        TankShooterAgent tankShooterAgent = tank.GetComponentInChildren <TankShooterAgent>();

        tankShooterAgent.battleArenaManager = this;
        tankShooterAgent.target             = enemy;
        tankShooterAgent.search             = tag;

        Destroyer destroyer = tank.GetComponent <Destroyer>();

        destroyer.tankBattleArenaManager = this;

        ColorSetter colorSetter = tank.GetComponent <ColorSetter>();

        colorSetter.SetColor(mat);
    }
Ejemplo n.º 23
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Enemy"))
        {
            ColorSetter enemyColor = collision.GetComponent <ColorSetter>();
            if (enemyColor.enemyColor != this.GetComponent <ColorSetter>().enemyColor)
            {
                ScreenShake.instance.TriggerShake();
                ScoreManager._instance.AddPoints();
            }
            else
            {
                ScoreManager._instance.TakePoints();
            }

            Instantiate(EnemyTypeManager._instance.GetParticles(enemyColor.enemyColor), collision.transform.position, Quaternion.identity);

            // Destroy(collision.gameObject);
            // Destroy(gameObject);
            collision.gameObject.SetActive(false);
            this.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 24
0
    protected override GameObject InstantiateTank(Transform transform, Material material)
    {
        player     = Instantiate(playerTank, transform);
        player.tag = "BlueTank";

        PlayerTankHealth playerTankHealth = player.GetComponent <PlayerTankHealth>();

        playerTankHealth.aiVSplayerBattleManager = this;

        ColorSetter colorSetter = player.GetComponent <ColorSetter>();

        colorSetter.SetColor(material);

        int        range   = Random.Range(0, positions.Length);
        GameObject redTank = Instantiate(aiTank, positions[range]);

        redTank.tag = "RedTank";

        SetAttributes(redTank, spawn2Mat, "Blue", player);

        tanks.Add(redTank);
        return(player);
    }
Ejemplo n.º 25
0
    public void InstanceInit()
    {
        if (!m_spawnLists.ContainsKey(m_ingredientType))
        {
            m_spawnLists[m_ingredientType] = new List <Ingredient>();
            m_spawnLists[m_ingredientType].Add(this);
        }

        // Grab the renderer
        m_renderer = GetComponentInChildren <Renderer>();

        // For setting the color
        m_colorSetter = GetComponentInChildren <ColorSetter>();

        // Used for fast lookup of orders
        m_ingredientMask = (uint)(1 << (int)m_ingredientType);

        m_rb = GetComponentInChildren <Rigidbody>();

        ChangeColor();

        m_grabbedByPlayer = false;
    }
Ejemplo n.º 26
0
    void UpdateInternals()
    {
        //_collectedMines
        int maxMines = GameState.Instance.MaxMinesBeforeExplosion;

        //float scale = 0.1f + 0.9f *( (float)_collectedMines.Count() / (float) maxMines );
        //InternalsModel.transform.localScale = new Vector3(scale, scale, scale);

        foreach (var slot in MineSlots)
        {
            slot.SetActive(false);
        }

        int slotIndex = 0;

        foreach (var mine in _collectedMines.Mines)
        {
            MineSlots[slotIndex].SetActive(true);

            Color mineColor = Mine.MineTypeToColor(mine);
            if (_lashDashIncreasmentStartingTime > 0f)
            {
                // It is indicator of full-dash collected
                mineColor = Color.magenta;
            }
            ColorSetter.UpdateModelColor(MineSlots[slotIndex], mineColor);
            slotIndex++;
            slotIndex = Mathf.Clamp(slotIndex, 0, MineSlots.Count - 1);
        }
        CalcShipMass();
        if (_collectedMines.Count() > maxMines)
        {
            Kill();
        }
        ActualizeLayer();
    }
Ejemplo n.º 27
0
		public ConsoleLogger (LoggerVerbosity verbosity,
				      WriteHandler write,
				      ColorSetter colorSet,
				      ColorResetter colorReset)
		{
			this.verbosity = verbosity;
			this.indent = 0;
			this.errorCount = 0;
			this.warningCount = 0;
			if (write == null)
				this.writeHandler += new WriteHandler (WriteHandlerFunction);
			else
				this.writeHandler += write;
			this.performanceSummary = false;
			this.showSummary = true;
			this.skipProjectStartedText = false;
			errors = new List<string> ();
			warnings = new List<string> ();
			this.colorSet = colorSet;
			this.colorReset = colorReset;

			events = new List<BuildStatusEventArgs> ();
			errorsTable = new Dictionary<string, List<string>> ();
			warningsTable = new Dictionary<string, List<string>> ();

			//defaults
			errorColor = ConsoleColor.DarkRed;
			warningColor = ConsoleColor.DarkYellow;
			eventColor = ConsoleColor.DarkCyan;
			messageColor = ConsoleColor.DarkGray;
			highMessageColor = ConsoleColor.White;

			// if message color is not set via the env var,
			// then don't use any color for it.
			no_message_color = true;

			use_colors = false;
			if (colorSet == null || colorReset == null)
				return;

			// color support
			string config = Environment.GetEnvironmentVariable ("XBUILD_COLORS");
			if (config == null) {
				use_colors = true;
				return;
			}

			if (config == "disable")
				return;

			use_colors = true;
			string [] pairs = config.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
			foreach (string pair in pairs) {
				string [] parts = pair.Split (new char[] {'='}, StringSplitOptions.RemoveEmptyEntries);
				if (parts.Length != 2)
					continue;

				if (parts [0] == "errors")
					TryParseConsoleColor (parts [1], ref errorColor);
				else if (parts [0] == "warnings")
					TryParseConsoleColor (parts [1], ref warningColor);
				else if (parts [0] == "events")
					TryParseConsoleColor (parts [1], ref eventColor);
				else if (parts [0] == "messages") {
					if (TryParseConsoleColor (parts [1], ref messageColor)) {
						highMessageColor = GetBrightColorFor (messageColor);
						no_message_color = false;
					}
				}
			}
		}
Ejemplo n.º 28
0
            internal virtual void PrintCounterMessage(WriteLinePrettyFromResourceDelegate WriteLinePrettyFromResource, ColorSetter setColor, ColorResetter resetColor)
            {
                    string time;
                    if (!reenteredScope)
                    {
                        // round: submillisecond values are not meaningful
                        time = String.Format(CultureInfo.CurrentCulture,
                            "{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0));
                    }
                    else
                    {
                        // no value available; instead display an asterisk
                        time = "    *";
                    }

                    WriteLinePrettyFromResource
                        (
                            2,
                            "PerformanceLine",
                            time,
                            String.Format(CultureInfo.CurrentCulture,
                                    "{0,-40}" /* pad to 40 align left */, scopeName),
                            String.Format(CultureInfo.CurrentCulture,
                                    "{0,3}", calls)
                        );
            }
Ejemplo n.º 29
0
        internal void InitializeConsoleMethods(LoggerVerbosity logverbosity, WriteHandler logwriter, ColorSetter colorSet, ColorResetter colorReset)
        {
            this.verbosity = logverbosity;
            this.write = logwriter;
            IsRunningWithCharacterFileType();
            // This is a workaround, because the Console class provides no way to check that a color
            // can actually be set or not. Color cannot be set if the console has been redirected
            // in certain ways (e.g. how BUILD.EXE does it)
            bool canSetColor = true;

            try
            {
                ConsoleColor c = Console.BackgroundColor;
            }
            catch (IOException)
            {
                // If the attempt to set a color fails with an IO exception then it is
                // likely that the console has been redirected in a way that cannot
                // cope with color (e.g. BUILD.EXE) so don't try to do color again.
                canSetColor = false;
            }

            if ((colorSet != null) && canSetColor)
            {
                this.setColor = colorSet;
            }
            else
            {
                this.setColor = new ColorSetter(DontSetColor);
            }

            if ((colorReset != null) && canSetColor)
            {
                this.resetColor = colorReset;
            }
            else
            {
                this.resetColor = new ColorResetter(DontResetColor);
            }
        }
Ejemplo n.º 30
0
    void Update()
    {
        if (_lockFlag)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.Return) && JoinObjects.Count > 0)
        {
            GoToGame();
        }

        int i = 0;

        while (i < playersConnected)
        {
            TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(i);
            if (InputMng.GetButtonDown("Button A", playerId))
            {
                PlayerInfo info = _holder.playersInfos.Find(infs => infs.playerNumber == i);
                if (info != null)
                {
                    _holder.RemovePlayerInfo(info);
                    GameObject hideGO = JoinObjects.Find(objs => objs.name == joinKeysPrefixes[i]);
                    if (hideGO)
                    {
                        hideGO.SetActive(false);
                    }
                }
                else
                {
                    //Color col = UnityEngine.Random.ColorHSV(0, 1, 1, 1, 1, 1);
                    Color col = PlayerColors[i];
                    _holder.AddPlayerInfo(new PlayerInfo(col, i));
                    GameObject showGO = JoinObjects.Find(objs => objs.activeSelf == false);
                    if (showGO)
                    {
                        showGO.SetActive(true);
                        showGO.name = joinKeysPrefixes[i];
                        ColorSetter.UpdateModelColor(showGO, col);
                    }
                }
                PlayMenuClick();
            }
            i++;
        }
        foreach (var player in _holder.playersInfos)
        {
            TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID))
                                               .GetValue(player.playerNumber);
            if (InputMng.GetButtonDown("Start", playerId))
            {
                player.ready = !player.ready;
                GameObject readyGOParent = JoinObjects.Find(objs => objs.name == joinKeysPrefixes[player.playerNumber]);
                readyGOParent.transform.Find("ReadyFlag").gameObject.SetActive(player.ready);
                PlayMenuClick();
            }
        }

        bool _allReady = true;

        if (_holder.playersInfos.Count > 1)
        {
            foreach (var player in _holder.playersInfos)
            {
                if (!player.ready)
                {
                    _allReady = false;
                }
            }
        }
        else
        {
            _allReady = false;
        }

        if (_allReady)
        {
            _lockFlag = true;
            Invoke("GoToGame", 0.5f);
        }
    }
Ejemplo n.º 31
0
            internal virtual void PrintCounterMessage(WriteLinePrettyFromResourceDelegate WriteLinePrettyFromResource, ColorSetter setColor, ColorResetter resetColor)
            {
                string time;

                if (!reenteredScope)
                {
                    // round: submillisecond values are not meaningful
                    time = String.Format(CultureInfo.CurrentCulture,
                                         "{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0));
                }
                else
                {
                    // no value available; instead display an asterisk
                    time = "    *";
                }

                WriteLinePrettyFromResource
                (
                    2,
                    "PerformanceLine",
                    time,
                    String.Format(CultureInfo.CurrentCulture,
                                  "{0,-40}" /* pad to 40 align left */, scopeName),
                    String.Format(CultureInfo.CurrentCulture,
                                  "{0,3}", calls)
                );
            }
 public ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
 {
 }
Ejemplo n.º 33
0
 public QBLogger(LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
     : base(verbosity, write, colorSet, colorReset)
 {
 }
Ejemplo n.º 34
0
        public void bw_makeArt(object sender, EventArgs e)
        {
            //read input image
            Bitmap bm = new Bitmap(ImagePath);

            //create a new excel document

            Excel.Workbook   xlWorkbook  = xlApp.Workbooks.Add();
            Excel._Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(1);
            xlWorksheet.Unprotect();
            xlWorksheet.StandardWidth = 20 / 7.25;

            Excel.Range xlRange = xlWorksheet.UsedRange;

            ColorSetter cs = new ColorSetter(xlRange);

            //assign it here rather than in the for loop to avoid multithreading calamities
            var Width  = bm.Width;
            var Height = bm.Height;

            decimal totalPixels  = (bm.Width - 1) * (bm.Height - 1);
            decimal pixelCounter = 0;

            //i = across, j = up, image coordinates start from bottom left corner whereas excel starts from top left
            Parallel.For(0, Height - 1, (j, loopState) =>
            {
                var bmClone_   = bm.Clone();
                Bitmap bmClone = ((Bitmap)(bmClone_));
                for (int i = 0; i < Width - 1; i++)
                {
                    //make sure a cancel hasn't been requested
                    if (!Quitting)
                    {
                        try
                        {
                            cs.setColor(i, j, ref bmClone);
                            pixelCounter++;
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        //stops all threads from executing for clean exit when cancel is called
                        loopState.Stop();
                        break;
                    }
                }
                if (Quitting)
                {
                    loopState.Stop();
                }
                string msg = pixelCounter + "/" + totalPixels;
                Debug.WriteLine(msg);
                decimal progress = ((pixelCounter / totalPixels) * 100);
                int progressInt  = Convert.ToInt32(progress);
                bw.ReportProgress(progressInt);
            });

            if (!Quitting)
            {
                xlWorkbook.SaveAs(OutputPath);
                bw.ReportProgress(101);
            }

            xlRange = cs.Finish();
            xlWorkbook.Close(0);
            xlApp.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkbook);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);
        }
Ejemplo n.º 35
0
 /// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public ConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     ErrorUtilities.VerifyThrowArgumentNull(write, "write");
     _verbosity = verbosity;
     _write = write;
     _colorSet = colorSet;
     _colorReset = colorReset;
 }
Ejemplo n.º 36
0
        /// <summary>
        /// The idea here is to cache descriptors so that we have lightning fast performance.
        /// </summary>
        /// <param name="parent">The ScriptEngine that owns this ColorInstance.</param>
        private static void PopulateDescriptors(ScriptEngine parent)
        {
            if (_descriptors != null) return;

            _descriptors = new PropertyDescriptor[5];
            for (int i = 0; i < 4; ++i)
            {
                var getter = new ColorGetter(parent, i);
                var setter = new ColorSetter(parent, i);
                _descriptors[i] = new PropertyDescriptor(getter, setter, PropertyAttributes.Sealed);
            }
            _descriptors[4] = new PropertyDescriptor(new ToStringFunc(parent, "color"), PropertyAttributes.Sealed);
        }
Ejemplo n.º 37
0
 public ConsoleLogger (LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
 {
         throw new NotImplementedException ();
 }
	public ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset) {}
Ejemplo n.º 39
0
        public ConsoleLogger(LoggerVerbosity verbosity,
                             WriteHandler write,
                             ColorSetter colorSet,
                             ColorResetter colorReset)
        {
            this.verbosity = verbosity;
            if (write == null)
            {
                this.writeHandler += new WriteHandler(WriteHandlerFunction);
            }
            else
            {
                this.writeHandler += write;
            }
            this.skipProjectStartedText = false;
            this.colorSet   = colorSet;
            this.colorReset = colorReset;

            //defaults
            errorColor       = ConsoleColor.DarkRed;
            warningColor     = ConsoleColor.DarkYellow;
            eventColor       = ConsoleColor.DarkCyan;
            messageColor     = ConsoleColor.DarkGray;
            highMessageColor = ConsoleColor.White;

            // if message color is not set via the env var,
            // then don't use any color for it.
            no_message_color = true;

            use_colors = false;
            if (colorSet == null || colorReset == null)
            {
                return;
            }

            // color support
            string config = Environment.GetEnvironmentVariable("XBUILD_COLORS");

            if (config == null)
            {
                use_colors = true;
                return;
            }

            if (config == "disable")
            {
                return;
            }

            use_colors = true;
            string [] pairs = config.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string pair in pairs)
            {
                string [] parts = pair.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length != 2)
                {
                    continue;
                }

                if (parts [0] == "errors")
                {
                    TryParseConsoleColor(parts [1], ref errorColor);
                }
                else if (parts [0] == "warnings")
                {
                    TryParseConsoleColor(parts [1], ref warningColor);
                }
                else if (parts [0] == "events")
                {
                    TryParseConsoleColor(parts [1], ref eventColor);
                }
                else if (parts [0] == "messages")
                {
                    if (TryParseConsoleColor(parts [1], ref messageColor))
                    {
                        highMessageColor = GetBrightColorFor(messageColor);
                        no_message_color = false;
                    }
                }
            }
        }
Ejemplo n.º 40
0
        internal void InitializeConsoleMethods(LoggerVerbosity logverbosity, WriteHandler logwriter, ColorSetter colorSet, ColorResetter colorReset)
        {
            this.verbosity = logverbosity;
            this.write     = logwriter;
            IsRunningWithCharacterFileType();
            // This is a workaround, because the Console class provides no way to check that a color
            // can actually be set or not. Color cannot be set if the console has been redirected
            // in certain ways (e.g. how BUILD.EXE does it)
            bool canSetColor = true;

            try
            {
                ConsoleColor c = Console.BackgroundColor;
            }
            catch (IOException)
            {
                // If the attempt to set a color fails with an IO exception then it is
                // likely that the console has been redirected in a way that cannot
                // cope with color (e.g. BUILD.EXE) so don't try to do color again.
                canSetColor = false;
            }

            if ((colorSet != null) && canSetColor)
            {
                this.setColor = colorSet;
            }
            else
            {
                this.setColor = new ColorSetter(DontSetColor);
            }

            if ((colorReset != null) && canSetColor)
            {
                this.resetColor = colorReset;
            }
            else
            {
                this.resetColor = new ColorResetter(DontResetColor);
            }
        }
Ejemplo n.º 41
0
        /// <summary>
        /// This is called by every event handler for compat reasons -- see DDB #136924
        /// However it will skip after the first call
        /// </summary>
        private void InitializeBaseConsoleLogger()
        {
            if (_consoleLogger == null)
            {
                bool useMPLogger = false;
                bool disableConsoleColor = false;
                bool forceConsoleColor = false;
                if (!string.IsNullOrEmpty(_parameters))
                {
                    string[] parameterComponents = _parameters.Split(BaseConsoleLogger.parameterDelimiters);
                    for (int param = 0; param < parameterComponents.Length; param++)
                    {
                        if (parameterComponents[param].Length > 0)
                        {
                            if (0 == String.Compare(parameterComponents[param], "ENABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = true;
                            }
                            if (0 == String.Compare(parameterComponents[param], "DISABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = false;
                            }
                            if (0 == String.Compare(parameterComponents[param], "DISABLECONSOLECOLOR", StringComparison.OrdinalIgnoreCase))
                            {
                                disableConsoleColor = true;
                            }
                            if (0 == String.Compare(parameterComponents[param], "FORCECONSOLECOLOR", StringComparison.OrdinalIgnoreCase))
                            {
                                forceConsoleColor = true;
                            }
                        }
                    }
                }

                if (forceConsoleColor)
                {
                    _colorSet = new ColorSetter(BaseConsoleLogger.SetColorANSI);
                    _colorReset = new ColorResetter(BaseConsoleLogger.ResetColorANSI);
                }
                else if (disableConsoleColor)
                {
                    _colorSet = new ColorSetter(BaseConsoleLogger.DontSetColor);
                    _colorReset = new ColorResetter(BaseConsoleLogger.DontResetColor);
                }

                if (_numberOfProcessors == 1 && !useMPLogger)
                {
                    _consoleLogger = new SerialConsoleLogger(_verbosity, _write, _colorSet, _colorReset);
                }
                else
                {
                    _consoleLogger = new ParallelConsoleLogger(_verbosity, _write, _colorSet, _colorReset);
                }

                if (!string.IsNullOrEmpty(_parameters))
                {
                    _consoleLogger.Parameters = _parameters;
                    _parameters = null;
                }

                if (_showSummary != null)
                {
                    _consoleLogger.ShowSummary = (bool)_showSummary;
                }

                _consoleLogger.SkipProjectStartedText = _skipProjectStartedText;
            }
        }
Ejemplo n.º 42
0
#pragma warning restore 0219, 414

    private void OnEnable()
    {
        this._sColorSetter = this.target as ColorSetter;
    }