示例#1
0
 public override void CreateNewData()
 {
     editingDisplay = new CharData ();
     originalDisplay = new CharData ();
     selectedDisplay = -1;
     LoadStatList();
 }
示例#2
0
    // Use this for initialization
    public ServerCharacter()
    {
        functionName = "Player Character Setup";
        // Database tables name
        tableName = "character_create_template";
        functionTitle = "Character Configuration";
        loadButtonLabel = "Load Character";
        notLoadedText = "No Character loaded.";
        // Init
        dataRegister = new Dictionary<int, CharData> ();

        editingDisplay = new CharData ();
        originalDisplay = new CharData ();
    }
 protected override void OnUpdate(float deltaTime)
 {
     CharData.Update(deltaTime);
     CharSkill.Update(deltaTime);
     CharMove.Update(deltaTime);
 }
示例#4
0
 private void storeData(CharData d)
 {
     d.SetFloat("Health", Health);
     d.SetFloat("MaxHealth", MaxHealth);
     d.SetInt("Faction", (int)Faction);
 }
示例#5
0
    public void ChangeTeamPos(CharData chara, TeamPos pos)
    {
        CharTeam charTeam;

        if (chara.isEnemy)
        {
            charTeam = enemies;
        }
        else
        {
            charTeam = heros;
        }

        if (GetTeamPos(chara) == pos)
        {
            return;
        }
        switch (GetTeamPos(chara))
        {
        case TeamPos.Front:
            if (pos == TeamPos.Middle)
            {
                slotControl.SetSlotPos(chara.charView, TeamPos.Middle, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.middle.charView, TeamPos.Front, chara.isEnemy);

                CharData temp = charTeam.front;
                charTeam.front  = charTeam.middle;
                charTeam.middle = temp;
            }
            else if (pos == TeamPos.Back)
            {
                slotControl.SetSlotPos(chara.charView, TeamPos.Back, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.middle.charView, TeamPos.Front, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.back.charView, TeamPos.Middle, chara.isEnemy);

                CharData temp = charTeam.back;
                charTeam.back   = charTeam.front;
                charTeam.front  = charTeam.middle;
                charTeam.middle = temp;
            }
            break;

        case TeamPos.Middle:
            if (pos == TeamPos.Front)
            {
                slotControl.SetSlotPos(chara.charView, TeamPos.Front, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.front.charView, TeamPos.Middle, chara.isEnemy);

                CharData temp = charTeam.front;
                charTeam.front  = charTeam.middle;
                charTeam.middle = temp;
            }
            else if (pos == TeamPos.Back)
            {
                slotControl.SetSlotPos(chara.charView, TeamPos.Back, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.back.charView, TeamPos.Middle, chara.isEnemy);

                CharData temp = charTeam.back;
                charTeam.back   = charTeam.middle;
                charTeam.middle = temp;
            }
            break;

        case TeamPos.Back:
            if (pos == TeamPos.Middle)
            {
                slotControl.SetSlotPos(chara.charView, TeamPos.Middle, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.middle.charView, TeamPos.Back, chara.isEnemy);

                CharData temp = charTeam.back;
                charTeam.back   = charTeam.middle;
                charTeam.middle = charTeam.back;
            }
            else if (pos == TeamPos.Front)
            {
                slotControl.SetSlotPos(chara.charView, TeamPos.Front, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.middle.charView, TeamPos.Back, chara.isEnemy);
                slotControl.SetSlotPos(charTeam.front.charView, TeamPos.Middle, chara.isEnemy);

                CharData temp = charTeam.front;
                charTeam.front  = charTeam.back;
                charTeam.back   = charTeam.middle;
                charTeam.middle = temp;
            }
            break;
        }
    }
示例#6
0
 public void CharMove(CharData chara, bool isEnemy)
 {
     chara.charView.CharMove(isEnemy);
 }
示例#7
0
 private void storeData(CharData d)
 {
     d.SetBool("TriggerUsed", TriggerUsed);
     d.SetString("TextboxString", TextboxString);
 }
        /// <summary>
        /// Build a BinaryTreeWithoutHeader object that extend the BinaryTree class.
        /// This object contains the encoded text as well as the binary tree.
        /// </summary>
        /// <param name="lstByte">The byte list from the compressed file.</param>
        /// <returns>The built BinaryTreeWithoutHeader object.</returns>
        protected BinaryTreeWithoutHeader<CharData> RebuildBinaryTree(byte[] lstByte)
        {
            BinaryTreeNode<CharData> currentNode = new BinaryTreeNode<CharData>();
            BinaryTreeWithoutHeader<CharData> binaryTree = new BinaryTreeWithoutHeader<CharData>();
            binaryTree.Root = currentNode;

            StringBuilder sb = new StringBuilder();
            foreach (byte b in lstByte)
            {
                sb.Append(Convert.ToString(b, 2).PadLeft(8, '0'));
            }
            bool headerDone = false;
            bool isCharCode = false;
            bool isRight = true;
            bool charCodeWasJustDone = false;
            int index = 0;
            string currentChunk = "";
            string currentBinaryCode = "";
            string previousBinaryCode = "";
            while (!headerDone)
            {
                if (!isCharCode && currentChunk.Length == 2)
                {
                    // Do something with the tree
                    switch (currentChunk)
                    {
                        case "01":
                            // Going right
                            currentBinaryCode += "1";
                            charCodeWasJustDone = false;
                            currentNode.Right = new BinaryTreeNode<CharData>();
                            currentNode.Right.Parent = currentNode;
                            currentNode = currentNode.Right;
                            isRight = true;
                            break;
                        case "10":
                            // Going left
                            currentBinaryCode += "0";
                            charCodeWasJustDone = false;
                            currentNode.Left = new BinaryTreeNode<CharData>();
                            currentNode.Left.Parent = currentNode;
                            currentNode = currentNode.Left;
                            isRight = false;
                            break;
                        case "11":
                            // Going parent
                            if (!charCodeWasJustDone)
                            {
                                isCharCode = true;
                            }
                            if (currentBinaryCode.Length > 0)
                            {
                                previousBinaryCode = currentBinaryCode;
                                currentBinaryCode = currentBinaryCode.Substring(0, currentBinaryCode.Length - 1);
                            }
                            currentNode = currentNode.Parent;
                            break;
                        case "00":
                            // Binary tree done
                            if(charCodeWasJustDone)
                                headerDone = true;
                            break;
                    }
                    currentChunk = "";
                }
                else if (isCharCode && currentChunk.Length == 8)
                {
                    CharData nodeToAdd = new CharData(new KeyValuePair<byte, int>(), previousBinaryCode, Convert.ToByte(currentChunk, 2));
                    // You got a char
                    if (isRight)
                    {
                        currentNode.Right.Value = nodeToAdd;
                    }
                    else
                    {
                        currentNode.Left.Value = nodeToAdd;
                    }
                    isCharCode = false;
                    charCodeWasJustDone = true;
                    currentChunk = "";
                }
                if (!headerDone)
                {
                    currentChunk += sb[index];
                    index++;
                }
            }
            sb.Remove(0, index);
            binaryTree.EncodedText = sb;
            return binaryTree;
        }
示例#9
0
        /// <summary>
        /// Creates a duplicate of a mobile minus its inventory.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="clone"></param>
        public static void CloneMobile(CharData parent, CharData clone)
        {
            int i;

            if (parent == null || clone == null || !parent.IsNPC())
            {
                return;
            }

            // Fix values.
            clone.Name             = parent.Name;
            clone.ShortDescription = parent.ShortDescription;
            clone.FullDescription  = parent.FullDescription;
            clone.Description      = parent.Description;
            clone.Gender           = parent.Gender;
            clone.CharacterClass   = parent.CharacterClass;
            clone.SetPermRace(parent.GetRace());
            clone.Level                = parent.Level;
            clone.TrustLevel           = 0;
            clone.SpecialFunction      = parent.SpecialFunction;
            clone.SpecialFunctionNames = parent.SpecialFunctionNames;
            clone.Timer                = parent.Timer;
            clone.Wait         = parent.Wait;
            clone.Hitpoints    = parent.Hitpoints;
            clone.MaxHitpoints = parent.MaxHitpoints;
            clone.CurrentMana  = parent.CurrentMana;
            clone.MaxMana      = parent.MaxMana;
            clone.CurrentMoves = parent.CurrentMoves;
            clone.MaxMoves     = parent.MaxMoves;
            clone.SetCoins(parent.GetCopper(), parent.GetSilver(), parent.GetGold(), parent.GetPlatinum());
            clone.ExperiencePoints     = parent.ExperiencePoints;
            clone.ActionFlags          = parent.ActionFlags;
            clone.Affected             = parent.Affected;
            clone.CurrentPosition      = parent.CurrentPosition;
            clone.Alignment            = parent.Alignment;
            clone.Hitroll              = parent.Hitroll;
            clone.Damroll              = parent.Damroll;
            clone.Wimpy                = parent.Wimpy;
            clone.Deaf                 = parent.Deaf;
            clone.Hunting              = parent.Hunting;
            clone.Hating               = parent.Hating;
            clone.Fearing              = parent.Fearing;
            clone.Resistant            = parent.Resistant;
            clone.Immune               = parent.Immune;
            clone.Susceptible          = parent.Susceptible;
            clone.CurrentSize          = parent.CurrentSize;
            clone.PermStrength         = parent.PermStrength;
            clone.PermIntelligence     = parent.PermIntelligence;
            clone.PermWisdom           = parent.PermWisdom;
            clone.PermDexterity        = parent.PermDexterity;
            clone.PermConstitution     = parent.PermConstitution;
            clone.PermAgility          = parent.PermAgility;
            clone.PermCharisma         = parent.PermCharisma;
            clone.PermPower            = parent.PermPower;
            clone.PermLuck             = parent.PermLuck;
            clone.ModifiedStrength     = parent.ModifiedStrength;
            clone.ModifiedIntelligence = parent.ModifiedIntelligence;
            clone.ModifiedWisdom       = parent.ModifiedWisdom;
            clone.ModifiedDexterity    = parent.ModifiedDexterity;
            clone.ModifiedConstitution = parent.ModifiedConstitution;
            clone.ModifiedAgility      = parent.ModifiedAgility;
            clone.ModifiedCharisma     = parent.ModifiedCharisma;
            clone.ModifiedPower        = parent.ModifiedPower;
            clone.ModifiedLuck         = parent.ModifiedLuck;
            clone.ArmorPoints          = parent.ArmorPoints;
            //clone._mpactnum = parent._mpactnum;

            for (i = 0; i < 6; i++)
            {
                clone.SavingThrows[i] = parent.SavingThrows[i];
            }

            // Now add the affects.
            foreach (Affect affect in parent.Affected)
            {
                clone.AddAffect(affect);
            }
        }
示例#10
0
    // Edit or Create
    public override void DrawEditor(Rect box, bool newItem)
    {
        // Setup the layout
        Rect pos = box;
        pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        pos.height = ImagePack.fieldHeight;

        if (!linkedTablesLoaded) {
            LoadFactionOptions();
            LoadAbilityOptions();
            raceOptions = ServerOptionChoices.LoadAtavismChoiceOptions("Race", false);
            classOptions = ServerOptionChoices.LoadAtavismChoiceOptions("Class", false);
            linkedTablesLoaded = true;
        }

        if (newItem) {
            ImagePack.DrawLabel (pos.x, pos.y, "Create a new Character");
            pos.y += ImagePack.fieldHeight;
        }

        pos.width /= 2;
        editingDisplay.race = ImagePack.DrawSelector (pos, "Character Race:", editingDisplay.race, raceOptions);
        pos.x += pos.width;
        editingDisplay.aspect = ImagePack.DrawSelector (pos, "Character Class:", editingDisplay.aspect, classOptions);
        pos.x -= pos.width;
        pos.y += ImagePack.fieldHeight;
        int otherFactionID = GetPositionOfFaction(editingDisplay.faction);
        otherFactionID = ImagePack.DrawSelector (pos, "Faction:", otherFactionID, factionOptions);
        editingDisplay.faction = factionIds[otherFactionID];
        pos.width *= 2;
        pos.y += ImagePack.fieldHeight;
        editingDisplay.instanceName = ImagePack.DrawField (pos, "Instance Name:", editingDisplay.instanceName, 0.75f);
        pos.y += 1.5f * ImagePack.fieldHeight;
        editingDisplay.Spawn = ImagePack.DrawGameObject (pos, "Drag a Game Object to get its Position:", editingDisplay.Spawn, 0.5f);
        pos.y += ImagePack.fieldHeight;
        editingDisplay.Position = ImagePack.Draw3DPosition (pos, "Or insert manually a Spawn Location:", editingDisplay.Position);
        pos.y += ImagePack.fieldHeight;
        pos.width /= 3;
        editingDisplay.orientation = ImagePack.DrawField (pos, "Orientation:", editingDisplay.orientation);
        //pos.x += pos.width;
        pos.width *= 3;
        pos.y += ImagePack.fieldHeight;
        int selectedAbility = GetPositionOfAbility (editingDisplay.autoAttack);
        selectedAbility = ImagePack.DrawSelector (pos, "Auto Attack:", selectedAbility, abilityOptions);
        editingDisplay.autoAttack = abilityIds [selectedAbility];

        pos.y += 1.5f*ImagePack.fieldHeight;
        ImagePack.DrawLabel (pos.x, pos.y, "Starting Stats");
        pos.y += 1.5f*ImagePack.fieldHeight;

        // Stats - show a map of all stats
        pos.width /= 2;
        foreach (CharStatsData charStat in editingDisplay.charStats) {
            charStat.statValue = ImagePack.DrawField (pos, charStat.stat, charStat.statValue);
            pos.y += ImagePack.fieldHeight;
            charStat.levelIncrease = ImagePack.DrawField (pos, "Increases by:", charStat.levelIncrease);
            pos.x += pos.width;
            charStat.levelPercentIncrease = ImagePack.DrawField (pos, "And Percent:", charStat.levelPercentIncrease);
            pos.x -= pos.width;
            pos.y += ImagePack.fieldHeight * 1.5f;
        }
        pos.width *= 2;

        if (!newItem) {
            if (skillsList == null)
                LoadSkillOptions();
            if (itemsList == null)
                LoadItemOptions();

            pos.y += 1.5f*ImagePack.fieldHeight;
            ImagePack.DrawLabel (pos.x, pos.y, "Starting Skills");
            pos.y += 1.5f*ImagePack.fieldHeight;

            pos.width /= 2;
            /*if (editingDisplay.charSkills.Count == 0) {
                editingDisplay.charSkills.Add(new CharSkillsData());
            }*/
            for (int i = 0; i < editingDisplay.charSkills.Count; i++) {
                int selectedSkill = GetPositionOfSkill(editingDisplay.charSkills[i].skill);
                selectedSkill = ImagePack.DrawSelector (pos, "Skill " + (i+1) + ":", selectedSkill, skillsList);
                editingDisplay.charSkills[i].skill = skillIds[selectedSkill];
                pos.x += pos.width;
                if (ImagePack.DrawButton (pos.x, pos.y, "Delete Skill")) {
                    if (editingDisplay.charSkills[i].id > 0)
                        editingDisplay.skillsToBeDeleted.Add(editingDisplay.charSkills[i].id);
                    editingDisplay.charSkills.RemoveAt(i);
                }
                pos.x -= pos.width;
                pos.y += ImagePack.fieldHeight;

            }
            if (ImagePack.DrawButton (pos.x, pos.y, "Add Skill")) {
                editingDisplay.charSkills.Add(new CharSkillsData());
            }

            pos.y += 1.5f*ImagePack.fieldHeight;
            ImagePack.DrawLabel (pos.x, pos.y, "Starting Items");
            pos.y += 1.5f*ImagePack.fieldHeight;

            /*if (editingDisplay.charItems.Count == 0) {
                editingDisplay.charItems.Add(new CharItemsData());
            }*/
            for (int i = 0; i < editingDisplay.charItems.Count; i++) {
                int selectedItem = GetPositionOfItem(editingDisplay.charItems[i].itemId);
                selectedItem = ImagePack.DrawSelector (pos, "Item " + (i+1) + ":", selectedItem, itemsList);
                editingDisplay.charItems[i].itemId = itemIds[selectedItem];
                pos.x += pos.width;
                editingDisplay.charItems[i].count = ImagePack.DrawField (pos, "Count:", editingDisplay.charItems[i].count);
                pos.x -= pos.width;
                pos.y += ImagePack.fieldHeight;
                editingDisplay.charItems[i].equipped = ImagePack.DrawToggleBox(pos, "Equipped", editingDisplay.charItems[i].equipped);
                pos.x += pos.width;
                if (ImagePack.DrawButton (pos.x, pos.y, "Delete Item")) {
                    if (editingDisplay.charItems[i].id > 0)
                        editingDisplay.itemsToBeDeleted.Add(editingDisplay.charItems[i].id);
                    editingDisplay.charItems.RemoveAt(i);
                }
                pos.x -= pos.width;
                pos.y += ImagePack.fieldHeight;
            }
            if (ImagePack.DrawButton (pos.x, pos.y, "Add Item")) {
                editingDisplay.charItems.Add(new CharItemsData());
            }

            pos.width *= 2;
            pos.x += ImagePack.innerMargin;
        }

        pos.y += 2.5f * ImagePack.fieldHeight;
        // Save data
        pos.x -= ImagePack.innerMargin;
        pos.width /= 3;
        if (ImagePack.DrawButton (pos.x, pos.y, "Save Data")) {
            if (newItem)
                InsertEntry ();
            else
                UpdateEntry ();

            state = State.Loaded;
        }

        // Delete data
        if (!newItem) {
            pos.x += pos.width;
            if (ImagePack.DrawButton (pos.x, pos.y, "Delete Data")) {
                DeleteEntry ();
                newSelectedDisplay = 0;
                state = State.Loaded;
            }
        }

        // Cancel editing
        pos.x += pos.width;
        if (ImagePack.DrawButton (pos.x, pos.y, "Cancel")) {
            editingDisplay = originalDisplay.Clone ();
            if (newItem)
                state = State.New;
            else
                state = State.Loaded;
        }

        if (resultTimeout != -1 && resultTimeout > Time.realtimeSinceStartup) {
            pos.x += pos.width;
            pos.y += ImagePack.fieldHeight;
            ImagePack.DrawText(pos, result);
        }

        if (!newItem)
            EnableScrollBar(pos.y - box.y + ImagePack.fieldHeight + 28);
        else
            EnableScrollBar(pos.y - box.y + ImagePack.fieldHeight);
    }
示例#11
0
    // Load Stats
    public void LoadCharacterStats(CharData charData)
    {
        List<CharStatsData> charStats = new List<CharStatsData>();
        // Read all entries from the table
        string query = "SELECT * FROM character_create_stats where character_create_id = " + charData.id;

        // If there is a row, clear it.
        if (rows != null)
            rows.Clear ();

        // Load data
        rows = DatabasePack.LoadData (DatabasePack.contentDatabasePrefix, query);
        // Read all the data
        if ((rows!=null) && (rows.Count > 0)) {
            foreach (Dictionary<string,string> data in rows) {
                CharStatsData display = new CharStatsData ();
                display.id = int.Parse (data ["id"]);
                display.charId = int.Parse (data ["character_create_id"]);
                display.stat = data ["stat"];
                display.statValue = int.Parse (data ["value"]);
                display.levelIncrease = float.Parse (data ["levelIncrease"]);
                display.levelPercentIncrease = float.Parse (data ["levelPercentIncrease"]);
                charStats.Add(display);
            }
        }
        // Check for any stats the template may not have
        foreach (string stat in statsList) {
            bool statExists = false;
            foreach (CharStatsData charStat in charStats) {
                if (stat == charStat.stat) {
                    statExists = true;
                }
            }

            if (!statExists) {
                CharStatsData statData = new CharStatsData();
                statData.stat = stat;
                statData.statValue = 0;
                charStats.Add(statData);
            }
        }
        charData.charStats = charStats;
    }
示例#12
0
    // Load Stats
    public void LoadCharacterSkills(CharData charData)
    {
        List<CharSkillsData> charSkills = new List<CharSkillsData>();
        // Read all entries from the table
        string query = "SELECT * FROM character_create_skills WHERE character_create_id = " + charData.id;

        // If there is a row, clear it.
        if (rows != null)
            rows.Clear ();

        // Load data
        rows = DatabasePack.LoadData (DatabasePack.contentDatabasePrefix, query);
        // Read all the data
        if ((rows!=null) && (rows.Count > 0)) {
            foreach (Dictionary<string,string> data in rows) {
                CharSkillsData display = new CharSkillsData ();
                display.id = int.Parse (data ["id"]);
                display.charId = int.Parse (data ["character_create_id"]);
                display.skill = int.Parse (data ["skill"]);
                charSkills.Add(display);
            }
        }
        charData.charSkills = charSkills;
    }
示例#13
0
    // Load Database Data
    public override void Load()
    {
        if (!dataLoaded) {
            // Clean old data
            dataRegister.Clear ();
            displayKeys.Clear ();

            // Read all entries from the table
            string query = "SELECT * FROM " + tableName;

            // If there is a row, clear it.
            if (rows != null)
                rows.Clear ();

            // Load data
            rows = DatabasePack.LoadData (DatabasePack.contentDatabasePrefix, query);
            //Debug.Log("#Rows:"+rows.Count);
            // Read all the data
            if ((rows!=null) && (rows.Count > 0)) {
                foreach (Dictionary<string,string> data in rows) {
                    //foreach(string key in data.Keys)
                    //	Debug.Log("Name[" + key + "]:" + data[key]);
                    //return;
                    CharData display = new CharData ();
                    display.id = int.Parse (data ["id"]);
                    display.race = data ["race"];
                    display.aspect = data ["aspect"];
                    display.faction = int.Parse(data["faction"]);
                    display.instanceName = data ["instanceName"];
                    display.pos_x = float.Parse (data ["pos_x"]);
                    display.pos_y = float.Parse (data ["pos_y"]);
                    display.pos_z = float.Parse (data ["pos_z"]);
                    display.orientation = float.Parse (data ["orientation"]);
                    display.autoAttack = int.Parse(data["autoAttack"]);

                    display.isLoaded = true;
                    //Debug.Log("Name:" + display.name  + "=[" +  display.id  + "]");
                    dataRegister.Add (display.id, display);
                    displayKeys.Add (display.id);
                }
                LoadSelectList ();
            }
            dataLoaded = true;
        }

        // Load character starting stats, skills and items
        foreach(CharData charData in dataRegister.Values) {
            LoadCharacterStats(charData);
            LoadCharacterSkills(charData);
            LoadCharacterItems(charData);
        }
    }
示例#14
0
    // Draw the loaded list
    public override void DrawLoaded(Rect box)
    {
        // Setup the layout
        Rect pos = box;
        pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        pos.height = ImagePack.fieldHeight;

        if (dataRegister.Count <= 0) {
            pos.y += ImagePack.fieldHeight;
            ImagePack.DrawLabel (pos.x, pos.y, "You must create an Character before edit it.");
            return;
        }

        // Draw the content database info
        ImagePack.DrawLabel (pos.x, pos.y, "Character Configuration");

        if (newItemCreated) {
            newItemCreated = false;
            LoadSelectList ();
            newSelectedDisplay = displayKeys.Count - 1;
        }

        // Draw data Editor
        if (newSelectedDisplay != selectedDisplay) {
            selectedDisplay = newSelectedDisplay;
            int displayKey = displayKeys [selectedDisplay];
            editingDisplay = dataRegister [displayKey];

            originalDisplay = editingDisplay.Clone ();
            //LoadOptions (displayKey);
        }

        //if (!displayList.showList) {
        pos.y += ImagePack.fieldHeight;
        pos.x -= ImagePack.innerMargin;
        pos.y -= ImagePack.innerMargin;
        pos.width += ImagePack.innerMargin;
        DrawEditor (pos, false);
        pos.y -= ImagePack.fieldHeight;
        //pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        //}

        if (state != State.Loaded) {
            // Draw combobox
            pos.width /= 2;
            pos.x += pos.width;
            newSelectedDisplay = ImagePack.DrawCombobox (pos, "", selectedDisplay, displayList);
            pos.x -= pos.width;
            pos.width *= 2;
        }
    }
示例#15
0
 private void loadBasic(CharData d)
 {
     gameObject.name = d.name;
     gameObject.name = getProperName();
 }
示例#16
0
 public override void onItemSave(CharData d)
 {
     d.SetInt("TimesUsed", timesUsed);
     d.SetInt("MaxUses", MaxUses);
 }
示例#17
0
 private void loadData(CharData d)
 {
     TriggerUsed   = d.PersistentBools ["TriggerUsed"];
     TextboxString = d.PersistentStrings ["TextboxString"];
 }
示例#18
0
 public override void onItemLoad(CharData d)
 {
     timesUsed = d.GetInt("TimesUsed");
     //MaxUses = d.GetInt("MaxUses");
 }
示例#19
0
 private void storeData(CharData d)
 {
     d.SetBool("IsPlayerControl", IsPlayerControl);
     d.SetBool("CanJump", CanJump);
     d.SetInt("MidAirJumps", MidAirJumps);
 }
示例#20
0
 /// <summary>
 /// Gets a character's alignment string.
 /// </summary>
 /// <param name="ch"></param>
 /// <returns></returns>
 public static string AlignmentString(CharData ch)
 {
     return(AlignmentString(ch.Alignment));
 }
示例#21
0
 private void loadData(CharData d)
 {
     SetDirection((Direction)d.GetInt("Direction"));
     FacingLeft = d.GetBool("FacingLeft");
 }
示例#22
0
    private void SetTextPerCharacter(Stats charStats, CharData charData)
    {
        // General Information
        charNameData[0].SetText(charData.name);
        charNameData[1].SetText("Lv " + charStats.level.ToString());
        charPortrait.color  = Color.white;
        charPortrait.sprite = charData.normalPortrait;


        // Level Information
        int num = 0;

        for (int i = 0; i < charStats.level - 1; ++i)
        {
            num += charStats.nextLevelExp[i];
        }
        expString[0].SetText("EXP: " + (num + charStats.exp).ToString());
        if (charStats.level < charStats.nextLevelExp.Count + 1)
        {
            expBar.fillAmount = (float)charStats.exp / charStats.nextLevelExp[charStats.level - 1];
            expString[1].SetText((charStats.nextLevelExp[charStats.level - 1] - charStats.exp).ToString());
        }
        else
        {
            expBar.fillAmount = 1;
            expString[1].SetText("--");
        }


        // Stats Information
        statsString[0].SetText(charStats.MaxHP().ToString());
        statsString[1].SetText(charStats.MaxTP().ToString());
        statsString[2].SetText(charStats.Attack().ToString());
        statsString[3].SetText(charStats.Defense().ToString());
        statsString[4].SetText(charStats.Speed().ToString());

        // Added Stats Information
        SetButtonData(0, charStats.maxHP, 0, charStats.HPPassives);
        SetButtonData(2, charStats.maxTP, 0, charStats.TPPassives);
        SetButtonData(4, charStats.atk, charStats.atkBonus, charStats.atkPassives);
        SetButtonData(6, charStats.def, charStats.defBonus, charStats.defPassives);
        SetButtonData(8, charStats.spd, 0, charStats.spdPassives);

        // Abilities Information
        int a = 0;

        abilitiesButtons[a].gameObject.SetActive(true);
        SetAbilityButtonData(a, 0, charData);
        a++;
        for (int i = 0; i < charData.learnedAbilities.Count; ++i)
        {
            if (charData.learnedAbilities[i])
            {
                if (i == 0)
                {
                    a = 0;
                }
                abilitiesButtons[a].gameObject.SetActive(true);
                SetAbilityButtonData(a, i, charData);
                a++;
            }
        }
    }
示例#23
0
 private void loadData(CharData d)
 {
     TriggerUsed   = d.GetBool("TriggerUsed");
     TextboxString = d.GetString("TextboxString");
 }
示例#24
0
    private void storeData(CharData d)
    {
        string s = convertToSaveList(items);

        d.SetString("initItemData", s);
    }
示例#25
0
 bool NotGuard(CharData chara)
 {
     return(chara.guardCount == 0);
 }
示例#26
0
 /// <summary>
 /// 增加空节点(4个)
 /// </summary>
 /// <param name="res">节点数组</param>
 /// <param name="cd">字符数据</param>
 static void addEmptyVertices(List <UIVertex> res, CharData cd)
 {
     res.Add(cd.verts[2]); res.Add(cd.verts[2]);
     res.Add(cd.verts[2]); res.Add(cd.verts[2]);
 }
示例#27
0
 public bool CheckCharIsAlive(CharData chara)
 {
     return(!chara.isDie);
 }
示例#28
0
 // Start is called before the first frame update
 void Start()
 {
     defaultY = transform.localPosition.y;
     data     = GetComponent <CharData>();
 }
示例#29
0
 private void loadData(CharData d)
 {
     MaxHealth = d.GetFloat("MaxHealth");
     Health    = d.GetFloat("Health");
     Faction   = (FactionType)d.GetInt("Faction");
 }
示例#30
0
 public void SetInfo(CharData a_data)
 {
     if (a_data.type != this.m_type)
     {
         this.m_type = a_data.type;
         this.Spawn(this.m_id, this.m_type, this.m_isOwnPlayer);
         this.m_handItem = -1;
         this.m_look     = -1;
         this.m_skin     = -1;
         this.m_body     = -1;
     }
     if (null != this.m_animControl)
     {
         if (this.m_handItem != a_data.handItem)
         {
             this.m_animControl.ChangeHandItem(a_data.handItem);
             this.m_handItem = a_data.handItem;
         }
         if (this.m_look != a_data.look)
         {
             this.m_animControl.ChangeHeadItem(a_data.look);
             this.m_look = a_data.look;
         }
         if (this.m_skin != a_data.skin)
         {
             this.m_animControl.ChangeSkin(a_data.skin);
             this.m_skin = a_data.skin;
         }
         if (this.m_body != a_data.body)
         {
             this.m_animControl.ChangeBodyItem(a_data.body);
             this.m_body = a_data.body;
         }
     }
     if (this.m_lastRank != a_data.rank)
     {
         if (this.m_lastRank == -1)
         {
             if (this.m_isOwnPlayer && Global.isSteamActive)
             {
                 bool flag  = false;
                 bool flag2 = true;
                 int  num   = Mathf.Min(10, a_data.rank);
                 for (int i = 1; i <= num; i++)
                 {
                     if (SteamUserStats.GetAchievement("ACH_IMM_RANK_" + i, out flag2) && !flag2)
                     {
                         SteamUserStats.SetAchievement("ACH_IMM_RANK_" + i);
                         flag = true;
                     }
                 }
                 if (flag)
                 {
                     SteamUserStats.StoreStats();
                 }
             }
         }
         else if (a_data.rank > this.m_lastRank && a_data.rank < 11)
         {
             UnityEngine.Object.Instantiate(this.m_lvlUpEffect, base.transform.position + Vector3.up * 3.5f, Quaternion.identity);
             if (this.m_isOwnPlayer && Global.isSteamActive)
             {
                 SteamUserStats.SetAchievement("ACH_IMM_RANK_" + Mathf.Clamp(a_data.rank, 1, 10));
                 SteamUserStats.StoreStats();
                 PlayerPrefs.SetInt("prefHints", 0);
             }
             Debug.Log(string.Concat(new object[]
             {
                 base.name,
                 " m_lastRank ",
                 this.m_lastRank,
                 " a_data.rank ",
                 a_data.rank,
                 " level up"
             }));
         }
         this.m_lastRank = a_data.rank;
     }
     this.SetName(a_data.rank, a_data.karma, a_data.name);
 }
示例#31
0
 public void UpdateFromString(string serializedData)
 {
     data = JsonUtility.FromJson <CharData>(serializedData);
     LoadData();
 }
        public virtual void ReadCharacters()
        {
            ArrayList temp = new ArrayList();

            while (Position + 184 < Length)
            {
                CharData charData = new CharData();

                charData.charName = ReadString(24);
                Skip(11); // ?
                ArrayList tmp = new ArrayList(13);
                for (byte j=0; j<13; j++)
                    tmp.Add(ReadByte());
                charData.unk3 = (byte[])tmp.ToArray(typeof (byte));
                charData.zoneDescription = ReadString(24);
                charData.className = ReadString(24);
                charData.raceName = ReadString(24);
                charData.level = ReadByte();
                charData.classID = ReadByte();
                charData.realm = ReadByte();
                charData.temp = ReadByte();
                charData.gender = (byte)((charData.temp >> 4) & 3);
                charData.race = (byte)((charData.temp & 0x0F) + ((charData.temp & 0x40) >> 2));
                charData.siStartLocation = (byte)(charData.temp >> 7);
                charData.model = ReadShortLowEndian();
                charData.regionID = ReadByte();
                charData.regionID2 = ReadByte();
                charData.databaseId = ReadIntLowEndian();
                charData.statStr = ReadByte();
                charData.statDex = ReadByte();
                charData.statCon = ReadByte();
                charData.statQui = ReadByte();
                charData.statInt = ReadByte();
                charData.statPie = ReadByte();
                charData.statEmp = ReadByte();
                charData.statChr = ReadByte();

                charData.armorModelBySlot = new SortedList(0x1D-0x15);
                for (int slot = 0x15; slot < 0x1D; slot++)
                {
                    charData.armorModelBySlot.Add(slot, ReadShortLowEndian());
                }

                charData.armorColorBySlot = new SortedList(0x1D-0x15);
                for (int slot = 0x15; slot < 0x1D; slot++)
                {
                    charData.armorColorBySlot.Add(slot, ReadShortLowEndian());
                }

                charData.weaponModelBySlot = new SortedList(0x0E-0x0A);
                for (int slot = 0x0A; slot < 0x0E; slot++)
                {
                    charData.weaponModelBySlot.Add(slot, ReadShortLowEndian());
                }

                charData.activeRightSlot = ReadByte();
                charData.activeLeftSlot = ReadByte();
                charData.siZone = ReadByte();
                charData.unk2 = ReadByte();

                temp.Add(charData);
            }

            chars = (CharData[])temp.ToArray(typeof (CharData));
        }
示例#33
0
 private void storeData(CharData d)
 {
     d.PersistentBools["TriggerUsed"]      = TriggerUsed;
     d.PersistentStrings ["TextboxString"] = TextboxString;
 }
示例#34
0
 public virtual void OnSave(CharData d)
 {
     d.PersistentBools[PropertyName + "_timed"]     = Timed;
     d.PersistentFloats[PropertyName + "_duration"] = Duration;
 }
示例#35
0
        /// <summary>
        /// Create an instance of a mobile from the provided template.
        /// </summary>
        /// <param name="mobTemplate"></param>
        /// <returns></returns>
        public static CharData CreateMobile(MobTemplate mobTemplate)
        {
            int count;

            if (!mobTemplate)
            {
                Log.Error("CreateMobile: null MobTemplate.", 0);
                throw new NullReferenceException();
            }

            CharData mob = new CharData();

            mob.MobileTemplate       = mobTemplate;
            mob.Followers            = null;
            mob.Name                 = mobTemplate.PlayerName;
            mob.ShortDescription     = mobTemplate.ShortDescription;
            mob.FullDescription      = mobTemplate.FullDescription;
            mob.Description          = mobTemplate.Description;
            mob.SpecialFunction      = mobTemplate.SpecFun;
            mob.SpecialFunctionNames = mobTemplate.SpecFunNames;
            mob.CharacterClass       = mobTemplate.CharacterClass;
            mob.Level                = MUDMath.FuzzyNumber(mobTemplate.Level);
            mob.ActionFlags          = mobTemplate.ActionFlags;
            mob.CurrentPosition      = mobTemplate.DefaultPosition;
            mob.ChatterBotName       = mobTemplate.ChatterBotName;
            // TODO: Look up the chatter bot name and load a runtime bot into the variable.
            mob.ChatBot = null;
            for (count = 0; count < Limits.NUM_AFFECT_VECTORS; ++count)
            {
                mob.AffectedBy[count] = mobTemplate.AffectedBy[count];
            }
            mob.Alignment = mobTemplate.Alignment;
            mob.Gender    = mobTemplate.Gender;
            mob.SetPermRace(mobTemplate.Race);
            mob.CurrentSize = Race.RaceList[mob.GetRace()].DefaultSize;
            if (mob.HasActionBit(MobTemplate.ACT_SIZEMINUS))
            {
                mob.CurrentSize--;
            }
            if (mob.HasActionBit(MobTemplate.ACT_SIZEPLUS))
            {
                mob.CurrentSize++;
            }

            mob.CastingSpell         = 0;
            mob.CastingTime          = 0;
            mob.PermStrength         = MUDMath.Dice(2, 46) + 8;
            mob.PermIntelligence     = MUDMath.Dice(2, 46) + 8;
            mob.PermWisdom           = MUDMath.Dice(2, 46) + 8;
            mob.PermDexterity        = MUDMath.Dice(2, 46) + 8;
            mob.PermConstitution     = MUDMath.Dice(2, 46) + 7;
            mob.PermAgility          = MUDMath.Dice(2, 46) + 8;
            mob.PermCharisma         = MUDMath.Dice(2, 46) + 8;
            mob.PermPower            = MUDMath.Dice(2, 46) + 8;
            mob.PermLuck             = MUDMath.Dice(2, 46) + 8;
            mob.ModifiedStrength     = 0;
            mob.ModifiedIntelligence = 0;
            mob.ModifiedWisdom       = 0;
            mob.ModifiedDexterity    = 0;
            mob.ModifiedConstitution = 0;
            mob.ModifiedAgility      = 0;
            mob.ModifiedCharisma     = 0;
            mob.ModifiedPower        = 0;
            mob.ModifiedLuck         = 0;
            mob.Resistant            = mobTemplate.Resistant;
            mob.Immune      = mobTemplate.Immune;
            mob.Susceptible = mobTemplate.Susceptible;
            mob.Vulnerable  = mobTemplate.Vulnerable;
            mob.MaxMana     = mob.Level * 10;
            if (Race.RaceList[mobTemplate.Race].Coins)
            {
                int level = mobTemplate.Level;
                mob.ReceiveCopper(MUDMath.Dice(12, level) / 32);
                mob.ReceiveSilver(MUDMath.Dice(9, level) / 32);
                mob.ReceiveGold(MUDMath.Dice(5, level) / 32);
                mob.ReceivePlatinum(MUDMath.Dice(2, level) / 32);
            }
            else
            {
                mob.SetCoins(0, 0, 0, 0);
            }
            mob.ArmorPoints = MUDMath.Interpolate(mob.Level, 100, -100);

            // * MOB HITPOINTS *
            //
            // Was level d 8, upped it to level d 13
            // considering mobs *still* won't have as many hitpoints as some players until
            // at least level 10, this shouldn't be too big an upgrade.
            //
            // Mob hitpoints are not based on constitution *unless* they have a
            // constitution modifier from an item, spell, or other affect

            // In light of recent player dissatisfaction with the
            // mob hitpoints, I'm implementing a log curve, using
            //  hp = exp( 2.15135 + level*0.151231)
            // This will will result in the following hp matrix:
            //     Level    Hitpoints
            //      20        175
            //      30        803
            //      40        3643
            //      50        16528
            //      55        35207
            //      60        75000
            mob.MaxHitpoints = MUDMath.Dice(mob.Level, 13) + 1;
            // Mob hps are non-linear above level 10.
            if (mob.Level > 20)
            {
                int upper = (int)Math.Exp(1.85 + mob.Level * 0.151231);
                int lower = (int)Math.Exp(1.80 + mob.Level * 0.151231);
                mob.MaxHitpoints += MUDMath.NumberRange(lower, upper);
            }
            else if (mob.Level > 10)
            {
                mob.MaxHitpoints += MUDMath.NumberRange(mob.Level * 2, ((mob.Level - 8) ^ 2 * mob.Level) / 2);
            }

            // Demons/devils/dragons gain an extra 30 hitpoints per level (+1500 at lvl 50).
            if (mob.GetRace() == Race.RACE_DEMON || mob.GetRace() == Race.RACE_DEVIL || mob.GetRace() == Race.RACE_DRAGON)
            {
                mob.MaxHitpoints += (mob.Level * 30);
            }

            mob.Hitpoints = mob.GetMaxHit();

            // Horses get more moves, necessary for mounts.
            if (Race.RaceList[mob.GetRace()].Name.Equals("Horse", StringComparison.CurrentCultureIgnoreCase))
            {
                mob.MaxMoves     = 290 + MUDMath.Dice(4, 5);
                mob.CurrentMoves = mob.MaxMoves;
            }
            mob.LoadRoomIndexNumber = 0;

            // Insert in list.
            CharList.Add(mob);
            // Increment count of in-game instances of mob.
            mobTemplate.NumActive++;
            return(mob);
        }
示例#36
0
 public virtual void OnLoad(CharData d)
 {
     Timed    = d.PersistentBools[PropertyName + "_timed"];
     Duration = d.PersistentFloats[PropertyName + "_duration"];
 }
示例#37
0
        /// <summary>
        /// Fills a coin structure based on some input text.  Valid inputs include:
        /// 3 platinum
        /// all.coins
        /// 1 p
        /// 2 p 3 copper all.gold
        /// all.silver
        /// all.g
        /// a
        /// </summary>
        /// <param name="str"></param>
        /// <param name="ch"></param>
        /// <returns></returns>
        public bool FillFromString(string[] str, CharData ch)
        {
            Copper   = 0;
            Silver   = 0;
            Gold     = 0;
            Platinum = 0;

            if (ch == null || str.Length < 1 || String.IsNullOrEmpty(str[0]))
            {
                return(false);
            }

            int currentNumber = 0;

            for (int i = 0; i < str.Length; i++)
            {
                if ("all.coins".StartsWith(str[i]))
                {
                    Copper   = ch.GetCopper();
                    Silver   = ch.GetSilver();
                    Gold     = ch.GetGold();
                    Platinum = ch.GetPlatinum();
                    return(true);
                }
                else if ("all.copper".StartsWith(str[i]))
                {
                    Copper = ch.GetCopper();
                }
                else if ("all.silver".StartsWith(str[i]))
                {
                    Silver = ch.GetSilver();
                }
                else if ("all.gold".StartsWith(str[i]))
                {
                    Gold = ch.GetGold();
                }
                else if ("all.platinum".StartsWith(str[i]))
                {
                    Platinum = ch.GetPlatinum();
                }
                else if ("copper".StartsWith(str[i]))
                {
                    Copper = currentNumber;
                }
                else if ("silver".StartsWith(str[i]))
                {
                    Silver = currentNumber;
                }
                else if ("gold".StartsWith(str[i]))
                {
                    Gold = currentNumber;
                }
                else if ("platinum".StartsWith(str[i]))
                {
                    Platinum = currentNumber;
                }
                // Treat it as a number.
                else
                {
                    Int32.TryParse(str[i], out currentNumber);
                }
            }
            if (Copper > 0 || Silver > 0 || Gold > 0 || Platinum > 0)
            {
                return(true);
            }
            return(false);
        }
示例#38
0
 private void storeData(CharData d)
 {
     d.SetInt("Direction", (int)CurrentDirection);
     d.SetBool("FacingLeft", FacingLeft);
 }
示例#39
0
 private void loadData(CharData d)
 {
     IsPlayerControl = d.GetBool("IsPlayerControl");
     CanJump         = d.GetBool("CanJump");
     MidAirJumps     = d.GetInt("MidAirJumps");
 }
示例#40
0
        /// <summary>
        /// Try to get the CharData needed to draw the character 'c'.
        /// </summary>
        public bool TryGetCharData( char c, out CharData cdata )
        {
            {
                int index = (int)c-(int)' ';
                if ( index >= 0 && index < AsciiCharSet.Length )
                {
                    cdata = m_ascii_char_data[index];
                    return m_ascii_char_data_valid[index];
                }
            }

            if ( !CharSet.TryGetValue( c, out cdata ) )
            {
                System.Console.WriteLine( "The character [" + c + "] is not present in the FontMap you are trying to use. Please double check the input character set." );
                return false;
            }

            return true;
        }