Esempio n. 1
0
    void OnCollisionEnter(Collision coll)
    {
        if (coll.gameObject.CompareTag("Ball"))
        {
            ballController ball = coll.gameObject.GetComponent <ballController>();
            if (ball != null)
            {
                currentColour = ball.BallColour;
            }


            rend.material.SetColor("_Color", currentColour);

            if (impactSfxs != null)
            {
                audioSfx.clip = impactSfxs [Random.Range(0, impactSfxs.Length)];
                //Debug.Log(Quantiser.GetNextBeatTime() + " , dsptime = " + AudioSettings.dspTime);
                if (!audioSfx.isPlaying)
                {
                    audioSfx.PlayScheduled(Quantiser.GetNextBeatTime());
                }

                //audioSfx.Play ();
            }
        }
        if (coll.gameObject.CompareTag("Bullet"))
        {
            Destroy(coll.gameObject);
        }
    }
Esempio n. 2
0
 //检查用户的操作
 void ballLaunchCheck()
 {
     //判断自定义按键launchBall
     if (Input.GetButtonDown("launchBall"))
     {
         if (ballLaunchList.Count > 0)
         {
             GameObject     ball      = (GameObject)ballLaunchList[0];
             ballController ball_ctrl = ball.GetComponent <ballController>();
             if (!levelController.isLevelPaused && !levelController.isGameOver)
             {
                 ball_ctrl.launchBall();
                 ballLaunchList.Remove(ball);
                 //如果发射后球数小于等于1则删除text
                 if (ballLaunchList.Count <= 1)
                 {
                     Destroy(text_waitforLaunch_inscene);
                 }
                 else
                 {
                     Text text = text_waitforLaunch_inscene.GetComponent <Text>();
                     text.text = "+" + (ballLaunchList.Count - 1);
                 }
             }
         }
     }
 }
Esempio n. 3
0
    void Start()
    {
        //初始化ball
        ball = transform.parent.gameObject;
        //动画控制
        Transform anim_trans = ball.transform.Find("Anim_ballColor(Clone)");

        if (anim_trans != null)
        {
            anim             = anim_trans.gameObject;
            anim_ctrl        = anim.GetComponent <anim_ballColor>();
            anim_ctrl.toward = true;
        }
        else
        {
            anim      = Instantiate(anim_ballColor, ball.transform);
            anim_ctrl = anim.GetComponent <anim_ballColor>();
        }
        ctrl            = ball.GetComponent <ballController>();
        ctrl.isPowerful = true;
        //修改砖块的碰撞参数
        for (int i = 0; i < levelController.bricks.Count; i++)
        {
            GameObject obj = (GameObject)levelController.bricks[i];
            obj.GetComponent <PolygonCollider2D>().isTrigger = true;
        }
    }
Esempio n. 4
0
    //物体进入(球)
    private void OnTriggerEnter2D(Collider2D collision)
    {
        ballController ctrl = collision.gameObject.GetComponent <ballController>();

        if (ctrl != null)
        {
            //球进入死亡区域
            GameObject[] ballList = GameObject.FindGameObjectsWithTag("Ball");
            //判断当前场景内的球数 为1则消耗一条命 否则不消耗
            if (ballList.Length == 1)
            {
                if (levelController.leftBall > 0)
                {
                    levelController.newBall();
                }
                levelController.decreaseLeftBall(1);
                //更新UI
                gameUIContorller.updateLeftBallUI();
                //销毁游戏物体
                destoryBall(collision.gameObject);
            }
            else
            {
                destoryBall(collision.gameObject);
                //更改levelController的currentBall为场景内的球
                ballList = GameObject.FindGameObjectsWithTag("Ball");
                levelController.currentBall = ballList[0];
            }
        }
    }
Esempio n. 5
0
 private void Awake()
 {
     ball          = GameObject.Find("/Basketball Court/halfcourt/ball");
     player        = GameObject.Find("Main Camera");
     ball_script   = ball.GetComponent <ballController>();
     player_script = player.GetComponent <playerController>();
     //canvas = transform.parent.gameObject.GetComponent<CanvasGroup>();
 }
Esempio n. 6
0
    void Shoot()
    {
        // if(bolaki !=null && _firePoint != null && Player !=null)
        //{
        GameObject     myBall        = Instantiate(bolaki, _firePoint.position, Quaternion.identity);
        ballController BallComponent = myBall.GetComponent <ballController>();

        //}
    }
Esempio n. 7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        ballController ctrl = collision.gameObject.GetComponent <ballController>();

        if (ctrl != null)
        {
            playAnim("fadeout");
        }
    }
    //碰撞检测
    private void OnTriggerEnter2D(Collider2D collision)
    {
        ballController ball = collision.gameObject.GetComponent <ballController>();

        //检测碰撞的物体是否为ball
        if (ball != null)
        {
            Instantiate(particle_launcher, collision.gameObject.transform.position, new Quaternion(0, 0, 0, 0));
        }
    }
Esempio n. 9
0
    public override void OnCollisionEnter2D(Collision2D collision)
    {
        ballController ball = collision.gameObject.GetComponent <ballController>();

        //检测碰撞的物体是否为ball
        if (ball != null)
        {
            ballHit(collision.gameObject.transform.position);
        }
    }
Esempio n. 10
0
 public override void padGot()
 {
     foreach (GameObject obj in levelController.ballList)
     {
         ballController ctrl = obj.GetComponent <ballController>();
         ctrl.downSpeed();
     }
     Destroy(gameObject);
     base.padGot();
 }
Esempio n. 11
0
 public override void padGot()
 {
     for (int i = 0; i < levelController.ballList.Count; i++)
     {
         GameObject     ball = (GameObject)levelController.ballList[i];
         ballController ctrl = ball.GetComponent <ballController>();
         ctrl.enablePowerful();
     }
     Destroy(gameObject);
     base.padGot();
 }
Esempio n. 12
0
 public override void padGot()
 {
     for (int i = 0; i < levelController.ballList.Count; i++)
     {
         GameObject     obj  = (GameObject)levelController.ballList[i];
         ballController ctrl = obj.GetComponent <ballController>();
         ctrl.upBallSize();
     }
     Destroy(gameObject);
     base.padGot();
 }
Esempio n. 13
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        ballController ctrl = collision.gameObject.GetComponent <ballController>();

        if (ctrl != null)
        {
            ctrl.isAttracted = true;
            pad_ctrl.addBallToLaunchList(collision.gameObject);
            //关闭尾迹渲染
            ctrl.gameObject.GetComponent <TrailRenderer>().enabled = false;
            //清除力
            ctrl.gameObject.GetComponent <Rigidbody2D>().velocity = new Vector3(0, 0, 0);
        }
    }
Esempio n. 14
0
 void Start()
 {
     ctrl = ball.GetComponent <ballController>();
     //计算每帧变化量
     if (Time.deltaTime > 0)
     {
         deltaScale         = ctrl.deltaScale / (liveTime / Time.deltaTime);
         deltaScale_reverse = ctrl.deltaScale_reverse / (liveTime / Time.deltaTime);
     }
     else
     {
         deltaScale         = ctrl.deltaScale / (liveTime / 0.0167f);
         deltaScale_reverse = ctrl.deltaScale_reverse / (liveTime / 0.0167f);
     }
 }
    public void foulBall(GameObject Ball)
    {
        //Removes ball from circulation and puts it back into the ball tray, even if the bar is down.
        myballs.Remove(Ball);
        ballController BC = Ball.GetComponent <ballController>();

        if (BC.red)
        {
            freeRed++;
        }
        else
        {
            freeWhite++;
        }
        Destroy(Ball);
    }
Esempio n. 16
0
    //碰撞检测
    public virtual void OnCollisionEnter2D(Collision2D collision)
    {
        ballController ball = collision.gameObject.GetComponent <ballController>();

        //检测碰撞的物体是否为ball
        if (ball != null)
        {
            ballHit(collision.gameObject.transform.position);
        }
        else
        {
            Prop_shoot_bullet bullet = collision.gameObject.GetComponent <Prop_shoot_bullet>();
            if (bullet != null)
            {
                ballHit(collision.gameObject.transform.position);
                Destroy(collision.gameObject);
            }
        }
    }
Esempio n. 17
0
 // Use this for initialization
 public void Start()
 {
     ball               = GameObject.Find("/Basketball Court/halfcourt/ball");
     ball_script        = ball.GetComponent <ballController>();
     zone_red           = new Color32(255, 0, 0, 255);
     zone_green         = new Color32(0, 255, 0, 178);
     zone_grey          = new Color32(128, 128, 128, 255);
     zone_blue          = new Color32(75, 139, 148, 96);
     pre                = -2;
     cur                = -1;
     player0            = GameObject.Find("/Basketball Court/halfcourt/player0/polySurface17");
     player1            = GameObject.Find("/Basketball Court/halfcourt/player1/polySurface17");
     player2            = GameObject.Find("/Basketball Court/halfcourt/player2/polySurface17");
     TriggerPointer     = GameObject.Find("/Basketball Court/TriggerPointer/default");
     TriggerRenderer    = TriggerPointer.GetComponent <Renderer>();
     bIsPlayerInTrigger = false;
     bExitWalkThru      = false;
     walkThruClips      = GetComponents <AudioSource> ();
     playWalkthrough();
 }
Esempio n. 18
0
    void OnTriggerEnter2D(Collider2D col)
    {
        switch (col.tag)
        {
        case "hitCollision":
            print("Enemy1: Pé na Cabeça");
            _PC = FindObjectOfType(typeof(playerController)) as playerController;
            takeHit(_PC.ataqueBase, col);

            break;

        case "projetilPlayer":
            print("Enemy1: Bolinha");
            _BC = FindObjectOfType(typeof(ballController)) as ballController;
            takeHit(_BC.ataqueCalculado);
            Destroy(col.gameObject, 0.01f);
            break;

        case "hammerHit":
            print("Enemy1: Marreta");
            _HC = FindObjectOfType(typeof(HammerController)) as HammerController;
            takeHit(_HC.ataqueCalculado);
            break;

        case "headHit":
            print("Enemy1: Cabeçada");
            _PC = FindObjectOfType(typeof(playerController)) as playerController;
            takeHit(_PC.ataqueBase);
            if (_PC.transform.position.x <= transform.position.x)
            {
                rbDinosaur1.AddForce(new Vector2(130f, 100f));
            }
            else
            {
                rbDinosaur1.AddForce(new Vector2(-130f, -100f));
            }
            break;
        }
    }
Esempio n. 19
0
    //用于刷新新球的静态方法
    public static void newBall()
    {
        Vector3 position;

        if (_pad != null)
        {
            //获取位置并做偏移
            position    = pad.transform.position;
            position.y += ballInitOffset;
        }
        else
        {
            //抓取不到pad,使用默认位置
            position = new Vector3(0, -4.15f, 0);
        }

        //刷新球
        //初始球不刷新特效
        if (isLevelStarted)
        {
            Instantiate(particle_ray_launcher, position, new Quaternion(0, 0, 0, 0));
        }
        //刷新新球
        GameObject ball_new = Instantiate(_ball, position, new Quaternion(0, 0, 0, 0));

        currentBall = ball_new;
        //把球加入到球列表
        ballList.Add(ball_new);
        //加入待发射列表
        if (pad_ctrl == null)
        {
            findPad();
        }
        pad_ctrl.addBallToLaunchList(ball_new);
        ballController ctrl = ball_new.GetComponent <ballController>();

        //让球附在板子上
        ctrl.isAttracted = true;
    }
Esempio n. 20
0
    //Trigger
    private void OnTriggerEnter2D(Collider2D collision)
    {
        ballController ball_ctrl = collision.gameObject.GetComponent <ballController>();

        //检测碰撞的物体是否为ball
        if (ball_ctrl != null)
        {
            if (ball_ctrl.isPowerful || collision_type == 2)
            {
                ball = collision.gameObject;
                if (!ball_ctrl.isPowerful)
                {
                    //如果球打到了砖块则不认为球卡住
                    ball_ctrl.updateRecordPosition();
                    ballHit_trigger();
                }
                else
                {
                    //如果球打到了砖块则不认为球卡住
                    ball_ctrl.updateRecordPosition();
                    //Powerful状态下直接摧毁砖块
                    destroyBrick();
                }
            }
        }
        else
        {
            Prop_shoot_bullet bullet_ctrl = collision.gameObject.GetComponent <Prop_shoot_bullet>();
            if (bullet_ctrl != null && collision_type == 2)
            {
                ball = collision.gameObject;
                ballHit_trigger();
                Destroy(collision.gameObject);
            }
        }
    }
Esempio n. 21
0
 void Shoot()
 {
     GameObject     myBall        = Instantiate(bolaki, _firePoint.position, Quaternion.identity);
     ballController BallComponent = myBall.GetComponent <ballController>();
 }
Esempio n. 22
0
 // Find our ball
 void Start()
 {
     ball = FindObjectOfType<ballController> ();
 }
Esempio n. 23
0
 void Awake()
 {
     ball_Instance = this;
 }
Esempio n. 24
0
 void Awake()
 {
     gameMnagerObject = GameManager.gameMangerInstance;
     playerObject     = ballController.ball_Instance;
 }
Esempio n. 25
0
 // Use this for initialization
 void Start()
 {
     ball        = GameObject.Find("/Basketball Court/halfcourt/ball");
     ball_script = ball.GetComponent <ballController>();
 }
Esempio n. 26
0
    void Start()
    {
        diskCtrl          = disk.GetComponent <diskController>();
        ballCtrl          = ball.GetComponent <ballController>();
        manualDiskCtrl    = disk.GetComponent <manualDiskControl>();
        manualBallCtrl    = ball.GetComponent <manualBallControl>();
        diskStartPosition = diskCtrl.GetPosition();
        ballStartPosition = ballCtrl.GetPosition();
        CreateLineMaterial();
        //		Neural.learnRate = learnRate;
        List <float[, ]> weights = new List <float[, ]>();

        weights.Add(new float[, ] {
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
        });
        weights.Add(new float[, ] {
            { 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0 }
        });
        NewNet("Empty", new int[] { 3 * 4, 4, 3 }, weights);
        weights = new List <float[, ]>();
        weights.Add(new float[, ] {
            { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0 },
            { 0, 0, -0.3f, -0.0f, 0, 0, 0, 0, 0, 1, 0, 0, 0.0f }, { -0.3f, 0, 0, 0, 0, 0.0f, 0, 0, 0, 0, 0, -1, 0 }
        });
        weights.Add(new float[, ] {
            { 0, 0.6f, 0, 1f, 0 },
            { 0, 0, 0, 0, 0 },
            { 0.6f, 0, 1f, 0, 0 }
        });
        NewNet("Centering", new int[] { 3 * 4, 4, 3 }, weights);
        weights = new List <float[, ]>();
        weights.Add(new float[, ] {
            { 0, 0, 0, 0, 0, 0, 0.8f, 0, 0, 0, 0, 0.4f, 0.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, -0.8f, 0.4f, 0, 0, 0 },
            { 0, 0, -0.3f, -0.0f, 0, 0, 0, 0, 0, 0, 0, 0, 0.0f }, { -0.3f, 0, 0, 0, 0, 0.0f, 0, 0, 0, 0, 0, 0, 0 }
        });
        weights.Add(new float[, ] {
            { 0, .5f, 0, 1f, 0 },
            { 0, 0, 0, 0, 0 },
            { .5f, 0, 1f, 0, 0 }
        });
        NewNet("Looping", new int[] { 3 * 4, 4, 3 }, weights);
        weights = new List <float[, ]>();
        weights.Add(new float[, ] {
            { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1.0f }, { 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1.0f },
            { 0, 0, -0.3f, -0.0f, 0, 0, 0, 0, 0, 1, 0, 0, 0.5f }, { -0.3f, 0, 0, 0, 0, 0.0f, 0, 0, 0, 0, 0, -1, 0.5f }
        });
        weights.Add(new float[, ] {
            { 0, 0.6f, 0, 1f, 0 },
            { 0, 0, 0, 0, 0 },
            { 0.6f, 0, 1f, 0, 0 }
        });
        NewNet("OnEdge", new int[] { 3 * 4, 4, 3 }, weights);

        ChangeNet(true);

        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 0, 0, 1, 0, 0, 0, 10, 0, 0, 18, 0, 0 },
            weight        = 0.2f
        }, true);
        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 0, 0, 3, 0, 0, 0, 10, 0, 0, 16, 0, 0 },
            weight        = -0.2f
        }, true);



        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 3, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 18 },
            weight        = -0.2f
        }, false);
        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 16 },
            weight        = 0.2f
        }, false);


        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 0, 0, 1, 0, 0, 0, 13, 0, 0, 18, 0, 0 },
            weight        = 0.2f
        }, true);
        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 0, 0, 3, 0, 0, 0, 11, 0, 0, 16, 0, 0 },
            weight        = -0.2f
        }, true);



        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 3, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 18 },
            weight        = -0.2f
        }, false);
        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 16 },
            weight        = 0.2f
        }, false);



        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 0, 0, 1, 0, 0, 0, 14, 0, 0, 18, 0, 0 },
            weight        = 2.9f
        }, true);
        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 0, 0, 3, 0, 0, 0, 10, 0, 0, 16, 0, 0 },
            weight        = -2.9f
        }, true);



        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 3, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 18 },
            weight        = -2.9f
        }, false);
        FuzzyLogic.AddRule(new Rule
        {
            usedFunctions = new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 16 },
            weight        = 2.9f
        }, false);

        return;

        Color[] colors = new Color[] { Color.red, Color.yellow, Color.gray, Color.blue, Color.green };
        for (int z = 0; z < 4; z++)
        {
            for (int i = -50; i < 50; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    //if (j % 2 == 0) continue;
                    float i2 = i / 4f;
                    float x = MembershipFunctions.functionCollection[j + 5 * z](i2), x2 = MembershipFunctions.functionCollection[j + 5 * z](i2 - 1 / 4f);

                    Debug.DrawLine(Vector3.up * (1.5f * z + 3 + x) + Vector3.right * i2 / 10f, Vector3.up * (1.5f * z + 3 + x2) + Vector3.right * (i2 / 10f - 1 / 40f), colors[j], 100);
                }
            }
        }
    }
Esempio n. 27
0
 void Start()
 {
     ballCtrl = GetComponent <ballController>();
 }