Пример #1
0
    void Update()
    {
        if (Input.GetButtonDown("Time+"))
        {
            Time.timeScale += 1;
        }
        if (Input.GetButtonDown("Time-"))
        {
            Time.timeScale -= 1;
        }
        if (Input.GetButtonDown("TimeReset"))
        {
            Time.timeScale = 1;
        }

        if (PlayerTypeManager.GetInstance().AllowNewPlayer())
        {
            for (int cont = 0; cont < 4; cont++)
            {
                if (Input.GetButtonDown("Player" + cont + "_START"))
                {
                    foreach (GameObject player in players)
                    {
                        if (player.GetComponent <PlayerMovementScript>().playerID == cont)
                        {
                            return;
                        }
                    }
                    NewPlayer(cont);
                }
            }
        }
    }
Пример #2
0
    /// <summary>
    /// プレイヤーを生成
    /// </summary>
    void GeneratePlayer(int index)
    {
        //ボールの生成
        var ball = Instantiate(ballPrefab);

        ball.transform.SetPositionAndRotation(generateTransforms[index].position,
                                              generateTransforms[index].rotation);
        var player = PlayerTypeManager.GetInstance().GeneratePlayer(index, PlayerTypeManager.SceneType.Game);

        var ballBehaviour = ball.GetComponent <BallBehaviour>();

        ballBehaviour.SetPlayerIndex(index);
        //プレイヤーにセットする
        player.transform.parent        = ball.transform;
        player.transform.localPosition = Vector3.zero;
        player.transform.localRotation = Quaternion.identity;

        GameObject imageObject = Instantiate(numberUI);
        Image      image       = imageObject.GetComponentInChildren <Image>();

        image.sprite = numbers[index];
        ballBehaviour.SetNumberUI(image.rectTransform);

        var uiPlayer = PlayerTypeManager.GetInstance().GeneratePlayer(index, PlayerTypeManager.SceneType.Object);

        ballBehaviour.SetUiPlayerAnim(uiPlayer.GetComponent <PlayerAnimationController>());
        uiPlayer.layer = LayerMask.NameToLayer("3DUI");
        foreach (var uiPlayerTransform in uiPlayer.GetComponentsInChildren <Transform>())
        {
            uiPlayerTransform.gameObject.layer = LayerMask.NameToLayer("3DUI");
        }
        const float length = 2.0f;

        switch (index)
        {
        case 0:
            uiPlayer.transform.position = new Vector3(0, 0, length);
            break;

        case 1:
            uiPlayer.transform.position = new Vector3(length, 0, 0);
            break;

        case 2:
            uiPlayer.transform.position = new Vector3(0, 0, -length);
            break;

        case 3:
            uiPlayer.transform.position = new Vector3(-length, 0, 0);
            break;
        }
        uiPlayer.transform.LookAt(Vector3.zero);
        var uiPos = uiPlayer.transform.position;

        uiPos.y = PlayerTypeManager.GetInstance().GetUiOffset(index);
        uiPlayer.transform.position = uiPos;
    }
Пример #3
0
    private void UpdatePlayers()
    {
        List <PlayerBehaviourManager.Player> playerEmpathyList = PlayerBehaviourManager.GetInstance().GetPlayers();

        if (players.Count == 0)
        {
            List <BFGIManager.Player>       playerBFGIList = BFGIManager.GetInstance().GetPlayers();
            List <PlayerTypeManager.Player> playerTypeList = PlayerTypeManager.GetInstance().GetPlayers();
            foreach (PlayerBehaviourManager.Player p in playerEmpathyList)
            {
                Player novoPlayer = new Player(p.playerID);
                novoPlayer.playerObj       = p.playerObj;
                novoPlayer.playerEmpathies = p.empathies;
                players.Add(novoPlayer);
            }
            foreach (BFGIManager.Player p in playerBFGIList)
            {
                foreach (Player a in players)
                {
                    if (p.playerID == a.playerID)
                    {
                        a.O = p.O;
                        a.C = p.C;
                        a.E = p.E;
                        a.A = p.A;
                        a.N = p.N;
                    }
                }
            }
            foreach (PlayerTypeManager.Player p in playerTypeList)
            {
                foreach (Player a in players)
                {
                    if (p.playerID == a.playerID)
                    {
                        a.agression = p.agression;
                        a.rescuer   = p.rescuer;
                        a.greed     = p.greed;
                    }
                }
            }
        }
        else
        {
            foreach (Player player in players)
            {
                foreach (PlayerBehaviourManager.Player p in playerEmpathyList)
                {
                    if (player.playerID == p.playerID)
                    {
                        player.playerEmpathies = p.empathies;
                    }
                }
            }
        }
    }
Пример #4
0
    /******************************************
     *
     * public void NewPlayer(int playerID)
     *		Creates a new player with a specified playerID value,
     *		signals the other managers to insert a new player on their player list,
     *		sets the BFGI questionnaire back to 1;
     *
     * Parameters
     *		int playerID - The number ID for the new player.
     * Return
     *
     * ***************************************/
    private void NewPlayer(int playerID)
    {
        GameObject newPlayer = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity);

        newPlayer.name = "Player_" + playerID;
        newPlayer.GetComponent <PlayerMovementScript>().playerID = playerID;
        newPlayer.GetComponent <MeshRenderer>().material.color   = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), 255);
        newPlayer.tag = GameManagerScript.Tags.Player.ToString();
        players.Add(newPlayer);

        BFGIManager.GetInstance().NewPlayer(newPlayer, playerID);
        PlayerBehaviourManager.GetInstance().NewPlayer(newPlayer, playerID);
        PlayerTypeManager.GetInstance().NewPlayer(newPlayer, playerID);
        UIManagerScript.GetInstance().StartDisplayOnScreen(newPlayer, "PlayerName_" + newPlayer.name, null);
    }
Пример #5
0
    // 動物とくす玉を生成
    void Generate()
    {
        for (int i = 0; i < PlayerCount.MaxValue; ++i)
        {
            if (!PlayerJoinManager.IsJoin(i))
            {
                continue;
            }
            // 動物生成
            GameObject player = PlayerTypeManager.GetInstance().GeneratePlayer(i, PlayerTypeManager.SceneType.Object);
            player.transform.position   = playerPosArray[i].transform.position;
            player.transform.rotation   = playerPosArray[i].transform.rotation;
            player.transform.localScale = playerPosArray[i].transform.localScale;
            var pos = player.transform.GetChild(0).transform.localPosition;
            pos.y = 0;
            player.transform.GetChild(0).transform.localPosition = pos;

            // くす玉生成
            GameObject kusudama = Instantiate(
                kusudamaPrefab[i],
                playerPosArray[i].transform.position + kusudamaOffset,
                playerPosArray[i].transform.rotation);
            kusudamaArray[i] = kusudama;

            // RankTextを取得
            foreach (Transform child in kusudama.transform)
            {
                if (child.name != "Canvas")
                {
                    continue;
                }

                foreach (Transform grandchild in child)
                {
                    if (grandchild.name != "RankImage")
                    {
                        continue;
                    }

                    rankTextArray[i]        = grandchild.GetComponent <Image>();
                    rankTextArray[i].sprite = rankSprites[PointManager.GetRank(i) - 1];
                    break;
                }
                break;
            }
        }
    }
Пример #6
0
    void Start()
    {
        playerRotation = transform.rotation;
        thisRigidbody.maxAngularVelocity = ballScriptableObject.MaxAngularVelocity;
        if (IsInPlayer())
        {
            //プレイヤーの情報を格納
            var playerStatus = PlayerTypeManager.GetInstance().GetPlayerStatus(playerIndex);
            if (playerStatus.Type == PlayerType.Alpaca)
            {
                ((AlpacaStatus)playerStatus).AlpacaStatusInit(
                    ref movePower, ref easyCurveWeight, ref mass, ref boostPower, ref boostInterval, ref brakePower);
            }
            else
            {
                movePower       = playerStatus.BallMovePower;
                easyCurveWeight = playerStatus.BallEasyCurveWeight;
                mass            = playerStatus.BallMass;
                boostPower      = playerStatus.BallBoostPower;
                boostInterval   = playerStatus.BallBoostInterval;
                brakePower      = playerStatus.BallBrakePower;
            }
            transform.GetComponent <SphereCollider>().material = playerStatus.BallPhysicalMaterial;
            thisRigidbody.mass        = mass;
            playerAnimationController = GetComponentInChildren <PlayerAnimationController>();
            playerTransform           = playerAnimationController.transform;
            initPosition = transform.position;
            initRotation = transform.rotation;

            //色をプレイヤーの色に変える
            var mat   = transform.GetComponent <MeshRenderer>().material;
            var color = PlayerColor.GetColor(playerIndex);
            mat.SetColor("_ColorDown", color);

            //回転しやすいように空のオブジェクトを作成
            playerRotationObject = new GameObject("PlayerRotationObject");
            playerRotationObject.transform.parent = transform;
            playerTransform.localPosition         = Vector3.zero;

            ballStateManager.Init(this, new HasPlayerState());
        }
        else
        {
            ballStateManager.Init(this, new NotHasPlayerState());
        }
    }
Пример #7
0
    private void OnGUI()
    {
        foreach (PlayerMsg display in players)
        {
            if (display.player == null)
            {
                continue;
            }

            if (!display.player.activeInHierarchy)
            {
                continue;
            }

            float width, height;
            width = height = 200;
            Vector3 pos         = Camera.main.WorldToScreenPoint(display.player.transform.position);
            string  displayMSG  = display.msg;
            Rect    displayRECT = new Rect(pos.x, Screen.height - pos.y, width, height);

            if (displayMSG.Contains("PlayerName_"))
            {
                //print("contains");
                displayMSG = displayMSG.Substring("PlayerName_".Length);
                //print(display.player.GetComponent<SpriteRenderer>().sprite.texture.height);
                displayRECT.y -= charSizeOffset.y;
                displayRECT.x -= charSizeOffset.x;
            }

            if (displayMSG.Contains("Situation"))
            {
                displayRECT.x      += situationOffset.x;
                displayRECT.y      += situationOffset.y;
                displayRECT.width  += situationRECT.x;
                displayRECT.height += situationRECT.y;
            }

            GUI.Label(displayRECT, displayMSG);
        }

        if (true)//GameManagerScript.GetInstance().currentStage == GameManagerScript.GameStage.MainGame)
        {
            List <string> ptText   = PlayerTypeManager.GetInstance().Display();
            List <string> bfgiText = BFGIManager.GetInstance().Display();
            List <string> pbText   = PlayerBehaviourManager.GetInstance().Display();

            Rect leftUI = new Rect(Screen.width * 0.05f, Screen.height * 0.05f, Screen.width * 0.20f, Screen.height * 0.9f);

            if (GameManagerScript.GetInstance().GetNumPlayers() > 2)
            {
                Rect   rightUI   = new Rect(Screen.width * 0.75f, Screen.height * 0.05f, Screen.width * 0.20f, Screen.height * 0.9f);
                string leftText  = ptText[0] + bfgiText[0] + pbText[0];
                string rightText = ptText[1] + bfgiText[1] + pbText[1];

                GUI.Box(leftUI, leftText);
                GUI.Box(rightUI, rightText);
            }
            else
            {
                string leftText = ptText[0] + bfgiText[0] + pbText[0];
                GUI.Box(leftUI, leftText);
            }
        }
    }