Beispiel #1
0
        protected void Start()
        {
            m_cheese.SetActive(value: false);
            m_meshFilter.mesh           = new Mesh();
            m_meshFilter.mesh.vertices  = new Vector3[0];
            m_meshFilter.mesh.triangles = new int[0];
            Texture2D texture2D = (Texture2D)m_meshRenderer.material.GetTexture("_MainTex");
            float     num       = (float)texture2D.width * 0.5f / 10f;
            float     num2      = (float)texture2D.height * 0.5f / 10f;

            m_gameXSpacing = m_baseRenderer.sprite.bounds.size.x * 0.5f / 10f;
            m_gameYSpacing = m_baseRenderer.sprite.bounds.size.y * 0.5f / 10f;
            m_xRadius      = m_baseRenderer.sprite.bounds.size.x * 0.2f;
            m_yRadius      = m_baseRenderer.sprite.bounds.size.y * 0.2f;
            m_pizzaPoints  = new mg_pt_PizzaPoint[21, 21];
            for (int i = 0; i < 21; i++)
            {
                for (int j = 0; j < 21; j++)
                {
                    float a = texture2D.GetPixel(Mathf.RoundToInt((float)i * num), Mathf.RoundToInt((float)j * num2)).a;
                    m_pizzaPoints[i, j] = new mg_pt_PizzaPoint
                    {
                        Transparent = (texture2D.GetPixel(Mathf.RoundToInt((float)i * num), Mathf.RoundToInt((float)j * num2)).a < 0.1f),
                        SauceAdded  = false
                    };
                    if (!m_pizzaPoints[i, j].Transparent)
                    {
                        m_totalPizzaPoints++;
                    }
                }
            }
        }
Beispiel #2
0
        public bool ContainsPoint(Vector2 p_globalPoint)
        {
            Vector2          p_localPoint      = base.transform.InverseTransformPoint(p_globalPoint);
            mg_pt_PizzaPoint mg_pt_PizzaPoint2 = CalculatePizzaPoint(p_localPoint);
            bool             result            = false;

            if (!(mg_pt_PizzaPoint2?.Transparent ?? true))
            {
                result = true;
            }
            return(result);
        }
Beispiel #3
0
        private bool WillAddSauce(mg_pt_Topping p_sauce)
        {
            bool             result            = false;
            Vector2          p_localPoint      = base.transform.InverseTransformPoint(p_sauce.SaucePosition);
            mg_pt_PizzaPoint mg_pt_PizzaPoint2 = null;
            float            num    = Mathf.Pow(m_xRadius * base.transform.lossyScale.x, 2f);
            float            num2   = Mathf.Pow(m_yRadius * base.transform.lossyScale.y, 2f);
            float            num3   = 0f - m_xRadius + p_localPoint.x;
            float            num4   = 0f - m_yRadius + p_localPoint.y;
            float            num5   = num4;
            Vector2          vector = CalculatePizzaPointIndex(p_localPoint);

            vector.y = Mathf.Abs(vector.y);
            while (num3 <= m_xRadius + p_localPoint.x)
            {
                float num6 = num3 * base.transform.lossyScale.x;
                float num7 = Mathf.Pow(num6 - p_localPoint.x, 2f);
                for (; num4 <= p_localPoint.y; num4 += m_gameYSpacing)
                {
                    float num8  = num4 * base.transform.lossyScale.y;
                    float num9  = Mathf.Pow(num8 - p_localPoint.y, 2f);
                    float num10 = num7 / num + num9 / num2;
                    if (!(num10 <= 1f))
                    {
                        continue;
                    }
                    Vector2 vector2 = CalculatePizzaPointIndex(new Vector2(num6, num8));
                    int     num11   = (int)(vector.y - vector2.y);
                    for (int i = (int)vector2.y; (float)i <= vector.y + (float)num11; i++)
                    {
                        mg_pt_PizzaPoint2 = GetPizzaPoint(new Vector2(vector2.x, i));
                        if (mg_pt_PizzaPoint2 != null && !mg_pt_PizzaPoint2.Transparent && !mg_pt_PizzaPoint2.SauceAdded)
                        {
                            result = true;
                            mg_pt_PizzaPoint2.SauceAdded = true;
                            m_saucePointsAdded++;
                        }
                    }
                    break;
                }
                num3 += m_gameXSpacing;
                num4  = num5;
            }
            return(result);
        }