예제 #1
0
    /// Remove all evidence of a ball just like in men in black but with less will smith
    public void RemoveBall(GameObject ball, CircleControl ballControl)
    {
        if (!activeBalls.Contains(ball))
        {
            Debug.LogError("Can't remove a removed ball!");
            return;
        }
        activeBalls.Remove(ball);
        activeBallColliders.Remove(ball.GetComponent <CircleControl>().tapCollider);
        activeUnfrozenBalls.Remove(ball);
        // allow new balls to be spawned in this slot
        usedBallSlots[ballControl.ballSlot] = false;

        if (gameMode == Mode.Lives)
        {
            LoseLife();
        }

        // end the round if no balls are being juggled and the first ball has been tapped
        if (activeUnfrozenBalls.Count == 0 && endOnBallsDropped && roundStartTime != -1)
        {
            EndRound();
        }
        else
        {
            sfx.Play(sfx.smash);              // don't play smash if timer is up
        }
    }
예제 #2
0
    private void Awake()
    {
        blockPositionList  = new List <Vector3>();
        foragePositionList = new List <Vector3>();

        CircleControl = FindObjectOfType <CircleControl>();
        circleRadius  = circlePrefab.GetComponent <CircleCollider2D>().radius * 2 + 0.5f;

        PrepareGame();
    }
예제 #3
0
	/// Slightly randomise eye size and spacing to make things a bit more interesting
	public void SetupSpacingAndSize() {
		circleControl = GetComponent<CircleControl>();
		
		eyeSpacing = Random.Range(eyeSpacingMin, eyeSpacingMax); // adjust position proportionally to ball size
		irises[0].transform.localPosition = new Vector2(-eyeSpacing * circleControl.actualRadius, 0);
		irises[1].transform.localPosition = new Vector2(eyeSpacing * circleControl.actualRadius, 0);
		
		eyeSize = Random.Range(eyeSizeMin, eyeSizeMax); // don't adjust size proportionally - small balls with big eyes are fun
		irises[0].transform.localScale = new Vector2(eyeSize, eyeSize);
		irises[1].transform.localScale = new Vector2(eyeSize, eyeSize);
	}
예제 #4
0
    /// Slightly randomise eye size and spacing to make things a bit more interesting
    public void SetupSpacingAndSize()
    {
        circleControl = GetComponent <CircleControl>();

        eyeSpacing = Random.Range(eyeSpacingMin, eyeSpacingMax);         // adjust position proportionally to ball size
        irises[0].transform.localPosition = new Vector2(-eyeSpacing * circleControl.actualRadius, 0);
        irises[1].transform.localPosition = new Vector2(eyeSpacing * circleControl.actualRadius, 0);

        eyeSize = Random.Range(eyeSizeMin, eyeSizeMax);         // don't adjust size proportionally - small balls with big eyes are fun
        irises[0].transform.localScale = new Vector2(eyeSize, eyeSize);
        irises[1].transform.localScale = new Vector2(eyeSize, eyeSize);
    }
예제 #5
0
    void SpawnBall()
    {
        if (activeBalls.Count >= maxBallsOnScreen)
        {
            return;             // don't spawn a new ball if there are too many already
        }
        // Create and set up a new ball
        float scale    = UnityEngine.Random.Range(minScale, maxScale);
        int   ballSlot = GetNewBallSlot();

        Vector2    position = new Vector2(GetXPosByBallSlot(ballSlot), UnityEngine.Random.Range(-maxYDistFromHorizontal, maxYDistFromHorizontal));
        GameObject ball     = (GameObject)Instantiate(ballPrefab, position, Quaternion.identity);

        CircleControl control = ball.GetComponent <CircleControl>();

        ball.GetComponent <SpriteRenderer>().color = ballColours[Random.Range(0, ballColours.Length)]; // assign a random colour
        control.SetupScale(scale);                                                                     // assign a random scale
        control.Freeze();
        control.ballSlot = ballSlot;
        activeBalls.Add(ball);
        activeBallColliders.Add(control.tapCollider);
        ball.GetComponent <BallAccessories>().AddRandomAccessory();        // some balls recieve a random accessory

        ballsSpawned++;

        if (ballsSpawned == 2)
        {
            if (gameMode == Mode.Timed)
            {
                UIController.ShowTutorialText("MORE BALLS = MORE POINTS");
                UIController.Invoke("HideTutorialText", UIController.tutorialDisplayTime);
            }
        }

        sfx.Play(sfx.pop);
    }
예제 #6
0
        /// <summary>
        /// element选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GridElements_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var select = gridElements.SelectedValue;

            if (select != null)
            {
                WatchElement element = (WatchElement)select;
                foreach (UIElement item in canvasMain.Children)
                {
                    Selector.SetIsSelected(item, false);
                }
                if (element.DesignerControl.Visibility == Visibility.Visible)
                {
                    Selector.SetIsSelected(element.DesignerControl, true);
                }

                if (element.HWElement is HWImage)
                {
                    ImageControl image = new ImageControl();
                    image.WatchElement = element;
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(image);
                }
                else if (element.HWElement is HWBox)
                {
                    BoxControl boxControl = new BoxControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(boxControl);
                }
                else if (element.HWElement is HWLine)
                {
                    LineControl Line = new LineControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(Line);
                }
                else if (element.HWElement is HWCircle)
                {
                    CircleControl circelControl = new CircleControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(circelControl);
                }
                else if (element.HWElement is HWSelectImage)
                {
                    SelecteImageControl selecte = new SelecteImageControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(selecte);
                }
                else if (element.HWElement is HWTextareaWithOneWildCard)
                {
                    TextareaWithOneWildCardControl textCtrl = new TextareaWithOneWildCardControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(textCtrl);
                }
                else if (element.HWElement is HWTextareaWithTwoWildCard)
                {
                    TextareaWithTwoWildCardControl textCtrl = new TextareaWithTwoWildCardControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(textCtrl);
                }
                else if (element.HWElement is HWTextureMapper)
                {
                    TextureMapperControl texture = new TextureMapperControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(texture);
                }
                else
                {
                    gridAttribute.Children.Clear();
                }
            }
        }
예제 #7
0
	/// Remove all evidence of a ball just like in men in black but with less will smith
	public void RemoveBall(GameObject ball, CircleControl ballControl) {
		if (!activeBalls.Contains(ball)) {
			Debug.LogError("Can't remove a removed ball!");
			return;
		}
		activeBalls.Remove(ball);
		activeBallColliders.Remove(ball.GetComponent<CircleControl>().tapCollider);
		activeUnfrozenBalls.Remove(ball);
		// allow new balls to be spawned in this slot
		usedBallSlots[ballControl.ballSlot] = false;
		
		if (gameMode == Mode.Lives) {
			LoseLife();
		}
		
		// end the round if no balls are being juggled and the first ball has been tapped
		if (activeUnfrozenBalls.Count == 0 && endOnBallsDropped && roundStartTime != -1) {
			EndRound();
		} else {
			sfx.Play(sfx.smash);  // don't play smash if timer is up
		}
	}