Exemplo n.º 1
0
 public Skill(SkillData.RootObject data, BattleCharacterInfo user, int lv)
 {
     _user = user;
     Data  = data;
     Lv    = lv;
     if (data.SubID != 0)
     {
         SkillData.RootObject skillData = SkillData.GetData(Data.SubID);
         _subSkill = SkillFactory.GetNewSkill(skillData, user, lv);
         _subSkill.SetPartnerSkill(this);
     }
 }
Exemplo n.º 2
0
 public DonothingSkill(SkillData.RootObject data, BattleCharacterInfo user, int lv)
 {
     Data         = data;
     Lv           = lv;
     _user        = user;
     _hasNoTarget = true;
     if (data.SubID != 0)
     {
         SkillData.RootObject skillData = SkillData.GetData(Data.SubID);
         _subSkill = SkillFactory.GetNewSkill(skillData, user, lv);
         _subSkill.SetPartnerSkill(this);
     }
 }
Exemplo n.º 3
0
 public RecoverMPItemSkill(SkillData.RootObject data, int lv)
 {
     _hasNoTarget = false;
     Data         = data;
     Lv           = lv;
     _value       = data.ValueList[lv - 1];
     if (data.SubID != 0)
     {
         SkillData.RootObject skillData = SkillData.GetData(Data.SubID);
         _subSkill = SkillFactory.GetNewSkill(skillData, null, lv);
         _subSkill.SetPartnerSkill(this);
     }
 }
Exemplo n.º 4
0
 public CureLeastHPSkill(SkillData.RootObject data, BattleCharacterInfo user, int lv)
 {
     Data         = data;
     Lv           = lv;
     _user        = user;
     _hasNoTarget = false;
     _value       = data.ValueList[lv - 1];
     if (data.SubID != 0)
     {
         SkillData.RootObject skillData = SkillData.GetData(Data.SubID);
         _subSkill = SkillFactory.GetNewSkill(skillData, user, lv);
         _subSkill.SetPartnerSkill(this);
     }
 }
Exemplo n.º 5
0
 public PoisonSkill(SkillData.RootObject data, BattleCharacterInfo user, int lv)
 {
     Data         = data;
     Lv           = lv;
     _user        = user;
     _hasNoTarget = false;
     _poison      = new Poison(Data.StatusID, lv);
     if (data.SubID != 0)
     {
         SkillData.RootObject skillData = SkillData.GetData(Data.SubID);
         _subSkill = SkillFactory.GetNewSkill(skillData, user, lv);
         _subSkill.SetPartnerSkill(this);
     }
 }
Exemplo n.º 6
0
    public virtual void Init(BattleCharacter character, List <int> list)
    {
        _myself = character;

        for (int i = 0; i < list.Count; i++)
        {
            _skillList.Add(SkillFactory.GetNewSkill(list[i], _myself.Info, 1)); //等級填1是暫時的
        }

        if (_skillList.Count > 0)
        {
            _myself.SelectedSkill = _skillList[0];
        }
    }
Exemplo n.º 7
0
    public void TestCureSkill()
    {
        if (SkillData.GetData(3) == null)
        {
            SkillData.Load();
        }

        CureSkill           cureSkill  = (CureSkill)SkillFactory.GetNewSkill(3, null, 1);
        BattleCharacterInfo Info       = new BattleCharacterInfo();
        TeamMember          teamMember = new TeamMember();

        teamMember.Init(3, true, 1);
        Info.Init(teamMember, 1);
        Debug.Log(Info.MEF + " " + cureSkill.Data.ValueList[0]);
        Assert.AreEqual(18, cureSkill.CalculateRecover(Info));
    }
Exemplo n.º 8
0
    private List <BattleCharacter> _playerList  = new List <BattleCharacter>(); //戰鬥結束時需要的友方資料

    public void Init(int battlefieldId, BattleGroupData.RootObject battleGroupData, Action winCallback, Action loseCallback)
    {
        BattlefieldGenerator.Instance.Generate(battlefieldId, battleGroupData.EnemyList.Count);

        Turn          = 1;
        _power        = TeamManager.Instance.Power;
        _exp          = battleGroupData.Exp;
        _winCallback  = winCallback;
        _loseCallback = loseCallback;
        CharacterList.Clear();

        BattleCharacter character;

        TeamMember        member;
        List <TeamMember> memberList = TeamManager.Instance.GetAttendList();

        for (int i = 0; i < memberList.Count; i++)
        {
            member         = memberList[i];
            character      = ResourceManager.Instance.Spawn("BattleCharacter/BattleCharacter", ResourceManager.Type.Other).GetComponent <BattleCharacter>();
            character.name = member.Data.Animator;
            character.Init(member, TeamManager.Instance.Lv);
            CharacterList.Add(character);
            _playerList.Add(character);
            character.SetPosition((Vector2)(member.Formation + BattleFieldManager.Instance.Center));

            if (character.LiveState == BattleCharacter.LiveStateEnum.Dead)
            {
                character.Sprite.color = Color.clear;
            }
        }

        EnemyData.RootObject            data;
        List <int>                      itemList  = new List <int>(); //單隻怪的掉落物
        List <KeyValuePair <int, int> > enemyList = battleGroupData.GetEnemy();

        for (int i = 0; i < enemyList.Count; i++)
        {
            data     = EnemyData.GetData(enemyList[i].Key);
            itemList = data.GetDropItemList();
            for (int j = 0; j < itemList.Count; j++)
            {
                _dropItemList.Add(itemList[j]);
            }
            character = ResourceManager.Instance.Spawn("BattleCharacter/BattleCharacter", ResourceManager.Type.Other).GetComponent <BattleCharacter>();
            character.Init(enemyList[i].Key, enemyList[i].Value);
            CharacterList.Add(character);
            character.SetPosition(BattleFieldManager.Instance.EnemyPositionList[i]);
        }

        int itemId;

        ItemData.RootObject  itemData;
        SkillData.RootObject skillData;
        Skill       skill;
        List <Item> medicineList = ItemManager.Instance.GetItemListByType(ItemManager.Type.Bag, ItemData.TypeEnum.Medicine);

        if (medicineList != null)
        {
            foreach (Item item in medicineList)
            {
                itemId       = item.ID;
                itemData     = ItemData.GetData(itemId);
                skillData    = SkillData.GetData(itemData.Skill);
                skill        = SkillFactory.GetNewSkill(skillData, null, 1);
                skill.ItemID = itemId;
                ItemSkillList.Add(skill);
            }
        }

        Camera.main.transform.position = new Vector3(BattleFieldManager.Instance.Center.x, BattleFieldManager.Instance.Center.y, Camera.main.transform.position.z);
        AudioSystem.Instance.Play("Battle", true);
        ChangeSceneUI.Instance.EndClock(() =>
        {
            BattleUI.Open();
            BattleUI.Instance.Init(_power, CharacterList, battleGroupData.CanEscape);
            ChangeState <TurnStartState>();
        });
    }
Exemplo n.º 9
0
    public void SpecialInit(Action winCallback, Action loseCallback) //特殊場景的 Init
    {
        BattlefieldGenerator.Instance.GenerateFromTilemap(BattlefieldId);

        Turn          = 1;
        _power        = TeamManager.Instance.Power;
        _exp          = Exp;
        _winCallback  = winCallback;
        _loseCallback = loseCallback;
        CharacterList.Clear();

        BattleCharacter character;

        TeamMember        member;
        List <TeamMember> memberList = TeamManager.Instance.GetAttendList();

        for (int i = 0; i < memberList.Count; i++)
        {
            member         = memberList[i];
            character      = ResourceManager.Instance.Spawn("BattleCharacter/BattleCharacter", ResourceManager.Type.Other).GetComponent <BattleCharacter>();
            character.name = member.Data.Animator;
            character.Init(member, TeamManager.Instance.Lv);
            CharacterList.Add(character);
            _playerList.Add(character);
            character.SetPosition((Vector2)(member.Formation + BattleFieldManager.Instance.Center));

            if (character.LiveState == BattleCharacter.LiveStateEnum.Dead)
            {
                character.Sprite.color = Color.clear;
            }
        }

        EnemyData.RootObject data;
        List <int>           itemList = new List <int>(); //單隻怪的掉落物

        for (int i = 0; i < Enemys.Length; i++)
        {
            character = Enemys[i];
            character.InitByInspector();
            CharacterList.Add(character);

            data     = character.Info.EnemyData;
            itemList = data.GetDropItemList();
            for (int j = 0; j < itemList.Count; j++)
            {
                _dropItemList.Add(itemList[j]);
            }
        }

        int itemId;

        ItemData.RootObject  itemData;
        SkillData.RootObject skillData;
        Skill       skill;
        List <Item> medicineList = ItemManager.Instance.GetItemListByType(ItemManager.Type.Bag, ItemData.TypeEnum.Medicine);

        if (medicineList != null)
        {
            foreach (Item item in medicineList)
            {
                itemId       = item.ID;
                itemData     = ItemData.GetData(itemId);
                skillData    = SkillData.GetData(itemData.Skill);
                skill        = SkillFactory.GetNewSkill(skillData, null, 1);
                skill.ItemID = itemId;
                ItemSkillList.Add(skill);
            }
        }

        Camera.main.transform.position = new Vector3(BattleFieldManager.Instance.Center.x, BattleFieldManager.Instance.Center.y, Camera.main.transform.position.z);
        AudioSystem.Instance.Play("Battle", true);
        ChangeSceneUI.Instance.EndClock(() =>
        {
            BattleUI.Open();
            BattleUI.Instance.Init(_power, CharacterList, false);

            if (InitHandler != null)
            {
                InitHandler();
            }

            ChangeState <TurnStartState>();
        });
    }
Exemplo n.º 10
0
    public void Init(TeamMember member, int lv) //for player
    {
        IsAI         = false;
        IsTeamMember = true;
        Lv           = lv;
        Name         = member.Data.GetName();
        MaxHP        = member.MaxHP;
        CurrentHP    = member.CurrentHP;
        MaxMP        = member.MaxMP;
        CurrentMP    = member.CurrentMP;
        _atk         = member.ATK;
        _def         = member.DEF;
        _mtk         = member.MTK;
        _mef         = member.MEF;
        _agi         = member.AGI;
        _sen         = member.SEN;
        _mov         = member.MOV;
        EquipATK     = member.Weapon.ATK;
        EquipDEF     = member.Armor.DEF;
        EquipMTK     = member.Weapon.MTK;
        EquipMEF     = member.Armor.MEF;
        Camp         = CampEnum.Partner;
        JobData      = member.Data;
        if (!member.FoodBuff.IsEmpty)
        {
            FoodBuff = member.FoodBuff;
        }

        int id;

        SkillData.RootObject skillData;
        Skill skill;

        foreach (KeyValuePair <int, int> item in member.SkillDic)
        {
            id        = item.Key;
            skillData = SkillData.GetData(id);
            skill     = SkillFactory.GetNewSkill(skillData, this, item.Value);

            //if (!PriorityList.Contains(skill.Data.Priority))
            //{
            //    PriorityList.Add(skill.Data.Priority);
            //}

            SkillList.Add(skill);
        }

        foreach (KeyValuePair <int, int> item in member.SpellCardDic)
        {
            id        = item.Key;
            skillData = SkillData.GetData(id);
            skill     = SkillFactory.GetNewSkill(skillData, this, item.Value);

            //if (!PriorityList.Contains(skill.Data.Priority))
            //{
            //    PriorityList.Add(skill.Data.Priority);
            //}

            SpellCardList.Add(skill);
        }
    }