void OnTriggerStay(Collider coll) { if (coll.tag == "Player") { // GameObject hitPlayer = coll.gameObject; nView = coll.GetComponent<NetworkView>(); nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 1); } if (coll.tag == "Boss") { // GameObject hitPlayer = coll.gameObject; nView = coll.GetComponent<NetworkView>(); nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 1); if (nView.isMine) { Sentry companion; companion = nView.GetComponent<Sentry>(); companion.ClientTakeDamageFromWeapon(1); } else { nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 1); } } }
public CombatHandler(NetworkView nv) { _nv = nv; //Get Memory for the list _effectDictionary = new Dictionary<PlayerObject, List<DynamicEffect>>(SIZE); }
void Awake() { cam = GetComponentInChildren<Camera>(); animator = (Animator)GetComponent<Animator> (); networkView = GetComponent<NetworkView> (); Respawn (); }
// Use this for initialization void Start() { text = ui.GetComponent<Text> (); mControl = GetComponent<MovementController> (); charClass = GetComponent<CharacterClass> (); netview = mControl.netView; }
public void Start () { //Initializes on start up to listen for messages //make sure this game object has both UDPPackIO and OSC script attached UDPPacketIO udp = (UDPPacketIO)GetComponent("UDPPacketIO"); udp.init(RemoteIP, SendToPort, ListenerPort); handler = (Osc)GetComponent("Osc"); handler.init(udp); handler.SetAllMessageHandler(AllMessageHandler); tornadoSlider = GameObject.Find("Tornado Slider").GetComponent<UnityEngine.UI.Slider>(); munchkinSlider = GameObject.Find("Munchkin Slider").GetComponent<UnityEngine.UI.Slider>(); poppySlider = GameObject.Find("Poppy Slider").GetComponent<UnityEngine.UI.Slider>(); monkeySlider = GameObject.Find("Monkey Slider").GetComponent<UnityEngine.UI.Slider>(); fireSlider = GameObject.Find("Fire Slider").GetComponent<UnityEngine.UI.Slider>(); transSpeedSlider = GameObject.Find("Transition Slider").GetComponent<UnityEngine.UI.Slider>(); nv = GameObject.Find("Network").GetComponent<NetworkView>(); Debug.Log("Osc Running"); }
// ============================================================================= // ============================================================================= // METHODS UNITY --------------------------------------------------------------- void Awake() { Config = GameObject.FindWithTag( "Config" ).GetComponent<Config>(); CamTransform = Cam.transform; NetView = gameObject.networkView; }
protected override void Awake() { base.Awake (); mView = networkView; mBallRigid = mBallGuard.rigidbody; mBallTransform = mBallGuard.transform; }
// Use this for initialization void Start() { gameLogic = GameObject.Find("GameLogic").GetComponent<RPCUpdates>(); audio = GetComponent<AudioSource>(); sphere = GetComponent<Rigidbody> (); nV = GetComponent<NetworkView>(); }
public void AllocateNetworkViewID(string _requestID, NetworkView _networkView) { if (mAllocateRequests.ContainsKey(_requestID)) { Debug.Log("Request " + _requestID + " is incomplete. Please wait."); return; } if (mAllocationCache.ContainsKey(_requestID)) { _networkView.viewID = mAllocationCache[_requestID]; return; } if (Network.isServer) { _networkView.viewID = Network.AllocateViewID(); mAllocationCache.Add(_requestID, _networkView.viewID); } else if (Network.isClient) { mAllocateRequests.Add(_requestID, new WeakReference(_networkView)); networkView.RPC("NetworkViewAllocator_RequestViewID", RPCMode.Server, Network.player, _requestID); } else { Debug.Log("The connect is not established yet, try after connected to server."); return; } }
void Awake() { MyNetworkView = gameObject.GetComponent<NetworkView> (); OnlineName = gameObject.name; // maybe reload the last used name from PlayerPrefs or generate a random name BroadcastNickName(); }
void Awake() { animationState = 0; animator = (Animator)GetComponent<Animator> (); animator.SetInteger ("State", animationState); networkView = GetComponent<NetworkView> (); }
//dan //protected PlayerRotation PlayerRot; // ============================================================================= // ============================================================================= // METHODS UNITY --------------------------------------------------------------- protected virtual void Awake() { Config = GameObject.FindWithTag ( "Config" ).GetComponent<Config> (); Trans = transform; Audio = audio; NetView = networkView; GameObject player = GameObject.FindWithTag ( "Player" ); PlayerMov = player.GetComponent<PlayerMovement> (); //dan //TODO: fix player Rotation //PlayerRot = player.GetComponent<PlayerRotation> (); Equip = gameObject.GetComponent<Equipment> (); if ( DisplayLeft ) { DisplayLeft.renderer.material.color = DisplayColor; } if ( DisplayRight ) { DisplayRight.renderer.material.color = DisplayColor; } }
/// <summary> /// find a networkview based on a networkviewid that was serialized into an rpc /// </summary> /// <param name="message">uses deserialize, so the read location does advance</param> /// <param name="view"></param> /// <returns></returns> public bool Find(ref NetIncomingMessage message, out NetworkView view) { var id = new NetworkViewId(); id.OnDeserialize(message); return Find(id, out view); }
public void Allocate(string _requestKey, NetworkView _networkView, Action _callback) { NetworkViewID _bufferedViewID; if (mAllocationBuffer.TryGetValue(_requestKey, out _bufferedViewID)) { _networkView.viewID = _bufferedViewID; return; } if (mAllocateRequests.ContainsKey(_requestKey)) { Debug.Log("Request " + _requestKey + " is incomplete. Please wait."); return; } if (Network.isServer) { _networkView.viewID = Network.AllocateViewID(); mAllocationBuffer.Add(_requestKey, _networkView.viewID); } else if (Network.isClient) { var _job = new AllocationJob(); _job.networkView = _networkView; _job.callback = _callback; mAllocateRequests.Add(_requestKey, _job); networkView.RPC("NetworkViewAllocator_RequestViewID", RPCMode.Server, Network.player, _requestKey); } else { Debug.Log("The connect is not established yet, try after connected to server."); return; } }
void Start() { m_animator = GetComponentInChildren<Animator>(); myNetworkView = GetComponent<NetworkView>(); myAudioSource = GetComponent<AudioSource>(); SetColliders( false ); }
public static void Buffer(NetworkView view, string func, RPCMode mode, params object[] args) { //first fix up the mode so no one accidentally passes in a buffered mode if(mode == RPCMode.AllBuffered) mode = RPCMode.All; else if(mode == RPCMode.OthersBuffered) mode = RPCMode.Others; if(m_RPCs == null) m_RPCs = new BufferedRPC[0]; BufferedRPC [] temp = new BufferedRPC[m_RPCs.Length+1]; if(m_RPCs.Length > 0) m_RPCs.CopyTo(temp,0); BufferedRPC tempRPC = new BufferedRPC(); tempRPC.func = func; tempRPC.mode = mode; if(args != null) { // for(int i = 0; i < args.Length; i++) // Debug.Log(args[i].ToString() + ", "); tempRPC.args = new object[args.Length]; args.CopyTo(tempRPC.args,0); } tempRPC.view = view; temp[temp.Length-1] = tempRPC; m_RPCs = temp; view.RPC(func, mode, args); }
void OnConnectedToServer() { if (Server.g && Server.g.IsClient()) { m_networkView = GetComponent<NetworkView>(); Server.g.SyncViewIds (m_networkView, "Avatar"); } }
// Use this for initialization void Start() { //myInputBox = GetComponentInChildren<UnityEngine.UI.InputField>(); //myChatBox = GetComponentInChildren<UnityEngine.UI.Text>(); myNetworkView = GetComponent<NetworkView>(); myNetworkManager = Camera.main.GetComponent<NetworkManager>(); }
public void addScopeNetView(NetworkView[] pNetworkViews) { foreach (var lNetworkView in pNetworkViews) { addScopeNetView(lNetworkView); } }
void Start() { tParent = transform.parent; networkView = tParent.GetComponent <NetworkView>(); gameObject.SetActive(networkView.isMine); gm = GameManager.Instance; }
/** * Diese Methode wird vor der Startmethode aufgerufen und setzt wichtige Parameter. */ void Awake() { Type = TriggerType.PermanentOpen; Trigger = TriggerObject.Script; Config = GameObject.FindWithTag( "Config" ).GetComponent<Config>(); Ani = animation; NetView = networkView; }
void Awake() { netView = gameObject.AddComponent( typeof( NetworkView ) ) as NetworkView; // добавляем компонент NetworkView нашему игровому обьекту netView.viewID = Network.AllocateViewID(); // присваеваем уникальный индификатор в сети netView.observed = this; // указиваем этот скрипт (компонент) для синхронизации netView.stateSynchronization = NetworkStateSynchronization.Unreliable; // нам подходит способ быстрой передачи с потерями так как наше передвижение интерполируется lastSynchronizationTime = Time.time; // последнее время синхронизации }
void Start() { Debug.Log("Start: " + name + " id:" + GetInstanceID()); netView = GetComponent<NetworkView>(); if (isNotMine) { collider.enabled = false; } }
// Use this for initialization void Awake() { //Objekt soll bestehen bleiben DontDestroyOnLoad(this); netView = gameObject.GetComponent<NetworkView>(); // NetworkView ID | Spielername | gewähltes Autos (Default: Dodge Charger Lee), abhängig vom ersten Auto in Carselection | ist Spieler bereit? playerData = new string[]{netView.viewID.ToString(), PlayerPrefs.GetString("PlayerOneName"), "Dodge Charger Lee", "nicht bereit"}; }
void OnTriggerEnter(Collider other) { if(other.tag == "Player") { nView = other.GetComponent<NetworkView>(); nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 50); } }
internal void RemoveView(NetworkView view) { if (view.Manager == this) { _allViews.Remove(view.ViewID.guid); RecycleNetworkView(view); } }
// Use this for initialization void Awake() { nView = GetComponent<NetworkView>(); if(!nView.isMine) enabled = false; Name = Get.Name; CreateNeeds(); SetDress (); }
public void SyncViewIds(NetworkView ownerView, string slaveTag) { NetworkViewID viewID = Network.AllocateViewID(); ownerView.viewID = viewID; Debug.Log("Local ID:"); Debug.Log(m_networkView.viewID); m_networkView.RPC("SyncNetworkViewID", RPCMode.Others, viewID, slaveTag); ownerView.stateSynchronization = NetworkStateSynchronization.Unreliable; }
void OnConnectedToServer() { if (Server.g && Server.g.IsClient()) { m_networkView = GetComponent<NetworkView>(); Server.g.SyncViewIds (m_networkView, "HeartBeat"); m_pulseComponent = GetComponent<Pulse>(); } }
// Use this for initialization void Start() { targetVector = Camera.main.GetComponent<CameraFollow>().mousePosition; parentedAngleOffset = transform.eulerAngles.y - transform.localEulerAngles.y + 90f; myNetworkView = GetComponent<NetworkView>(); myNetworkManager = Camera.main.GetComponent<NetworkManager>(); }
void Start() { Application.runInBackground = true; _networkView = GetComponent <NetworkView>(); _config = GameObject.Find("Main").GetComponent <ConfigProperties>(); _draw = GameObject.Find("Main").GetComponent <Draw>(); _slicer = GameObject.Find("Main").GetComponent <Slicer>(); _otherSlices = GameObject.Find("Main").GetComponent <OtherSlices>(); port = _config.port; serverAddress = _config.address; peerType = _config.networkPeerType; if (peerType == ASSPeerType.server) { Network.InitializeServer(16, port, false); } else { Network.Connect(serverAddress, port); } _userID = _config.userID; }
void Start() { nw = GetComponent <NetworkView>(); Anim_Minotauro = GetComponent <Animator> (); Position = transform.position; FC = GameObject.FindGameObjectWithTag("FC"); F_Check_Script = FC.GetComponent <Forward_Check> (); BC = GameObject.FindGameObjectWithTag("BC"); B_Check_Script = BC.GetComponent <Back_Check> (); LC = GameObject.FindGameObjectWithTag("LC"); L_Check_Script = LC.GetComponent <Left_Check> (); RC = GameObject.FindGameObjectWithTag("RC"); R_Check_Script = RC.GetComponent <Right_Check> (); GameObject Floor = GameObject.Find("Floor"); Floor_Scale = Floor.transform.localScale; Floor_Scale_X = (Floor_Scale.x / 2) - 1; Floor_Scale_Z = (Floor_Scale.z / 2) - 1; }
/// <summary> /// Event raised on mouse down in the NetworkView. /// </summary> private void NetworkControl_MouseDown(object sender, MouseButtonEventArgs e) { NetworkView networkView = sender as NetworkView; networkView.Focus(); Keyboard.Focus(networkView); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(networkView); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left && (Keyboard.Modifiers & ModifierKeys.Control) == 0) { // // Initiate panning, when control is not held down. // When control is held down left dragging is used for drag selection. // After panning has been initiated the user must drag further than the threshold value to actually start drag panning. // mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. networkView.CaptureMouse(); e.Handled = true; } }
// Use this for initialization void Awake() { switch (PlayerSt) { case PlayerTypeEnum.FeiJi: InstanceFeiJi = this; PlayerTranFeiJi = transform; KaQiuShaAimPlayerTranFJ = KaQiuShaAimPoint; Invoke("DelaySetFeiJiNpcInfo", 1f); break; case PlayerTypeEnum.TanKe: InstanceTanKe = this; PlayerTranTanKe = transform; KaQiuShaAimPlayerTranTK = KaQiuShaAimPoint; break; case PlayerTypeEnum.CartoonCamera: InstanceCartoon = this; break; } if (PlayerSt != PlayerTypeEnum.CartoonCamera) { XkGameCtrl.GetInstance().ChangeAudioListParent(); } PlayerObj = gameObject; PlayerTran = transform; AimSpawnPoint = new List <XKSpawnNpcPoint>(); NetViewCom = GetComponent <NetworkView>(); if ((XkGameCtrl.GameModeVal == GameMode.LianJi && Network.peerType == NetworkPeerType.Disconnected) || XkGameCtrl.GameModeVal != GameMode.LianJi) { NetViewCom.enabled = false; } }
void Start() { machineName = System.Environment.MachineName; if (machineName == MasterTrackingData.HeadNodeMachineName) { Network.InitializeServer(numSlaveNodes, port, false); } else { Network.Connect(headNodeIP, port); } Time.fixedDeltaTime = 0.05f; Network.sendRate = networkUpdatesPerSecond; Rigidbody[] gO = GameObject.FindObjectsOfType <Rigidbody>(); foreach (Rigidbody rb in gO) { GameObject gameObject = rb.gameObject; gameObject.AddComponent <NetworkView>(); NetworkView nv = gameObject.GetComponent <NetworkView>(); nv.observed = rb; } }
// Use this for initialization void Start() { //initialize things that will be the same regardless of role NetworkView net = this.GetComponent <NetworkView>(); ice = (GameObject)Instantiate(rink, new Vector3(0, 0, 0), Quaternion.identity); int localPlayers = PlayerPrefs.GetInt("numPlayers"); if (PlayerPrefs.GetString("multiplayerType") == "online") { if (PlayerPrefs.GetString("onlineRole") == "host") { //create serverBehavior gameObject.AddComponent <ServerBehavior>(); ServerBehavior serv = gameObject.GetComponent <ServerBehavior>(); serv.InitServerBehavior(net, prefab, localPlayers); action = serv; } else { //create clientBehavior gameObject.AddComponent <ClientBehavior>(); ClientBehavior cli = gameObject.GetComponent <ClientBehavior>(); cli.InitClientBehavior(net, prefab, localPlayers); action = cli; } } else { //create localBehavior gameObject.AddComponent <LocalBehavior>(); LocalBehavior loc = gameObject.GetComponent <LocalBehavior>(); loc.InitLocalBehavior(prefab, localPlayers); action = loc; } }
private void worldList_SelectedIndexChanged(object sender, EventArgs e) { CloseObservers(Project.World); if (worldList.SelectedItem != null) { MyWorldConfig wc = worldList.SelectedItem as MyWorldConfig; if (Project.World == null || wc.NodeType != Project.World.GetType()) { var oldWorld = Project.World; Project.CreateWorld(wc.NodeType); Project.World.EnableDefaultTasks(); NodePropertyView.Target = null; if (NetworkView != null) { NetworkView.ReloadContent(); } foreach (GraphLayoutForm graphView in GraphViews.Values) { graphView.Desktop.Invalidate(); graphView.worldButton_Click(sender, e); } ProjectStateChanged("World selected"); if (WorldChanged != null) { WorldChanged(this, new WorldChangedEventArgs(oldWorld, Project.World)); } } } }
//--------------------------------------------------------------------- void Start() { // Set Network Log Level for Information if (debugging) { Network.logLevel = NetworkLogLevel.Informational; } else { Network.logLevel = NetworkLogLevel.Off; } this.networkView = GetComponent <NetworkView>(); // Clamps max RenterTexture Rate per second to the max RPC Send rate per second if (globalRPCSendRate > Network.sendRate && clampSendRate) { globalRPCSendRate = Network.sendRate; } if (debugging) { Debug.Log("Global RPC Send Rate = " + this.globalRPCSendRate); } }
public void askRespawn(bool bed) { if (this.dead) { Vector3 vector3 = base.transform.position; Vector3 vector31 = base.transform.rotation.eulerAngles; SpawnPlayers.die(vector3, (int)vector31.y, base.GetComponent <Clothes>().face, base.GetComponent <Clothes>().hair, base.GetComponent <Clothes>().skinColor, base.GetComponent <Clothes>().hairColor); this.health = 100; this.food = 100; this.water = 100; this.sickness = 100; this.bleeding = false; this.startedBleeding = Single.MaxValue; this.startedBones = Single.MaxValue; this.bones = false; this.dead = false; this.death = string.Empty; base.GetComponent <Inventory>().load(); base.GetComponent <Clothes>().load(); base.GetComponent <Skills>().load(); // TODO: this is temporary fix!! this.loadAllVitalityFromSerial(String.Empty); base.GetComponent <Player>().owner.spawned = Time.realtimeSinceStartup; if (bed && Time.realtimeSinceStartup - this.lastDied < 20f && NetworkUserList.users.Count > 1 && ServerSettings.pvp) { bed = false; } Transform spawnPoint = SpawnPlayers.getSpawnPoint(base.networkView.owner, bed); NetworkView networkView = base.networkView; object[] objArray = new object[] { spawnPoint.position, null }; Vector3 vector32 = spawnPoint.rotation.eulerAngles; objArray[1] = Quaternion.Euler(0f, vector32.y + 90f, 0f); networkView.RPC("tellStatePosition", RPCMode.All, objArray); } }
void Start() { if (GlobalData.GetInstance().gameMode == GameMode.OnlineMode) { netView = networkView; bool isChangeParent = false; switch (tag) { case "DianDaoFuObj": case "DingShenFuObj": case "HuanWeiFuObj": case "HuanYingFuObj": case "JuLiFuObj": isChangeParent = true; break; } if (isChangeParent) { transform.parent = GameCtrlXK.MissionCleanup; } } DaoJuNetCtrl daoJuScript = GetComponent <DaoJuNetCtrl>(); PlayerNetScript = GetComponent <WaterwheelPlayerNetCtrl>(); if (PlayerNetScript != null || daoJuScript != null) { DamageTime = 0.05f; } else { DamageTime = 0f; } }
void NetworkViewAllocator_ResponseViewID(NetworkViewID _viewID, string _requestID) { var _networkViewRef = mAllocateRequests[_requestID]; if (_networkViewRef == null) { Debug.LogWarning("Network view does not exist!"); } else { NetworkView _networkView = _networkViewRef.Target as NetworkView; if (_networkView != null) { _networkView.viewID = _viewID; mAllocationCache[_requestID] = _networkView.viewID; } else { Debug.Log("Network viewID is allocated but target view does not exist anymore."); } } mAllocateRequests.Remove(_requestID); }
private CustomInstantiationArgs(NetMainPrefab netMain, Object customInstantiator, IDMain prefab, ref NetworkInstantiateArgs args, bool server, bool checkCustomInstantitorArgument) { this.netMain = netMain; this.prefab = prefab; this.prefabNetworkView = prefab.networkView; this.args = args; this.server = server; if (checkCustomInstantitorArgument && (customInstantiator != null)) { this.customInstantiate = customInstantiator as IPrefabCustomInstantiate; if (this.customInstantiate == null) { this.hasCustomInstantiator = CheckNetworkViewCustomInstantiator(this.prefabNetworkView, this.prefab, out this.customInstantiate); } else { this.hasCustomInstantiator = true; } } else { this.hasCustomInstantiator = CheckNetworkViewCustomInstantiator(this.prefabNetworkView, this.prefab, out this.customInstantiate); } }
// Update is called once per frame void Update() { if (!NA.isClient()) //server and standalone { timer += Time.deltaTime; if (timer > currentInterval) { timer -= currentInterval; currentInterval = interval + interval * (Random.value - 0.5f) * intervalVariance * 2f; NetworkView nv = GetComponent <NetworkView>(); if (nv != null) { nv.RPC("Apply", RPCMode.All, 1f, 1f); } else { if (source) { Apply(1f, 1f); } } } } }
private void SetPokemonControllerValues(string playerGuid, NetworkViewID viewId, int teamId) { // When a client sends its chosen pokemon id, asks every one to spawn the chosen pokemon bool isMine = Network.player.guid == playerGuid; NetworkView networkView = NetworkView.Find(viewId); if (networkView != null) { GameObject gameObject = networkView.gameObject; if (gameObject != null) { EntityManager em = gameObject.AddComponent <EntityManager>(); if (em != null) { em.team = teamId; } PokemonController controller = (PokemonController)gameObject.GetComponent("PokemonController"); if (controller != null) { if (isMine) { gameObject.tag = "CameraTarget"; controller.SetMine(); } } PlayerRegistrar.Instance.List.Add(viewId, new PlayerEntry() { GameObject = gameObject, Team = teamId }); } } }
void OnDisconnectedFromServer(NetworkDisconnection info) { Destroy(vaisseau); NetworkView.Destroy(vaisseau); }
public void Start() { nv = this.GetComponent <NetworkView>(); }
void setTargetRPC(NetworkViewID networkViewID_, NetworkMessageInfo info_) { setTarget(NetworkView.Find(networkViewID_).gameObject.GetComponent <Creep>()); }
public void Awake() { N = gameObject.GetComponent <NetworkView>(); DontDestroyOnLoad(gameObject); }
void OnConnectedToServer() { networkview = GameObject.Find("ClientScripts").GetComponent <NetworkView>(); networkview.RPC("Change", RPCMode.OthersBuffered, "Vuforia"); }
public ViewportDrag(NetworkView networkView, MouseEventArgs mouseEventArgs) { PrevPosition = mouseEventArgs.GetPosition(networkView); NetworkView = networkView; _scrollViewer = NetworkView.FindChild <InfiniteScrollViewer>(x => true); }
void SpawnAvatar(NetworkViewID viewID, Vector3 color, string name) { //appelé chez tout le monde pour créer un avatar GameObject clone; //clone = GameObject.CreatePrimitive(PrimitiveType.Capsule); clone = GameObject.Instantiate(NA.app.goPrefabAvatar, Vector3.zero, Quaternion.identity) as GameObject; clone.name = name; Collider.Destroy(clone.GetComponent <Collider>()); //clone.GetComponent<Collider>().isTrigger = true; SphereCollider sc = clone.AddComponent <SphereCollider>(); sc.isTrigger = true; NetworkView nView = clone.AddComponent <NetworkView>(); nView.viewID = viewID; //JT Oct 2016 - test with manual sync instead of built-in //nView.stateSynchronization = NetworkStateSynchronization.Unreliable; nView.stateSynchronization = NetworkStateSynchronization.Off; nView.observed = null; clone.AddComponent <NASyncTransform>(); //=== Light l = clone.AddComponent <Light>(); l.intensity = 2f; l.enabled = false; l.type = LightType.Spot; l.range = 100f; l.spotAngle = 90f; if (nView.owner == Network.player) { NA.goAvatar = clone; //mine } else { //NA.player_objects.Add(clone); //this is considered as a player object } MeshRenderer renderer = clone.GetComponent <MeshRenderer>(); if (renderer != null) { renderer.material.color = new Color(color.x, color.y, color.z, 0.3f); } else { Color col = new Color(color.x, color.y, color.z, 0.3f); Renderer[] renderers = clone.GetComponentsInChildren <Renderer>(); Material m = null; foreach (Renderer r in renderers) { if (m == null) { m = r.material; } r.material = m; //r.sharedMaterial.color = col; m.color = col; } } clone.transform.parent = NA.app.goRootAvatars.transform; //LogManager.Log ("New Avatar:" + name + " owner:" + nView.owner); LogManager.Log(name + " joined!"); NA.AddAvatar(clone); }
void GiveMeACart(string cartModel, string ballModel, string characterModel, NetworkMessageInfo info) { // create new buggy for the new guy - his must be done on the server otherwise collisions wont work! Vector3 spawnLocation = new Vector3(0, 5, 0); Vector3 velocity = new Vector3(0, 0, 0); // instantiate the prefabs GameObject cartContainerObject = (Instantiate(Resources.Load(cartModel), spawnLocation, Quaternion.identity) as GameObject); GameObject ballGameObject = Instantiate(Resources.Load(ballModel), spawnLocation + new Vector3(3, 0, 0), Quaternion.identity) as GameObject; GameObject characterGameObject = Instantiate(Resources.Load(characterModel), spawnLocation + new Vector3(0, -1, 0), Quaternion.identity) as GameObject; GameObject cartGameObject = cartContainerObject.transform.FindChild("buggy").gameObject; // set buggy as characters parent characterGameObject.transform.parent = cartGameObject.transform; // create and set viewIDs NetworkViewID cartViewIDTransform = Network.AllocateViewID(); NetworkView cgt = cartContainerObject.AddComponent("NetworkView") as NetworkView; cgt.observed = cartContainerObject.transform; cgt.viewID = cartViewIDTransform; cgt.stateSynchronization = NetworkStateSynchronization.Unreliable; NetworkViewID cartViewIDRigidbody = Network.AllocateViewID(); NetworkView cgr = cartGameObject.AddComponent("NetworkView") as NetworkView; cgr.observed = cartGameObject.rigidbody; cgr.viewID = cartViewIDRigidbody; cgr.stateSynchronization = NetworkStateSynchronization.Unreliable; NetworkViewID ballViewID = Network.AllocateViewID(); ballGameObject.networkView.viewID = ballViewID; NetworkViewID characterViewID = Network.AllocateViewID(); characterGameObject.networkView.viewID = characterViewID; // tell everyone else about it networkView.RPC("SpawnPrefab", RPCMode.Others, cartViewIDTransform, spawnLocation, velocity, cartModel); networkView.RPC("SpawnPrefab", RPCMode.Others, ballViewID, spawnLocation, velocity, ballModel); networkView.RPC("SpawnPrefab", RPCMode.Others, characterViewID, spawnLocation, velocity, characterModel); // tell all players this is a player and not some random objects networkView.RPC("SpawnPlayer", RPCMode.Others, cartViewIDTransform, cartViewIDRigidbody, ballViewID, characterViewID, 0, info.sender); // tell the player it's theirs networkView.RPC("ThisOnesYours", info.sender, cartViewIDTransform, ballViewID, characterViewID); // create a PlayerInfo for it PlayerInfo newGuy = new PlayerInfo(); newGuy.cartModel = cartModel; newGuy.cartContainerObject = cartContainerObject; newGuy.cartGameObject = cartGameObject; newGuy.cartViewIDTransform = cartViewIDTransform; newGuy.cartViewIDRigidbody = cartViewIDRigidbody; newGuy.ballModel = ballModel; newGuy.ballGameObject = ballGameObject; newGuy.ballViewID = ballViewID; newGuy.characterModel = characterModel; newGuy.characterGameObject = characterGameObject; newGuy.characterViewID = characterViewID; newGuy.currentMode = 0; // set them in buggy newGuy.player = info.sender; // add it to the lists nvs.players.Add(newGuy); }
public override void tick() { if (this.startedUse == Single.MaxValue) { Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out Structure.hit, 10f, RayMasks.PLACEABLE); if (Structure.hit.collider == null) { this.bad(); Interact.hint = "Cannot Reach"; Interact.icon = "Textures/Icons/error"; this.help.transform.position = Vector3.zero; } else { this.help.transform.position = Structure.hit.point; Transform transforms = this.help.transform; Quaternion quaternion = this.help.transform.rotation; Vector3 vector3 = base.transform.rotation.eulerAngles; transforms.rotation = Quaternion.Lerp(quaternion, Quaternion.Euler(0f, vector3.y + (float)this.rotation, 0f), 4f * Time.deltaTime); if (Structure.hit.point.y <= Ocean.level) { this.bad(); Interact.hint = "Not Waterproof"; Interact.icon = "Textures/Icons/error"; } else if (StructureStats.isFloor(Equipment.id)) { if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name))) { this.bad(); Interact.hint = "No Base"; Interact.icon = "Textures/Icons/error"; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((int)Physics.OverlapSphere(Structure.hit.collider.transform.position + new Vector3(0f, 3f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0) { this.bad(); Interact.hint = "No Supports"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = Structure.hit.collider.transform.position + new Vector3(0f, 3f, 0f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } else if (StructureStats.isPillar(Equipment.id)) { if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name))) { this.bad(); Interact.hint = "No Base"; Interact.icon = "Textures/Icons/error"; } else if (Structure.hit.normal.y > 0f) { if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0) { this.bad(); Interact.hint = "No Corners"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -3f, 0f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -3f, 0f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -3f, 0f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0) { this.bad(); Interact.hint = "No Corners"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -3f, 0f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } else if (StructureStats.isPost(Equipment.id)) { if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name))) { this.bad(); Interact.hint = "No Base"; Interact.icon = "Textures/Icons/error"; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0) { this.bad(); Interact.hint = "No Corners"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } else if (StructureStats.isWall(Equipment.id)) { if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name))) { this.bad(); Interact.hint = "No Base"; Interact.icon = "Textures/Icons/error"; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0) { this.bad(); Interact.hint = "No Pillars"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } else if (StructureStats.isRampart(Equipment.id)) { if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name))) { this.bad(); Interact.hint = "No Base"; Interact.icon = "Textures/Icons/error"; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0) { this.bad(); Interact.hint = "No Posts"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } else if (!StructureStats.isFoundation(Equipment.id)) { if (StructureStats.isLadder(Equipment.id)) { if (!(Structure.hit.collider.tag == "Structure") || !(Structure.hit.collider.transform.parent.tag == "Structure") || !StructureStats.isLadder(int.Parse(Structure.hit.collider.transform.parent.name))) { this.help.transform.position = Structure.hit.point; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if ((int)Physics.OverlapSphere(Structure.hit.collider.transform.position + new Vector3(0f, 4.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0) { this.bad(); Interact.hint = "No Space"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = Structure.hit.collider.transform.position + new Vector3(0f, 3f, 0f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } } else if ((double)Structure.hit.normal.y <= 0.5) { this.bad(); Interact.hint = "Too Steep"; Interact.icon = "Textures/Icons/error"; } else if (Structure.hit.collider.name == "ground") { this.help.transform.position = Structure.hit.point + new Vector3(0f, 0.3f, 0f); this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name))) { this.bad(); Interact.hint = "No Base"; Interact.icon = "Textures/Icons/error"; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0) { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0) { this.bad(); Interact.hint = "No Edges"; Interact.icon = "Textures/Icons/error"; } else { this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f); this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation; this.good(); Interact.hint = string.Empty; Interact.icon = string.Empty; } } if (Input.GetMouseButtonDown(1)) { Structure structure = this; structure.rotation = structure.rotation + 45; } } if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done) { this.done = true; if (!Network.isServer) { NetworkView networkView = base.networkView; object[] state = new object[] { Equipment.equipped.x, Equipment.equipped.y, this.help.transform.position, null, null }; Quaternion quaternion1 = this.help.transform.rotation; state[3] = (int)quaternion1.eulerAngles.y; state[4] = StructureStats.getState(Equipment.id); networkView.RPC("askBuild", RPCMode.Server, state); } else { int num = Equipment.equipped.x; int num1 = Equipment.equipped.y; Vector3 vector31 = this.help.transform.position; Vector3 vector32 = this.help.transform.rotation.eulerAngles; // FIXME: cliend side? //this.askBuild(num, num1, vector31, (int)vector32.y, StructureStats.getState(Equipment.id)); } NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); Equipment.use(); } }
/// <summary> /// /// </summary> public DeselectNodesUndoCommand(NetworkView view_, IEnumerable <NodeViewModel> nodesVM_) { m_View = view_; m_NodesVM = new List <NodeViewModel>(nodesVM_); }
// Use this for initialization void Start() { // setup reference to networkVariables nvs = gameObject.GetComponent("networkVariables") as networkVariables; // get server version serverVersion = nvs.serverVersion; // Use NAT punchthrough if no public IP present Network.InitializeServer(32, 11177, !Network.HavePublicAddress()); MasterServer.RegisterHost(serverVersion, SystemInfo.deviceName, "Test server"); // create server owners buggy GameObject cartContainerObject = (Instantiate(Resources.Load("multi_buggy"), new Vector3(0, 5, 0), Quaternion.identity) as GameObject); GameObject ballGameObject = Instantiate(Resources.Load("ball"), new Vector3(3, 5, 0), Quaternion.identity) as GameObject; GameObject characterGameObject = Instantiate(Resources.Load("lil_patrick"), new Vector3(0, 4, 0), Quaternion.identity) as GameObject; GameObject cartGameObject = cartContainerObject.transform.FindChild("buggy").gameObject; // set buggy as characters parent characterGameObject.transform.parent = cartGameObject.transform; // networkview that shit NetworkViewID cartViewIDTransform = Network.AllocateViewID(); NetworkView cgt = cartContainerObject.AddComponent("NetworkView") as NetworkView; cgt.observed = cartContainerObject.transform; cgt.viewID = cartViewIDTransform; cgt.stateSynchronization = NetworkStateSynchronization.Unreliable; NetworkViewID cartViewIDRigidbody = Network.AllocateViewID(); NetworkView cgr = cartGameObject.AddComponent("NetworkView") as NetworkView; cgr.observed = cartGameObject.rigidbody; cgr.viewID = cartViewIDRigidbody; cgr.stateSynchronization = NetworkStateSynchronization.Unreliable; NetworkViewID ballViewID = Network.AllocateViewID(); ballGameObject.networkView.viewID = ballViewID; NetworkViewID characterViewID = Network.AllocateViewID(); characterGameObject.networkView.viewID = characterViewID; // turn it into a PlayerInfo nvs.myInfo.cartContainerObject = cartContainerObject; nvs.myInfo.cartGameObject = cartGameObject; nvs.myInfo.cartModel = "multi_buggy"; nvs.myInfo.cartViewIDTransform = cartViewIDTransform; nvs.myInfo.cartViewIDRigidbody = cartViewIDRigidbody; nvs.myInfo.ballGameObject = ballGameObject; nvs.myInfo.ballModel = "ball"; nvs.myInfo.ballViewID = ballViewID; nvs.myInfo.characterGameObject = characterGameObject; nvs.myInfo.characterModel = "lil_patrick"; nvs.myInfo.characterViewID = characterViewID; nvs.myInfo.currentMode = 0; // set in buggy // get self nvs.myInfo.player = Network.player; // keep a copy myInfo = nvs.myInfo; // add myInfo to the player list nvs.players = new ArrayList(); nvs.players.Add(myInfo); // ANY SERVER SIDE SCRIPTS GO HERE //******************************************** // receives all players inputs and handles fiziks gameObject.AddComponent("controlServer"); // chat gameObject.AddComponent("netChat"); //pause gameObject.AddComponent("netPause"); //******************************************** }
void Start() { TurnManager.networkView = this.GetComponent <NetworkView>(); TurnManager.instance = this; }
public static bool ContextOf(NetworkViewID networkViewID, out Contextual contextual) { return(GetMB(NetworkView.Find(networkViewID), out contextual)); }
public static bool ContextOf(NetworkView networkView, out Contextual contextual) { return(GetMB(networkView, out contextual)); }
void Awake() { _netWorkView = GetComponent <NetworkView>(); Points = GameObject.Find("PlayerSpawnPoint").GetComponentsInChildren <Transform>(); VaccinePoints = GameObject.Find("ItemSpawnPoint").GetComponentsInChildren <Transform>(); }
void Awake() { this.networkView = this.GetComponent <NetworkView>(); }