Exemplo n.º 1
0
    public void DeactiveFood()
    {
        if (OwnerQuadtree != null)
        {
            OwnerQuadtree.RemoveElement(this);
            OwnerQuadtree = null;
        }

        gameObject.SetActive(false);

        m_Properties = null;

        m_State = State.Notset;
    }
Exemplo n.º 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;
    }
Exemplo n.º 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++;
    }