예제 #1
0
    private void DestroyFood(slFood food)
    {
        slFoodPresentation foodPresentation = food.GetPresentation();

        if (foodPresentation != null)
        {
            foodPresentation.gameObject.SetActive(false);
            m_FoodPresentationPools[(int)foodPresentation.FoodType].Push(foodPresentation);
        }
        m_Foods.Remove(food.GetIndex());
        food.DeactiveFood();
        m_FoodPool.Push(food);

        m_FoodCount--;
    }
예제 #2
0
    private void CreateFood(slConstants.FoodType foodType, Vector3 position, Color color, float power)
    {
        slFoodProperties foodProperties = m_FoodPropertiess[(int)foodType];
        slFood           food           = m_FoodPool.Pop();
        int foodIndex = food.GetIndex();

        if (foodIndex == slConstants.FOOD_NOTSET_INDEX)
        {
            foodIndex = ++m_LastFoodIndex;
        }
        m_Foods.Add(foodIndex, food);
        slFoodPresentation foodPresentation = m_FoodPresentationPools != null ? m_FoodPresentationPools[(int)foodType].Pop() : null;

        if (foodPresentation != null)
        {
            foodPresentation.gameObject.SetActive(true);

            foodPresentation.SetColor(color);
        }
        food.ActiveFood(foodIndex, foodProperties, foodPresentation, position, color, power);
        m_FoodCount++;
    }