예제 #1
0
    public CharacterDescription GetCharacterDescription(PawnType type, string name)
    {
        CharacterDescription data = new CharacterDescription();

        string     xpath = "";
        XmlElement node  = null;

        if (type == PawnType.Monster)
        {
            xpath = "/character/monster//" + name;
            node  = (XmlElement)xmlDocDescription.SelectSingleNode(xpath);
        }
        else if (type == PawnType.Enemy)
        {
            xpath = "/character/enemy//" + name;
            node  = (XmlElement)xmlDocDescription.SelectSingleNode(xpath);
        }
        if (node == null)
        {
            Debug.Log("On CharacterReader GetCharacterDescription: " + name + " not found");
            return(null);
        }
        data.race        = (node["race"].InnerXml);
        data.story       = (node["story"].InnerXml);
        data.description = (node["description"].InnerXml);
        return(data);
    }
 void Start()
 {
     indexPlayer1 = 0;
     indexPlayer2 = 0;
     player1      = GetCharacterDescription(indexPlayer1);
     player2      = GetCharacterDescription(indexPlayer2);
 }
예제 #3
0
    //grabs all relevent UI components on children
    void SetUI()
    {
        GameObject heightholder = transform.GetChild(0).gameObject;

        _heightText = heightholder.transform.GetChild(0).GetComponent <Text>();

        _timeline = transform.GetChild(1).gameObject;
        _timeRef  = _timeline.GetComponent <BattleTimeLine>();
        _timeRef.Init(this);

        _shortHolder = transform.GetChild(2).gameObject;
        _shortPort   = _shortHolder.transform.GetChild(0).GetComponent <Image>();
        _shortHealth = _shortHolder.transform.GetChild(1).GetComponent <Text>();
        _shortMana   = _shortHolder.transform.GetChild(2).GetComponent <Text>();
        _shortHolder.SetActive(false);

        _optionsRef = transform.GetChild(3).GetComponent <CharacterOptions>();
        _optionsRef.Init();

        _detailHolder = transform.GetChild(4).GetComponent <CharacterDescription>();
        _detailHolder.Init();

        _endingHolder = transform.GetChild(5).GetComponent <BattleEnding>();
        _endingHolder.Init();

        _initialized = true;

        _timeRef.ContinueFight();
    }
예제 #4
0
 public CharacterData(string playerName, CharacterDescription description)
 {
     PlayerName = playerName;
     if (description != null)
     {
         Type = description.CharacterType;
     }
 }
예제 #5
0
    /// <summary> Create and initialisation character </summary>
    /// <param name="spawnPoint"> Spawn character position </param>
    /// <param name="description"> Character description</param>
    public static Character CreateCharacter(Vector3 spawnPoint, CharacterDescription description)
    {
        var newCharacter = Instantiate(description.CharacterPrefab);

        newCharacter.transform.position = spawnPoint;
        newCharacter.InitCharacter(description);
        return(newCharacter);
    }
예제 #6
0
    /// <summary> Initialisation character after start </summary>
    /// <param name="description"> Character description</param>
    private void InitCharacter(CharacterDescription description)
    {
        Description = description;
        Health      = Description.MaxHealth;
        RB          = GetComponent <Rigidbody2D>();
        Animator    = GetComponent <Animator>();

        SelectedWeapon = new WeaponEntity(this, Description.StartedWeapon);
        SelectedWeapon.CartridgesTotal = SelectedWeapon.Weapon.MaxCartridges;
        Weapons.Add(SelectedWeapon);

        if (RB == null)
        {
            Debug.LogError("RigidBody2D not found", this);
        }
        if (Animator == null)
        {
            Debug.LogError("Animator not found", this);
        }

        Animator.runtimeAnimatorController = Description.Animator;

        //Set hands
        if (FirstShoulder)
        {
            FirstShoulder.sprite = Description.FirstShoulder;
        }
        if (FirstForearm)
        {
            FirstForearm.sprite = Description.FirstForearm;
        }
        if (FirstForearmOutline)
        {
            FirstForearmOutline.sprite = Description.FirstForearmOutline;
        }
        if (SecondShoulder)
        {
            SecondShoulder.sprite = Description.SecondShoulder;
        }
        if (SecondForearm)
        {
            SecondForearm.sprite = Description.SecondForearm;
        }
        if (SecondForearmOutline)
        {
            SecondForearmOutline.sprite = Description.SecondForearmOutline;
        }

        //Set head
        if (HeadTransform)
        {
            HeadTransform.sprite = Description.HeadSprite;
        }
    }
 public void PreviousCharacter(ref int index, ref CharacterDescription player)
 {
     if (index == 0)
     {
         index = charactersList.Length - 1;
     }
     else
     {
         index--;
     }
     player = GetCharacterDescription(index);
 }
 public void NextCharacter(ref int index, ref CharacterDescription player)
 {
     if (index == (charactersList.Length - 1))
     {
         index = 0;
     }
     else
     {
         index++;
     }
     player = GetCharacterDescription(index);
 }
예제 #9
0
        public async Task <bool> DeleteDescription(int id)
        {
            CharacterDescription characterDescription = await _unitOfWork.CharacterRepository.GetCharacterDescription(id);

            _unitOfWork.CharacterRepository.Delete <CharacterDescription>(characterDescription);

            if (await _unitOfWork.CharacterRepository.SaveAll())
            {
                return(true);
            }

            return(false);
        }
예제 #10
0
        public async Task <CharacterDescriptionForScriptDto> CreateDescription(CharacterDescriptionForScriptDto entity)
        {
            if (entity.Title.Length > 20)
            {
                entity.Title = entity.Title.Remove(20);
            }
            CharacterDescription characterDescription = _mapper.Map <CharacterDescription>(entity);

            _unitOfWork.CharacterRepository.Add <CharacterDescription>(characterDescription);

            await _unitOfWork.CharacterRepository.SaveAll();

            entity.Id = characterDescription.Id;

            return(entity);
        }
예제 #11
0
        public override Dictionary <string, object> SaveToDict()
        {
            var dict = new Dictionary <string, object>();

            dict.Add(GDMConstants.SchemaKey, "Characters");

            dict.Merge(true, HealthPoints.ToGDEDict(HealthPointsKey));
            dict.Merge(true, Experience.ToGDEDict(ExperienceKey));
            dict.Merge(true, Level.ToGDEDict(LevelKey));
            dict.Merge(true, BasicMelee.ToGDEDict(BasicMeleeKey));
            dict.Merge(true, BasicDistance.ToGDEDict(BasicDistanceKey));
            dict.Merge(true, BasicMagic.ToGDEDict(BasicMagicKey));
            dict.Merge(true, CharacterName.ToGDEDict(CharacterNameKey));
            dict.Merge(true, CharacterDescription.ToGDEDict(CharacterDescriptionKey));
            dict.Merge(true, DifficultyLevel.ToGDEDict(DifficultyLevelKey));
            return(dict);
        }
예제 #12
0
        public TalentBundle CreateNewBundle(CharacterDescription characterDescription)
        {
            TalentBundle            bundle = new TalentBundle();
            List <List <TalentId> > rows   = characterDescription.Talents;

            foreach (List <TalentId> row in rows)
            {
                var talents = new List <TalentData>();

                foreach (TalentId talentId in row)
                {
                    var description = storage[talentId];
                    var data        = new TalentData(description);
                    talents.Add(data);
                }
                bundle.TalentRows.Add(talents);
            }
            return(bundle);
        }
예제 #13
0
        public CharacterData CreateNewCharacter(string playerName, CharacterDescription characterDescription)
        {
            CharacterData data = new CharacterData(playerName, characterDescription);

            return(data);
        }