本文整理汇总了C#中GameObject.GetPhotonView方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetPhotonView方法的具体用法?C# GameObject.GetPhotonView怎么用?C# GameObject.GetPhotonView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.GetPhotonView方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnJoinedRoom
void OnJoinedRoom()
{
// GameObject player = PhotonNetwork.Instantiate(prefabName, SpawnPoints[i].position, SpawnPoints[i].rotation, group);
player = PhotonNetwork.Instantiate(prefabName, SpawnPoint1.position, SpawnPoint1.rotation, group);
// player.tag = Globals.Tags.Player.ToString();
player.transform.position = SpawnPoints[player.GetPhotonView().viewID/1000%2].position;
player.SetActive(true);
Debug.Log("prefab Name:" + prefabName + " number: " + player.GetPhotonView().viewID +"\nIsActive: " + player.GetActive());
//create to spawn points
}
示例2: OnJoinedRoom
public void OnJoinedRoom()
{
if (this.PrefabsToInstantiate != null)
{
GameObject controller = GameObject.Find("Control");
foreach (GameObject o in this.PrefabsToInstantiate)
{
Debug.Log("Instantiating: " + o.name);
Vector3 spawnPos = Vector3.up;
if (this.SpawnPosition != null)
{
spawnPos = this.SpawnPosition.position;
}
Vector3 random = Random.insideUnitSphere;
random.y = 0;
random = random.normalized;
Vector3 itempos = spawnPos + this.PositionOffset * random;
player = PhotonNetwork.Instantiate(o.name, itempos, Quaternion.identity, 0);
PhotonView photonView = player.GetPhotonView();
CameraController camera = PlayerCamera.GetComponent<CameraController>();
camera.enabled = true;
camera.player = player;
redPlayers = PunTeams.PlayersPerTeam[PunTeams.Team.red].Count;
bluePlayers = PunTeams.PlayersPerTeam[PunTeams.Team.blue].Count;
ExitGames.Client.Photon.Hashtable ht = new ExitGames.Client.Photon.Hashtable();
ht.Add("ready", false);
ht.Add("all ready", false);
PhotonNetwork.player.SetCustomProperties(ht);
if (redPlayers > bluePlayers)
{
PhotonNetwork.player.SetTeam(PunTeams.Team.blue);
photonView.RPC("ChangeColorToBlue", PhotonTargets.AllBuffered);
}
else {
PhotonNetwork.player.SetTeam(PunTeams.Team.red);
photonView.RPC("ChangeColorToRed", PhotonTargets.AllBuffered);
}
}
}
}
示例3: Update
// Update is called once per frame
void Update () {
//Debug.Log(completion);
if (photonView.isMine){
lifetimeAccum += Time.deltaTime;
if (completion >= required){
tempObject = PhotonNetwork.Instantiate(completedBuilding.name,transform.position,transform.rotation,0) as GameObject;
SetTeam (tempObject.GetPhotonView().viewID,(int)currentTeam, lifetimeAccum);
DestroyBox(GetComponent<PhotonView>().viewID);
}
if (lifetimeAccum >= totalLifetime){
DestroyBox(GetComponent<PhotonView>().viewID);
}
}
}
示例4: Execute
public override ActionResult Execute(AI ai)
{
//enemyObject = enemy.Evaluate(ai.DeltaTime, ai.WorkingMemory).GetValue<GameObject>();
enemyObject = ai.WorkingMemory.GetItem("Wizard").GetValue<RAIN.Entities.Aspects.VisualAspect>().Entity.Form;
if( enemyObject != null )
{
if( enemyObject.GetPhotonView().isMine )
enemyObject.GetComponent<PlayerController>().TakeDamage((int)ai.WorkingMemory.GetItem("damageToApply").GetValue<int>(),ai.Body.transform);
}
if( enemyObject == null )
{
Debug.Log("no player to hit");
}
return ActionResult.SUCCESS;
}
示例5: ApplyWind
void ApplyWind()
{
if(isControlable){
print ("wind sent");
data[0] = windForce;
data[1] = windDirection;
Transform[] projectiles = projectileHolder.GetComponentsInChildren<Transform>();
foreach(Transform proj in projectiles){
if(proj.gameObject.GetPhotonView()!=null){
projectile=proj.gameObject;
projectile.GetPhotonView().RPC("WindData",PhotonTargets.All,data);
}
}
}
}
示例6: Start
// Update is called once per frame
void Start () {
Vector3 random = Random.insideUnitSphere;
random.y = 0;
random = random.normalized;
Vector3 itempos = new Vector3(0,11,0) + 10.0f * random;
player = PhotonNetwork.Instantiate("PlayerSphere", itempos, Quaternion.identity, 0);
PhotonView photonView = player.GetPhotonView();
CameraController camera = PlayerCamera.GetComponent<CameraController>();
camera.enabled = true;
camera.player = player;
if (PhotonNetwork.player.GetTeam() == PunTeams.Team.red)
{
photonView.RPC("ChangeColorToRed", PhotonTargets.AllBuffered);
}
else {
photonView.RPC("ChangeColorToBlue", PhotonTargets.AllBuffered);
}
}
示例7: Grab
void Grab()
{
if (grabbed) {
grabbed.GetPhotonView().RPC("released",PhotonTargets.All);
grabbed = null;
}
else {
RaycastHit hit;
Ray ray = new Ray(transform.position, new Vector3(0,-1,0));
//Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit)) {
grabbed = hit.collider.gameObject;
int newID = PhotonNetwork.AllocateViewID();
grabbed.GetPhotonView().RPC("grabbed",PhotonTargets.All,newID);
grabbedPosition = hit.transform.position;
//grabbedBottom = hit.collider.bounds.min.y;
}
}
}
示例8: DespawnObject
/// <summary>
/// Despawns the object. Must be called only from master server
/// </summary>
/// <param name="obj">Object.</param>
public virtual void DespawnObject(GameObject obj)
{
if (!isMaster)
return;
int objectID = obj.GetPhotonView ().viewID;
photonView.RPC ("RPC_DespawnObject", PhotonTargets.AllBufferedViaServer, objectID);
//[[Updating the list]]
if(SpawnedObjects.Contains (objectID))
SpawnedObjects.Remove (objectID);
}
示例9: FindView
private int FindView(GameObject go)
{
return go.GetPhotonView ().viewID;
}
示例10: Venediction
/// <summary>
/// プレイヤーを全回復させる関数
/// </summary>
/// <param name="player">回復させる対象</param>
private void Venediction(GameObject player)
{
if (player)
{
// プレイヤーの情報をゲットする
PlayerChar playerChar = player.GetComponent<PlayerChar>();
// プレイヤーが取得できれば
if (playerChar)
{
// 他の誰かのHPを回復させる
gameObject.GetPhotonView().RPC("Recover", player.GetPhotonView().owner, playerChar.GetPlayerData().MaxHP);
// 処理が完了したので抜ける
return;
}
}
// 自分のHPを回復させる
Recover(playerData.MaxHP);
}
示例11: Regene
/// <summary>
/// プレイヤーのHPを徐々に回復させる「リジェネ」
/// </summary>
/// <param name="player"></param>
private void Regene(GameObject player)
{
// リジェネのスキルを取得する
SkillBase regeneSkill = SkillControl.GetSkill("リジェネ");
if (player)
{
// プレイヤーのスクリプトを取得する
PlayerChar playerChar = player.GetComponent<PlayerChar>();
// playerがプレイヤーならば
if (player)
{
// 回復量を計算する
int healHP = (int)((float)playerChar.GetPlayerData().MaxHP * (regeneSkill.GetBonus() + regeneSkill.attack));
// 効果時間を計算する
float skillTime = 20 + regeneSkill.GetLv() * 5;
// 回復する時間を計算する
float healTime = 5f - regeneSkill.GetLv() * 0.2f;
// リジェネを発動させる
photonView.RPC("GenerationRegeneration", player.GetPhotonView().owner, healHP, skillTime, healTime);
return;
}
}
// 回復量を計算する
int healHp = (int)((float)playerData.MaxHP * (regeneSkill.GetBonus() + regeneSkill.attack));
// 効果時間を計算する
float skillTimer = 20 + regeneSkill.level * 5;
// 回復する時間を計算する
float healTimer = 5f - regeneSkill.level * 0.5f;
// リジェネを発動する
GenerationRegeneration(healHp, skillTimer, healTimer);
}
示例12: Heal
/// <summary>
/// ヒール
/// </summary>
/// <param name="player">回復させるプレイヤーオブジェクト</param>
private void Heal(GameObject player)
{
// ヒールのスキルを取得する
SkillBase healSkill = SkillControl.GetSkill("ヒール");
// プレイヤーが存在すれば
if (player)
{
// プレイヤーの情報を取得する
PlayerChar playerChar = player.GetComponent<PlayerChar>();
// プレイヤーが取得できれば
if (playerChar)
{
// そのプレイヤーの場所に回復エフェクトを表示させる
PhotonNetwork.Instantiate("Magics/HealEffect", player.transform.position + Vector3.up * 1f, Quaternion.identity, 0);
// 回復させるHPの量を計算する
int recoverHP = (int)((float)playerChar.GetPlayerData().MaxHP * (healSkill.GetBonus() + healSkill.attack));
// そのプレイヤーのHPを回復させる
gameObject.GetPhotonView().RPC("Recover", player.GetPhotonView().owner, recoverHP);
// 処理が完了したので抜ける
return;
}
}
// 自分の位置に回復エフェクトを表示させる
PhotonNetwork.Instantiate("Magics/HealEffect", gameObject.transform.position + Vector3.up * 1f, Quaternion.identity, 0);
// 自分のHPを回復する
Recover((int)((float)playerData.MaxHP * (healSkill.GetBonus() + healSkill.attack)));
}