コード例 #1
0
 // Use this for initialization
 void Start()
 {
     player = transform.parent.GetComponent <RpsHumanPlayer>();
     if (!player.isLocalPlayer)
     {
         this.gameObject.SetActive(false);
         //Destroy(this.gameObject);
         return;
     }
     view = player.GetComponentInChildren <MatchPlayerUI>();
 }
コード例 #2
0
    void SetPlayers(Color[] colors)
    {
        for (int i = 0; i < colors.Length; i++)
        {
            if (colors [i].a == 0f)
            {
                // no color for this player = no player
                uiCanvas.FindChild("PlayerPanel" + (i + 1)).gameObject.SetActive(false);
                continue;
            }
            else
            {
                int        j = i + 1;
                GameObject p = Instantiate(playerPrefab) as GameObject;
                p.transform.name   = "Player" + j;
                p.transform.parent = level.transform;
                PlayerController pc = p.GetComponent <PlayerController> ();
                pc.SetID(j);
                pc.color = colors [i];
                p.transform.localPosition = spawnPoint [i];
                p.transform.localScale    = Vector3.one * playerScale;
                switch (i)
                {
                case 0: p.transform.Rotate(0, 0, 45f);
                    break;

                case 1: p.transform.Rotate(0f, 0f, -135f);
                    break;

                case 2: p.transform.Rotate(0f, 0f, -45f);
                    break;

                case 3: p.transform.Rotate(0f, 0f, 135f);
                    break;
                }
                p.GetComponent <Respawn>().respawner = respawner;
                respawner.AddPlayer(p.transform, i);
                DropBomb db = p.GetComponent <DropBomb>();
                db.level = level.transform;
                StartCoroutine(UnlockPlayerBombing(db, timeBeforeStarting));
                GameObject    uiPanel  = uiCanvas.Find("PlayerPanel" + j).gameObject;
                MatchPlayerUI playerui = uiPanel.GetComponent <MatchPlayerUI>();
                playerui.player = pc;
                playerui.mode   = defaultType;
                uiPanel.GetComponent <Image>().color = pc.color;
                control.AddPlayer(pc);
            }
        }
    }