private void OnPlayerCollidedWith(System.Object prevCollisionInfoObj, System.Object collisionInfoObj) { CollisionInfo collisionInfo = (CollisionInfo)collisionInfoObj; GameObject otherObj = collisionInfo.other.gameObject; if (otherObj.layer == layerMapper.GetLayer(LayerEnum.Enemy)) { EnemyController enemy = otherObj.GetComponent <EnemyController>(); if (HungerLevel.Value >= HungerInstantKillThreshold.Value) { enemy.DamageEnemy(999); } else { enemy.KnockbackEnemy(NewVelocity.Value.normalized, KnockbackTime.Value, KnockbackSpeed.Value); } } else if (otherObj.layer == layerMapper.GetLayer(LayerEnum.Interactable)) { InteractionReceiver interactionReceiver = collisionInfo.other.GetComponent <InteractionReceiver>(); if (interactionReceiver != null) { interactionReceiver.ReceiveRollIntoInteraction(new RollIntoPayload()); } } }
private void CheckRaycast() { ray = new Ray(rayOrigin.transform.position, rayOrigin.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.distance < minInteractionDistance) { currentReceiver = hit.transform.gameObject.GetComponent <InteractionReceiver>(); if (currentReceiver != null) { #region ESPAÑOL //Aquí puedes hacer algo con el mensaje de interacción #endregion #region ENGLISH //Here you can make something with the interact message #endregion #region DEUTSCH //Hier kannst du etwas mit der Interaktionsbotschaft machen #endregion Debug.Log(currentReceiver.GetInteractionMessage()); ui.showMessage(currentReceiver.GetInteractionMessage()); canInteract = true; } else { canInteract = false; } } } }
private void AttemptJumpAttack(Collider otherCollider) { float playerBottomY = collider.bounds.center.y - collider.bounds.extents.y; float otherColliderBottomY = otherCollider.bounds.center.y - otherCollider.bounds.extents.y; //Only jump attack if player is above bottom of trigger and falling downwards if (playerBottomY > otherColliderBottomY && NewVelocity.Value.y <= 0f) { InteractionReceiver interactionReceiver = otherCollider.GetComponent <InteractionReceiver>(); if (interactionReceiver != null) { bool hasJumpInteraction = interactionReceiver.ReceiveJumpOnInteraction(new JumpOnPayload()); if (!hasJumpInteraction) { return; } } JumpAttackTrigger.Activate(); CameraShakeManager.Instance.ShakeCamera(1.75f, .3f, .3f); EffectsManager.Instance?.PlayClipAtPoint(jumpAttackClip, transform.position, .4f); } }
// Create the customer menu based on productId public async Task CreateCustomerMenu(string id) { // Populate accounts list using web api call List <Account> accounts = await DataController.getCustomers(id); parent = gameObject; // Save position and scale and minize the menu untill loading is done //Vector3 currentLocation = GameObject.Find("MenuObject").transform.localPosition; transform.localScale = new Vector3(1f, 1f, 1f); Vector3 currentScale = transform.localScale; transform.localScale = new Vector3(0f, 0f, 0f); // Setting up ObjectCollection on parent -- takes care of placement in relation to other gameObjects ObjectCollection buttonCollection = parent.GetComponent <ObjectCollection>(); buttonCollection.CellWidth = 0.45f; buttonCollection.CellHeight = 0.45f; buttonCollection.SurfaceType = SurfaceTypeEnum.Plane; buttonCollection.Rows = 1; // Tagging the menu as a customer menu gameObject.tag = "CustomerMenu"; // Sizing the box collider based on amount of customers parent.GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * accounts.Count, buttonCollection.CellHeight - 0.2f, 0.1f); GameObject.Find("MenuObject").GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * accounts.Count, buttonCollection.CellHeight - 0.2f, 0.1f); // Iterate through the accounts list foreach (Account a in accounts) { Debug.Log(name); // Instantiate the prefab button GameObject button = Instantiate(Resources.Load("HolographicButton")) as GameObject; button.name = id + "/" + a.id; Debug.Log(button.name); // Load image from url -- This needs to be changed in CRM (No url field) //StartCoroutine(loadImageFromUrl(p.productLogo, button)); // Change the button text CompoundButtonText buttonText = button.GetComponent <CompoundButtonText>(); buttonText.Text = a.naam; buttonText.Size = 75; buttonText.OverrideSize = true; buttonText.Style = FontStyle.Bold; // Initialize Receiver receiver = parent.GetComponent <InteractionReceiver>(); // Add button to the receiver receiver.interactables.Add(button); // Add the button to the menu button.transform.SetParent(parent.transform); Debug.Log(parent.transform.childCount); // Scale the button button.transform.localScale = new Vector3(currentScale.x * 3f, currentScale.x * 3f, 1f); counter++; } // Update button placements buttonCollection.UpdateCollection(); // Scale the menu //GameObject.Find("MenuObject").transform.localPosition = currentLocation; transform.localScale = new Vector3(1f, 1f, 1f); if (WorldAnchorManager.Instance != null) { // Add world anchor when object placement is done. WorldAnchorManager.Instance.AttachAnchor(GameObject.Find("MenuObject")); } }
// Creates the Product menu public async Task CreateProductMenu() { // Populate products list with web api get call List <Product> products = await DataController.getProducts(); parent = gameObject; // Save position and scale and minize the menu untill loading is done //Vector3 currentLocation = GameObject.Find("MenuObject").transform.localPosition; transform.localScale = new Vector3(1f, 1f, 1f); Vector3 currentScale = transform.localScale; transform.localScale = new Vector3(0f, 0f, 0f); // Setting up ObjectCollection on parent -- takes care of placement in relation to other gameObjects ObjectCollection buttonCollection = parent.GetComponent <ObjectCollection>(); buttonCollection.CellWidth = 0.45f; buttonCollection.CellHeight = 0.45f; buttonCollection.SurfaceType = SurfaceTypeEnum.Plane; buttonCollection.Rows = 1; // Change this based on amount of products? !! // Tag the menu as a product menu gameObject.tag = "ProductMenu"; // Size the collider based on the size of product list parent.GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * products.Count, buttonCollection.CellHeight - 0.2f, 0.1f); GameObject.Find("MenuObject").GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * products.Count, buttonCollection.CellHeight - 0.2f, 0.1f); // Iterate through the products list foreach (Product p in products) { Debug.Log(name); // Instantiate the prefab button GameObject button = Instantiate(Resources.Load("HolographicButton")) as GameObject; button.name = p.productId; Debug.Log(button.name); // Load the image from url and scale it StartCoroutine(loadImageFromUrl(p.productLogo, button)); // Change the button text value and style CompoundButtonText buttonText = button.GetComponent <CompoundButtonText>(); buttonText.Text = p.productNaam; buttonText.Size = 75; buttonText.OverrideSize = true; buttonText.Style = FontStyle.Bold; // Initialize Receiver receiver = parent.GetComponent <InteractionReceiver>(); // Add button to the receiver receiver.interactables.Add(button); // Add the button to the menu button.transform.SetParent(parent.transform); Debug.Log(parent.transform.childCount); Debug.Log(p.productLogo); // Scale the button button.transform.localScale = new Vector3(currentScale.x * 3f, currentScale.x * 3f, 1f); counter++; } // Update the button placements buttonCollection.UpdateCollection(); // Scale the menu //GameObject.Find("MenuObject").transform.localPosition = currentLocation; transform.localScale = new Vector3(1f, 1f, 1f); if (WorldAnchorManager.Instance != null) { // Add world anchor when object placement is done. WorldAnchorManager.Instance.AttachAnchor(GameObject.Find("MenuObject")); } }