Exemplo n.º 1
0
    private void ManagePetalsLoss()
    {
        m_LoseTimer -= Time.deltaTime;
        if (m_LoseTimer < 0)
        {
            if (m_PetalsDownMatchingPattern.Count > 0)
            {
                Petal leavingPetal = m_PetalsDownMatchingPattern[0];
                leavingPetal.Leave();
                m_PetalsDownMatchingPattern.Remove(leavingPetal);
            }
            else
            {
                m_CanLeaveOtherPetals = true;
            }

            if (m_CanLeaveOtherPetals)
            {
                if (m_PetalsUpCount > LevelManager.FlowerToMatch.m_PetalsUpCount)
                {
                    for (int j = 0; j < Petals.Count; j++)
                    {
                        if (!LevelManager.PetalsDownIndexes.Contains(j) && Petals[j].IsUp)
                        {
                            Petals[j].Leave();
                            break;
                        }
                    }
                }
            }
            m_LoseTimer = Random.Range(m_MinLoseTime, m_MaxLoseTime);
        }
    }
Exemplo n.º 2
0
 public Petal(int d)
 {
     data   = d;
     right  = null;
     left   = null;
     parent = null;
 }
Exemplo n.º 3
0
    private IEnumerator OpenRoutine(Petal petal)
    {
        busy = true;

        if (prevPetal != petal)
        {
            prevPetal       = petal;
            inputField.text = "";
        }

        petalTitle.text       = petal.ToString().ToLower();
        petalDescription.text = Petals.PetalDescription(petal);
        petalQuestions.text   = Petals.PETAL_QUESTIONS[(int)petal].Replace("|", System.Environment.NewLine + System.Environment.NewLine);
        background.color      = Color.Lerp(Petals.PetalColor(petal), Color.black, 0.5f);

        group.blocksRaycasts     = true;
        background.raycastTarget = true;

        for (float f = 0; f < fadeLength; f += Time.deltaTime)
        {
            group.alpha = Mathf.SmoothStep(0, 1, f / fadeLength);
            SetBackgroundAlpha(group.alpha);
            yield return(null);
        }

        group.alpha = 1;
        SetBackgroundAlpha(1);
        group.interactable = true;

        open = true;
        busy = false;
    }
Exemplo n.º 4
0
 public void Open(Petal petal)
 {
     if (!open && !busy)
     {
         StartCoroutine(OpenRoutine(petal));
     }
 }
Exemplo n.º 5
0
    // ========================================================================================================================

    // This is called by the CommentEntryFlower when one of its petals is clicked,
    // signifying that the user wants to enter a comment for that petal.

    public void PetalClicked(Petal petal)
    {
        if (state == CommentEntryState.FlowerScreen)
        {
            StartCoroutine(FlowerScreenToEntryScreenRoutine(petal));
        }
    }
Exemplo n.º 6
0
    public Petal AddPetalToFolder()
    {
        Petal newPetal = Instantiate(petalPrefab, petalParent.transform).GetComponent <Petal>();

        newPetal.transform.parent = petalParent.transform;
        folder.AddPetal(newPetal);
        folder.isDirty = true;
        return(newPetal);
    }
Exemplo n.º 7
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Debug.Log("Enter Final");
        Petal petal = col.gameObject.GetComponent <Petal>();

        if (petal != null)
        {
            EventManager.Instance.PostEvent(EventDefine.EnterFinal);
        }
    }
Exemplo n.º 8
0
    void OnTriggerEnter(Collider col)
    {
        Petal petal = col.GetComponent <Petal>();

        if (petal != null)
        {
            petal.myGrowInfo.type            = toType;
            petal.myGrowInfo.affectPointArea = this;
        }
    }
Exemplo n.º 9
0
    private IEnumerator FlowerScreenToEntryScreenRoutine(Petal petal)
    {
        state = CommentEntryState.Busy;

        entryScreen.Open(petal);
        CommentCreator.PETAL = petal.ToString();
        yield return(new WaitForSeconds(0.3f));

        state = CommentEntryState.EntryScreen;
    }
Exemplo n.º 10
0
    public Petal AddPetalToFolder(Sprite icon, string name)
    {
        Petal newPetal = Instantiate(petalPrefab, petalParent.transform).GetComponent <Petal>();

        newPetal.iconImage.texture = icon.texture;
        newPetal.name = name;
        newPetal.transform.SetParent(petalParent.transform, false);
        folder.AddPetal(newPetal);
        folder.isDirty = true;
        return(newPetal);
    }
Exemplo n.º 11
0
        internal override void Update(Farmer who, GameLocation location)
        {
            // Ensure we can force a critter to appear
            if (location.critters is null)
            {
                location.critters = new List <Critter>();
            }

            // Spawn petal
            _petal = new Petal(who.getTileLocation(), 0, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f);

            location.critters.Add(_petal);
        }
Exemplo n.º 12
0
    void OnTriggerStay2D(Collider2D col)
    {
        Petal petal = col.GetComponent <Petal>();

        if (petal != null)
        {
            float distrubution = Mathf.Pow(distrubutionX.Evaluate(petal.transform.position.x), 1f)
                                 * Mathf.Pow(distrubutionY.Evaluate(petal.transform.position.y), 1f);

            petal.AddForce(tempIntense * tempDirection.normalized * distrubution);
            // rigid.AddTorque(Random.Range(torqueIntense.min, torqueIntense.max));
        }
    }
Exemplo n.º 13
0
    public void Initialize(CommentEntryFlower flower, Transform lookAt, Petal petal)
    {
        this.flower = flower;
        this.lookAt = lookAt;
        this.petal  = petal;

        rect.SetParent(flower.transform);
        rect.localPosition = Vector3.zero;
        rect.localScale    = Vector3.one;

        colorDefault = Petals.PetalColor(petal);
        text.text    = petal.ToString().ToLower();
    }
Exemplo n.º 14
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (isEntered)
        {
            return;
        }
        Petal petal = col.gameObject.GetComponent <Petal>();

        if (petal != null)
        {
            EventManager.Instance.PostEvent(EventDefine.AddSwipeTime);
            isEntered = true;
        }
    }
Exemplo n.º 15
0
    virtual public void CreatePatel()
    {
        GameObject petalObj = Instantiate(petalPrefabList[Random.Range(0, petalPrefabList.Count)]) as GameObject;

        petalObj.transform.parent        = petalRoot;
        petalObj.transform.localPosition = Vector3.zero;
        petalObj.transform.localScale    = Vector3.one;

        Petal petal = petalObj.GetComponent <Petal>();

        petal.Init(this, petals.Count);
        petals.Add(petal);

        initPetalTime = Time.time;
    }
Exemplo n.º 16
0
 void OnPetalDestory(Message msg)
 {
     if (msg.ContainMessage("petal"))
     {
         Petal p = msg.GetMessage("petal") as Petal;
         for (int i = 0; i < blowPetals.Count; ++i)
         {
             if (blowPetals[i].ID == p.ID)
             {
                 blowPetals.Clear();
                 CameraStopFollow();
                 break;
             }
         }
     }
 }
Exemplo n.º 17
0
    void Start()
    {
        // GameObjects
        player = GameObject.Find("Player").GetComponent <Player>();

        // Components
        thisTransform = transform;

        // Init
        completed      = false;
        fullyCompleted = false;
        petals         = new Petal[thisTransform.childCount];
        for (int i = 0; i < thisTransform.childCount; i++)
        {
            petals[i] = thisTransform.GetChild(i).GetComponent <Petal>();
            petals[i].setAlive(false);
        }
    }
Exemplo n.º 18
0
    void OnGrowFlower(Message msg)
    {
        Petal p = msg.sender as Petal;

        CameraStopFollow();

        if (p != null)
        {
            for (int i = 0; i < blowPetals.Count; ++i)
            {
                if (blowPetals[i].ID == p.ID)
                {
                    blowPetals.Clear();
                    break;
                }
            }
        }
    }
Exemplo n.º 19
0
    protected bool canBlow(Vector2 velocity)
    {
        if (velocity.magnitude < minBlowVelocity)
        {
            return(false);
        }
        if (petals.Count < petalNum - 1)
        {
            return(false);
        }
        Petal petal = petals[0];

        if (petal != null && Time.time - initPetalTime < petal.GetGrowTime())
        {
            return(false);
        }

        return(base.canBlow());
    }
Exemplo n.º 20
0
 public void Add(int d)
 {
     if (root != null)
     {
         Petal newPetal     = new Petal(d);
         Petal currentPetal = root;
         while (currentPetal != null)
         {
             if (newPetal.data > currentPetal.data)
             {
                 if (currentPetal.right != null)
                 {
                     currentPetal = currentPetal.right;
                 }
                 else
                 {
                     currentPetal.right = newPetal;
                     newPetal.parent    = currentPetal;
                     break;
                 }
             }
             if (newPetal.data < currentPetal.data)
             {
                 if (currentPetal.left != null)
                 {
                     currentPetal = currentPetal.left;
                 }
                 else
                 {
                     currentPetal.left = newPetal;
                     newPetal.parent   = currentPetal;
                     break;
                 }
             }
         }
     }
     else
     {
         root = new Petal(d);
     }
 }
Exemplo n.º 21
0
    // Gets the description that explains the given petal.

    public static string PetalDescription(Petal petal)
    {
        switch (petal)
        {
        case Petal.Site:        return("to realign how people understand and relate to the natural environment that sustains us");

        case Petal.Water:       return("to realign how people use water and to redefine 'waste' in the built environment so that water is respected as a precious resource");

        case Petal.Energy:      return("to signal a new age of design, wherein the built environment relies solely on renewable forms of energy and operates year round in a safe, pollution-free manner");

        case Petal.Equity:      return("to transform developments to foster a true, inclusive sense of community that is just and equitable regardless of an individual’s background, age, class, race, gender or sexual orientation");

        case Petal.Health:      return("to focus on the most important environmental conditions that must be present to create robust, healthy spaces");

        case Petal.Beauty:      return("to recognize the need for beauty as a precursor to caring enough to preserve, conserve, and serve the greater good");

        case Petal.Materials:   return("to help create a materials economy that is non-toxic, ecologically restorative, transparent, and socially equitable");

        default:                return("");
        }
    }
Exemplo n.º 22
0
    // Gets the color that represents the given petal.

    public static Color PetalColor(Petal petal)
    {
        switch (petal)
        {
        case Petal.Site:        return(RGB(196, 217, 48));

        case Petal.Water:       return(RGB(26, 187, 214));

        case Petal.Energy:      return(RGB(255, 205, 7));

        case Petal.Equity:      return(RGB(131, 166, 62));

        case Petal.Health:      return(RGB(144, 215, 233));

        case Petal.Beauty:      return(RGB(139, 91, 132));

        case Petal.Materials:   return(RGB(242, 156, 54));

        default:                return(Color.black);
        }
    }
Exemplo n.º 23
0
    public Petal search(int val)
    {
        Petal currentPetal = root;

        while (currentPetal != null)
        {
            if (currentPetal.data == val)
            {
                return(currentPetal);
            }
            else if (val > currentPetal.data)
            {
                currentPetal = currentPetal.right;
            }
            else
            {
                currentPetal = currentPetal.left;
            }
        }
        return(null);
    }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            LST myLst = new LST();

            //добавление в список
            myLst.Add(1);
            myLst.Add(2);
            myLst.Add(3);
            myLst.Add(2);
            //вывод на экран
            myLst.Show();
            Console.WriteLine("\n");
            //удаление из списка по индексу(начало с 1)
            myLst.Remove(2);
            myLst.Show();
            Console.WriteLine("\n");
            //реверс
            myLst.Reverse();
            //myLst.Add(88);
            myLst.Show();
            Console.WriteLine("\n");

            BinTree Tree = new BinTree();

            //добавление в бинарное дерево

            /*
             * Tree.Add(10);
             * Tree.Add(7);
             * Tree.Add(12);
             * Tree.Add(6);
             * Tree.Add(9);
             * Tree.Add(11);
             * Tree.Add(14);
             * Tree.Add(3);
             * Tree.Add(4);
             * Tree.Add(8);*/

            Tree.Add(10);
            Tree.Add(3);
            Tree.Add(12);
            Tree.Add(11);
            Tree.Add(14);
            Tree.Add(2);
            Tree.Add(1);
            Tree.Add(6);
            Tree.Add(8);
            Tree.Add(5);

            /* Tree.Add(14);
             * Tree.Add(9);
             * Tree.Add(19);
             * Tree.Add(1);
             * Tree.Add(10);
             * Tree.Add(12);
             * Tree.Add(8);*/


            //показ дерева
            Tree.Show2(0, null);

            //поиск по значению, возвращает узел
            Petal p = Tree.search(12);

            if (p != null)
            {
                Console.Write("Найдено:" + p.data);
            }
            else
            {
                Console.Write("Нет узла с заданным значением");
            }
            //удаление узла
            Tree.remove(p);
            Console.Write("\n");
            Tree.Show2(0, null);



            //сортировка вставками
            int[] A = new int[10] {
                5, 3, 2, 7, 1, -4, 0, 2, 3, 2
            };
            sortA(A);
            Console.Write("\n");
            for (int i = 0; i < A.Length; i++)
            {
                Console.Write(A[i] + " ");
            }

            Console.ReadKey();
        }
Exemplo n.º 25
0
    // Allows the petals to check if they are the most recently touched petal.

    public bool IsRecentPetal(Petal petal)
    {
        return(petal == recentPetal);
    }
Exemplo n.º 26
0
    // Allows the petals to report that they have received a touch,
    // which allows the flower to keep track of the most recently touched petal.

    public void PetalDown(Petal petal)
    {
        recentPetal = petal;
    }
Exemplo n.º 27
0
    // Allows the petals to get what size they should be.

    public float GetScale(Petal petal)
    {
        return(1);
    }
Exemplo n.º 28
0
    // Allows the petals to report that they were clicked,
    // which the flower reports to the CommentEntryManager.

    public void PetalClicked(Petal petal)
    {
        manager.PetalClicked(petal);
    }
Exemplo n.º 29
0
    public void remove(Petal curPetal)
    {
        if (curPetal.left == null && curPetal.right == null)
        {
            Petal parentPetal = curPetal.parent;
            if (curPetal == parentPetal.left)
            {
                parentPetal.left = null;
            }
            if (curPetal == parentPetal.right)
            {
                parentPetal.right = null;
            }
        }

        if ((curPetal.left == null && curPetal.right != null) || (curPetal.left != null && curPetal.right == null))
        {
            if (curPetal.parent.left == curPetal)
            {
                if (curPetal.left != null)
                {
                    curPetal.parent.left = curPetal.left;
                }
                else
                {
                    curPetal.parent.left = curPetal.right;
                }
            }
            if (curPetal.parent.right == curPetal)
            {
                if (curPetal.right != null)
                {
                    curPetal.parent.right = curPetal.right;
                }
                else
                {
                    curPetal.parent.right = curPetal.left;
                }
            }
        }

        if (curPetal.left != null && curPetal.right != null)
        {
            if (curPetal.right != null && curPetal.right.left != null)
            {
                Petal leftTree = curPetal.left;
                Petal start    = curPetal.right.left;
                while (start.left != null)
                {
                    start = start.left;
                }

                start.parent.left = null;
                Petal rightTree = curPetal.right;
                start.left  = leftTree;
                start.right = rightTree;
                if (curPetal.parent.left == curPetal)
                {
                    curPetal.parent.left = start;
                }
                else
                {
                    curPetal.parent.right = start;
                }
                return;
            }
            if (curPetal.right != null && curPetal.right.left == null)
            {
                Console.Write("HERE");
                Petal leftChild  = curPetal.left;
                Petal rightChild = curPetal.right;
                rightChild.left = leftChild;
                if (curPetal.parent.left == curPetal)
                {
                    curPetal.parent.left = rightChild;
                }
                else
                {
                    curPetal.parent.right = rightChild;
                }
            }
        }
    }
 protected override void OnSizeAllocated(Gdk.Rectangle allocation)
 {
     base.OnSizeAllocated(allocation);
     blossom = Petal.CalculateBlossom(allocation.Width, allocation.Height);
 }