- 最后登录
- 2016-8-29
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 23585
- 纳金币
- 20645
- 精华
- 62
|
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// 游戏管理员
- /// </summary>
- public class GameMaster : MonoBehaviour {
- /// <summary>
- /// 玩家的复活点
- /// </summary>
- private Vector3 _playerSpwanPointPos;
- void Start () {
- //初始化玩家的复活点
- _playerSpwanPointPos = new Vector3(836f, 0, 790f);
- GameObject go = GameObject.Find(GameSetting.PLAYER_SPWAN_POINT);
- if (go == null)
- {
- Debug.LogWarning("没有找到玩家的复活点");
- go = new GameObject(GameSetting.PLAYER_SPWAN_POINT);
- go.transform.position = _playerSpwanPointPos;
- }
- //构建玩家游戏对象
- GameObject obj = Resources.LoadAssetAtPath("Assets\\Prefabs\\Player\\Sample Hero\\Player-Swordman.prefab", typeof(GameObject)) as GameObject;
- obj = Instantiate(obj) as GameObject;
- obj.name = "Player";
- //构建主相机
- GameObject cam=Resources.LoadAssetAtPath("Assets\\Prefabs\\Player\\Camera\\main Camera.prefab", typeof(GameObject)) as GameObject;
- cam = Instantiate(cam) as GameObject;
- cam.name = "Main Camera";
- cam.GetComponent<MouseOrbit>().m_target = obj;
- LoadCharacter();
- }
- #region 加载角色的信息
- /// <summary>
- /// 加载角色的信息
- /// </summary>
- public void LoadCharacter()
- {
- GameObject go = GameObject.Find("GameSetting");
- if (go == null)
- {
- go = Resources.LoadAssetAtPath("Assets\\Prefabs\\Global\\GameSetting.prefab", typeof(GameObject)) as GameObject;
- go = Instantiate(go) as GameObject;
- go.name = "GameSetting";
- }
- GameSetting setting = GameObject.Find("GameSetting").GetComponent<GameSetting>();
- //加载角色保存的信息
- setting.LoadCharacterData();
- }
- #endregion
- }
复制代码 |
|