//tips
//Golem同期対応
Golemsoulのドロップ・リドロップの対応はきちんと同期できたが、soulpostにてsoulを提出した後にsoulpostの個数表示メッセージが他シーンに同期されていないので、そちらの同期方法を確認する。
SoulPostTextcountスクリプトで
soultext = Postcount.ToString();
GetComponent<Text>().text = "現在差し出された魂は"+soultext+ "個です”;
と管理しているので、Postcount++;を同期させるようにする。
下記のようにスクリプトを修正。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using Photon.Pun;
public class SoulPostTextcount : MonoBehaviourPunCallbacks
{
int Postcount;
string soultext;
void Update()
{
soultext = Postcount.ToString();
GetComponent<Text>().text = "現在差し出された魂は"+soultext+ "個です";
}
public void PostManage()
{
photonView.RPC(nameof(DoPostManage), RpcTarget.All);
}
void DoPostManage()
{
Postcount++;
if (Postcount == 3)
{
SceneManager.LoadScene("GoalScene");
Postcount = 0;
}
}
}
他方のUIのGolemSoulPostが非表示になっているためDoPostManage()のカウントがうまく受け取れていないよう。
常に表示されているsoulpostそのものにcountの通知を共有させれば良いのでSoulPostTextcountスクリプトからsoulpostに新たにアタッチした下記参照を行わせるようにした。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;
public class PostCount : MonoBehaviourPunCallbacks
{
public int count;
public void PManage()
{
photonView.RPC(nameof(DoPManage), RpcTarget.All);
}
[PunRPC]
void DoPManage()
{
count++;
if (count == 3)
{
SceneManager.LoadScene("GoalScene");
count = 0;
}
}
}
次は複数個に増やしても問題ないか確認していく。GoalSceneをbuildsettingの中に組み込んでおく。
3つ提出すると無事にゲームクリアシーンに遷移した。
ただ、このゲームクリアシーンは人間役の勝利なのでsurvivor winのような表示に変える必要がある。また、人狼側はプレイヤーが自身のみになった際にhunter winの表示をさせる。
ゴーレム3体も生成するようにゴーレムprefabも整備する。
現在はそれぞれのgolemfollowオブジェクトにfindで自身の担当のゴーレム名を探させているのでここを新たに生成するゴーレム名に変更する必要がある。
Golemfollowスクリプトをアタッチされているdropitem名で検索するオブジェクトを変える式を加える。