Beispiel #1
0
    internal void Init(PlayerInfo playerInfo)
    {
        this.playerInfo = playerInfo;
        //英雄是不是自己的角色
        isSelf = PlayerModel.Instance.CheckIsSelf(playerInfo.RolesInfo.RolesID);

        //复活的时候 会用到
        spawnPosition = transform.position;
        spawnRotaiton = transform.eulerAngles;

        //获取它的属性 当前的属性 还有总的属性
        currenAttribute = HeroAttributeConfig.GetInstance(playerInfo.HeroID);
        totalAttribute  = HeroAttributeConfig.GetInstance(playerInfo.HeroID);

        RoomModel.Instance.SaveHeroAttribute(playerInfo.RolesInfo.RolesID, currenAttribute, totalAttribute);

        //人物的HUD 血条 蓝条 昵称 等级
        HUD = ResManager.Instance.LoadHUD();
        HUD.transform.position    = transform.position + hudOffset;
        HUD.transform.eulerAngles = Camera.main.transform.eulerAngles;

        HPFill = HUD.transform.Find("HP/Fill").GetComponent <Image>();
        MPFill = HUD.transform.Find("MP/Fill").GetComponent <Image>();

        HPText       = HUD.transform.Find("HP/Text").GetComponent <Text>();
        MPText       = HUD.transform.Find("MP/Text").GetComponent <Text>();
        NickNameText = HUD.transform.Find("NickName").GetComponent <Text>();
        LevelText    = HUD.transform.Find("Level/Text").GetComponent <Text>();
        HUDUpdate(true);


        //技能管理器
        skillManager = this.gameObject.AddComponent <SkillManager>();
        skillManager.Init(this);

        //动画管理器
        animatorManager = this.gameObject.AddComponent <AnimatorManager>();
        animatorManager.Init(this);

        //角色的状态机 FSM
        playerFSM = this.gameObject.AddComponent <PlayerFSM>();
        playerFSM.Init(this);


        //相机的跟随->相机的脚本里去做
        if (isSelf == true)
        {
            if (playerInfo.TeamID == 0)
            {
                Camera.main.transform.eulerAngles = new Vector3(45, 180, 0);
            }
            else
            {
                Camera.main.transform.eulerAngles = new Vector3(45, -180, 0);
            }
        }
    }