//各キャラクターのphoton対応継続
次はFoxの整備を進めていく。
ベースとなる変更は、envpalymove5photonスクリプトの組み込み、HPscript2への更新、photonview、photontransform、photonanimatorviewおよびnetworkcharactorスクリプトのアタッチ。攻撃判定箇所へのcharamodemanagerスクリプトの追加。UIへのDeerActionlistスクリプトの追加。minimapsphere,Particle System moonlight,minimapmonstercameraの追加、playwalkingboolなどのanimationの編集、UIとの連携の調整。
4体目のキャラクター用imageをPIckUIへの追加、それをcharachangeスクリプトへ反映。
UIとオブジェクト操作の紐付けに移っていく。
まず、foxのminicameraにはEnemyしか映さないのでMinimapのrawimageのtextureを変更。
Foxにはテレポート機能をつけるのでそちらも整備する。warpControllerスクリプトのSetwarp()をボタンクリック時に実行させれば良い。
public void Foxskill2()
{
warpController warpController = myPlayer.GetComponent<warpController>();
warpController.Setwarp();
}
ポジションの変更なので同期先シーンではTransformで自動的に反映されることになる。
Fogの発生スキルは同期タイミングをRPCで指示する必要があるのでfogManagerスクリプトをphoton対応の形に変更した。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class fogManager : MonoBehaviourPunCallbacks
{
[SerializeField]
GameObject fogObject;
public void Fogon()
{
photonView.RPC(nameof(DoFogon), RpcTarget.All);
}
[PunRPC]
void DoFogon()
{
fogObject.SetActive(true);
}
}
攻撃先への暗闇の付与効果を実装する。攻撃の受け手側にUIeffectcanvasの子要素にあたるDarkeffectスクリプトを実行さればよい。
HPscript2のenvPlaymove5photon.rabitslowflagと同様の対応だが、HPscript2側の記述も少し修正。
if (envPlaymove5photon == null)
{
Debug.Log("Debuffcheck2");
return;
}
else
{
Debug.Log("DebuffcheckSucces1");
if (envPlaymove5photon.rabitslowflag)
{
Debuffcheck();
Debug.Log("DebuffcheckSuccess2");
envPlaymove5photon.rabitslowflag = false;
}
if (envPlaymove5photon.foxdarkflag)
{
Debuffcheck2();
Debug.Log("DebuffcheckSuccess2");
envPlaymove5photon.foxdarkflag = false;
}
}
void Debuffcheck2()
{
Debug.Log("Debuffcheck2");
EnvPlaymove5photon myenvPlaymove5photon = GetComponent<EnvPlaymove5photon>();
myenvPlaymove5photon.DarkPanelon();
}
ただ、こうしてしまうと一部のシーンではenvPlaymove5photon.foxdarkflag = trueとなったままになってしまうことに気づき、envPlaymove5photon.Foxdarkflag();で再度攻撃側のスクリプト内で下記を実行させることでRPCでオフにさせるようにした。
public void Rabitslowflag()
{
photonView.RPC(nameof(Rabbitskill4photon), RpcTarget.All);
}
[PunRPC]
void Rabbitskill4photon()
{
if (rabitslowflag)
{
rabitslowflag = false;
}
else
{
rabitslowflag = true;
}
}
ただ、UIeffectdarkerをstartメソッドにしているためUIeffectcanvasを非表示にしなければならず、結果として、EnvPlaymove5photonでオブジェクトを取得できていない。
UIeffectdarkerスクリプトを修正する。
public void UIDarkOn()
{
UIdark.SetActive(true);
}
これをEnvPlaymove5photonで実行することでcanvasを非表示にする必要がなくなる。
public void DarkPanelon()
{
UIeffectdarker UIeffectdarker = Darkpanel.GetComponent<UIeffectdarker>();
UIeffectdarker.UIDarkOn();
}
また、Darkeffectスクリプトを修正し、連続して暗闇動作を行わせることができるようにした。
void Update()
{
GetComponent<Image>().color = new Color(0, 0, 0, alfa);
if (alfa < 1)
{
timer += Time.deltaTime;
if (timer > 1)
{
alfa += speed;
timer = 0;
}
}
Debug.Log(alfa);
if (alfa >= 1)
{
effectdarker.UIDarkOff();
Debug.Log("a");
timer = 0;
}
}