示例#1
0
文件: Rocket.cs 项目: KallumP/Bubbles
        /// <summary>
        /// Snaps to a particular bubble
        /// </summary>
        /// <param name="b">The bubble to snap to</param>
        /// <param name="x">The mouse x</param>
        /// <param name="y">The mouse y</param>
        public void Snap(Bubble b, int x, int y)
        {
            //sets what bubble it is snapped to
            snappedTo = b;

            //changes the status to snapped
            status = Statuses.tempSnapped;

            //updates the position to appear snapped
            UpdateSnapPos(x, y);
        }
示例#2
0
 public void DetachBubble(Bubble bubble)
 {
     for (int i = 0; i < linked.Length; i++)
     {
         if (linked[i] == bubble)
         {
             linked[i] = null;
             break;
         }
     }
 }
示例#3
0
        public void Init(int power)
        {
            var bubbleDataIndex = Settings.Bubbles.FindIndex(x => x.number == Bubble.GetNumber(power));

            if (bubbleDataIndex == -1)
            {
                return;
            }

            var bubbleData = Settings.Bubbles[bubbleDataIndex];

            back.color   = bubbleData.backColor;
            border.color = bubbleData.borderColor;
        }
        private void OnCurrentPowerChanged(int currentPower)
        {
            var bubbleDataIndex = settings.Bubbles.FindIndex(x => x.number == Bubble.GetNumber(sessionController.BubblesController.CurrentPower));

            if (bubbleDataIndex == -1)
            {
                return;
            }

            var color = settings.Bubbles[bubbleDataIndex].backColor;

            color.a        = (byte)(renderer.color.a * 255);
            renderer.color = color;
        }
        private void OnStartRaycasting()
        {
            var bubbleDataIndex = settings.Bubbles.FindIndex(x => x.number == Bubble.GetNumber(sessionController.BubblesController.CurrentPower));

            if (bubbleDataIndex == -1)
            {
                return;
            }

            var color = settings.Bubbles[bubbleDataIndex].backColor;

            color.a        = (byte)(renderer.color.a * 255);
            renderer.color = color;
            gameObject.SetActive(true);
        }
        private void GetAllLinks(Bubble bubble, List <Bubble> buffer)
        {
            for (int i = 0; i < SIDES_COUNT; i++)
            {
                var bubbleSide = i;
                var link       = bubble.GetLinked((BubbleSide)bubbleSide);

                if (link == null || buffer.Contains(link) || merged.Contains(link))
                {
                    continue;
                }

                buffer.Add(link);
                GetAllLinks(link, buffer);
            }
        }
示例#7
0
 /// <summary>
 /// Checks to see if a rocket needs to unsnap from the input bubble
 /// </summary>
 /// <param name="toUnsnap">The bubble being checked for rockets</param>
 public void CheckForUnSnap(Bubble toUnsnap)
 {
     //loops backwards through each of the rocket to apply the force
     for (int i = rockets.Count - 1; i >= 0; i--)
     {
         //makes sure that the rocket exists
         if (rockets[i] != null)
         {
             //checks to see if the current rocket was snapped to the current bubble
             if (rockets[i].snappedTo == toUnsnap)
             {
                 //unsnaps the rocket from the bubble
                 rockets[i].UnSnap();
             }
         }
     }
 }
示例#8
0
        private void OnBubbleReleased(Bubble bubble)
        {
            var bubbleSettingsIndex = bubbleSettings.Bubbles.FindIndex(x => x.number == bubble.CurrentNumber);

            if (bubbleSettingsIndex == -1)
            {
                return;
            }

            var bubbleData = bubbleSettings.Bubbles[bubbleSettingsIndex];

            var effect = effectsPool.GetOrInstantiate(MERGE_EFFECT_ID);

            effect.transform.position = bubble.transform.position;

            effect.SetColor(bubbleData.backColor);
            effect.Init(effectsPool);
        }
        private void CheckBubblePower(Bubble prevBubble, Bubble bubble, List <Bubble> linked)
        {
            for (int i = 0; i < SIDES_COUNT; i++)
            {
                var bubbleSide = i;
                var link       = bubble.GetLinked((BubbleSide)bubbleSide);

                if (link == null || link.Power != bubble.Power || prevBubble == link)
                {
                    continue;
                }

                if (!linked.Contains(link))
                {
                    linked.Add(link);
                    CheckBubblePower(bubble, link, linked);
                }
            }
        }
示例#10
0
        private void OnMerge(MergeInfo info)
        {
            var bubbleSettingsIndex = bubbleSettings.Bubbles.FindIndex(x => x.number == Bubble.GetNumber(info.power));

            if (bubbleSettingsIndex == -1)
            {
                return;
            }

            var bubbleData = bubbleSettings.Bubbles[bubbleSettingsIndex];

            var effect = effectsPool.GetOrInstantiate(MERGE_EFFECT_ID);

            effect.transform.position = sessionController.BubblesController.GetGlobalSpawnPosition(info.x, info.y);

            effect.SetColor(bubbleData.backColor);
            effect.Init(effectsPool);
        }
示例#11
0
 /// <summary>
 /// Removes a selected bubble from the list
 /// </summary>
 /// <param name="b">The bubble to remove</param>
 public void RemoveBubble(Bubble b)
 {
     //removes the bubble
     bubbles.Remove(b);
 }
示例#12
0
 /// <summary>
 /// Adds a new bubbles into the environment's list of bubbles
 /// </summary>
 /// <param name="b">The bubble to be added</param>
 public void AddBubble(Bubble b)
 {
     //adds the bubble into the list
     bubbles.Add(b);
 }
 private void Awake()
 {
     _animator = GetComponent <Animator>();
     _bubble   = GetComponent <Bubble>();
 }
示例#14
0
 private void Awake()
 {
     _audio  = GetComponent <AudioSource>();
     _bubble = GetComponent <Bubble>();
 }