예제 #1
0
    public void Initialize(slLevel level)
    {
        m_FoodRoot = new GameObject("Foods").transform;

        m_FoodMaxPosition = level.MapSize * 0.5f - new Vector2(slConstants.FOOD_MAP_EDGE, slConstants.FOOD_MAP_EDGE);
        m_FoodMinPosition = -m_FoodMaxPosition;

        m_MaxFood = level.FoodCount;

        m_FoodPropertiess = new slFoodProperties[(int)slConstants.FoodType.Count];
        for (int iFood = 0; iFood < m_FoodPropertiess.Length; iFood++)
        {
            m_FoodPropertiess[iFood] = hwmSystem.GetInstance().GetAssetLoader().LoadAsset(hwmAssetLoader.AssetType.Game
                                                                                          , slConstants.FOOD_PROPERTIES_PREFAB_STARTWITHS + slConstants.FoodTypeToString((slConstants.FoodType)iFood)) as slFoodProperties;
        }

        m_Quadtree = new hwmQuadtree <slFood>();
        m_Quadtree.Initialize(CalculateQuadtreeDepth()
                              , slConstants.FOOD_QUADTREE_MAXELEMENT_PERNODE
                              , slConstants.FOOD_QUADTREE_MINELEMENT_PREPARENTNODE
                              , new Vector2(slConstants.FOOD_QUADTREE_LOOSESIZE, slConstants.FOOD_QUADTREE_LOOSESIZE)
                              , slWorld.GetInstance().GetMap().GetMapBox());
#if UNITY_EDITOR
        slQuadtreeGizmos.FoodQuadtree = m_Quadtree;
#endif

        m_FoodPool = new FoodPool(m_FoodRoot);
        m_FoodPool.Initialize(Mathf.CeilToInt(m_MaxFood * slConstants.FOOD_POOL_INITIALIZE_MULTIPLY));
        if (slWorld.GetInstance().NeedPresentation())
        {
            m_FoodPresentationPools = new FoodPresentationPool[(int)slConstants.FoodType.Count];
            for (int iFood = 0; iFood < m_FoodPropertiess.Length; iFood++)
            {
                slConstants.FoodType foodType = (slConstants.FoodType)iFood;
                m_FoodPresentationPools[iFood] = new FoodPresentationPool(m_FoodRoot, foodType);
                m_FoodPresentationPools[iFood].Initialize(0);
            }
        }

        m_CreateEvents  = new Queue <CreateEvent>();
        m_Foods         = new hwmBetterDictionary <int, slFood>();
        m_DestroyEvents = new hwmBetterList <slFood>();
        m_FoodCount     = 0;
    }
예제 #2
0
    public void Initialize()
    {
        m_PoolRoot             = new GameObject("Snakes").transform;
        m_SnakeNameToIndex     = new Dictionary <string, int>();
        m_TweakablePropertiess = new Dictionary <string, slSnakeTweakableProperties>();
        m_Propertiess          = new List <slSnakeProperties>();

        m_HeadPools        = new List <NodePool <slSnake.HeadNode> >();
        m_ClothesNodePools = new List <NodePool <slSnake.ClothesNode> >();
        m_BodyPools        = new List <NodePool <slSnake.BodyNode> >();

        m_Quadtree = new hwmQuadtree <slSnake.QuadtreeElement>();
        m_Quadtree.Initialize(CalculateQuadtreeDepth()
                              , slConstants.SNAKE_QUADTREE_MAXELEMENT_PERNODE
                              , slConstants.SNAKE_QUADTREE_MINELEMENT_PREPARENTNODE
                              , new Vector2(slConstants.SNAKE_QUADTREE_LOOSESIZE, slConstants.SNAKE_QUADTREE_LOOSESIZE)
                              , slWorld.GetInstance().GetMap().GetMapBox());
        m_Quadtree.AutoMergeAndSplitNode = false;
#if UNITY_EDITOR
        slQuadtreeGizmos.SnakeQuadtree = m_Quadtree;
#endif
    }