//显示全部好友
        public void ShowAllFriends(List <object> friendNameList)
        {
            Debug.Log("ShowAllFriends: " + friendNameList.Count);
            //清空面板
            ClearAllFriends();
            //遍历friendNameList
            foreach (object a in friendNameList)
            {
                //实例化新条目
                var item = Instantiate(AssetTool.LoadAsset_Database_Or_Bundle(
                                           AssetTool.Assets__Resources_Ours__UIPanel_ + "Views/FriendsListItem.prefab",
                                           "Prefabs",
                                           "uipanel_bundle",
                                           "FriendsListItem"));

                Debug.Log("item == " + item);
                if (item != null)
                {
                    item.name = a as string;
                    //设置父节点
                    ((GameObject)item).transform.SetParent(_friListContent);
                    //显示好有名字
                    ((GameObject)item).GetComponent <FriendsListItem>().friendName = a.ToString();
                }
            }
        }
    private void Start()
    {
        _instance  = this;
        AvatarView = GetComponent <AvatarView>();
        if (Application.platform == RuntimePlatform.Android)
        {
            _playerState = new AndroidPlayerState(this);
        }
        else
        {
            if (XmlSceneManager.Instance.ControlMode == XmlSceneManager.ControlModeEnum.PcControl)
            {
                _playerState = new PcPlayerState(this);
            }
            else
            {
                _playerState = new AndroidPlayerState(this);
            }
        }
        _deadState           = new DeadState(this);
        _currentState        = _playerState;
        _characterController = GetComponent <CharacterController>();

        _clickPointAuxiliaryPrefab =
            AssetTool.LoadAsset_Database_Or_Bundle(
                AssetTool.Assets__Resources_Ours__Prefabs_ + "AuxiliaryPrefabs/ClickPointAuxiliary.prefab",
                "Prefabs",
                "auxiliaryprefabs_bundle",
                "ClickPointAuxiliary");

        _clickPointObject = Instantiate(_clickPointAuxiliaryPrefab) as GameObject;
    }
 void CreateItem()
 {
     for (int i = 0; i < _content.childCount; i++)
     {
         Destroy(_content.GetChild(i).gameObject);
     }
     foreach (var goodsId in _bagGoodsList)
     {
         var tempItem =
             Instantiate(
                 AssetTool.LoadAsset_Database_Or_Bundle(
                     AssetTool.Assets__Resources_Ours__UIPanel_ + "StoreItems/" + (int)goodsId + ".prefab",
                     "Prefabs",
                     "uipanel_bundle",
                     "" + (int)goodsId)) as GameObject;
         if (tempItem != null)
         {
             tempItem.transform.SetParent(_content);
             tempItem.GetComponent <StoreItem>().goodsID     = (int)goodsId;
             tempItem.GetComponent <StoreItem>().parentPanel = this;
             RectTransform itemObjectRectTrans = tempItem.transform.Find("Object").GetComponent <RectTransform>();
             itemObjectRectTrans.anchorMin = new Vector2(0.0f, 0.0f);
             itemObjectRectTrans.anchorMax = new Vector2(1, 1);
             itemObjectRectTrans.offsetMax = new Vector2(-10, -10);
             itemObjectRectTrans.offsetMin = new Vector2(10, 10);
             RectTransform describeRectTrans = tempItem.transform.Find("Describe").GetComponent <RectTransform>();
             describeRectTrans.anchorMin     = new Vector2(0.0f, 0.0f);
             describeRectTrans.anchorMax     = new Vector2(1, 0.0f);
             describeRectTrans.localPosition = new Vector3(0, -1, 0);
             describeRectTrans.sizeDelta     = new Vector2(20, 20);
         }
     }
 }
Exemple #4
0
        public Skill(AvatarView spellcaster)
        {
            _spellcaster = spellcaster;
            if (SkillTrajectory == null)
            {
                var className = this.GetType().Name;
                var prefab    =
                    AssetTool.LoadAsset_Database_Or_Bundle(
                        AssetTool.Assets__Resources_Ours__Prefabs_ + "Trigger/Skill/" + className + "/" + className + "_SkillTrajectory.prefab",
                        "Prefabs",
                        "trigger_bundle",
                        className + "_SkillTrajectory");

                if (prefab != null)
                {
                    SkillTrajectory = Object.Instantiate(prefab) as GameObject;
                    if (SkillTrajectory != null)
                    {
                        SkillTrajectory.SetActive(false);
                    }
                }
                else
                {
                    Debug.LogError(className + " SkillTrajectory prefab == null!");
                }
            }
        }
Exemple #5
0
 public virtual void OnDie(object[] args)
 {
     Instantiate(
         AssetTool.LoadAsset_Database_Or_Bundle(
             AssetTool.Assets__Resources_Ours__Prefabs_ + "DieEffect.prefab",
             "Prefabs",
             "trigger_bundle",
             "Trigger"),
         transform.position,
         transform.rotation);
 }
Exemple #6
0
        // Update is called once per frame
        void Update()
        {
            if (_currentSelectObject != null)
            {
                if (_selectTipsCircle == null)
                {
                    _selectTipsCircle = GameObject.Find("SelectObject (Clone)");
                    if (_selectTipsCircle == null)
                    {
                        _selectTipsCircle =
                            Instantiate(
                                AssetTool.LoadAsset_Database_Or_Bundle(
                                    AssetTool.Assets__Resources_Ours__Prefabs_ + "Npc/SelectObject.prefab",
                                    "Prefabs",
                                    "npc_bundle",
                                    "SelectObject"),
                                _currentSelectObject.transform.position,
                                Quaternion.identity) as GameObject;
                    }
                }
                else
                {
                    if (_selectTipsCircle.activeInHierarchy == false)
                    {
                        _selectTipsCircle.SetActive(true);
                    }
                    else
                    {
                        _selectTipsCircle.transform.position = new Vector3(_currentSelectObject.transform.position.x, 0.2f, _currentSelectObject.transform.position.z);
                    }
                }
            }
            else
            {
                if (_selectTipsCircle != null)
                {
                    if (_selectTipsCircle.activeInHierarchy == true)
                    {
                        _selectTipsCircle.SetActive(false);
                    }
                }
            }
            RaycastHit hit;
            Ray        ray       = Camera.main.ScreenPointToRay(Input.mousePosition);
            LayerMask  layerMask = (1 << LayerMask.NameToLayer("Npc"));

            if (Physics.Raycast(ray, out hit, 100, layerMask) && Input.GetMouseButtonDown(0))
            {
                _currentSelectObject = hit.collider.gameObject;
            }
        }
 public AndroidPlayerState(PlayerInputController playerInputController)
 {
     _playerInputController = playerInputController;
     Instantiate(AssetTool.LoadAsset_Database_Or_Bundle(
                     AssetTool.Assets__Resources_Ours__Prefabs_ + "AuxiliaryPrefabs/EasyTouchControlsCanvas.prefab",
                     "Prefabs",
                     "auxiliaryprefabs_bundle",
                     "EasyTouchControlsCanvas"));
     Instantiate(AssetTool.LoadAsset_Database_Or_Bundle(
                     AssetTool.Assets__Resources_Ours__Prefabs_ + "AuxiliaryPrefabs/InputManager.prefab",
                     "Prefabs",
                     "auxiliaryprefabs_bundle",
                     "InputManager"));
 }
        protected override void Start()
        {
            base.Start();
            transform.SetParent(SingletonGather.UiManager.CanvasLayerFront.transform);
            _friListItem = AssetTool.LoadAsset_Database_Or_Bundle(
                AssetTool.Assets__Resources_Ours__UIPanel_ + "Views/FriendsListItem.prefab",
                "Prefabs",
                "uipanel_bundle",
                "FriendsListItem");

            transform.localScale = new Vector3(1, 1, 1);

            var rect = GetComponent <RectTransform>();

            rect.anchorMin        = new Vector2(1.0f, 0.5f);
            rect.anchorMax        = new Vector2(1.0f, 0.5f);
            rect.pivot            = new Vector2(0.5f, 0.5f);
            rect.anchoredPosition = new Vector2(-97, 0);
            rect.sizeDelta        = new Vector2(195, 245);
        }
Exemple #9
0
 void CreateItem()
 {
     for (int i = 0; i < _content.childCount; i++)
     {
         Destroy(_content.GetChild(i).gameObject);
     }
     foreach (var goodsId in _storeGoodsIdList)
     {
         var tempItem =
             Instantiate(
                 AssetTool.LoadAsset_Database_Or_Bundle(
                     AssetTool.Assets__Resources_Ours__UIPanel_ + "StoreItems/" + (int)goodsId + ".prefab",
                     "Prefabs",
                     "uipanel_bundle",
                     "" + (int)goodsId)) as GameObject;
         if (tempItem != null)
         {
             tempItem.transform.SetParent(_content);
             tempItem.GetComponent <StoreItem>().goodsID     = (int)goodsId;
             tempItem.GetComponent <StoreItem>().parentPanel = this;
         }
     }
 }
        public GameObject TryGetOrCreatePanel(string panelName)
        {
            GameObject tempPanel;

            if (!_panels.ContainsKey(panelName))
            {
                tempPanel =
                    Object.Instantiate(
                        AssetTool.LoadAsset_Database_Or_Bundle(
                            AssetTool.Assets__Resources_Ours__UIPanel_ + "Views/" + panelName + ".prefab",
                            "Prefabs",
                            "uipanel_bundle",
                            panelName)) as GameObject;
                _panels.Add(panelName, tempPanel);
            }
            else
            {
                _panels.TryGetValue(panelName, out tempPanel);
                if (tempPanel == null)
                {
                    tempPanel =
                        Object.Instantiate(
                            AssetTool.LoadAsset_Database_Or_Bundle(
                                AssetTool.Assets__Resources_Ours__UIPanel_ + "Views/" + panelName + ".prefab",
                                "Prefabs",
                                "uipanel_bundle",
                                panelName)) as GameObject;
                    _panels.Remove(panelName);
                    _panels.Add(panelName, tempPanel);
                }
            }
            if (tempPanel != null)
            {
                tempPanel.GetComponent <RectTransform>().SetAsLastSibling();
            }
            return(tempPanel);
        }
        /// 优化版
        static void LoadSceneFromDatabase(string sceneName)
        {
            var filepath = Application.streamingAssetsPath + "/SceneDescription/" + sceneName + ".xml";

            if (File.Exists(filepath)) //如果文件存在话开始解析。
            {
                var xmlPath     = filepath;
                var xmlDocument = new XmlDocument();
                xmlDocument.Load(xmlPath);

                var xmlNodeList = xmlDocument.SelectNodes("//gameObject"); // 使用 XPATH 获取所有 gameObject 节点
                if (xmlNodeList != null)
                {
                    foreach (XmlNode xmlNode in xmlNodeList)
                    {
                        if (xmlNode.Attributes != null)
                        {
                            var prefabName     = xmlNode.Attributes["objectAsset"].Value;
                            var gameObjectName = xmlNode.Attributes["objectName"].Value;

                            var prefabObject =
                                AssetTool.LoadAsset_Database_Or_Bundle(
                                    "Assets/_Scenes/" + sceneName + "/" + prefabName + ".prefab",
                                    "SceneAssets",
                                    sceneName.ToLower(),
                                    prefabName);

                            var gameObj = (GameObject)Instantiate(prefabObject);
                            gameObj.name = gameObjectName;
                            _originalSceneObjects.Add(gameObj);
                            ParseAttributes(xmlNode, gameObj); // 使用 XPATH 获取 位置、旋转、缩放数据
                        }
                    }
                }
            }
        }
Exemple #12
0
        //技能预备
        public virtual void Ready(AvatarView spellcaster)
        {
            if (SkillTrajectory == null)
            {
                var prefab =
                    AssetTool.LoadAsset_Database_Or_Bundle(
                        AssetTool.Assets__Resources_Ours__Prefabs_ + "Trigger/Skill/" + this.GetType().Name + "/SkillTrajectory.prefab",
                        "Prefabs",
                        "trigger_bundle",
                        this.GetType().Name + "_SkillTrajectory");

                if (prefab != null)
                {
                    SkillTrajectory = Object.Instantiate(prefab) as GameObject;
                }
            }
            else
            {
                if (SkillTrajectory.activeInHierarchy == false)
                {
                    SkillTrajectory.SetActive(true);
                }
            }
        }
Exemple #13
0
        private EntityObjectView CreateRenderObjectView(Entity entity, string viewType)
        {
            Dictionary <string, Object> typeProducts;

            _products.TryGetValue(typeof(EntityObjectView), out typeProducts);
            if (typeProducts == null)
            {
                typeProducts = new Dictionary <string, Object>();
                _products.Add(typeof(EntityObjectView), typeProducts);
            }
            Object productPrefab;

            switch (viewType)
            {
            case "Avatar":
                typeProducts.TryGetValue(viewType, out productPrefab);
                break;

            case "Monster":
                typeProducts.TryGetValue(viewType + entity.getDefinedProperty("modelName"), out productPrefab);
                break;

            case "Npc":
                typeProducts.TryGetValue(viewType + entity.getDefinedProperty("modelName"), out productPrefab);
                break;

            case "Trigger":
                typeProducts.TryGetValue(viewType, out productPrefab);
                break;

            default:
                productPrefab = null;
                break;
            }

            if (productPrefab == null)
            {
                var productPrefabPath = "";
                var databasePath      = "";
                var bundlePath        = "Prefabs";
                var bundleName        = "";
                var assetName         = "";

                switch (viewType)
                {
                case "Avatar":
                    productPrefabPath = "Player/Player";
                    bundleName        = "player_bundle";
                    assetName         = "Player";
                    break;

                case "Monster":
                    productPrefabPath = "Monster/" + entity.getDefinedProperty("modelName");
                    bundleName        = "monster_bundle";
                    assetName         = "" + entity.getDefinedProperty("modelName");
                    break;

                case "Npc":
                    productPrefabPath = "Npc/" + entity.getDefinedProperty("modelName");
                    bundleName        = "npc_bundle";
                    assetName         = "" + entity.getDefinedProperty("modelName");
                    break;

                case "Trigger":
                    productPrefabPath = "Trigger/Trigger";
                    bundleName        = "trigger_bundle";
                    assetName         = "Trigger";
                    break;
                }
                databasePath  = "Assets/_Resources/Ours/_Prefabs/" + productPrefabPath + ".prefab";
                productPrefab = AssetTool.LoadAsset_Database_Or_Bundle(databasePath, bundlePath, bundleName, assetName);
                if (productPrefab != null)
                {
                    switch (viewType)
                    {
                    case "Avatar":
                        typeProducts.Add(viewType, productPrefab);
                        break;

                    case "Monster":
                        typeProducts.Add(viewType + entity.getDefinedProperty("modelName"), productPrefab);
                        break;

                    case "Npc":
                        typeProducts.Add(viewType + entity.getDefinedProperty("modelName"), productPrefab);
                        break;

                    case "Trigger":
                        typeProducts.Add(viewType, productPrefab);
                        break;

                    default:
                        productPrefab = null;
                        break;
                    }
                }
                else
                {
                    Debug.LogError(entity.getDefinedProperty("entityName") + " no " + entity.getDefinedProperty("modelName") + " prefab!");
                    return(null);
                }
            }
            EntityObjectView entityView = null;

            if (productPrefab != null)
            {
                var gameObject = Object.Instantiate(productPrefab, entity.position, Quaternion.identity) as GameObject;
                entity.renderObj = gameObject;
                if (gameObject != null)
                {
                    gameObject.name = entity.className + ":" + entity.getDefinedProperty("entityName");
                    entityView      = gameObject.GetComponent <EntityObjectView>();
                    entityView.InitializeView(entity as KBEngine.Model);
                    if (entity.isPlayer())
                    {
                        SingletonGather.WorldMediator.MainAvatarView = entityView as AvatarView;
                        gameObject.AddComponent <PlayerInputController>();
                    }
                }
            }
            return(entityView);
        }
Exemple #14
0
        private EntityPanelView CreateEntityPanelView(Entity entity)
        {
            if (!_entityPanelViewPrefab)
            {
                _entityPanelViewPrefab =
                    AssetTool.LoadAsset_Database_Or_Bundle(
                        AssetTool.Assets__Resources_Ours__UIPanel_ + "EntityPanel.prefab",
                        "Prefabs",
                        "uipanel_bundle",
                        "EntityPanel");
                if (_entityPanelViewPrefab == null)
                {
                    Debug.LogError("_entityPanelViewPrefab == null!");
                    return(null);
                }
            }

            var tempVector = Camera.main.WorldToScreenPoint(entity.position);

            tempVector = new Vector3(tempVector.x, tempVector.y, 0);
            GameObject gObj;

            switch (entity.className)
            {
            case "Avatar":
                gObj = Object.Instantiate(_entityPanelViewPrefab, tempVector, Quaternion.identity) as GameObject;
                if (gObj != null)
                {
                    gObj.AddComponent <AvatarPanelView>();
                }
                break;

            case "Monster":
                gObj = Object.Instantiate(_entityPanelViewPrefab, tempVector, Quaternion.identity) as GameObject;
                if (gObj != null)
                {
                    gObj.AddComponent <MonsterPanelView>();
                }
                break;

            case "Npc":
                gObj = Object.Instantiate(_entityPanelViewPrefab, tempVector, Quaternion.identity) as GameObject;
                if (gObj != null)
                {
                    gObj.AddComponent <NpcPanelView>();
                }
                break;

            default:
                return(null);
            }
            if (gObj == null)
            {
                return(null);
            }
            gObj.transform.SetParent(SingletonGather.UiManager.CanvasLayerBack.transform);
            var view = gObj.GetComponent <EntityPanelView>();

            view.InitializeView(entity as KBEngine.Model);
            return(view);
        }
Exemple #15
0
        public override void InitializeView(IModel model)
        {
            base.InitializeView(model);

            var model1 = Model as KBEngine.Model;

            if (model1 != null)
            {
                string entityName
                      = transform.Find("Name").GetComponent <TextMesh>().text
                      = (string)model1.getDefinedProperty("name");
                transform.Find("Name").GetComponent <TextMesh>().text = "";

                if (entityName == "GateWayTrigger")
                {
                    //transform.Find("Name").GetComponent<TextMesh>().text
                    //    = (string)model1.getDefinedProperty("name");

                    var trigger =
                        Instantiate(
                            AssetTool.LoadAsset_Database_Or_Bundle(
                                AssetTool.Assets__Resources_Ours__Prefabs_ + "Trigger/Skill/GateWayTrigger/GateWayTrigger.prefab",
                                "Prefabs",
                                "trigger_bundle",
                                "GateWayTrigger")) as GameObject;
                    if (trigger != null)
                    {
                        trigger.transform.SetParent(transform);
                        trigger.transform.localPosition = new Vector3(0, 0, 0);
                    }
                }
                else
                {
                    var trigger =
                        Instantiate(
                            AssetTool.LoadAsset_Database_Or_Bundle(
                                AssetTool.Assets__Resources_Ours__Prefabs_ + "Trigger/Skill/" + entityName + "/" + entityName + "_Trigger.prefab",
                                "Prefabs",
                                "trigger_bundle",
                                entityName + "_Trigger")) as GameObject;
                    if (trigger != null)
                    {
                        trigger.SetActive(false);
                        trigger.transform.SetParent(transform);
                        trigger.transform.localPosition = new Vector3(0, 0, 0);
                        trigger.transform.eulerAngles   = Vector3.zero;
                        _myTriggerObject = trigger;
                        Invoke("InvokeMethod", 0.1f);
                    }
                    else
                    {
                        Debug.LogError(entityName + "_Trigger.prefab is null");
                    }
                }
            }

            HandleTriggerSizeUpdate(0);
            HandleParentSkillUpdate(0);

            model.SubscribePropertyUpdate(TriggerPeopertys.ParentSkill, HandleParentSkillUpdate);
            model.SubscribePropertyUpdate(TriggerPeopertys.TriggerSize, HandleTriggerSizeUpdate);
        }