예제 #1
0
    private void SetUpNextEnviroment(GameEnviroment ge)
    {
        float newX = 0;

        //Randomise the position of the next gbb
        if (targetRange.x < targetRange.y)
        {
            newX = UnityEngine.Random.Range(targetRange.x, targetRange.y);
        }
        if (targetRange.y < targetRange.x)
        {
            newX = UnityEngine.Random.Range(targetRange.y, targetRange.x);
        }
        ge.gbb.transform.position = new Vector3(newX, ge.gbb.transform.position.y, 0);
        // Calculate game target size based on score and difficulty
        float xDiff = 1;
        float yDiff = 1;

        if (difficulty)
        {
            Vector2 diff = difficulty.GetGoalSize(score);
            xDiff = diff.x;
            yDiff = diff.y;
        }
        // Determine size of target
        Vector2 newSize = new Vector2((ge.gbb.transform.localScale.x + targetIncrease.x) * xDiff,
                                      (ge.gbb.transform.transform.localScale.y + targetIncrease.y) * yDiff);

        // Increase size of game target
        ge.gbb.transform.localScale = newSize;
        // Add spin/flair
        float   randZ  = UnityEngine.Random.Range(flairStrength.x, flairStrength.y);
        Vector3 newRot = new Vector3(0, 0, randZ);

        ge.gbb.transform.DORotate(newRot, flairDuration, RotateMode.FastBeyond360);
        // Add Pan
        if (score >= difficulty.addPanAt)
        {
            Pan newPan = ge.gbb.gameObject.AddComponent <Pan>();
            newPan.target   = new Vector2(-ge.gbb.transform.position.x, ge.gbb.transform.localPosition.y);
            newPan.duration = difficulty.GetPanDuration(score);
        }

        // Calculate players gbb size based on score and difficulty
        if (difficulty)
        {
            Vector2 diff = difficulty.GetGbbSize(score);
            xDiff = diff.x;
            yDiff = diff.y;
        }
        // Determine size of the players gbb
        newSize = new Vector2((player.GetComponent <ThingController>().bounds.transform.lossyScale.x + boundsIncrease.x) * xDiff, (player.GetComponent <ThingController>().bounds.transform.lossyScale.y + boundsIncrease.y) * yDiff);
        //Increase size of players gbb
        player.GetComponent <ThingController>().bounds.transform.DOScale(newSize, animationDuration);
        if (player.GetComponent <ThingController>().bounds.GetComponent <Pan>())
        {
            Destroy(player.GetComponent <ThingController>().bounds.GetComponent <Pan>());
        }
    }
예제 #2
0
 protected override void LoadContent()
 {
     spriteBatch               = new SpriteBatch(GraphicsDevice);
     AnimationLoader.content   = Content;
     RectangleGenerator.device = GraphicsDevice;
     //TODO: switch healthbar to use the rectangle generator
     HealthBar.device = GraphicsDevice;
     Constants.setConstants(Window.ClientBounds);
     left  = new AICastle(CharacterEnums.EDirection.RIGHT, Constants.leftBaseX);
     right = new AICastle(CharacterEnums.EDirection.LEFT, Constants.rightBaseX);
     env   = new GameEnviroment(Window.ClientBounds, left, right);
 }