Пример #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
    public void ActiveFood(int index, slFoodProperties foodProperties, slFoodPresentation foodPresentation, Vector3 position, Color color, float power)
    {
        m_Index = index;
        m_State = State.Idle;

        gameObject.SetActive(true);

        m_Properties     = foodProperties;
        m_RemainLifeTime = hwmRandom.RandFloat(m_Properties.MinLifeTime, m_Properties.MaxLifeTime);

        m_Presentation = foodPresentation;
        SetPosition(position);

        OwnerQuadtree = slWorld.GetInstance().GetFoodSystem().GetQuadtree();
        AABB          = hwmBox2D.BuildAABB(transform.localPosition, new Vector2(m_Properties.Radius, m_Properties.Radius));
        OwnerQuadtree.UpdateElement(this);

        m_Power = power;
    }
Пример #3
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++;
    }