public void Deselect() { curState = PlacementState.nothing; // UIBeltModeOverlay.SetActive (false); Player_MasterControlCheck.s.ToggleMovement(true); Player_MasterControlCheck.s.TogglePlacingItem(false); }
public void SetState(PlacementState newState) { switch (newState) { case PlacementState.PLACED: // enable collider myCollider.enabled = true; // change color SetColor(new Color(0, 0, 1, 0.5f)); // play placement sound AudioSource mAudio = GetComponent <AudioSource>(); if (mAudio != null) { mAudio.PlayOneShot(GameManager.Instance.placementSound); } break; case PlacementState.MOVING: // disable collider myCollider.enabled = false; // change color ResetColor(); break; } mPlacementState = newState; }
void PlaceItemCheck() { if (Input.GetMouseButton(0)) { TileData myTile = Grid.s.GetTileUnderPointer(); if (myTile != null) { lastTile = myTile; if (curItemPlacementScript != null) { curItemPlacementScript.UpdatePosition(myTile); } } } else { print("Item Placement Done"); curState = PlacementState.nothing; Player_MasterControlCheck.s.TogglePlacingItem(false); if (curItemPlacementScript != null) { if (IsPointerOutsideBuildingBar() && FactoryPlayerConnector.s.CheckPlaceable(buildingItem, lastTile.location)) { curItemPlacementScript.PlaceSelf(); FactoryPlayerConnector.s.BuildObject(buildingItem, lastTile.location, false, isRocket, instantBuildCheat, inventory); buildCompleteCallback?.Invoke(); } else { Debug.Log("Item placement failed due: pointer place =" + IsPointerOutsideBuildingBar() + " or checkplaceable = " + FactoryPlayerConnector.s.CheckPlaceable(buildingItem, lastTile.location)); curItemPlacementScript.FailedPlacingSelf(); } } } }
public OnlineGame(PlayerRole playerRole, PlacementState placement, IPAddress ip = null) { IsOne = false; PlayerRole = playerRole; Placement = placement; InitGame(ip); }
IEnumerator CoRequestInterstitial(string placementId, AdsManager.InterstitialDelegate onAdLoaded = null, bool showLoading = true) { float _timeoutRequestAds = timeoutRequestAds; PlacementState adState = PlacementState.Waiting; float retryInterval = 0.4f; WaitForSecondsRealtime delay = new WaitForSecondsRealtime(retryInterval); int tryTimes = 0; if (Application.internetReachability == NetworkReachability.NotReachable) { Debug.Log("unity ad not reachable " + Application.internetReachability); _timeoutRequestAds = 3f; } while (adState != PlacementState.Ready && tryTimes < _timeoutRequestAds / retryInterval) { adState = Advertisement.GetPlacementState(placementId); if (adState != PlacementState.Ready) { yield return(delay); tryTimes++; } } Debug.Log("Unity request ad state " + adState); onAdLoaded?.Invoke(adState == PlacementState.Ready); //if (showLoading) // Manager.LoadingAnimation(false); }
private void Type_Click(object sender, RoutedEventArgs e) { RadioButton button = (RadioButton)sender; Grid grid = (Grid)button.Parent; switch (button.Content) { case "Новая": foreach (var el in grid.Children) { if ((el is RadioButton) && (((RadioButton)el).GroupName == "Placement")) { ((RadioButton)el).IsEnabled = true; } } break; case "Сохранённая": foreach (var el in grid.Children) { if ((el is RadioButton) && (((RadioButton)el).GroupName == "Placement")) { ((RadioButton)el).IsEnabled = false; _placement = PlacementState.Randomly; } } break; } }
public WaitingWindow(OnlineGame onlineGame, ShipArrangement arrangment, PlacementState placement) { InitializeComponent(); OnlineGame = onlineGame; Arrangment = arrangment; Placement = placement; }
public void ActivateSellMode() { Deselect(); curState = PlacementState.sell; Player_MasterControlCheck.s.ToggleMovement(true); Player_MasterControlCheck.s.TogglePlacingItem(true); //UIBeltModeOverlay.SetActive (false); }
protected override void OnGUI() { if (placementState == PlacementState.Place) { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { placementState = PlacementState.Delete; actionButtonText = "Delete"; } } if (placementState == PlacementState.Delete) { if (!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift)) { placementState = PlacementState.Place; actionButtonText = "Place"; } } if (GUI.Button(new Rect( Screen.width - (15 + (int)(110 * fontSizeModifier / 3)) + 38 * fontSizeModifier - (GUI.skin.label.CalcSize(new GUIContent(actionButtonText)).x + 10), Screen.height - (35 + (int)(20 * fontSizeModifier)), GUI.skin.label.CalcSize(new GUIContent(actionButtonText)).x + 10, 20 * fontSizeModifier), actionButtonText, buttonStyle)) { switch (actionButtonText) { case "Add Object": render = true; break; case "Place": actionButtonText = "Add Object"; placementState = PlacementState.Add; selected = -1; cameraControl.allowRotation = true; selectedObject.GetComponent <Rigging>().ActivatePhysics(true); SetShader(selectedObject, ShaderType.Default); break; case "Delete": DeleteVoxeme(selectedObject); actionButtonText = "Add Object"; placementState = PlacementState.Add; selected = -1; cameraControl.allowRotation = true; break; default: break; } } base.OnGUI(); }
public void ActivateConnectorMode() { Deselect(); Player_MasterControlCheck.s.ToggleMovement(true); Player_MasterControlCheck.s.TogglePlacingItem(true); curState = PlacementState.connector; //UIBeltModeOverlay.SetActive (true); // handled by GUI building bar controller lastFrameStuff = true; }
// Update is called once per frame void Update() { SpawnCell closest; switch (placementState) { case PlacementState.Begin: spawnCell = GetClosestCell(); if (placementVolume.bounds.Contains(hitPosition)) { moveTarget.position = hitPosition + new Vector3(0.0f, dragHeight, 0.0f); if (Input.GetMouseButtonUp(0) && spawnCell) { OnMouseUp(); } } break; case PlacementState.StartDrag: closest = GetClosestCell(); if (closest != spawnCell && placementVolume.bounds.Contains(hitPosition)) { spawnCell.SetItem(null); spawnCell = closest; placementState = PlacementState.Dragged; SendMessage("OnDrag", SendMessageOptions.DontRequireReceiver); Vector3 targetPosition = hitPosition + new Vector3(0.0f, dragHeight, 0.0f); moveTarget.position = targetPosition; } break; case PlacementState.Dragged: spawnCell = GetClosestCell(); moveTarget.position = hitPosition + new Vector3(0.0f, dragHeight, 0.0f); break; case PlacementState.Placed: break; case PlacementState.Invalid: if (CanPlace()) { placementState = PlacementState.Placed; moveTarget.position = spawnCell.transform.position; SendMessage("OnPlace", SendMessageOptions.DontRequireReceiver); } break; default: break; } }
public void SetNoneState() { if (TutorialCanvas.tutorialInProgress && Util.tutCanvas.IsWaitingTapState() || Util.tutCanvas.IsWaitingButtonTapState()) { } else { placementState = PlacementState.NONE; structureToPlace = StructureType.NONE; EventManager.Structures.onSetNonePlacementState?.Invoke(); } }
// Use this for initialization void Start() { movement = this.gameObject.AddComponent <TimedTargetMovement>(); movement.movementTime = magicTime; movement.shouldOrientWithGround = false; movement.shouldFaceTarget = false; moveTarget = new GameObject("MoveTarget").transform; moveTarget.position = this.transform.position; movement.SetTarget(moveTarget); movement.fixedTime = false; placementState = PlacementState.Begin; placementVolume = GameObject.Find("PlacementVolume").GetComponent <Collider>(); }
public void GoToGameWindow(PlacementState placement, ShipArrangement shipArrangement, Window owner) { //if (placement != PlacementState.Manualy) //{ // CreateGame(shipArrangement); // PlayWindow window = new PlayWindow(this) { Owner = owner }; // window.Show(); //} //else //{ // PlacingWindow window = new PlacingWindow(this) { Owner = owner }; // window.Show(); //} }
IEnumerator ShowBannerWhenReady(string placementId, BannerPosition bannerPosition, AdsManager.InterstitialDelegate onAdLoaded = null) { Advertisement.Banner.SetPosition(bannerPosition); BannerLoadOptions options = new BannerLoadOptions { loadCallback = OnLoadBannerSuccess, errorCallback = OnLoadBannerFail }; Advertisement.Banner.Load(placementId, options); float timeoutTime = 5f, retryInterval = 0.2f; WaitForSecondsRealtime delay = new WaitForSecondsRealtime(retryInterval); int tryTimes = 0; while (!bannerLoadSuccess.HasValue && tryTimes < timeoutTime / retryInterval) { yield return(delay); tryTimes++; } if (!bannerLoadSuccess.HasValue) { LogEvent("LoadBannerTimeout", "", ""); bannerLoadSuccess = false; } onAdLoaded?.Invoke(bannerLoadSuccess.Value); bool adReady = Advertisement.IsReady(placementId); PlacementState adState = Advertisement.GetPlacementState(placementId); if (bannerLoadSuccess.Value) { Debug.Log($"Unity banner showing. State: {Advertisement.GetPlacementState(placementId)}, ready {adReady}"); Advertisement.Banner.Show(placementId); } else { Debug.Log($"Unity banner show failed. State: {Advertisement.GetPlacementState(placementId)}, ready {adReady}"); } /*if (adReady) //show banner regardless of load success or not since Unity Ads is the only ads * Advertisement.Banner.Show(placementId);*/ bannerLoadSuccess = null; }
private void Placement_Click(object sender, RoutedEventArgs e) { RadioButton button = (RadioButton)sender; switch (button.Content) { case "Ручной": _placement = PlacementState.Manualy; break; case "Случайный": _placement = PlacementState.Randomly; _shipArrangement = ShipArrangement.Random(); break; case "По стратегии": _shipArrangement = ShipArrangement.Strategy(); _placement = PlacementState.Strategily; break; } }
// Set the sprite properties based on the state of the entity. public void SetState(PlacementState newState) { placementState = newState; switch (placementState) { case PlacementState.Hidden: gameObject.SetActive(false); break; case PlacementState.Active: gameObject.SetActive(true); renderer.color = activeColour; break; case PlacementState.Placed: renderer.color = Color.white; glowEffect.OutlineWidth = 0; break; } }
/*public void TryToPlaceItem (BuildingData myData) { * TryToPlaceItem(myData, false, false, null); * }*/ /// <summary> /// spawns a placement helper and lets the user try and place an item down in the world based on the parameters. /// </summary> /// <param name="myData"></param> /// <param name="_isSpaceLanding"></param> /// <param name="_isInventory"></param> /// <param name="_inventory"></param> public void TryToPlaceItem(BuildingData myData, bool _isRocket, List <InventoryItemSlot> _inventory, GenericCallback _buildCompleteCallback) { Deselect(); print("Placing Item"); buildCompleteCallback = _buildCompleteCallback; inventory = _inventory; isRocket = _isRocket; curState = PlacementState.item; Player_MasterControlCheck.s.ToggleMovement(true); Player_MasterControlCheck.s.TogglePlacingItem(true); //UIBeltModeOverlay.SetActive (false); buildingItem = myData; if (buildingItem != null) { GameObject curItemPlacement = Instantiate(ItemPlacementHelperPrefab, transform.position, Quaternion.identity); curItemPlacementScript = curItemPlacement.GetComponent <ItemPlacementHelper>(); curItemPlacementScript.Setup(myData); } }
public void OnMouseDown() { switch (placementState) { case PlacementState.Dragged: //Clicking while dragging? This shouldn't happen break; case PlacementState.Placed: placementState = PlacementState.StartDrag; break; case PlacementState.Invalid: placementState = PlacementState.Dragged; SendMessage("OnDrag", SendMessageOptions.DontRequireReceiver); break; default: break; } }
public void OnMouseUp() { switch (placementState) { case PlacementState.StartDrag: placementState = PlacementState.Placed; SendMessage("OnClick", SendMessageOptions.DontRequireReceiver); break; case PlacementState.Begin: case PlacementState.Dragged: if (CanPlace()) { placementState = PlacementState.Placed; moveTarget.position = spawnCell.transform.position; spawnCell.SetItem(this.gameObject); SendMessage("OnPlace", SendMessageOptions.DontRequireReceiver); } else { placementState = PlacementState.Invalid; SendMessage("OnInvalid", SendMessageOptions.DontRequireReceiver); } break; case PlacementState.Placed: //This won't happen break; case PlacementState.Invalid: //This also won't happen break; default: break; } }
private void setState(PlacementState newState) { state = newState; }
public IEnumerator PlacementStatusTestsLoadEnabled(string placementId, bool isReadyResult, PlacementState stateResult, bool enableLoad) { var platform = new Platform(); MockRequest(BaseUrl, StaticResponse); platform.Initialize("12345", true, enableLoad); while (!(platform.isInitialized && platform.m_PlacementMap.Count == 3)) { yield return(null); } Assert.That(platform.IsReady(placementId), Is.EqualTo(isReadyResult)); Assert.That(platform.GetPlacementState(placementId), Is.EqualTo(stateResult)); listener.Stop(); listener.Close(); }
public void SetPlacingState(StructureType structureType) { placementState = PlacementState.PLACING; structureToPlace = structureType; EventManager.Structures.onStartPlacementState?.Invoke(structureType); }
// Update is called once per frame void Update() { if (sandboxSurface != Helper.GetMostImmediateParentVoxeme(sandboxSurface)) { sandboxSurface = Helper.GetMostImmediateParentVoxeme(sandboxSurface); } if (placementState == PlacementState.Delete) { if (Input.GetMouseButtonDown(0)) { if (Helper.PointOutsideMaskedAreas( new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y), new Rect[] { new Rect(Screen.width - (15 + (int)(110 * fontSizeModifier / 3)) + 38 * fontSizeModifier - 60, Screen.height - (35 + (int)(20 * fontSizeModifier)), 60, 20 * fontSizeModifier) })) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // Casts the ray and get the first game object hit Physics.Raycast(ray, out selectRayhit); if (selectRayhit.collider != null) { if (selectRayhit.collider.gameObject.transform.root.gameObject == selectedObject) { DeleteVoxeme(selectedObject); actionButtonText = "Add Object"; placementState = PlacementState.Add; selected = -1; cameraControl.allowRotation = true; } } } } } else if (placementState == PlacementState.Place) { if (Input.GetMouseButton(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // Casts the ray and get the first game object hit Physics.Raycast(ray, out selectRayhit); if (selectRayhit.collider != null) { if (selectRayhit.collider.gameObject.transform.root.gameObject == sandboxSurface) { Debug.Log(selectRayhit.point.y); if (Mathf.Abs(selectRayhit.point.y - preds.ON(new object[] { sandboxSurface }).y) <= Constants.EPSILON) { if ((Mathf.Abs(selectRayhit.point.x - Helper.GetObjectWorldSize(sandboxSurface).min.x) >= Helper.GetObjectWorldSize(selectedObject).extents.x) && (Mathf.Abs(selectRayhit.point.x - Helper.GetObjectWorldSize(sandboxSurface).max.x) >= Helper.GetObjectWorldSize(selectedObject).extents.x) && (Mathf.Abs(selectRayhit.point.z - Helper.GetObjectWorldSize(sandboxSurface).min.z) >= Helper.GetObjectWorldSize(selectedObject).extents.z) && (Mathf.Abs(selectRayhit.point.z - Helper.GetObjectWorldSize(sandboxSurface).max.z) >= Helper.GetObjectWorldSize(selectedObject).extents.z)) { selectedObject.transform.position = new Vector3(selectRayhit.point.x, preds.ON(new object[] { sandboxSurface }).y + surfacePlacementOffset, selectRayhit.point.z); Voxeme voxComponent = selectedObject.GetComponent <Voxeme>(); voxComponent.targetPosition = selectedObject.transform.position; foreach (Voxeme child in voxComponent.children) { if (child.isActiveAndEnabled) { if (child.gameObject != voxComponent.gameObject) { child.transform.localPosition = voxComponent.parentToChildPositionOffset[child.gameObject]; child.targetPosition = child.transform.position; } } } } } } } } if (Input.GetKeyDown(KeyCode.Return)) { actionButtonText = "Add Object"; placementState = PlacementState.Add; selected = -1; cameraControl.allowRotation = true; selectedObject.GetComponent <Rigging>().ActivatePhysics(true); SetShader(selectedObject, ShaderType.Default); } } else if (placementState == PlacementState.Add) { if (Input.GetMouseButton(0)) { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // Casts the ray and get the first game object hit Physics.Raycast(ray, out selectRayhit); if (selectRayhit.collider != null) { if (Helper.IsSupportedBy(selectRayhit.collider.gameObject.transform.root.gameObject, sandboxSurface)) { if (selectRayhit.collider.gameObject.transform.root.gameObject.GetComponent <Voxeme>() != null) { selectedObject = selectRayhit.collider.gameObject.transform.root.gameObject; surfacePlacementOffset = (Helper.GetObjectWorldSize(selectedObject.gameObject).center.y - Helper.GetObjectWorldSize(selectedObject.gameObject).min.y) + (selectedObject.gameObject.transform.position.y - Helper.GetObjectWorldSize(selectedObject.gameObject).center.y); SetShader(selectedObject, ShaderType.Highlight); actionButtonText = "Place"; placementState = PlacementState.Place; cameraControl.allowRotation = false; if (selectedObject != null) { selectedObject.GetComponent <Rigging>().ActivatePhysics(false); } } } } } } } }
public override void DoModalWindow(int windowID) { if (placementState != PlacementState.Add) { return; } base.DoModalWindow(windowID); //makes GUI window scrollable scrollPosition = GUILayout.BeginScrollView(scrollPosition); selected = GUILayout.SelectionGrid(selected, listItems, 1, buttonStyle, GUILayout.ExpandWidth(true)); GUILayout.EndScrollView(); if (selected != -1) { render = false; GameObject go = (GameObject)Instantiate(prefabs[selected]); go.transform.position = Helper.FindClearRegion(sandboxSurface, go).center; Debug.Log(go.transform.position); go.SetActive(true); go.name = go.name.Replace("(Clone)", ""); List <Voxeme> existingObjsOfType = objSelector.allVoxemes.FindAll(v => v.gameObject.name.StartsWith(go.name)); List <int> objIndices = existingObjsOfType.Select(v => Convert.ToInt32(v.name.Replace(go.name, "0"))) .ToList(); for (int i = 0; i < objIndices.Count; i++) { if (objIndices[i] == 0) { objIndices[i] = 1; } } int j; for (j = 0; j < objIndices.Count; j++) { if (objIndices[j] != j + 1) { break; } } go.name = go.name + (j + 1); // store shaders foreach (Renderer renderer in go.GetComponentsInChildren <Renderer>()) { defaultShaders[renderer] = renderer.material.shader; } voxemeInit.InitializeVoxemes(); // Debug.Log (go); // foreach (Voxeme vox in objSelector.allVoxemes) { // Debug.Log (vox.gameObject); // } selectedObject = objSelector.allVoxemes.Find(v => v.gameObject.transform.Find(go.name) != null).gameObject; selectedObject.GetComponent <Voxeme>().VoxMLLoaded += VoxMLUpdated; surfacePlacementOffset = (Helper.GetObjectWorldSize(selectedObject.gameObject).center.y - Helper.GetObjectWorldSize(selectedObject.gameObject).min.y) + (selectedObject.gameObject.transform.position.y - Helper.GetObjectWorldSize(selectedObject.gameObject).center.y); selectedObject.transform.position = new Vector3(go.transform.position.x, preds.ON(new object[] { sandboxSurface }).y + surfacePlacementOffset, go.transform.position.z); SetShader(selectedObject, ShaderType.Highlight); actionButtonText = "Place"; placementState = PlacementState.Place; cameraControl.allowRotation = false; selectedObject.GetComponent <Rigging>().ActivatePhysics(false); } }