Exemplo n.º 1
0
    private void CreateMonster(int index, MonsterType type = MonsterType.Rubbish)
    {
        ModelMonsterData data     = GetModel <MMonsterData>().GetMonsterData(type);
        GameObject       monster  = GameObject.Instantiate(data.Prefab);
        string           nodeName = string.Concat(data.PrefabName, index);

        monster.name = nodeName;
        monster.transform.SetParent(m_parent);
        monster.transform.position = data.GetScenePostion();
        ModelMonster script = new ModelMonster(monster, data, type);

        if (m_dicNameMonster.ContainsKey(nodeName))
        {
            m_dicNameMonster[nodeName] = script;
        }
        else
        {
            m_dicNameMonster.Add(nodeName, script);
        }
        m_listMonster.Add(script);
        Vector3 screenPos = GameSceneManager.ToScreenPoint(monster.transform.position);

        script.HPPosY = ModelRoleManager.GetModelRoleHpPosY(data.PrefabName);
        float distance = GameSceneManager.DistanceToCamera(monster.transform.position);
        ModelMonsterHPData hpProcessData = new ModelMonsterHPData(monster.name, screenPos, script.HPPosY, distance);

        EventManager.Dispatch(GameMoudle.Player, GameEvent.Type.MonsterCreate, hpProcessData);
    }
Exemplo n.º 2
0
    private void OpenMainView(object arg)
    {
        Dictionary <string, GameObject> dicNodeName = arg as Dictionary <string, GameObject>;
        string              playerPrefabName        = "Blade_Warrior_Prefab";
        GameObject          playerObj = dicNodeName[playerPrefabName];
        ModelAttackRoleData data      = new ModelAttackRoleData(GetModel <MPlayerData>().PlayerHP, 0.5f, 30);

        m_player           = new ModelPlayer(playerObj, data);
        m_monsterScaleFlag = GameSceneManager.DistanceToCamera(playerObj.transform.position);

        m_cameraTrans           = dicNodeName[GameConst.PlayerCamera].transform;
        m_cameraRotationY       = m_cameraTrans.rotation.eulerAngles.y;
        m_cameraHeight          = m_cameraTrans.position.y - GameConfig.CameraHeightFix;
        m_cameraToPlayerDis     = m_player.transform.position.z - m_cameraTrans.position.z;
        m_cameraToPlayerDisVec3 = m_player.transform.position - m_cameraTrans.position;

        GameView viewType = GameView.MainView;

        ViewManager.Open(GameViewInfo.GetViewName(Moudle, GameView.MainView),
                         (GameObject gameObject) => {
            m_playerView     = new PlayerView(Moudle, viewType, gameObject.GetComponent <UIPrefab>());
            Vector3 position = GameSceneManager.ToScreenPoint(playerObj.transform.position);
            position.y      += ModelRoleManager.GetModelRoleHpPosY(playerPrefabName);
            m_playerView.CreateHPProcess(playerPrefabName, position, 1, true);
        }
                         );

        EventManager.Register(GameEvent.Type.FrameUpdate, FrameUpdate);
    }
Exemplo n.º 3
0
 private void LastUpdate(object arg)
 {
     for (int i = 0; i < m_listMonster.Count; i++)
     {
         string  nodeName = m_listMonster[i].gameObject.name;
         Vector3 position = m_listMonster[i].transform.position;
         position = GameSceneManager.ToScreenPoint(position);
         float distance          = GameSceneManager.DistanceToCamera(m_listMonster[i].transform.position);
         ModelMonsterHPData data = new ModelMonsterHPData(nodeName, position, m_listMonster[i].HPPosY, distance);
         EventManager.Dispatch(GameMoudle.Player, GameEvent.Type.MonsterMove, data);
     }
 }