Ejemplo n.º 1
0
    public Common2dRes()
    {
        _commonPool = PoolManager.Pools.Create("Common2dRes");
        _commonPool.dontDestroyOnLoad = true;

        #region ui canvas
        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_Debug", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_ImgSprite", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "GroupCard", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_Tips", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        #endregion
    }
Ejemplo n.º 2
0
        public ResponseStatus Add(HttpRequestBase req, Func <T> m_InstanceModel, Func <PoolUtil> m_InstanceDal, Action <T> m_SetValues)
        {
            ResponseStatus resp = ResponseStatus.NONE;

            m = m_InstanceModel();
            if (this.CreateInstance(req, m_SetValues, m))
            {
                poolUtil = m_InstanceDal();
                if (poolUtil.Insert(m))
                {
                    poolUtil.ReturnUnitToPool();
                    resp = ResponseStatus.SUCCESS;
                }
                else
                {
                    resp = ResponseStatus.FAILED;
                }
            }
            else
            {
                m    = default(T);
                resp = ResponseStatus.FAILED;
            }
            return(resp);
        }
Ejemplo n.º 3
0
    public InGame2dRes()
    {
        _spawnPool = PoolManager.Pools.Create("InGame2dRes");
        _spawnPool.dontDestroyOnLoad = true;

        #region ui canvas
        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_Combo", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_LackSetting", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_GameUIInfo", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_HuPrompt", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_GameResult", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });
        #endregion
    }
Ejemplo n.º 4
0
        public ResponseStatus Delete(HttpRequestBase req, Func <PoolUtil> m_InstanceDal)
        {
            ResponseStatus resp = ResponseStatus.NONE;
            int            id;
            bool           isclose = false;

            poolUtil = m_InstanceDal();
            for (int i = 0; i < req.Form.Count; ++i)
            {
                if (i == req.Form.Count - 1)
                {
                    isclose = true;
                }
                if (int.TryParse(req.Form.AllKeys[i], out id))
                {
                    if (poolUtil.Delete(id, isclose))
                    {
                        resp = ResponseStatus.SUCCESS;
                    }
                    else
                    {
                        resp = ResponseStatus.FAILED;
                        break;
                    }
                }
                else
                {
                    resp = ResponseStatus.FAILED;
                    break;
                }
            }
            poolUtil.ReturnUnitToPool();
            return(resp);
        }
Ejemplo n.º 5
0
    public InGameEffectRes()
    {
        _commonPool = PoolManager.Pools.Create("InGameEffectRes");
        _commonPool.dontDestroyOnLoad = true;

        #region ui canvas
//		ResourceManager.Instance.LoadAsync(_assetBundleName, "FX_Canvas", delegate(UnityEngine.Object obj)
//        {
//            PoolUtil.SingletonPrefabPool(_commonPool, obj);
//        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_PengGang", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_Dingque", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_Indictor 1", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_kong", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_pong", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_rain", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_Tornado", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_win", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "FX_zimo", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        #endregion
    }
    /// <summary>
    /// 加载敌人prefab
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    private GameObject LoadRes(string name)
    {
        var        path = "Unit/Enemy/Customized/" + name;
        var        res  = Resources.Load(path);
        GameObject go   = PoolUtil.SpawnGameObject((GameObject)res, Vector3.zero, Quaternion.identity, viewObjectRoot);

        go.name = res.name;
        return(go);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 金币特效
    /// </summary>
    /// <param name="spawnPos"></param>
    private void CreateIconEffect(Vector3 spawnPos)
    {
        var        res = Resources.Load("Unit/Effect/Coin");
        GameObject go  = PoolUtil.SpawnGameObject((GameObject)res, spawnPos, Quaternion.identity, viewObjectRoot);

        go.name = res.name;
        if (go.GetComponent <CoinView>() == null)
        {
            go.AddComponent <CoinView>();
        }
    }
Ejemplo n.º 8
0
    public void DestroyUnityObject()
    {
        if (gameObject != null)
        {
            gameObject.Unlink();
            Destroy(this);
            gameEntity.RemoveView();

            PoolUtil.DeSpawnGameObject(gameObject);
        }
    }
Ejemplo n.º 9
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         BaseView view = collision.gameObject.GetComponent <BaseView>();
         if (view != null)
         {
             view.gameEntity.ReplaceEnemyState(EnemyState.Die);
         }
         PoolUtil.DeSpawnGameObject(gameObject);
     }
 }
Ejemplo n.º 10
0
        public ResponseStatus GetSingle(int id, Func <T> m_InstanceModel, Func <PoolUtil> m_InstanceDal)
        {
            ResponseStatus resp = ResponseStatus.NONE;

            poolUtil = m_InstanceDal();
            resp     = poolUtil.GetSingle(id, m_InstanceModel());
            if (resp == ResponseStatus.FAILED)
            {
                m = default(T);
            }
            poolUtil.ReturnUnitToPool();
            return(resp);
        }
Ejemplo n.º 11
0
        public ResponseStatus GetMuti(HttpRequestBase req, Func <PoolUtil> m_InstanceDal, List <T> m_List, Paginate paginate)
        {
            ResponseStatus resp = ResponseStatus.NONE;

            poolUtil = m_InstanceDal();
            resp     = poolUtil.GetMuti(m_List, paginate);
            if (resp == ResponseStatus.FAILED)
            {
                list_m = default(List <T>);
            }
            poolUtil.ReturnUnitToPool();
            return(resp);
        }
Ejemplo n.º 12
0
    /// <summary>
    /// 生成子弹
    /// </summary>
    private void SpawnBullet()
    {
        var        res = Resources.Load("Unit/Effect/Bullet");
        GameObject go  = PoolUtil.SpawnGameObject((GameObject)res, bulletPos.position, gameEntity.rotation.value, viewObjectRoot);

        go.name = res.name;

        if (go.GetComponent <BulletView>() != null)
        {
            Destroy(go.GetComponent <BulletView>());
        }

        go.AddComponent <BulletView>();
    }
Ejemplo n.º 13
0
        public ResponseStatus Delete(int id, Func <PoolUtil> m_InstanceDal)
        {
            ResponseStatus resp    = ResponseStatus.NONE;
            bool           isclose = true;

            poolUtil = m_InstanceDal();
            if (poolUtil.Delete(id, isclose))
            {
                resp = ResponseStatus.SUCCESS;
            }
            else
            {
                resp = ResponseStatus.FAILED;
            }
            poolUtil.ReturnUnitToPool();
            return(resp);
        }
Ejemplo n.º 14
0
    public void OnAsset(GameEntity entity, object value)
    {
        //根据entity中的asset类型来创建prefab
        int        index  = -1;
        IView      view   = null;
        UnitType   type   = entity.unitType.value;
        GameObject prefab = null;
        GameObject obj    = null;

        switch (type)
        {
        //从配置中读取prefab然后实例化,将view脚本和entity链接
        case UnitType.Player:
            prefab = entity.playerInfo.value.prefab;
            obj    = PoolUtil.SpawnGameObject(prefab, entity.position.value, entity.rotation.value, viewObjectRoot);

            view = obj.AddComponent <PlayerView>();
            break;

        case UnitType.Enemy:
            if (context.gameProgress.state == GameProgressState.InGame)
            {
                var enemyType = entity.enemyType.value;
                //不同类型的敌人
                switch (enemyType)
                {
                case EnemyType.NormalBehavior:
                    index = (int)entity.uID.value % (entity.enemyInfo.value.enemyList.Length);
                    entity.AddColorType(index);

                    prefab = entity.enemyInfo.value.enemyList[index];
                    obj    = PoolUtil.SpawnGameObject(prefab, entity.position.value, entity.rotation.value, viewObjectRoot);
                    view   = obj.AddComponent <NormalEnemyView>();
                    break;

                case EnemyType.PingpongBehavior:
                    index = (int)entity.uID.value % (entity.enemyInfo.value.enemyList.Length);
                    entity.AddColorType(index);

                    prefab = entity.enemyInfo.value.enemyList[index];
                    obj    = PoolUtil.SpawnGameObject(prefab, entity.position.value, entity.rotation.value, viewObjectRoot);
                    view   = obj.AddComponent <PingpongEnemyView>();
                    break;

                case EnemyType.CustomizedBehavior:
                    obj   = (GameObject)value;
                    index = int.Parse(obj.name) - 1;
                    entity.AddColorType(index);

                    view = obj.AddComponent <CustomizedEnemyView>();
                    break;

                default:
                    break;
                }
            }
            else
            {
                entity.isDestroyed = true;
            }
            break;

        case UnitType.GameMap:
            prefab = entity.mapInfo.value.prefab;
            obj    = PoolUtil.SpawnGameObject(prefab, entity.position.value, entity.rotation.value, viewObjectRoot);

            view = obj.AddComponent <MapView>();
            break;

        case UnitType.Spilt:
            index  = MathUtils.RandomInt(0, entity.spiltInfo.value.spiltList.Length - 1);
            prefab = entity.spiltInfo.value.spiltList[index];
            obj    = PoolUtil.SpawnGameObject(prefab, entity.position.value, entity.rotation.value, viewObjectRoot);
            obj.GetComponent <SpriteRenderer>().color = ConstantUtils.spiltColorList[entity.colorType.value];

            view = obj.AddComponent <SpiltView>();
            break;

        case UnitType.Item:
            index  = (int)entity.itemType.value;
            prefab = entity.itemInfo.value.itemList[index];
            obj    = PoolUtil.SpawnGameObject(prefab, entity.position.value, entity.rotation.value, viewObjectRoot);

            view = obj.AddComponent <ItemView>();
            break;

        case UnitType.PlayerItem:
            index  = (int)entity.itemType.value;
            prefab = entity.itemInfo.value.itemList[index];
            obj    = PoolUtil.SpawnGameObject(prefab, entity.position.value, entity.rotation.value, viewObjectRoot);

            view = obj.GetComponent <BaseView>();     //预先在人物item的gameobjct上挂好脚本
            break;

        default:
            Debug.Log("无法创建预制体类型:" + type.ToString());
            break;
        }
        if (view != null)
        {
            view.Link(context, entity);
            entity.AddView(view);
        }
    }
Ejemplo n.º 15
0
 private void DelayDestroy()
 {
     PoolUtil.DeSpawnGameObject(gameObject);
     isDestroyed = true;
     // Destroy(this);
 }
Ejemplo n.º 16
0
 private void DelayDestroy()
 {
     Destroy(this);
     PoolUtil.DeSpawnGameObject(gameObject);
 }