void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { //parentTransform.position += new Vector3(1f,1f,0f); notifications.PostNotification(this, "GoBack"); notifications.PostNotification(this, "GoRight"); notifications.PostNotification(this, "onBoardMove"); } }
void Update() { if (Input.anyKeyDown && notif != null) { notif.PostNotification(this, "OnKeyboardInput"); } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("KillBox") && Notifications != null) { Notifications.PostNotification(this, "KillBarrierDeath"); } }
// Update is called once per frame void Update() { //Check for keyboard input if (Input.anyKeyDown && Notifications != null) { Notifications.PostNotification(this, "OnKeyboardInput2"); } }
// Use this for initialization void Start() { manager = GameObject.Find("GameManager").GetComponent <StateManager> (); notifications = manager.NotificationRef; thisCollider = gameObject.GetComponent <BoxCollider2D> (); notifications.PostNotification(gameObject.transform.position, "newBoard"); }
void OnTriggerExit2D(Collider2D other) { notifications.PostNotification(gameObject.transform.position, "boardDestroyed"); if (other.CompareTag("Player")) { Destroy(gameObject); } }
void Start() { GameObject notmantmp = GameObject.FindGameObjectWithTag("Manager"); NM = notmantmp.GetComponent<NotificationsManager>(); NM.AddListener(OnPortalTimeSet,"PortalTimeSet"); NM.PostNotification("PortalSpawn", type, 0); Debug.Log("spwn"); }
public void StateUpdate() { input_x = Input.GetAxisRaw("Horizontal"); input_y = Input.GetAxisRaw("Vertical"); if (Mathf.Abs(input_x) > 0 || Mathf.Abs(input_y) > 0) { Notifications.PostNotification(manager, "onPlayerMove"); } }
public void OnEndTalkToGoblin() { DisableScreen(dialogueScreen); Notifications.PostNotification(this, "OnEndTalkToGoblin"); //PauseFalse(); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerState = PlayerState.none; }
void Start() { Notifications.PostNotification(this, "OnGameSetupComplete"); //Debug.Log("ugh."); }
void FixedUpdate() { //Scanning environment for interactions Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); //position of ray/origin if (Physics.Raycast(ray, out hit, rayLength)) { //Debug.Log(hit.collider.gameObject.name); if (hit.collider.gameObject.tag == "Container") { Container_Data containerScript = hit.collider.gameObject.transform.parent.GetComponent <Container_Data>(); if (!containerScript.Searched) { uiScript.InfoBoxText = "Left-click to search this container"; //SEARCHING CRATES if ((playerState == PlayerState.none) && (Input.GetMouseButtonDown(0))) { PlaySound(crate_open); containerScript.Searched = true; uiScript.InfoBoxText = ""; } } else { uiScript.InfoBoxText = containerScript.ContainerText; } } //else if (hit.collider.gameObject.tag == "Goblin") else if (hit.collider.gameObject.CompareTag("Goblin")) { //display name of goblin somewhere on the screen string gobName = hit.collider.gameObject.GetComponent <GoblinData>().goblinName; //get name of goblin you're lookin at if (!armed) { //uiScript.EnableInfoBox("Left-click to talk to " + gobName); //turn on info box and set text uiScript.InfoBoxText = "Left-click to talk to " + gobName; } if ((playerState == PlayerState.none) && (Input.GetMouseButtonDown(0)) && (!armed)) { PlaySound(goblin_talk); currentGoblin = hit.collider.gameObject; playerState = PlayerState.TalkingToGoblin; if (!list_goblinsTalkedTo.Contains(gobName)) { list_goblinsTalkedTo.Add(gobName); } uiScript.GoblinA_Name = gobName; uiScript.List_DialogueDropdownChoices = list_goblinsTalkedTo; currentGoblin.SendMessage("OnTalkToGoblin", this); Notifications.PostNotification(this, "OnTalkToGoblin"); } if (stopGoblinTalking) { currentGoblin.SendMessage("OnEndTalkToGoblin"); stopGoblinTalking = false; } } else if (hit.collider.gameObject.tag == "Weapon") { //Debug.Log("Weapon"); if (!armed) //if player isn't currently holding anything { //TODO - display "Pick Up" prompt somewhere on screen canPickUp = true; weapon = hit.collider.gameObject; } if (canPickUp) { //uiScript.EnableInfoBox("Left-click to pick up"); //uiScript.InfoBoxText = "Left-click to pick up " + hit.collider.gameObject.transform.parent.gameObject.GetComponent<Weapon_Spawner>().WeaponName; string weaponType = hit.collider.gameObject.name; string damageType = ""; if ((weaponType == "sword") || (weaponType == "axe")) { damageType = "slashy"; } else if ((weaponType == "dagger") || (weaponType == "spear")) { damageType = "stabby"; } else if ((weaponType == "brick") || (weaponType == "club")) { damageType = "bashy"; } else { damageType = "ERROR"; } uiScript.InfoBoxText = "Left-click to pick up the " + damageType + " " + weaponType; //PLAYER PICKS STUFF UP if (Input.GetMouseButtonDown(0)) //if player left-clicks mouse { PlaySound(weapon_pickup); weapon.transform.parent = transform; //make object child of hand weaponScript = weapon.GetComponent <ObjectInteraction>(); weaponRb = weapon.GetComponent <Rigidbody>(); weaponRb.isKinematic = true; //set item to kinematic to prevent from flying around armed = true; canPickUp = false; uiScript.InfoBoxText = ""; } } else if (armed) { //uiScript.EnableInfoBox("Hold E + Left-click to throw"); uiScript.InfoBoxText = "Hold E + Left-click to throw, or right-click to drop " + hit.collider.gameObject.name; } } else if (hit.collider.gameObject.CompareTag("Victim")) { uiScript.InfoBoxText = hit.collider.gameObject.GetComponent <Victim_Data>().InspectionText; } else { uiScript.InfoBoxText = ""; } } else { uiScript.InfoBoxText = ""; } //Throwing & Dropping Stuff if (armed) { //DROP WEAPON if player right clicks if (Input.GetMouseButtonDown(1)) { PlaySound(weapon_pickup); uiScript.InfoBoxText = ""; weaponRb.isKinematic = false; //...set to not kinematic - allows weapon to move again weapon.transform.parent = null; //...remove parent weapon = null; //...nullify weapon and weaponRb weaponRb = null; armed = false; //...set armed to false } //THROW WEAPON if player holds E then clicks the mouse button... if ((Input.GetKey(KeyCode.E)) && (Input.GetMouseButtonDown(0))) { PlaySound(weapon_throw); uiScript.InfoBoxText = ""; weaponScript.OnBeingThrown(); weaponRb.isKinematic = false; //...set to not kinematic - allows weapon to move again weaponRb.AddForce(transform.forward * throwSpeed); //...send item flying weapon.transform.parent = null; //...remove parent weapon = null; //...nullify weapon and weaponRb weaponRb = null; armed = false; //...set armed to false } } }