コード例 #1
0
        private static int GetDegreesForVisualEffect(string direction, int degreeVariance = 30)
        {
            int startDegree = direction == "S" ? 0
                            : direction == "SW" ? 315
                            : direction == "W" ? 270
                            : direction == "NW" ? 225
                            : direction == "N" ? 180
                            : direction == "NE" ? 135
                            : direction == "E" ? 90
                            : direction == "SE" ? 45
                            : (degreeVariance = 359); //random if direction didn't match
            int boundA = (startDegree - degreeVariance);
            int boundB = (startDegree + degreeVariance);

            return(QudUX_Random.NextInclusive(boundA, boundB) % 360);
        }
コード例 #2
0
        public static void EmitText(GameObject fromObject, List <string> formattedTextOptions, GameObject towardsObject = null, GameObject awayFromObject = null, int degreeVariance = 30)
        {
            if (!Options.Exploration.ParticleText)
            {
                return; //player has disabled this feature
            }
            string direction;

            if (towardsObject == null && awayFromObject == null) //emit toward center of zone by default
            {
                Cell centerCell = fromObject.CurrentCell.ParentZone.GetCell(40, 12);
                direction = fromObject.CurrentCell.GetDirectionFromCell(centerCell);
            }
            else if (towardsObject != null)
            {
                direction = fromObject.CurrentCell.GetDirectionFromCell(towardsObject.CurrentCell);
            }
            else //awayFromObject != null
            {
                direction = awayFromObject.CurrentCell.GetDirectionFromCell(fromObject.CurrentCell);
            }
            Cell   effectOriginCell = fromObject.CurrentCell.GetCellFromDirection(direction, true) ?? fromObject.CurrentCell;
            int    effectX          = effectOriginCell.X;
            int    effectY          = effectOriginCell.Y;
            int    randIndex        = QudUX_Random.Next(0, formattedTextOptions.Count);
            string text             = formattedTextOptions[randIndex];

            //adjust starting position of text if it would overflow off right side of the screen
            int phraseLength = ConsoleLib.Console.ColorUtility.StripFormatting(text).Length;

            if ((80 - effectX) < phraseLength)
            {
                effectX = Math.Max(10, 80 - phraseLength);
            }

            float num  = (float)GetDegreesForVisualEffect(direction, degreeVariance) / 58f;
            float xDel = (float)Math.Sin((double)num) / 4f;
            float yDel = (float)Math.Cos((double)num) / 4f;

            XRLCore.ParticleManager.Add(text, (float)effectX, (float)effectY, xDel, yDel, 22, 0f, 0f);
        }