Esempio n. 1
0
    public void SetCharacterToDisplay(CharacterId character)
    {
        _currentCharacter = character;
        Debug.Log($"Displaying character info for {_currentCharacter.ToString()}");

        DisplayPortrait();
    }
Esempio n. 2
0
        public override void DumpBody(XmlWriter writer)
        {
            writer.WriteAttributeString("id", CharacterId.ToString());

            if (!string.IsNullOrEmpty(Name))
            {
                writer.WriteAttributeString("name", Name);
            }
        }
Esempio n. 3
0
    /// <summary>
    /// Updates the character data of given name with parameters.
    /// </summary>
    /// <param name="name">Name.</param>
    /// <param name="experience">Experience.</param>
    /// <param name="curHealth">Current health.</param>
    /// <param name="curEnergy">Current energy.</param>
    public static void UpdateCharacterData(CharacterId name, int experience, int curHealth, int curEnergy)
    {
//        if (((int)name) < m_savedCharacterData.Length)
        CharacterSaveData character;

        if (GetCharacterSavedData(name, out character))
        {
            Debug.LogError(string.Format("Could not find character with name {0}", name.ToString()));
            return;
        }

        character.m_experience = experience;
        character.m_curHealth  = curHealth;
        character.m_curEnergy  = curEnergy;
    }
Esempio n. 4
0
    /// <summary>
    /// Gets the character saved data.
    /// </summary>
    /// <returns>The character saved data.</returns>
    /// <param name="name">Name of the character.</param>
    public static bool GetCharacterSavedData(CharacterId name, out CharacterSaveData data)
    {
        data = null;
        if (LoadedSaveFile == null)
        {
            Debug.Log("No loaded save file.");
            return(false);
        }

        for (int i = 0; i < LoadedSaveFile.m_savedCharacterData.Length; i++)
        {
            CharacterSaveData character = LoadedSaveFile.m_savedCharacterData[i];
            if (character.m_id == name)
            {
                data = character;
                return(true);
            }
        }

        Debug.LogError(string.Format("Could not find character with name {0}", name.ToString()));
        return(false);
    }
Esempio n. 5
0
            private void DrawIconOfCharacterOfSpawner()
            {
                if (textureByMonsterId == null)
                {
                    textureByMonsterId = new Dictionary <string, Texture>();
                }

                CharacterId characterId = new CharacterId(monsterId);
                Texture     icon        = null;
                bool        found       = textureByMonsterId.TryGetValue(characterId.ToString(), out icon);

                if (!found)
                {
                    string pathToIcon = string.Format(Config.characterIconPathFormat, characterId.GroupId,
                                                      characterId.SubId);
                    icon = EditorGUIUtility.Load(pathToIcon) as Texture;
                    textureByMonsterId[characterId.StringValue] = icon;
                }

                if (icon != null)
                {
                    EditorGUILayout.LabelField("", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false),
                                               GUILayout.Height(89), GUILayout.Width(89));
                    Rect     lastRect = GUILayoutUtility.GetLastRect();
                    GUIStyle gs       = new GUIStyle(EditorStyles.label);
                    gs.normal.background = Texture2D.grayTexture;
                    Rect positionOfBackground = new Rect(lastRect.position - new Vector2(34, 0), lastRect.size);
                    EditorGUI.LabelField(positionOfBackground, "", gs);
                    EditorGUI.LabelField(positionOfBackground, "", gs);
                    EditorGUI.LabelField(positionOfBackground, "", gs);

                    if (materialForIcon == null)
                    {
                        materialForIcon = new Material(Shader.Find("Sprites/Default"));
                    }
                    EditorGUI.DrawPreviewTexture(lastRect, icon, materialForIcon);
                }
            }
Esempio n. 6
0
            public void OnDrawGizmos(bool isChallengeSelected)
            {
                if (frustumHeightByMonsterId == null)
                {
                    frustumHeightByMonsterId          = new Dictionary <string, float>();
                    frustumHeightByMonsterId["1100"]  = 3;
                    frustumHeightByMonsterId["4003"]  = 3;
                    frustumHeightByMonsterId["4004"]  = 2;
                    frustumHeightByMonsterId["4005"]  = 2;
                    frustumHeightByMonsterId["4006"]  = 2;
                    frustumHeightByMonsterId["4007"]  = 1;
                    frustumHeightByMonsterId["40010"] = 4;
                }

                if (textureByMonsterId == null)
                {
                    textureByMonsterId = new Dictionary <string, Texture>();
                }


                CharacterId characterId;

                try
                {
                    characterId = new CharacterId(monsterId);
                }
                catch (Exception e)
                {
                    DLog.LogError(e);
                    characterId = new CharacterId(1, 1);
                }

                Texture icon;
                bool    found = textureByMonsterId.TryGetValue(characterId.ToString(), out icon);

                if (!found)
                {
                    string pathToIcon = string.Format(Config.characterIconPathFormat, characterId.GroupId, characterId.SubId);
                    icon = EditorGUIUtility.Load(pathToIcon) as Texture;
                    textureByMonsterId[characterId.StringValue] = icon;
                }

//				Gizmos.DrawIcon((Vector3) ShowWorldPosition() + Vector3.up * 3.25f, pathToIcon, true);
                if (icon)
                {
                    Gizmos.DrawGUITexture(
                        new Rect(ShowWorldPosition() + new Vector3(-3.25f, 6), new Vector2(6, -6)),
                        icon
                        );
                }

                float height    = 4;
                float newHeight = height;

                if (frustumHeightByMonsterId.TryGetValue(characterId.GroupId.ToString(), out newHeight))
                {
                    height = newHeight;
                }

                Gizmos.color = Color.red;
                Matrix4x4 originalMatrix    = Gizmos.matrix;
                Matrix4x4 rotationMatrix    = Matrix4x4.Rotate(Quaternion.LookRotation(Vector3.up, Vector3.up));
                Matrix4x4 translationMatrix = Matrix4x4.Translate(ShowWorldPosition() + Vector3.up * height);

                Gizmos.matrix = Matrix4x4.identity * translationMatrix * rotationMatrix;
                Gizmos.DrawFrustum(Vector3.zero, 45, 1, 0, 1);
                Gizmos.matrix = originalMatrix;

                if (!isChallengeSelected)
                {
                    return;
                }

                Gizmos.color = Color.green;
                Vector2           rectDimension = new Vector2(xAxisAmplitude, .5f);
                RectPivotPosition rpp           = new RectPivotPosition(RectPivotPosition.PivotType.Center, Vector2.zero, rectDimension);
                Vector2           offset        = rpp.RelativePositionOfPivotAt(RectPivotPosition.PivotType.BottomLeft);

                Gizmos.DrawCube(
                    ShowWorldPosition() + new Vector3(offset.x * -1, offset.y),
                    rectDimension
                    );
            }
Esempio n. 7
0
    private void DisplayPortrait()
    {
        string imageName = $"FullPortrait{_currentCharacter.ToString()}";

        Portrait.GetComponent <Image>().sprite = Resources.Load <Sprite>($"TeamManageScene/{imageName}");
    }
Esempio n. 8
0
            private void DrawIconOfCharacterOfSpawner()
            {
                if (Spawn.ShowCacheOfTextureByMonsterId() == null)
                {
                    return;
                }

                if (onGuiCount % 13 == 0)
                {
                    onGuiCount = 0;

                    if (!string.IsNullOrEmpty(path))
                    {
                        resourceRequest = Resources.LoadAsync <ChallengePresetAsset>(path);
                    }
                }

                if (resourceRequest != null)
                {
                    if (resourceRequest.isDone)
                    {
                        if (resourceRequest.asset == null)
                        {
                            resourceRequest = null;
                            return;
                        }
                        ChallengePresetAsset challengePresetAsset = (ChallengePresetAsset)resourceRequest.asset;
                        Challenge            challenge            = challengePresetAsset.DeserializeToObject();
                        CharacterId          characterId          = new CharacterId(challenge.spawn.monsterId);
                        bool found = Spawn.ShowCacheOfTextureByMonsterId().TryGetValue(characterId.ToString(), out icon);
                        if (!found)
                        {
                            string pathToIcon = string.Format(Config.characterIconPathFormat, characterId.GroupId,
                                                              characterId.SubId);
                            icon = EditorGUIUtility.Load(pathToIcon) as Texture;
                            Spawn.ShowCacheOfTextureByMonsterId()[characterId.StringValue] = icon;
                        }
                        resourceRequest = null;
                    }
                }

                if (icon != null)
                {
                    /*EditorGUILayout.LabelField("", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false),
                     *      GUILayout.Height(89), GUILayout.Width(89));*/
                    Rect     lastRect    = GUILayoutUtility.GetLastRect();
                    Rect     rectForIcon = new Rect(lastRect.position + new Vector2(lastRect.width, 0), new Vector2(89, 89));
                    GUIStyle gs          = new GUIStyle(EditorStyles.label);
                    gs.normal.background = Texture2D.grayTexture;
                    Rect positionOfBackground = new Rect(rectForIcon.position - new Vector2(34, 0), rectForIcon.size);
                    EditorGUI.LabelField(positionOfBackground, "", gs);
                    EditorGUI.LabelField(positionOfBackground, "", gs);
                    EditorGUI.LabelField(positionOfBackground, "", gs);

                    if (materialForIcon == null)
                    {
                        materialForIcon = new Material(Shader.Find("Sprites/Default"));
                    }
                    EditorGUI.DrawPreviewTexture(rectForIcon, icon, materialForIcon);
                }
            }
Esempio n. 9
0
 /// <summary>
 /// Serializes the specified writer.
 /// </summary>
 /// <param name="writer">Writer.</param>
 public override void Serialize(XmlWriter writer)
 {
     writer.WriteAttributeString("CharacterId", CharacterId.ToString());
     this.rect.Serialize(writer);
     this.shape.Serialize(writer);
 }