public Gradient(params CharAttribute[] colors)
        {
            int paletteLength = shadeSequence.Length * (colors.Length - 1) - (colors.Length - 2);

            palette = new CharInfo[paletteLength];

            for (int colorIndex = 0; colorIndex < colors.Length - 1; colorIndex++)
            {
                CharAttribute from = colors[colorIndex];
                CharAttribute to   = colors[colorIndex + 1];

                if (from <= CharAttribute.ForegroundWhite)
                {
                    from = (CharAttribute)((int)from << 4);
                }
                if (to > CharAttribute.ForegroundWhite)
                {
                    to = (CharAttribute)((int)to >> 4);
                }

                CharInfo shade = new CharInfo {
                    Attributes = from | to
                };

                for (int shadeIndex = 0; shadeIndex < shadeSequence.Length; shadeIndex++)
                {
                    shade.UnicodeChar = shadeSequence[shadeIndex];
                    if (shadeIndex > shadeSequence.Length / 2)
                    {
                        shade.Attributes |= CharAttribute.Reverse;
                    }
                    palette[shadeIndex - colorIndex + colorIndex * shadeSequence.Length] = shade;
                }
            }
        }
Example #2
0
        private void ReceiveCharacterCreate(BinaryReader reader)
        {
            Nickname = reader.ReadString();

            PlayerEntity = new Player();

            ushort attribCount = reader.ReadUInt16();

            for (int i = 0; i < attribCount; ++i)
            {
                CharAttribute attrib = CharAttribute.GetByID(reader.ReadUInt16());
                int           value  = reader.ReadByte();

                PlayerEntity.SetBaseAttributeLevel(attrib, value);
            }

            ushort skillCount = reader.ReadUInt16();

            for (int i = 0; i < skillCount; ++i)
            {
                CharSkill skill = CharSkill.GetByID(reader.ReadUInt16());
                int       value = reader.ReadByte();

                PlayerEntity.SetBaseSkillLevel(skill, value);
            }

            SendCharacterCreate();
        }
Example #3
0
 public static extern bool FillConsoleOutputAttribute(
     ConsoleHandle hConsoleOutput,
     CharAttribute wAttribute,
     int nLength,
     COORD dwWriteCoord,
     out uint lpNumberOfAttrsWritten
     );
Example #4
0
        public Character(System.IO.BinaryReader reader, bool sentFromServer)
            : base(reader, sentFromServer)
        {
            myHitPoints = reader.ReadInt16();
            myManaLevel = reader.ReadInt16();

            ushort attribCount = reader.ReadUInt16();

            for (int i = 0; i < attribCount; ++i)
            {
                myBaseAttributes.Add(CharAttribute.GetByID(reader.ReadUInt16()), reader.ReadByte());
            }

            ushort skillCount = reader.ReadUInt16();

            for (int i = 0; i < skillCount; ++i)
            {
                myBaseSkills.Add(CharSkill.GetByID(reader.ReadUInt16()), reader.ReadByte());
            }

            myCurrentWalkDirection = myFacingDirection = (WalkDirection)reader.ReadByte();

            if (!sentFromServer)
            {
                Inventory = new Inventory(this, reader);
            }
        }
Example #5
0
    public void AddExperiencia(ATRIBUTO atributo, int experiencia)
    {
        CharAttribute atribute       = attributes[atributo];
        int           thisExperience = GetFixedExperience(level);

        atribute.AddExperiencie(experiencia);

        Debug.Log("Has ganado " + experiencia + " de experiencia en el atributo " + atributo.ToString() + ". Total experiencia: " + atribute.experiencia + "/" + thisExperience);

        if (atribute.experiencia > thisExperience)
        {
            int newExperience = GetFixedExperience(level + 1);

            float porc = GetAumento(level, thisExperience, newExperience);
            atribute.AddLevel(newExperience);

            Debug.Log("Ha subido el atributo " + atributo + "Al nivel " + atribute.level);

            foreach (KeyValuePair <ATRIBUTO, CharAttribute> value in attributes)
            {
                if (value.Value.hasExperience)
                {
                    value.Value.RecalculateExperience(porc);
                }
            }

            level++;
        }

        //Actualizar el gráfico.
        actionUpdate();
    }
Example #6
0
 public BeliefBinding(CharAttribute attribute, BeliefWidget widget, bool inv)
     : base(attribute)
 {
     this.widget = widget;
     this.inv    = inv;
     UpdateWidget();
 }
Example #7
0
 public Character(char chr, CharColor foreground, CharColor background,
                  CharAttribute attr)
 {
     Char       = chr;
     Foreground = foreground;
     Background = background;
     Attribute  = attr;
 }
Example #8
0
 public SkillAttributeBinding(CharAttribute attribute, Label label)
     : base(attribute)
 {
     this.label     = label;
     this.baseValue = attribute.BaseValue;
     this.compValue = attribute.ModifiedValue;
     UpdateLabel();
 }
Example #9
0
        public void Set(int x, int y, byte b, CharAttribute attr = CharAttribute.FOREGROUND_RED)
        {
            var index = x + y * m_Width;
            var ci    = m_DrawBuffer[index];

            ci.Attributes       = (short)attr;
            ci.Char.AsciiChar   = b;
            m_DrawBuffer[index] = ci;
        }
 public DrawArgs(int x, int y, CharAttribute attributes, bool skipBuffer = false, bool transparency = false, char hiddenChar = 'Ö')
 {
     this.x            = x;
     this.y            = y;
     this.transparency = transparency;
     this.attributes   = attributes;
     this.hiddenChar   = hiddenChar;
     this.skipBuffer   = skipBuffer;
 }
Example #11
0
        public void Set(int x, int y, char c, CharAttribute attr = CharAttribute.FOREGROUND_RED)
        {
            var index = x + y * m_Width;
            var ci    = m_DrawBuffer[index];

            ci.Attributes       = (short)attr;
            ci.Char.UnicodeChar = c;
            m_DrawBuffer[index] = ci;
        }
        public void Clear(Rectangle rect, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
        {
            CharInfo clearChar = new CharInfo
            {
                Attributes  = attributes,
                UnicodeChar = '\0'
            };

            FillRect(rect, clearChar);
        }
        public void Clear(CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
        {
            CharInfo clearChar = new CharInfo
            {
                Attributes  = attributes,
                UnicodeChar = '\0'
            };

            Fill(clearChar);
        }
Example #14
0
 private bool DecreaseAttrib(CharAttribute attrib, int value)
 {
     if (value > 5)
     {
         UnusedPoints += 5;
         myOutput.SetAttributePoints(attrib, value - 5);
         RefreshSkills();
         return(true);
     }
     return(false);
 }
Example #15
0
 private bool IncreaseAttrib(CharAttribute attrib, int value)
 {
     if (UnusedPoints > 0 && value < 100)
     {
         UnusedPoints -= 5;
         myOutput.SetAttributePoints(attrib, value + 5);
         RefreshSkills();
         return(true);
     }
     return(false);
 }
        public static CharInfo[] ToCharInfoArray(this string s, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
        {
            CharInfo[] output = new CharInfo[s.Length];

            for (int i = 0; i < s.Length; i++)
            {
                output[i].UnicodeChar = s[i];
                output[i].Attributes  = attributes;
            }
            return(output);
        }
 public void Draw(char c, int x, int y, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
 {
     if (IsBoundedIndex(x, width) && IsBoundedIndex(y, height))
     {
         content[y, x] = new CharInfo
         {
             UnicodeChar = c,
             Attributes  = attributes
         }
     }
     ;
 }
Example #18
0
        public CharacterCreationOutput(int baseAttributePoints, int baseSkillPoints)
        {
            PlayerName       = "Player";
            myBaseAttributes = new Dictionary <CharAttribute, int>();
            myBaseSkills     = new Dictionary <CharSkill, int>();

            foreach (CharAttribute attrib in CharAttribute.GetAll())
            {
                myBaseAttributes.Add(attrib, baseAttributePoints);
            }

            foreach (CharSkill skill in CharSkill.GetAll())
            {
                myBaseSkills.Add(skill, baseSkillPoints);
            }
        }
Example #19
0
        static IList <Span> AnalyzeExtendedAndItemize(
            TextItemizer textItemizer,
            IntPtr text,
            uint length,
            CultureInfo numberCulture,
            IClassification classification
            )
        {
            Debug.Assert(length >= 0);

            CharAttribute[] pCharAttribute = new CharAttribute[length];

            // Analyze the extended character ranges.
            AnalyzeExtendedCharactersAndDigits(text, length, textItemizer, pCharAttribute, numberCulture, classification);
            return(textItemizer.Itemize(numberCulture, pCharAttribute));
        }
        public void Draw(string s, int x, int y, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
        {
            int safeHeight = SafeSourceEnd(y, 1, height);

            if (safeHeight > 0)
            {
                int safeStart = SafeSourceStart(x);
                int safeEnd   = SafeSourceEnd(x, s.Length, width);

                var infos = s.ToCharInfoArray(attributes);

                for (int index = safeStart; index < safeEnd; index++)
                {
                    content[y, x + index] = infos[index];
                }
            }
        }
        public static CharInfo[][] ToCharInfoArray(this string[] strings, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
        {
            CharInfo[][] output = new CharInfo[strings.Length][];// strings[0]?.Length ?? 0];

            for (int i = 0; i < strings.Length; i++)
            {
                var str = strings[i];
                output[i] = new CharInfo[str.Length];
                for (int j = 0; j < output[i].Length; j++)
                {
                    output[i][j].UnicodeChar = str[j];
                    output[i][j].Attributes  = attributes;
                }
            }

            return(output);
        }
Example #22
0
        public Player()
        {
            foreach (CharAttribute attrib in CharAttribute.GetAll())
            {
                SetBaseAttributeLevel(attrib, 10);
            }

            Inventory.SetCapacity(24);

            int items = (int)(Tools.Random() * 4) + 2;

            ItemInfo[] loots = Loot.GetAll();

            for (int i = 0; i < items; ++i)
            {
                Inventory.Add(new Loot(loots[(int)(Tools.Random() * loots.Length)], Tools.Random()));
            }

            Inventory.Add(new SpellOrb(SpellInfo.Get("firebolt"), 0.1));
        }
Example #23
0
            public AttribRow(AttributeCreation parent, CharAttribute attrib, CharacterCreationOutput output)
            {
                myParent = parent;
                myOutput = output;

                myAttrib = attrib;

                myMinusButton = new UIButton(new Vector2(20, 20), new Vector2(LeftColumn, 0))
                {
                    Text       = "-",
                    CentreText = true
                };

                myPlusButton = new UIButton(new Vector2(20, 20), new Vector2(LeftColumn + RightColumn - 20, 0))
                {
                    Text       = "+",
                    CentreText = true
                };


                myLabel = new UILabel(Font.Large, new Vector2(0, 5))
                {
                    Text = attrib.ToString()
                };
                myValueLabel = new UILabel(Font.Large, new Vector2(LeftColumn + RightColumn / 2 - 10, 5))
                {
                    //Text = value.ToString()
                };

                AddChild(myMinusButton);
                AddChild(myPlusButton);
                AddChild(myLabel);
                AddChild(myValueLabel);

                Value = myOutput.GetAttributePoints(myAttrib);

                myMinusButton.Click += new MouseButtonEventHandler(myMinusButton_Click);
                myPlusButton.Click  += new MouseButtonEventHandler(myPlusButton_Click);
            }
Example #24
0
        public void SetBaseAttributeLevel(CharAttribute attribute, int amount)
        {
            amount = Tools.Clamp(amount, 0, 100);

            if (!myBaseAttributes.ContainsKey(attribute))
            {
                myBaseAttributes.Add(attribute, amount);
            }
            else
            {
                myBaseAttributes[attribute] = amount;
            }

            if (Map != null && IsServer)
            {
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                stream.Write(BitConverter.GetBytes(attribute.ID), 0, 2);
                stream.WriteByte((byte)amount);
                SendStateUpdate("SetBaseAttribute", stream);
                stream.Close();
            }
        }
Example #25
0
        /// <summary>
        /// Sets a text attribute. previously set attributes are cleared
        /// </summary>
        /// <param name="C">Text attribute (can be combined)</param>
        public void setAttribute(CharAttribute C)
        {
            string s = string.Empty;

            if ((C & CharAttribute.Blink) == CharAttribute.Blink)
            {
                s += ";5";
            }
            if ((C & CharAttribute.Highligt) == CharAttribute.Highligt)
            {
                s += ";1";
            }
            if ((C & CharAttribute.Inverse) == CharAttribute.Inverse)
            {
                s += ";7";
            }
            if ((C & CharAttribute.Underline) == CharAttribute.Underline)
            {
                s += ";4";
            }
            sendCode("0" + s + "m");
        }
Example #26
0
        public void SendCharacterCreate(CharacterCreationOutput output)
        {
            myClients[GameClient.ID].Nickname = output.PlayerName;

            BinaryWriter writer = GetWriter();

            writer.Write((byte)PacketID.CharacterCreate);
            writer.Write(output.PlayerName);
            writer.Write((ushort)CharAttribute.GetAll().Length);
            foreach (CharAttribute attrib in CharAttribute.GetAll())
            {
                writer.Write(attrib.ID);
                writer.Write((byte)output.GetAttributePoints(attrib));
            }
            writer.Write((ushort)CharSkill.GetAll().Length);
            foreach (CharSkill skill in CharSkill.GetAll())
            {
                writer.Write(skill.ID);
                writer.Write((byte)output.GetBaseSkillPoints(skill));
            }

            SendPacket();
        }
        public void Draw(string[] strings, int x, int y, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
        {
            int safeHeight = SafeSourceEnd(y, strings.Length, height);

            if (safeHeight > 0)
            {
                int safeStartX = SafeSourceStart(x);
                int safeStartY = SafeSourceStart(y);

                int safeEndY = SafeSourceEnd(y, strings.Length, height);

                var infos = strings.ToCharInfoArray(attributes);

                for (int indexY = safeStartY; indexY < safeEndY; indexY++)
                {
                    int safeEndX = SafeSourceEnd(x, infos[indexY].Length, width);

                    for (int indexX = safeStartX; indexX < safeEndX; indexX++)
                    {
                        content[y + indexY, x + indexX] = infos[indexY][indexX];
                    }
                }
            }
        }
Example #28
0
    public CharacterAttribute(GameManager manager)
    {
        attributes = new Dictionary <ATRIBUTO, CharAttribute>();

        foreach (ATRIBUTO tipo in System.Enum.GetValues(typeof(ATRIBUTO)))
        {
            CharAttribute script = null;

            if (tipo == ATRIBUTO.Salud || tipo == ATRIBUTO.Estres || tipo == ATRIBUTO.Hambre)
            {
                script = new CharAttribute(tipo);
            }
            else
            {
                script = new CharAttribute(tipo, UnityEngine.Random.Range(-2, 6), 0);
            }

            attributes.Add(tipo, script);
        }

        level = 0;

        actionUpdate += () => manager.characterController.Actualizar();
    }
 public void FillRect(int x, int y, int width, int height, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
 {
     FillRect(x, y, width, height, new CharInfo {
         UnicodeChar = '\0', Attributes = attributes
     });
 }
 public void FillRect(Rectangle rect, CharAttribute attributes = ConsoleRenderer.DefaultAttributes)
 {
     FillRect(rect.Left, rect.Top, rect.Width, rect.Height, new CharInfo {
         UnicodeChar = '\0', Attributes = attributes
     });
 }