当前位置: 首页>>代码示例>>C#>>正文


C# GameController.CreateSafeNet方法代码示例

本文整理汇总了C#中GameController.CreateSafeNet方法的典型用法代码示例。如果您正苦于以下问题:C# GameController.CreateSafeNet方法的具体用法?C# GameController.CreateSafeNet怎么用?C# GameController.CreateSafeNet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameController的用法示例。


在下文中一共展示了GameController.CreateSafeNet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Apply

    public void Apply(GameController gc)
    {
        switch (type)
        {
            case PowerUpType.lenght:
                gc.paddle.GetComponent<PaddleController>().ChangeState(PaddleController.PaddlePowerState.lenght);
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = false;
                }
                break;

            case PowerUpType.tripple:
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = false;
                }
                gc.paddle.GetComponent<PaddleController>().ChangeState(PaddleController.PaddlePowerState.normal);
                GameObject[] clones = new GameObject[gc.balls.Count * 2];
                int counter = 0;
                foreach(GameObject ball in gc.balls)
                {
                    Rigidbody2D rb2dOriginal = ball.GetComponent<Rigidbody2D>();
                    GameObject ballClone1 = Instantiate(ball, ball.transform.position, Quaternion.identity) as GameObject;
                    clones[counter++] = ballClone1;
                    Vector2 rndVector = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
                    Rigidbody2D rb2d = ballClone1.GetComponent<Rigidbody2D>();
                    rb2d.velocity = (rb2dOriginal.velocity + rndVector).normalized * rb2dOriginal.velocity.magnitude;
                    GameObject ballClone2 = Instantiate(ball, ball.transform.position, Quaternion.identity) as GameObject;
                    clones[counter++] = ballClone2;
                    rndVector = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
                    rb2d = ballClone2.GetComponent<Rigidbody2D>();
                    rb2d.velocity = (rb2dOriginal.velocity + rndVector).normalized * rb2dOriginal.velocity.magnitude;
                }
                gc.balls.AddRange(clones);
                break;

            case PowerUpType.speedUp:
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = false;
                }
                gc.paddle.GetComponent<PaddleController>().ChangeState(PaddleController.PaddlePowerState.normal);
                foreach (GameObject ball in gc.balls)
                {
                    Rigidbody2D rb2dOriginal = ball.GetComponent<Rigidbody2D>();
                    rb2dOriginal.velocity = new Vector2(rb2dOriginal.velocity.x + rb2dOriginal.velocity.normalized.x * 2,
                        rb2dOriginal.velocity.y + rb2dOriginal.velocity.normalized.y * 2);
                }
                break;

            case PowerUpType.speedDown:
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = false;
                }
                gc.paddle.GetComponent<PaddleController>().ChangeState(PaddleController.PaddlePowerState.normal);
                foreach (GameObject ball in gc.balls)
                {
                    Rigidbody2D rb2dOriginal = ball.GetComponent<Rigidbody2D>();
                    if (rb2dOriginal.velocity.magnitude >= 3)
                    {
                        rb2dOriginal.velocity = new Vector2(rb2dOriginal.velocity.x - rb2dOriginal.velocity.normalized.x * 2,
                            rb2dOriginal.velocity.y - rb2dOriginal.velocity.normalized.y * 2);
                    }
                }
                break;

            case PowerUpType.sticky:
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = false;
                }
                gc.paddle.GetComponent<PaddleController>().ChangeState(PaddleController.PaddlePowerState.sticky);
                gc.paddle.GetComponent<PaddleController>().stickyCount = 3;
                break;

            case PowerUpType.shooting:
                gc.paddle.GetComponent<PaddleController>().ChangeState(PaddleController.PaddlePowerState.shooting);
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = false;
                }
                break;

            case PowerUpType.penetrate:
                gc.paddle.GetComponent<PaddleController>().ChangeState(PaddleController.PaddlePowerState.normal);
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = true;
                }
                break;

            case PowerUpType.safe:
                foreach (GameObject ball in gc.balls)
                {
                    ball.GetComponent<CircleCollider2D>().isTrigger = false;
                }
                gc.CreateSafeNet();
                break;
//.........这里部分代码省略.........
开发者ID:Exerionius,项目名称:Exerinoid,代码行数:101,代码来源:PowerUp.cs


注:本文中的GameController.CreateSafeNet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。