예제 #1
0
    void addPlayer()
    {
        newplayer = Instantiate(playerfabs, this.transform);
        Player _player = newplayer.GetComponent <Player>();

        playerList.Add(_player);

        if (playerNum == 0)
        {
            _player.up       = inputs.player1and3StateInput(changeFinger.state, 0, "3");
            _player.down     = inputs.player1and3StateInput(changeFinger.state, 1, "3");
            _player.left     = inputs.player1and3StateInput(changeFinger.state, 2, "3");
            _player.right    = inputs.player1and3StateInput(changeFinger.state, 3, "3");
            _player.interact = inputs.player1and3StateInput(changeFinger.state, 4, "3");
        }
        if (playerNum == 1)
        {
            _player.up       = inputs.player2and4StateInput(changeFinger.state, 0, "4");
            _player.down     = inputs.player2and4StateInput(changeFinger.state, 1, "4");
            _player.left     = inputs.player2and4StateInput(changeFinger.state, 2, "4");
            _player.right    = inputs.player2and4StateInput(changeFinger.state, 3, "4");
            _player.interact = inputs.player2and4StateInput(changeFinger.state, 4, "4");
        }
        playerNum++;
    }
예제 #2
0
    void movingFinger(GameObject nowFinger)//主要指頭動作部分
    {
        var firstKnuckles = nowFinger.GetComponentsInChildren <first>();

        if (Input.GetKey(inputs.player1and3StateInput(state, 0, "1")))
        {
            firstKnuckles[2].GetComponent <addForceToThirdKnuckles>().thirdKnucklesRotateLeft();
        }
        if (Input.GetKey(inputs.player1and3StateInput(state, 1, "1")))
        {
            firstKnuckles[2].GetComponent <addForceToThirdKnuckles>().thirdKnucklesRotateRight();
        }
        if (Input.GetKey(inputs.player1and3StateInput(state, 2, "1")))
        {
            firstKnuckles[1].GetComponent <addForceToThirdKnuckles>().thirdKnucklesRotateLeft();
        }
        if (Input.GetKey(inputs.player1and3StateInput(state, 3, "1")))
        {
            firstKnuckles[1].GetComponent <addForceToThirdKnuckles>().thirdKnucklesRotateRight();
        }
        if (Input.GetKey(inputs.player2and4StateInput(state, 0, "2")))
        {
            firstKnuckles[0].GetComponent <addForceToThirdKnuckles>().thirdKnucklesRotateLeft();
        }
        if (Input.GetKey(inputs.player2and4StateInput(state, 1, "2")))
        {
            firstKnuckles[0].GetComponent <addForceToThirdKnuckles>().thirdKnucklesRotateRight();
        }
    }
예제 #3
0
    void Update()
    {
        if (shotTimes == 2)
        {
            print("close");
            Invoke("closeObject", 0.5f);
        }
        if (isActive)
        {
            this.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + speed);
            if (this.transform.position.y > maxY && isToOverMaxY)
            {
                speed        = speed * -1;
                isToOverMaxY = false;
            }
            else if (this.transform.position.y < minY && isToOverMaxY == false)
            {
                speed        = speed * -1;
                isToOverMaxY = true;
            }
        }

        if (Input.GetKeyDown(inputs.player1and3StateInput(changeFinger.state, 4, "3")) && shotTimes < 2 || Input.GetKeyDown(inputs.player2and4StateInput(changeFinger.state, 4, "4")) && shotTimes < 2)
        {
            if (bullet.activeInHierarchy == false)
            {
                soundManager.InitSoundeffect(2);
                print("shot");
                bullet.SetActive(true);
                bullet.transform.position = firePoint.transform.position;
                shotTimes++;
            }
        }


        if (bullet.activeInHierarchy == true)
        {
            foreach (GameObject go in fingertipList)
            {
                print("inLoop");
                if (Vector2.Distance(go.transform.position, bullet.transform.position) < 2f)
                {
                    if (changeFinger.state == 1)
                    {
                        uiManager.blueTeamScorePlus(5);
                    }
                    if (changeFinger.state == 0)
                    {
                        uiManager.redTeamScorePlus(5);
                    }
                    print("hit");
                    soundManager.InitSoundeffect(1);
                    bullet.SetActive(false);
                    go.transform.parent.transform.parent.transform.Rotate(new Vector3(0, 0, 90f));
                    Debug.Log("hit kuncle");
                }
            }
        }
    }
예제 #4
0
파일: Player.cs 프로젝트: aekly268/CityApe
 // Update is called once per frame
 void Update()
 {
     if (gameObject.name == "Player (1)")
     {
         up       = inputs.player1and3StateInput(changeFinger.state, 0, "3");
         down     = inputs.player1and3StateInput(changeFinger.state, 1, "3");
         left     = inputs.player1and3StateInput(changeFinger.state, 2, "3");
         right    = inputs.player1and3StateInput(changeFinger.state, 3, "3");
         interact = inputs.player1and3StateInput(changeFinger.state, 4, "3");
     }
     if (gameObject.name == "Player (2)")
     {
         up       = inputs.player2and4StateInput(changeFinger.state, 0, "4");
         down     = inputs.player2and4StateInput(changeFinger.state, 1, "4");
         left     = inputs.player2and4StateInput(changeFinger.state, 2, "4");
         right    = inputs.player2and4StateInput(changeFinger.state, 3, "4");
         interact = inputs.player2and4StateInput(changeFinger.state, 4, "4");
     }
     move();
     raycastBox();
 }
예제 #5
0
    void Update()
    {
        //定位點功能
        if (UImanager.isGameStart)
        {
            checkPoint();
        }


        //外對內妨礙功能

        if (aimFunction)
        {
            leftGun.SetActive(true);
            aimPoint.SetActive(true);
            if (Input.GetKey(inputs.player1and3StateInput(changeFinger.state, 0, "1")))
            {
                aimPoint.transform.Translate(Vector2.up * 5 * Time.deltaTime);
            }
            if (Input.GetKey(inputs.player1and3StateInput(changeFinger.state, 1, "1")))
            {
                aimPoint.transform.Translate(Vector2.down * 5 * Time.deltaTime);
            }
            if (Input.GetKey(inputs.player1and3StateInput(changeFinger.state, 2, "1")))
            {
                aimPoint.transform.Translate(Vector2.left * 5 * Time.deltaTime);
            }
            if (Input.GetKey(inputs.player1and3StateInput(changeFinger.state, 3, "1")))
            {
                aimPoint.transform.Translate(Vector2.right * 5 * Time.deltaTime);
            }

            if (Input.GetKeyDown(inputs.player2and4StateInput(changeFinger.state, 4, "2")))
            {
                soundManager.InitSoundeffect(3);
                aimFunction = !aimFunction;
                aimPoint.SetActive(false);
                leftGun.SetActive(false);
                if (handPoseModChange.r == 0)
                {
                    handPoseModChange.r++;
                }
                if (handPoseModChange.r == 2)
                {
                    handPoseModChange.r--;
                }
                if (handPoseModChange.r > 0 && handPoseModChange.r < 2)
                {
                    handPoseModChange.r++;
                }

                for (int i = 0; i < players.Length; i++)//在內的玩家兩位
                {
                    if (Vector2.Distance(players[i].transform.position, aimPoint.transform.position) <= 1.0f)
                    {
                        soundManager.InitSoundeffect(4);
                        if (changeFinger.state == 0)
                        {
                            uiManager.blueTeamScorePlus(5);
                        }
                        if (changeFinger.state == 1)
                        {
                            uiManager.redTeamScorePlus(5);
                        }
                        Debug.Log("74283954893270");//對內效果
                    }
                }
            }
        }
    }