Ejemplo n.º 1
0
    public ActorInfo CreateTableActor(CharacterTableData characterTableData)
    {
        ActorInfo actorInfo = new ActorInfo();

        actorInfo.Costume        = new Costume[(int)CostumeType.Max];
        actorInfo.DefaultCostume = new Costume[(int)CostumeType.Max];
        for (int i = 0; i < characterTableData.DefaultCostumeIndex.Length; ++i)
        {
            int index = characterTableData.DefaultCostumeIndex[i];
            CostumeTableData costumeTableData = CostumeTable.Instance.FindToIndex(index);
            Costume          costume          = new Costume(i,
                                                            costumeTableData.Index,
                                                            costumeTableData.Name,
                                                            costumeTableData.Path,
                                                            costumeTableData.Path[0],
                                                            costumeTableData.CostumeType);
            costume.SetCount(1);
            costume.SetWear(true);
            actorInfo.DefaultCostume[(int)costume.CostumeType] = costume;
        }

        actorInfo.Equips = new Equip[(int)EquipType.Max];
        actorInfo.Skills = new Skill[1];
        actorInfo.Status = characterTableData.status;
        actorInfo.IsMy   = false;
        actorInfo.Name   = "";
        actorInfo.Path   = characterTableData.path;
        actorInfo.Tag    = "";
        return(actorInfo);
    }
Ejemplo n.º 2
0
    private void SetCharacter()
    {
        characterTable = CharacterTable.Instance.FindToIndex(1);
        ActorModel actorModel = new ActorModel();
        ActorInfo  actorInfo  = actorModel.CreateTableActor(characterTable);

        characterController.CreateCharacter(actorInfo);
    }
    public override void Execute()
    {
        var heroDataList   = new List <Dictionary <string, System.Object> >();
        var characterTable = CharacterTableData.CreateFromJson();

        // 获取英雄数据
        for (int i = 0; i < userInfoModel.heroList.Count; i++)
        {
            var heroInfo      = userInfoModel.heroList[i];
            var characterData = characterTable.GetCharacterInfoById(heroInfo.characterId);
            var heroPrefab    = (GameObject)Resources.Load(characterData.heroPath);

            heroDataList.Add(new Dictionary <string, object>
            {
                { "id", heroInfo.id },
                { "heroPath", characterData.heroPath },
                { "atk", characterData.atk },
                { "hp", heroInfo.lastHp },
                { "maxHp", characterData.hp },
                { "heroInfoId", heroInfo.id },
                { "atkDis", characterData.atkDis },
                { "atkSpeed", characterData.atkSpeed },
                { "roleType1", Role.RoleType.HERO },
                { "moveSpeed", characterData.moveSpeed }
            });
        }

        var monsterDataList    = new List <Dictionary <string, System.Object> >();
        var chapterTable       = ChapterTableData.CreateFromJson();
        var currentChapterData = chapterTable.GetChapterInfoById(userInfoModel.fightChapterId);

        //  获取副本怪物数据
        for (int i = 0; i < currentChapterData.enemy.Length; i++)
        {
            var characterData = characterTable.GetCharacterInfoById(currentChapterData.enemy[i]);
            var heroPrefab    = (GameObject)Resources.Load(characterData.heroPath);

            monsterDataList.Add(new Dictionary <string, object>
            {
                { "heroPath", characterData.heroPath },
                { "atk", characterData.atk },
                { "hp", characterData.hp },
                { "maxHp", characterData.hp },
                { "atkDis", characterData.atkDis },
                { "atkSpeed", characterData.atkSpeed },
                { "roleType1", Role.RoleType.ENEMY },
                { "moveSpeed", characterData.moveSpeed }
            });
        }

        dispatcher.Dispatch(MediatorEvent.LoadFightCharacter, new System.Object[] { heroDataList, monsterDataList });
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        roleGo = GameObject.Find("Role");

        var userInfo       = DataManager.GetInstance().GetUserInfo();
        var characterTable = CharacterTableData.CreateFromJson();

        // 加载英雄数据
        for (int i = 0; i < userInfo.heroList.Count; i++)
        {
            var heroInfo      = userInfo.heroList[i];
            var characterData = characterTable.GetCharacterInfoById(heroInfo.characterId);
            var heroPrefab    = (GameObject)Resources.Load(characterData.heroPath);

            GameObject go = Instantiate(heroPrefab, new Vector3(-12, -i, 0), Quaternion.identity, roleGo.transform);

            Role role = go.GetComponent <Role>();
            role.Atk        = characterData.atk;
            role.Hp         = heroInfo.lastHp; // 英雄剩下的血量
            role.MaxHp      = characterData.hp;
            role.HeroInfoId = heroInfo.id;     // 战斗模型跟英雄数据的关系
            role.AtkDis     = characterData.atkDis;
            role.AtkSpeed   = characterData.atkSpeed;
            role.RoleType1  = Role.RoleType.HERO;
            role.MoveSpeed  = characterData.moveSpeed;

            Instantiate(hpBar, go.transform); // 创建血条
        }

        var chapterTable = ChapterTableData.CreateFromJson();

        currentChapterData = chapterTable.GetChapterInfoById(userInfo.fightChapterId);

        //  加载副本怪物数据
        for (int i = 0; i < currentChapterData.enemy.Length; i++)
        {
            var characterData = characterTable.GetCharacterInfoById(currentChapterData.enemy[i]);
            var heroPrefab    = (GameObject)Resources.Load(characterData.heroPath);

            GameObject go   = Instantiate(heroPrefab, new Vector3(12, -i, 0), Quaternion.identity, roleGo.transform);
            Role       role = go.GetComponent <Role>();
            role.Atk       = characterData.atk;
            role.Hp        = characterData.hp;
            role.MaxHp     = characterData.hp;
            role.AtkDis    = characterData.atkDis;
            role.AtkSpeed  = characterData.atkSpeed;
            role.RoleType1 = Role.RoleType.ENEMY;
            role.MoveSpeed = characterData.moveSpeed;

            Instantiate(hpBar, go.transform); // 创建血条
        }
    }
Ejemplo n.º 5
0
    public void SetPlayer()
    {
        // 나중에는 선택한 캐릭터 정보를 넘겨받아 Player를 완성시켜야 한다.
        // 1. 스텟
        // 2. 스킬
        MyPlayer            = new Player();
        MyPlayer.createTime = 0;
        MyPlayer.pid        = "";

        ActorInfo          actorInfo          = new ActorInfo();
        CharacterTableData characterTableData = CharacterTable.Instance.FindToIndex(1);

        actorInfo.Costume        = new Costume[(int)CostumeType.Max];
        actorInfo.DefaultCostume = new Costume[(int)CostumeType.Max];
        for (int i = 0; i < characterTableData.DefaultCostumeIndex.Length; ++i)
        {
            int index = characterTableData.DefaultCostumeIndex[i];
            CostumeTableData costumeTableData = CostumeTable.Instance.FindToIndex(index);
            Costume          costume          = new Costume(i, costumeTableData.Index, costumeTableData.Name, costumeTableData.Path,
                                                            costumeTableData.Path[0], costumeTableData.CostumeType);
            costume.SetCount(1);
            costume.SetWear(true);
            actorInfo.DefaultCostume[(int)costume.CostumeType] = costume;
        }

        actorInfo.Equips         = new Equip[(int)EquipType.Max];
        actorInfo.Skills         = new Skill[1];
        actorInfo.Status         = characterTableData.status;
        actorInfo.IsMy           = true;
        actorInfo.Name           = "다람쥐";
        actorInfo.Path           = characterTableData.path;
        actorInfo.Tag            = "Player";
        MyPlayer.SelectActorInfo = actorInfo;


        // 캐릭터 정보와 함께 아래 정보들을 받아와야 한다.
        // 1. 인벤토리
        // 2. 현재 위치 (필드 Index, 좌표 Vector)
        // 3. 미션
        // 4, 길드
        // 5. 친구
        // 6. 도감
        EquipManager.Instance.TestSetEquip();
    }
Ejemplo n.º 6
0
    public override void Execute()
    {
        var summonLv    = (int)evt.data;
        var summonTable = SummonTableData.CreateFromJson();

        characterTable = CharacterTableData.CreateFromJson();
        summonData     = summonTable.GetSummonDataByLv(summonLv);

        if (userInfoModel.money >= summonData.consume)
        {
            // 扣除需要的钱
            userInfoModel.money -= summonData.consume;
            RecruitHero();
            userInfoService.SaveUserInfo(userInfoModel);
            dispatcher.Dispatch(CommandEvent.GetMoney);
        }
        else
        {
            Debug.Log("钱不够");
        }
    }