public static Destroy ( GameObject go ) : void | ||
go | GameObject | |
Résultat | void |
IEnumerator DestroyGameObject(GameObject objectToDestroy, float waitTime) { yield return(new WaitForSeconds(waitTime)); PhotonNetwork.Destroy(objectToDestroy); }
public void OnApplicationQuit() { //ServerNetwork.Instance.PlayerRequestDisconnect(PhotonNetwork.LocalPlayer); PhotonNetwork.Destroy(gameObject); PhotonNetwork.Disconnect(); }
/// <summary> /// Coroutine function to destory player game object. /// </summary> /// <param name="delayTime">Delay time before destory.</param> IEnumerator DestoryPlayer(float delayTime) { yield return(new WaitForSeconds(delayTime)); PhotonNetwork.Destroy(gameObject); }
IEnumerator DieIn(float lifetime) { yield return(new WaitForSeconds(lifetime)); PhotonNetwork.Destroy(gameObject); }
/// <summary> /// Updates the game over ai logic /// </summary> void UpdateAI() { // Must do this here as health component gets turned off when it dies var ai = PlayerManager.GetAllAI(); GameObject aiToDestroy = null; for (int i = 0; i < ai.Count; ++i) { if (Utilities.IsControllableAI(ai[i])) { // This includes all AI contolled by the client (including Rogues) var health = ai[i].GetComponent <AIHealth>(); var network = ai[i].GetComponent <NetworkedAI>(); bool assignedPlayerDead = network.GetAssignedPlayer() != null && !network.IsAssignedPlayerIsAlive(); if (health.IsAlive && assignedPlayerDead) { health.AssignedPlayerDead = true; //This caused player owned Ai to be destroyed when the player died. //This is now disabled as this was not desired functionality. //network.SetVisible(false, true); } if (!health.IsAlive) { if (health.AssignedPlayerDead) { // Wait until assigned player is no longer dead to respawn if (!assignedPlayerDead) { health.AssignedPlayerDead = false; if (network.aiType == NetworkedAI.AIType.FLEET) { if (network.GetComponent <FleetAI>().Purchased) { network.SetVisible(true, false); } } } } else { //Handles ai respawning and showing on game start. switch (network.aiType) { case NetworkedAI.AIType.ROGUE: if (network.AlreadySpawned) { network.SetVisible(false, true); StartCoroutine(RespawnAI(network, 5.0f)); } else { network.SetVisible(false, true); network.SetVisible(true, false); network.AlreadySpawned = true; } break; case NetworkedAI.AIType.FLEET: //DONE: Handle fleet ship spawning and dying. Also make sure that fleet ships a not visible on game start // and only become visible once they have been purchased by the player. The shop manager will hold // a list of AI fleet ships. The FleetAI class will keep track of whether a fleet ship has been purchased. FleetAI fleet = network.GetComponent <FleetAI>(); if (fleet.Purchased) { network.SetVisible(false, true); fleet.UnassignFormationPosition(); fleet.Purchased = false; } //temp death and spawn code break; case NetworkedAI.AIType.PATROL: /* TODO: Implement patrol ship death handling. * Patrol ships will be owned by the scene and * there will be one per island. * Once a player has captured an island and bought a * patrol ship for that island. The designated * patrol ship will be made visible and * the ship's owning player will be set. * There will also be a purchased variable * that will be used to determine whether the * player has purchased the patrol ship for an island. */ network.SetVisible(false, true); aiToDestroy = ai[i]; break; default: break; } // No assigned player, immediate respawn } } } } //Destory flagged AI if (aiToDestroy != null) { PlayerManager.RemoveAI(aiToDestroy); PhotonNetwork.Destroy(aiToDestroy.transform.parent.gameObject); } }
/*public void ShootArrow() * { * if (mg.PlayerPref) * { * physic.AddForce(new Vector2(trans.position.x, 0), ForceMode2D.Force); * } * else if (mg.PlayerPref2) * { * physic.AddForce(new Vector2(-trans.position.x, 0), ForceMode2D.Force); * } * }*/ void OnBecameInvisible() { PhotonNetwork.Destroy(gameObject); }
void Start() { PickupTarget.Instance.OnStatusChange += status => { if (status == TrackableBehaviour.Status.NO_POSE) { Deselect(); } }; PickupTarget.Instance.LostPlayer += player => { Deselect(); }; Highlight.GetComponent <Button>().onClick.AddListener(() => { CurrentSelected.Interact(OOI.OOI.InteractionFlag.Highlight); Deselect(); }); Animation.GetComponent <Button>().onClick.AddListener(() => { CurrentSelected.Interact(OOI.OOI.InteractionFlag.Animation); Deselect(); }); Text.GetComponent <Button>().onClick.AddListener(() => { CurrentSelected.Interact(OOI.OOI.InteractionFlag.Text); Deselect(); }); Video.GetComponent <Button>().onClick.AddListener(() => { CurrentSelected.Interact(OOI.OOI.InteractionFlag.Video); Deselect(); }); Slider.GetComponent <Slider>().onValueChanged.AddListener(value => { if (CurrentSelected != null) { CurrentSelected.transform.localScale = new Vector3(value, value, value); } }); TangibleLock.GetComponent <Toggle>().onValueChanged.AddListener(value => { if (CurrentSelected == null) { return; } if (value) { var target = CurrentSelected.GetComponentInParent <TangibleTarget>(); CurrentSelected.transform.parent = Treveris.GetTreverisByPlayer(PickupTarget.Instance.Current.photonView.Owner).transform; CurrentSelected.GetComponent <TangibleView>().IsLocked = true; target.AddOOI("Tangibles/" + ((AndroidTargetManager)TargetManager.Instance).EmptyTangible.name); Delete.gameObject.SetActive(true); } else { var targets = FindObjectsOfType <TangibleTarget>().Where(target => target.GetComponent <ImageTargetBehaviour>().CurrentStatus != TrackableBehaviour.Status.NO_POSE && target.Current.GetComponent <TangibleView>().IsEmpty).ToList(); TangibleTarget closest = null; foreach (var target in targets) { if (closest == null || Vector3.Distance(closest.transform.position, CurrentSelected.transform.position) > Vector3.Distance(target.transform.position, CurrentSelected.transform.position)) { closest = target; } } PhotonNetwork.Destroy(closest.GetComponentInChildren <TangibleView>().gameObject); CurrentSelected.transform.parent = closest.transform; CurrentSelected.transform.localPosition = Vector3.zero; CurrentSelected.transform.localRotation = Quaternion.identity; CurrentSelected.GetComponent <TangibleView>().IsLocked = false; Delete.gameObject.SetActive(false); } //Deselect(); }); Dropdown.GetComponent <TMP_Dropdown>().onValueChanged.AddListener(value => { if (CurrentSelected == null) { return; } var current = CurrentSelected; Deselect(); var target = current.GetComponentInParent <TangibleTarget>(); PhotonNetwork.Destroy(current.gameObject); target.AddOOI("Tangibles/" + Dropdown.GetComponent <TMP_Dropdown>().options[value].text); }); var options = ((AndroidTargetManager)AndroidTargetManager.Instance).TangiblePrefabs.Select(o => o.name) .ToList(); options.Insert(0, ((AndroidTargetManager)AndroidTargetManager.Instance).EmptyTangible.name); Dropdown.GetComponent <TMP_Dropdown>().AddOptions(options); Delete.GetComponent <Button>().onClick.AddListener(() => { var current = CurrentSelected.gameObject; Deselect(); PhotonNetwork.Destroy(current); }); OnSelect += ooi => { foreach (Transform child in transform) { child.gameObject.SetActive(false); } if (PickupTarget.Instance.Current == null) { return; } _buttons?.Clear(); _buttons = GetButtons(ooi); if (ooi.Flags.HasFlag(OOI.OOI.InteractionFlag.Scale)) { Slider.gameObject.SetActive(true); var scale = ooi.transform.localScale.x; var slider = Slider.GetComponent <Slider>(); slider.minValue = scale / 5f; slider.value = scale; slider.maxValue = scale * 5f; } if (ooi.Flags.HasFlag(OOI.OOI.InteractionFlag.Changeable)) { var dropdown = Dropdown.GetComponent <TMP_Dropdown>(); var o = dropdown.options.First(data => ooi.gameObject.name.Equals(data.text + "(Clone)")); dropdown.value = dropdown.options.IndexOf(o); Dropdown.gameObject.SetActive(true); } if (ooi.GetComponent <TangibleView>() && ooi.Flags.HasFlag(OOI.OOI.InteractionFlag.Lockable)) { TangibleLock.gameObject.SetActive(true); TangibleLock.GetComponent <Toggle>().isOn = ooi.GetComponent <TangibleView>().IsLocked; } if (ooi.GetComponent <TangibleView>() && ooi.GetComponent <TangibleView>().IsLocked) { Delete.gameObject.SetActive(true); } _center = new Vector3(); var renderers = ooi.GetComponentsInChildren <MeshRenderer>(); if (renderers.Length > 0) { foreach (var child in renderers) { _center += child.bounds.center; } _center = _center / renderers.Length; _center = _center - ooi.transform.position; } }; OnDeselect += () => { foreach (Transform child in transform) { child.gameObject.SetActive(false); } }; }
public void OnPressRight() { Debug.Log("RightClick Destroy"); PhotonNetwork.Destroy(base.gameObject); }
/* * void OnTriggerEnter2D(Collider2D other) * { * if (other.gameObject.tag == "Item") * { * Debug.Log("COLLISION WITH " + other.gameObject.name); * // PhotonView photonViewOther = PhotonView.Get(other.gameObject); * // photonViewOther.RPC("TransitionToPosition", RpcTarget.All, parentObject.transform.position); * PhotonView photonViewOther = PhotonView.Get(other.gameObject); * // other.gameObject.GetComponent<ObjectController_Network>().TransitionToPosition(parentObject.transform.position); * photonViewOther.RPC("TransitionToPosition", RpcTarget.All, parentObject.transform.position); * //parentObject.GetComponent<SimpleTeleport_NetworkVersion>().TransitionToPosition(other.transform.position); * * Destroy(gameObject); * } * } */ void OnTriggerEnter2D(Collider2D other) { Vector3 bulletPos = this.transform.position; if (!(other.gameObject == parentObject)) { Debug.Log("COLLISION WITH " + other.gameObject.name); if (photonView.IsMine && other.gameObject.name == "Drop(Clone)") { PhotonView photonViewParent = PhotonView.Get(parentObject.gameObject); photonViewParent.RPC("MoveLine", RpcTarget.All, other.transform.position); Debug.Log("-----------------ismine" + other.gameObject.name); Vector2 temp = other.transform.position; //other.transform.position = parentObject.transform.position; PhotonView photonViewOther = PhotonView.Get(other.gameObject); photonViewOther.RPC("TransitionToPosition", RpcTarget.All, parentObject.transform.position); parentObject.transform.position = temp; //parentObject.GetComponent<SimpleTeleport_NetworkVersion>().TransitionToPosition(temp); PhotonNetwork.Destroy(this.gameObject); //parentObject.GetComponent<SimpleTeleport_NetworkVersion>().TransitionToPosition(temp); } if (photonView.IsMine && other.gameObject.name == "Player(Clone)") { PhotonView photonViewParent = PhotonView.Get(parentObject.gameObject); photonViewParent.RPC("MoveLine", RpcTarget.All, bulletPos); Debug.Log("-----------------ismine" + other.gameObject.name); Vector3 temp = other.transform.position; PhotonView photonViewOther = PhotonView.Get(other.gameObject); //other.transform.position = parentObject.transform.position; //other.gameObject.GetComponent<SimpleTeleport_NetworkVersion>().TransitionToPosition(parentObject.transform.position); photonViewOther.RPC("TransitionToPosition", RpcTarget.All, parentObject.transform.position); //PhotonView photonViewParent = PhotonView.Get(parentObject.gameObject); //photonViewParent.RPC("TransitionToPosition", RpcTarget.All, temp); ///parentObject.transform.position = bulletPos; photonViewParent.RPC("TransitionToPosition3", RpcTarget.All, bulletPos); //generateEnergy(parentObject); //other.transform.position = temp; //other.transform.position = parentObject.transform.position+new Vector3(0,5,0); PhotonNetwork.Destroy(this.gameObject); //other.gameObject.GetComponent<SimpleTeleport_NetworkVersion>().TransitionToPosition(parentObject.transform.position); //parentObject.GetComponent<SimpleTeleport_NetworkVersion>().TransitionToPosition(temp); } } //if(photonView.IsMine) // if( other.gameObject.name == "Drop(Clone)" || other.gameObject.name == "Player_Network(Clone)") }
public void HandRemove(GameObject _hand) { PhotonNetwork.Destroy(_hand); }
void Destroy() { PhotonNetwork.Destroy(gameObject); }
public override void OnLeftRoom() { base.OnLeftRoom(); PhotonNetwork.Destroy(spawnedPlayerPrefab); }
private void LateUpdate() { if ((this.myHero == null) && base.photonView.isMine) { PhotonNetwork.Destroy(base.gameObject); } if (this.State == "mounted") { if (this.myHero == null) { this.unmounted(); return; } this.myHero.transform.position = base.transform.position + ((Vector3)(Vector3.up * 1.68f)); this.myHero.transform.rotation = base.transform.rotation; this.myHero.GetComponent <Rigidbody>().velocity = base.GetComponent <Rigidbody>().velocity; if (this.controller.targetDirection != -874f) { base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, this.controller.targetDirection, 0f), (100f * Time.deltaTime) / (base.GetComponent <Rigidbody>().velocity.magnitude + 20f)); if (this.controller.isWALKDown) { base.GetComponent <Rigidbody>().AddForce((Vector3)((base.transform.forward * this.speed) * 0.6f), ForceMode.Acceleration); if (base.GetComponent <Rigidbody>().velocity.magnitude >= (this.speed * 0.6f)) { base.GetComponent <Rigidbody>().AddForce((Vector3)((-this.speed * 0.6f) * base.GetComponent <Rigidbody>().velocity.normalized), ForceMode.Acceleration); } } else { base.GetComponent <Rigidbody>().AddForce((Vector3)(base.transform.forward * this.speed), ForceMode.Acceleration); if (base.GetComponent <Rigidbody>().velocity.magnitude >= this.speed) { base.GetComponent <Rigidbody>().AddForce((Vector3)(-this.speed * base.GetComponent <Rigidbody>().velocity.normalized), ForceMode.Acceleration); } } if (base.GetComponent <Rigidbody>().velocity.magnitude > 8f) { if (!base.GetComponent <Animation>().IsPlaying("horse_Run")) { this.crossFade("horse_Run", 0.1f); } if (!this.myHero.GetComponent <Animation>().IsPlaying("horse_Run")) { this.myHero.GetComponent <Hero>().crossFade("horse_run", 0.1f); } if (!this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = true; object[] parameters = new object[] { true }; base.photonView.RPC("setDust", PhotonTargets.Others, parameters); } } else { if (!base.GetComponent <Animation>().IsPlaying("horse_WALK")) { this.crossFade("horse_WALK", 0.1f); } if (!this.myHero.GetComponent <Animation>().IsPlaying("horse_idle")) { this.myHero.GetComponent <Hero>().crossFade("horse_idle", 0.1f); } if (this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = false; object[] objArray2 = new object[] { false }; base.photonView.RPC("setDust", PhotonTargets.Others, objArray2); } } } else { this.toIdleAnimation(); if (base.GetComponent <Rigidbody>().velocity.magnitude > 15f) { if (!this.myHero.GetComponent <Animation>().IsPlaying("horse_Run")) { this.myHero.GetComponent <Hero>().crossFade("horse_run", 0.1f); } } else if (!this.myHero.GetComponent <Animation>().IsPlaying("horse_idle")) { this.myHero.GetComponent <Hero>().crossFade("horse_idle", 0.1f); } } if ((this.controller.isAttackDown || this.controller.isAttackIIDown) && this.IsGrounded()) { base.GetComponent <Rigidbody>().AddForce((Vector3)(Vector3.up * 25f), ForceMode.VelocityChange); } } else if (this.State == "follow") { if (this.myHero == null) { this.unmounted(); return; } if (base.GetComponent <Rigidbody>().velocity.magnitude > 8f) { if (!base.GetComponent <Animation>().IsPlaying("horse_Run")) { this.crossFade("horse_Run", 0.1f); } if (!this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = true; object[] objArray3 = new object[] { true }; base.photonView.RPC("setDust", PhotonTargets.Others, objArray3); } } else { if (!base.GetComponent <Animation>().IsPlaying("horse_WALK")) { this.crossFade("horse_WALK", 0.1f); } if (this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = false; object[] objArray4 = new object[] { false }; base.photonView.RPC("setDust", PhotonTargets.Others, objArray4); } } var horizontalVector = setPoint - transform.position; var horizontalAngle = -Mathf.Atan2(horizontalVector.z, horizontalVector.x) * 57.29578f; float num = -Mathf.DeltaAngle(horizontalAngle, base.gameObject.transform.rotation.eulerAngles.y - 90f); base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, base.gameObject.transform.rotation.eulerAngles.y + num, 0f), (200f * Time.deltaTime) / (base.GetComponent <Rigidbody>().velocity.magnitude + 20f)); if (Vector3.Distance(this.setPoint, base.transform.position) < 20f) { base.GetComponent <Rigidbody>().AddForce((Vector3)((base.transform.forward * this.speed) * 0.7f), ForceMode.Acceleration); if (base.GetComponent <Rigidbody>().velocity.magnitude >= this.speed) { base.GetComponent <Rigidbody>().AddForce((Vector3)((-this.speed * 0.7f) * base.GetComponent <Rigidbody>().velocity.normalized), ForceMode.Acceleration); } } else { base.GetComponent <Rigidbody>().AddForce((Vector3)(base.transform.forward * this.speed), ForceMode.Acceleration); if (base.GetComponent <Rigidbody>().velocity.magnitude >= this.speed) { base.GetComponent <Rigidbody>().AddForce((Vector3)(-this.speed * base.GetComponent <Rigidbody>().velocity.normalized), ForceMode.Acceleration); } } this.timeElapsed += Time.deltaTime; if (this.timeElapsed > 0.6f) { this.timeElapsed = 0f; if (Vector3.Distance(this.myHero.transform.position, this.setPoint) > 20f) { this.followed(); } } if (Vector3.Distance(this.myHero.transform.position, base.transform.position) < 5f) { this.unmounted(); } if (Vector3.Distance(this.setPoint, base.transform.position) < 5f) { this.unmounted(); } this.awayTimer += Time.deltaTime; if (this.awayTimer > 6f) { this.awayTimer = 0f; LayerMask mask2 = ((int)1) << LayerMask.NameToLayer("Ground"); if (Physics.Linecast(base.transform.position + Vector3.up, this.myHero.transform.position + Vector3.up, mask2.value)) { base.transform.position = new Vector3(this.myHero.transform.position.x, this.getHeight(this.myHero.transform.position + ((Vector3)(Vector3.up * 5f))), this.myHero.transform.position.z); } } } else if (this.State == "idle") { this.toIdleAnimation(); if ((this.myHero != null) && (Vector3.Distance(this.myHero.transform.position, base.transform.position) > 20f)) { this.followed(); } } base.GetComponent <Rigidbody>().AddForce(new Vector3(0f, -50f * base.GetComponent <Rigidbody>().mass, 0f)); }
public void update2() { this.healthTime -= Time.deltaTime; this.updateLabel(); if (this.state != "null") { if (this.state == "wait") { this.waitTime -= Time.deltaTime; if (this.waitTime <= 0f) { base.transform.position = new Vector3(30f, 0f, 784f); UnityEngine.Object.Instantiate(Resources.Load("FX/ThunderCT"), base.transform.position + ((Vector3)(Vector3.up * 350f)), Quaternion.Euler(270f, 0f, 0f)); Camera.main.GetComponent <IN_GAME_MAIN_CAMERA>().flashBlind(); if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE) { this.idle(); } else if (base.photonView.isMine) { this.idle(); } else { this.state = "null"; } } } else if (this.state != "idle") { if (this.state == "attack_sweep") { if ((this.attackCheckTimeA != 0f) && !(((base.GetComponent <Animation>()["attack_" + this.attackAnimation].normalizedTime < this.attackCheckTimeA) || (base.GetComponent <Animation>()["attack_" + this.attackAnimation].normalizedTime > this.attackCheckTimeB)) ? (this.attackChkOnce || (base.GetComponent <Animation>()["attack_" + this.attackAnimation].normalizedTime < this.attackCheckTimeA)) : false)) { if (!this.attackChkOnce) { this.attackChkOnce = true; } foreach (RaycastHit hit in this.checkHitCapsule(this.checkHitCapsuleStart.position, this.checkHitCapsuleEnd.position, this.checkHitCapsuleR)) { GameObject gameObject = hit.collider.gameObject; if (gameObject.tag == "Player") { this.killPlayer(gameObject); } if ((((gameObject.tag == "erenHitbox") && (this.attackAnimation == "combo_3")) && (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.MULTIPLAYER)) && (!FengGameManagerMKII.LAN ? PhotonNetwork.isMasterClient : Network.isServer)) { gameObject.transform.root.gameObject.GetComponent <TITAN_EREN>().hitByFTByServer(3); } } foreach (RaycastHit hit2 in this.checkHitCapsule(this.checkHitCapsuleEndOld, this.checkHitCapsuleEnd.position, this.checkHitCapsuleR)) { GameObject hitHero = hit2.collider.gameObject; if (hitHero.tag == "Player") { this.killPlayer(hitHero); } } this.checkHitCapsuleEndOld = this.checkHitCapsuleEnd.position; } if (base.GetComponent <Animation>()["attack_" + this.attackAnimation].normalizedTime >= 1f) { this.sweepSmokeObject.GetComponent <ParticleSystem>().enableEmission = false; this.sweepSmokeObject.GetComponent <ParticleSystem>().Stop(); if (!((IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.MULTIPLAYER) || FengGameManagerMKII.LAN)) { base.photonView.RPC("stopSweepSmoke", PhotonTargets.Others, new object[0]); } this.findNearestHero(); this.idle(); this.playAnimation("idle"); } } else if (this.state == "kick") { if (!this.attackChkOnce && (base.GetComponent <Animation>()[this.actionName].normalizedTime >= this.attackCheckTime)) { this.attackChkOnce = true; this.door_broken.SetActive(true); this.door_closed.SetActive(false); if (!((IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.MULTIPLAYER) || FengGameManagerMKII.LAN)) { base.photonView.RPC("changeDoor", PhotonTargets.OthersBuffered, new object[0]); } if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.MULTIPLAYER) { if (FengGameManagerMKII.LAN) { Network.Instantiate(Resources.Load("FX/boom1_CT_KICK"), (Vector3)((base.transform.position + (base.transform.forward * 120f)) + (base.transform.right * 30f)), Quaternion.Euler(270f, 0f, 0f), 0); Network.Instantiate(Resources.Load("rock"), (Vector3)((base.transform.position + (base.transform.forward * 120f)) + (base.transform.right * 30f)), Quaternion.Euler(0f, 0f, 0f), 0); } else { PhotonNetwork.Instantiate("FX/boom1_CT_KICK", (Vector3)((base.transform.position + (base.transform.forward * 120f)) + (base.transform.right * 30f)), Quaternion.Euler(270f, 0f, 0f), 0); PhotonNetwork.Instantiate("rock", (Vector3)((base.transform.position + (base.transform.forward * 120f)) + (base.transform.right * 30f)), Quaternion.Euler(0f, 0f, 0f), 0); } } else { UnityEngine.Object.Instantiate(Resources.Load("FX/boom1_CT_KICK"), (Vector3)((base.transform.position + (base.transform.forward * 120f)) + (base.transform.right * 30f)), Quaternion.Euler(270f, 0f, 0f)); UnityEngine.Object.Instantiate(Resources.Load("rock"), (Vector3)((base.transform.position + (base.transform.forward * 120f)) + (base.transform.right * 30f)), Quaternion.Euler(0f, 0f, 0f)); } } if (base.GetComponent <Animation>()[this.actionName].normalizedTime >= 1f) { this.findNearestHero(); this.idle(); this.playAnimation("idle"); } } else if (this.state == "slap") { if (!this.attackChkOnce && (base.GetComponent <Animation>()["attack_slap_" + this.attackAnimation].normalizedTime >= this.attackCheckTime)) { GameObject obj4; this.attackChkOnce = true; if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.MULTIPLAYER) { if (FengGameManagerMKII.LAN) { obj4 = (GameObject)Network.Instantiate(Resources.Load("FX/boom1"), this.checkHitCapsuleStart.position, Quaternion.Euler(270f, 0f, 0f), 0); } else { obj4 = PhotonNetwork.Instantiate("FX/boom1", this.checkHitCapsuleStart.position, Quaternion.Euler(270f, 0f, 0f), 0); } if (obj4.GetComponent <EnemyfxIDcontainer>() != null) { obj4.GetComponent <EnemyfxIDcontainer>().titanName = base.name; } } else { obj4 = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("FX/boom1"), this.checkHitCapsuleStart.position, Quaternion.Euler(270f, 0f, 0f)); } obj4.transform.localScale = new Vector3(5f, 5f, 5f); } if (base.GetComponent <Animation>()["attack_slap_" + this.attackAnimation].normalizedTime >= 1f) { this.findNearestHero(); this.idle(); this.playAnimation("idle"); } } else if (this.state == "steam") { if (!this.attackChkOnce && (base.GetComponent <Animation>()[this.actionName].normalizedTime >= this.attackCheckTime)) { this.attackChkOnce = true; if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.MULTIPLAYER) { if (FengGameManagerMKII.LAN) { Network.Instantiate(Resources.Load("FX/colossal_steam"), base.transform.position + ((Vector3)(base.transform.up * 185f)), Quaternion.Euler(270f, 0f, 0f), 0); Network.Instantiate(Resources.Load("FX/colossal_steam"), base.transform.position + ((Vector3)(base.transform.up * 303f)), Quaternion.Euler(270f, 0f, 0f), 0); Network.Instantiate(Resources.Load("FX/colossal_steam"), base.transform.position + ((Vector3)(base.transform.up * 50f)), Quaternion.Euler(270f, 0f, 0f), 0); } else { PhotonNetwork.Instantiate("FX/colossal_steam", base.transform.position + ((Vector3)(base.transform.up * 185f)), Quaternion.Euler(270f, 0f, 0f), 0); PhotonNetwork.Instantiate("FX/colossal_steam", base.transform.position + ((Vector3)(base.transform.up * 303f)), Quaternion.Euler(270f, 0f, 0f), 0); PhotonNetwork.Instantiate("FX/colossal_steam", base.transform.position + ((Vector3)(base.transform.up * 50f)), Quaternion.Euler(270f, 0f, 0f), 0); } } else { UnityEngine.Object.Instantiate(Resources.Load("FX/colossal_steam"), base.transform.position + ((Vector3)(base.transform.forward * 185f)), Quaternion.Euler(270f, 0f, 0f)); UnityEngine.Object.Instantiate(Resources.Load("FX/colossal_steam"), base.transform.position + ((Vector3)(base.transform.forward * 303f)), Quaternion.Euler(270f, 0f, 0f)); UnityEngine.Object.Instantiate(Resources.Load("FX/colossal_steam"), base.transform.position + ((Vector3)(base.transform.forward * 50f)), Quaternion.Euler(270f, 0f, 0f)); } } if (base.GetComponent <Animation>()[this.actionName].normalizedTime >= 1f) { if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.MULTIPLAYER) { if (FengGameManagerMKII.LAN) { Network.Instantiate(Resources.Load("FX/colossal_steam_dmg"), base.transform.position + ((Vector3)(base.transform.up * 185f)), Quaternion.Euler(270f, 0f, 0f), 0); Network.Instantiate(Resources.Load("FX/colossal_steam_dmg"), base.transform.position + ((Vector3)(base.transform.up * 303f)), Quaternion.Euler(270f, 0f, 0f), 0); Network.Instantiate(Resources.Load("FX/colossal_steam_dmg"), base.transform.position + ((Vector3)(base.transform.up * 50f)), Quaternion.Euler(270f, 0f, 0f), 0); } else { GameObject obj5 = PhotonNetwork.Instantiate("FX/colossal_steam_dmg", base.transform.position + ((Vector3)(base.transform.up * 185f)), Quaternion.Euler(270f, 0f, 0f), 0); if (obj5.GetComponent <EnemyfxIDcontainer>() != null) { obj5.GetComponent <EnemyfxIDcontainer>().titanName = base.name; } obj5 = PhotonNetwork.Instantiate("FX/colossal_steam_dmg", base.transform.position + ((Vector3)(base.transform.up * 303f)), Quaternion.Euler(270f, 0f, 0f), 0); if (obj5.GetComponent <EnemyfxIDcontainer>() != null) { obj5.GetComponent <EnemyfxIDcontainer>().titanName = base.name; } obj5 = PhotonNetwork.Instantiate("FX/colossal_steam_dmg", base.transform.position + ((Vector3)(base.transform.up * 50f)), Quaternion.Euler(270f, 0f, 0f), 0); if (obj5.GetComponent <EnemyfxIDcontainer>() != null) { obj5.GetComponent <EnemyfxIDcontainer>().titanName = base.name; } } } else { UnityEngine.Object.Instantiate(Resources.Load("FX/colossal_steam_dmg"), base.transform.position + ((Vector3)(base.transform.forward * 185f)), Quaternion.Euler(270f, 0f, 0f)); UnityEngine.Object.Instantiate(Resources.Load("FX/colossal_steam_dmg"), base.transform.position + ((Vector3)(base.transform.forward * 303f)), Quaternion.Euler(270f, 0f, 0f)); UnityEngine.Object.Instantiate(Resources.Load("FX/colossal_steam_dmg"), base.transform.position + ((Vector3)(base.transform.forward * 50f)), Quaternion.Euler(270f, 0f, 0f)); } if (this.hasDie) { if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE) { UnityEngine.Object.Destroy(base.gameObject); } else if (FengGameManagerMKII.LAN) { if (base.photonView.isMine) { } } else if (PhotonNetwork.isMasterClient) { PhotonNetwork.Destroy(base.photonView); } GameObject.Find("MultiplayerManager").GetComponent <FengGameManagerMKII>().gameWin2(); } this.findNearestHero(); this.idle(); this.playAnimation("idle"); } } else if (this.state == string.Empty) { } } else if (this.attackPattern == -1) { this.slap("r1"); this.attackPattern++; } else if (this.attackPattern == 0) { this.attack_sweep(string.Empty); this.attackPattern++; } else if (this.attackPattern == 1) { this.steam(); this.attackPattern++; } else if (this.attackPattern == 2) { this.kick(); this.attackPattern++; } else if (this.isSteamNeed || this.hasDie) { this.steam(); this.isSteamNeed = false; } else if (this.myHero == null) { this.findNearestHero(); } else { Vector3 vector = this.myHero.transform.position - base.transform.position; float current = -Mathf.Atan2(vector.z, vector.x) * 57.29578f; float f = -Mathf.DeltaAngle(current, base.gameObject.transform.rotation.eulerAngles.y - 90f); this.myDistance = Mathf.Sqrt(((this.myHero.transform.position.x - base.transform.position.x) * (this.myHero.transform.position.x - base.transform.position.x)) + ((this.myHero.transform.position.z - base.transform.position.z) * (this.myHero.transform.position.z - base.transform.position.z))); float num4 = this.myHero.transform.position.y - base.transform.position.y; if ((this.myDistance < 85f) && (UnityEngine.Random.Range(0, 100) < 5)) { this.steam(); } else { if ((num4 > 310f) && (num4 < 350f)) { if (Vector3.Distance(this.myHero.transform.position, base.transform.Find("APL1").position) < 40f) { this.slap("l1"); return; } if (Vector3.Distance(this.myHero.transform.position, base.transform.Find("APL2").position) < 40f) { this.slap("l2"); return; } if (Vector3.Distance(this.myHero.transform.position, base.transform.Find("APR1").position) < 40f) { this.slap("r1"); return; } if (Vector3.Distance(this.myHero.transform.position, base.transform.Find("APR2").position) < 40f) { this.slap("r2"); return; } if ((this.myDistance < 150f) && (Mathf.Abs(f) < 80f)) { this.attack_sweep(string.Empty); return; } } if (((num4 < 300f) && (Mathf.Abs(f) < 80f)) && (this.myDistance < 85f)) { this.attack_sweep("_vertical"); } else { switch (UnityEngine.Random.Range(0, 7)) { case 0: this.slap("l1"); break; case 1: this.slap("l2"); break; case 2: this.slap("r1"); break; case 3: this.slap("r2"); break; case 4: this.attack_sweep(string.Empty); break; case 5: this.attack_sweep("_vertical"); break; case 6: this.steam(); break; } } } } } }
public void OnTriggerEnter(Collider other) { var parentTag = other.transform.root.tag; //If we collide with Player if (parentTag == "Player") { //If the obj we collided with is ourselves, return, else we collided with something important if (other.transform.GetComponentInParent <NetworkPlayer>().gameObject.name == PFC.myID) { Debug.Log("Collided with self"); return; } else { var player = other.GetComponentInParent <NetworkPlayer>().gameObject; Debug.Log("Collided with another player with ID: " + player.name + ", set bool value here for social menu"); //Setup Pause Menu inside player model prefabs instead of GO inside hirearchy and re-assign links and store ID of player were infront of in our panel for easy Add Req //PFC.friendListPanel.transform.GetChild(3).GetComponent<Text>().text = player.name; return; } } //If we collide with ChangeScene OBJ if (parentTag == "ChangeScene") { if (other.transform.GetComponent <ChangeScene>()) { Debug.Log("Press E To Change Scene"); currrentSceneChageOBJ = other.gameObject; changeScenes = true; return; } } if (parentTag == "Item") { var item = other.GetComponent <Item>(); itemPV = item.GetComponent <PhotonView>(); if (itemPV == null) { Debug.Log("PhotonView of item is missing!"); return; } else { inventory.AddItem(item.item, 1, item.item.image); if (itemPV.InstantiationId != 0) { //This deletes INSTANTIATED items on the Network PhotonNetwork.Destroy(other.gameObject); return; } if (itemPV.InstantiationId == 0) { Destroy(other.gameObject); return; } } } }
//Denne funktion kører når vi forlader et rum public override void OnLeftRoom() { //Disable player for alle andre spillere base.OnLeftRoom(); PhotonNetwork.Destroy(spawnedPlayerPrefab); }
public void onRemove() { PhotonNetwork.Destroy(gameObject); }
public void DIE() { PhotonNetwork.Destroy(me); PhotonNetwork.Disconnect(); Application.LoadLevel(0); }
protected void DestroyObject() { OnNPCKilledCallback?.Invoke(); PhotonNetwork.Destroy(gameObject); }
// Update is called once per frame void Update() { if (Life <= 0) { anim.SetBool("died", true); PhotonNetwork.Destroy(weapon); if ((TTD -= Time.deltaTime) <= 0) { PhotonNetwork.Disconnect(); SceneManager.LoadScene("Dead"); SceneManager.UnloadScene(SceneManager.GetActiveScene()); PhotonNetwork.Destroy(this.gameObject); } } else { /*if(Camera.main.transform.position.x>-30 && Camera.main.transform.position.y>=-3.6f) * Camera.main.transform.position = new Vector3(transform.position.x, 0, 0); * else * Camera.main.transform.position = new Vector3(transform.position.x, transform.position.y + 3.595003f, 0);*/ if (transform.position.y > 4.7f || transform.position.y < -3.8f) { Camera.main.transform.position = new Vector3(transform.position.x, transform.position.y + 2, 0); } else { Camera.main.transform.position = new Vector3(transform.position.x, 0, 0); } if (can_jump == false) { anim.SetInteger("speed", 0); } /*if (transform.position.x < -11.2) * Rg2d.AddForce(new Vector3(1,0,0)); * * if(transform.position.x > 11.15f) * Rg2d.AddForce(new Vector3(-1, 0, 0));*/ if (Input.GetKeyDown(KeyCode.Escape)) { Cursor.visible = true; } if (Input.GetKey(KeyCode.A)) { anim.SetInteger("speed", -1); this.transform.Translate(-speed, 0, 0); } if (Input.GetKey(KeyCode.D)) { anim.SetInteger("speed", 1); this.transform.Translate(speed, 0, 0); } if (Input.GetKeyDown(KeyCode.Space) && can_jump) { can_jump = false; Rg2d.AddForce(Vector3.up * jump_force); } if (!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.Space)) { anim.SetInteger("speed", 0); } } }
private void LateUpdate() { if (this.myHero == null && BasePV.IsMine) { PhotonNetwork.Destroy(base.gameObject); } if (this.State == "mounted") { if (this.myHero == null) { this.unmounted(); return; } this.myHero.transform.position = base.transform.position + Vectors.up * 1.68f; this.myHero.transform.rotation = base.transform.rotation; this.myHero.rigidbody.velocity = base.rigidbody.velocity; if (this.controller.targetDirection != -874f) { base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, this.controller.targetDirection, 0f), 100f * Time.deltaTime / (base.rigidbody.velocity.magnitude + 20f)); if (this.controller.isWALKDown) { base.rigidbody.AddForce(base.transform.Forward() * this.speed * 0.6f, ForceMode.Acceleration); if (base.rigidbody.velocity.magnitude >= this.speed * 0.6f) { base.rigidbody.AddForce(-this.speed * 0.6f * base.rigidbody.velocity.normalized, ForceMode.Acceleration); } } else { base.rigidbody.AddForce(base.transform.Forward() * this.speed, ForceMode.Acceleration); if (base.rigidbody.velocity.magnitude >= this.speed) { base.rigidbody.AddForce(-this.speed * base.rigidbody.velocity.normalized, ForceMode.Acceleration); } } if (base.rigidbody.velocity.magnitude > 8f) { if (!base.animation.IsPlaying("horse_Run")) { this.crossFade("horse_Run", 0.1f); } if (!this.myHero.animation.IsPlaying("horse_Run")) { this.myHero.GetComponent <HERO>().crossFade("horse_run", 0.1f); } if (!this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = true; BasePV.RPC("setDust", PhotonTargets.Others, new object[] { true }); } } else { if (!base.animation.IsPlaying("horse_WALK")) { this.crossFade("horse_WALK", 0.1f); } if (!this.myHero.animation.IsPlaying("horse_idle")) { this.myHero.GetComponent <HERO>().crossFade("horse_idle", 0.1f); } if (this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = false; BasePV.RPC("setDust", PhotonTargets.Others, new object[] { false }); } } } else { this.toIdleAnimation(); if (base.rigidbody.velocity.magnitude > 15f) { if (!this.myHero.animation.IsPlaying("horse_Run")) { this.myHero.GetComponent <HERO>().crossFade("horse_run", 0.1f); } } else if (!this.myHero.animation.IsPlaying("horse_idle")) { this.myHero.GetComponent <HERO>().crossFade("horse_idle", 0.1f); } } if ((this.controller.isAttackDown || this.controller.isAttackIIDown) && this.IsGrounded()) { base.rigidbody.AddForce(Vectors.up * 25f, ForceMode.VelocityChange); } } else if (this.State == "follow") { if (this.myHero == null) { this.unmounted(); return; } if (base.rigidbody.velocity.magnitude > 8f) { if (!base.animation.IsPlaying("horse_Run")) { this.crossFade("horse_Run", 0.1f); } if (!this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = true; BasePV.RPC("setDust", PhotonTargets.Others, new object[] { true }); } } else { if (!base.animation.IsPlaying("horse_WALK")) { this.crossFade("horse_WALK", 0.1f); } if (this.dust.GetComponent <ParticleSystem>().enableEmission) { this.dust.GetComponent <ParticleSystem>().enableEmission = false; BasePV.RPC("setDust", PhotonTargets.Others, new object[] { false }); } } float num = -Mathf.DeltaAngle(FengMath.getHorizontalAngle(base.transform.position, this.setPoint), base.gameObject.transform.rotation.eulerAngles.y - 90f); base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, base.gameObject.transform.rotation.eulerAngles.y + num, 0f), 200f * Time.deltaTime / (base.rigidbody.velocity.magnitude + 20f)); if (Vector3.Distance(this.setPoint, base.transform.position) < 20f) { base.rigidbody.AddForce(base.transform.Forward() * this.speed * 0.7f, ForceMode.Acceleration); if (base.rigidbody.velocity.magnitude >= this.speed) { base.rigidbody.AddForce(-this.speed * 0.7f * base.rigidbody.velocity.normalized, ForceMode.Acceleration); } } else { base.rigidbody.AddForce(base.transform.Forward() * this.speed, ForceMode.Acceleration); if (base.rigidbody.velocity.magnitude >= this.speed) { base.rigidbody.AddForce(-this.speed * base.rigidbody.velocity.normalized, ForceMode.Acceleration); } } this.timeElapsed += Time.deltaTime; if (this.timeElapsed > 0.6f) { this.timeElapsed = 0f; if (Vector3.Distance(this.myHero.transform.position, this.setPoint) > 20f) { this.followed(); } } if (Vector3.Distance(this.myHero.transform.position, base.transform.position) < 5f) { this.unmounted(); } if (Vector3.Distance(this.setPoint, base.transform.position) < 5f) { this.unmounted(); } this.awayTimer += Time.deltaTime; if (this.awayTimer > 6f) { this.awayTimer = 0f; if (Physics.Linecast(base.transform.position + Vectors.up, this.myHero.transform.position + Vectors.up, Layers.Ground.value)) { base.transform.position = new Vector3(this.myHero.transform.position.x, this.getHeight(this.myHero.transform.position + Vectors.up * 5f), this.myHero.transform.position.z); } } } else if (this.State == "idle") { this.toIdleAnimation(); if (this.myHero != null && Vector3.Distance(this.myHero.transform.position, base.transform.position) > 20f) { this.followed(); } } base.rigidbody.AddForce(new Vector3(0f, -50f * base.rigidbody.mass, 0f)); }
public void netDie(Vector3 v, bool isBite, int viewID = -1, string titanName = "", bool killByTitan = true, PhotonMessageInfo info = null) { if (PhotonNetwork.IsMasterClient) { OnDeathEvent(viewID, killByTitan); if (RCManager.heroHash.ContainsKey(viewID)) { RCManager.heroHash.Remove(viewID); } } if (BasePV.IsMine && titanForm && eren != null) { eren.GetComponent <TITAN_EREN>().lifeTime = 0.1f; } if (bulletLeft) { bulletLeft.RemoveMe(); } if (bulletRight) { bulletRight.RemoveMe(); } meatDie.Play(); if (!Gunner && (IN_GAME_MAIN_CAMERA.GameType == GameType.Single || BasePV.IsMine)) { leftbladetrail.Deactivate(); rightbladetrail.Deactivate(); leftbladetrail2.Deactivate(); rightbladetrail2.Deactivate(); } FalseAttack(); BreakApart(v, isBite); if (BasePV.IsMine) { IN_GAME_MAIN_CAMERA.MainCamera.setSpectorMode(false); IN_GAME_MAIN_CAMERA.MainCamera.gameOver = true; FengGameManagerMKII.FGM.logic.MyRespawnTime = 0f; } IsDead = true; var audioTransform = baseT.Find("audio_die"); audioTransform.parent = null; audioTransform.GetComponent <AudioSource>().Play(); baseG.GetComponent <SmoothSyncMovement>().Disabled = true; if (BasePV.IsMine) { if (myBomb != null) { myBomb.destroyMe(); } if (myCannon != null) { PhotonNetwork.Destroy(myCannon); } PhotonNetwork.RemoveRPCs(BasePV); PhotonNetwork.player.Dead = true; PhotonNetwork.player.Deaths++; FengGameManagerMKII.FGM.BasePV.RPC("someOneIsDead", PhotonTargets.MasterClient, titanName == string.Empty ? 0 : 1); if (viewID != -1) { var photonView = PhotonView.Find(viewID); if (photonView != null) { FengGameManagerMKII.FGM.SendKillInfo(killByTitan, User.DeathFormat(info.Sender.ID, info.Sender.UIName), false, User.DeathName); photonView.owner.Kills++; } } else { FengGameManagerMKII.FGM.SendKillInfo(titanName != string.Empty, User.DeathFormat(info.Sender.ID, titanName), false, User.DeathName); } AnarchyManager.Feed.Kill(titanName, User.DeathName, 0); } if (BasePV.IsMine) { PhotonNetwork.Destroy(BasePV); } }
void OnCollisionEnter(Collision collision) { PhotonNetwork.Destroy(gameObject); //Destroy(gameObject); }
private void netDie2(int viewID = -1, string titanName = "", PhotonMessageInfo info = null) { if (BasePV.IsMine) { if (myBomb != null) { myBomb.destroyMe(); } if (myCannon != null) { PhotonNetwork.Destroy(myCannon); } PhotonNetwork.RemoveRPCs(BasePV); if (titanForm && eren != null) { eren.GetComponent <TITAN_EREN>().lifeTime = 0.1f; } if (skillCD != null) { skillCD.transform.localPosition = Vectors.up * 5000f; } } meatDie.Play(); if (bulletLeft != null) { bulletLeft.RemoveMe(); } if (bulletRight != null) { bulletRight.RemoveMe(); } var audioTf = baseT.Find("audio_die"); if (audioTf != null) { audioTf.parent = null; audioTf.GetComponent <AudioSource>().Play(); } if (BasePV.IsMine) { IN_GAME_MAIN_CAMERA.MainCamera.SetMainObject(null); IN_GAME_MAIN_CAMERA.MainCamera.setSpectorMode(true); IN_GAME_MAIN_CAMERA.MainCamera.gameOver = true; FengGameManagerMKII.FGM.logic.MyRespawnTime = 0f; } FalseAttack(); IsDead = true; baseG.GetComponent <SmoothSyncMovement>().Disabled = true; if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && BasePV.IsMine) { PhotonNetwork.RemoveRPCs(BasePV); PhotonNetwork.player.Dead = true; PhotonNetwork.player.Deaths++; if (viewID != -1) { var photonView = PhotonView.Find(viewID); if (photonView != null) { FengGameManagerMKII.FGM.SendKillInfo(true, User.DeathFormat(info.Sender.ID, info.Sender.UIName), false, User.DeathName); photonView.owner.Kills++; } } else { FengGameManagerMKII.FGM.SendKillInfo(true, User.DeathFormat(info.Sender.ID, titanName), false, User.DeathName); } AnarchyManager.Feed.Kill(titanName, User.DeathName, 0); FengGameManagerMKII.FGM.BasePV.RPC("someOneIsDead", PhotonTargets.MasterClient, titanName != string.Empty ? 1 : 0); } if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && BasePV.IsMine) { Pool.NetworkEnable("hitMeat2", baseT.position, Quaternion.Euler(270f, 0f, 0f)); } else { Pool.Enable("hitMeat2", baseT.position, Quaternion.identity); } if (PhotonNetwork.IsMasterClient) { OnDeathEvent(viewID, true); if (RCManager.heroHash.ContainsKey(viewID)) { RCManager.heroHash.Remove(viewID); } } if (BasePV.IsMine) { PhotonNetwork.Destroy(BasePV); } }
void Kill() { PhotonNetwork.Destroy(this.gameObject); }
public void Die() { gameManager_gm.OnDie(); PhotonNetwork.Destroy(nameTag); PhotonNetwork.Destroy(gameObject); }
private void checkInput() { if (timeCantBeHit > 0 && pH.isPlayScene) { timeCantBeHit -= Time.deltaTime; borderHit(); } transform.rotation = selfQuat; if (Input.GetKeyDown(KeyCode.W)) { //gameObject.GetComponent<SpriteRenderer>().sprite = sprDir[0]; currSpr = 0; dirY = 1; dirX = 0; currSpBull = 0; prevDir = new Vector3(dirX, dirY, 0); } if (Input.GetKeyDown(KeyCode.S)) { //gameObject.GetComponent<SpriteRenderer>().sprite = sprDir[2]; currSpr = 2; dirY = -1; dirX = 0; currSpBull = 3; prevDir = new Vector3(dirX, dirY, 0); } if (Input.GetKeyDown(KeyCode.A)) { //gameObject.GetComponent<SpriteRenderer>().sprite = sprDir[1]; currSpr = 1; dirY = 0; dirX = -1; currSpBull = 2; prevDir = new Vector3(dirX, dirY, 0); } if (Input.GetKeyDown(KeyCode.D)) { //gameObject.GetComponent<SpriteRenderer>().sprite = sprDir[3]; currSpr = 3; dirY = 0; dirX = 1; currSpBull = 1; prevDir = new Vector3(dirX, dirY, 0); } if (Input.GetKeyUp(KeyCode.Space) && pH.isPlayScene) { bullet.GetComponent <buMove>().dirX = prevDir.x; bullet.GetComponent <buMove>().dirY = prevDir.y; //PhotonNetwork.Instantiate(bullet.name,spBulls[currSpBull].transform.position, bullet.transform.rotation, 0); pH.CreateBullet(bullet, spBulls[currSpBull]); } if (Input.GetKeyUp(KeyCode.Escape)) { if (photonView.isMine) { PhotonNetwork.Destroy(gameObject); //PhotonNetwork.LeaveRoom(true); PhotonNetwork.Disconnect(); } } if (!Input.anyKey) { //prevDir = new Vector3(dirX, dirY, 0); dirY = 0; dirX = 0; } //var moveHor = new Vector3(Input.GetAxis("Horizontal"),0); //moveHor = new Vector3( 0, Input.GetAxis("Vertical")); gameObject.GetComponent <SpriteRenderer>().sprite = sprDir[currSpr]; transform.position += new Vector3(1 * dirX, 1 * dirY, 0) * moveSpeed * Time.deltaTime; if (Hp <= 0) { Respawn(); } }
private void FixedUpdate() { leftVal = leftHeld ? 1.0f : 0.0f; rightVal = rightHeld ? 1.0f : 0.0f; upVal = upHeld ? 1.0f : 0.0f; downVal = downHeld ? 1.0f : 0.0f; float zVal = upVal - downVal; float xVal = rightVal - leftVal; Vector3 moveDir = new Vector3(xVal, 0f, zVal).normalized *speed; // Rotation if (moveDir != Vector3.zero) { transform.rotation = Quaternion.LookRotation(moveDir, Vector3.up); } if (dashTime == .5f) { dashCD = 2.0f; } // Dash if (dashTime > 0) { moveDir *= 3f; } // Update movement rb.velocity = moveDir; dashCD -= Time.deltaTime; if (animator) { animator.SetFloat("speed", rb.velocity.magnitude); } if (trashThrow) { GameObject trashSpawned = Instantiate(trash, transform.position + transform.forward * 2f + Vector3.up * 1.5f, Quaternion.identity); trashSpawned.transform.rotation = transform.rotation; trashSpawned.GetComponent <Rigidbody>().velocity = ((trashSpawned.transform.forward + (trashSpawned.transform.right * Random.Range(-throwSpread, throwSpread))).normalized * 40.0f); trashSpawned.GetComponent <Rigidbody>().AddRelativeTorque(new Vector3(0, 0, 100.0f)); trashThrow = false; } // This section down here is dependent to be only for the main player's racoon if (photonView.IsMine == false && PhotonNetwork.IsConnected == true) { return; } // CHECK FOR BOUNDS CHECKING FOR MINIGAMES, THERE WILL BE A BETTER WAY THAN THIS FOR NOW if (!isInMinigame && transform.position.x < -27) { isInMinigame = true; // Go to the minigame PhotonNetwork.LoadLevel(2); //Delete the player PhotonNetwork.Destroy(gameObject); } }
bool destroyedAlready = false; //this can cause a problem when both eye and body collide with the portal at the same time. So when we get the first hit, we set a bool to not //trigger photonnetwork.destroy twice void GetDestroyed() { destroyedAlready = true; PhotonNetwork.Destroy(gameObject); }
IEnumerator DestroyThis() { yield return(new WaitForSeconds(0.15f)); PhotonNetwork.Destroy(this.gameObject); }