void OnTriggerEnter2D(Collider2D other) { //If octopus with bullet, reset the octopus if (other.gameObject.tag == "Bullet") { OctopusController octopus = other.gameObject.GetComponent <OctopusController>(); if (octopus != null) { GameObject bld = Instantiate(blood); bld.transform.position = octopus.transform.position; octopus.Reset(); } } }
IEnumerator CreateInvaders() { for (int i = 0; i < 5; i++) { for (int j = 0; j < 11; j++) { Vector3 birthPosition = new Vector3(-2.4f + j * 0.4f, 0.45f * i, 0); if (i < 2) { GameObject obj = Instantiate(bee, birthPosition, Quaternion.identity) as GameObject; BeeController controller = obj.GetComponent <BeeController>(); controller.invaderId = i * 5 + j; InvaderPlatoon.Add(controller); } else if (i < 4) { GameObject obj = Instantiate(squid, birthPosition, Quaternion.identity) as GameObject; SquidController controller = obj.GetComponent <SquidController>(); controller.invaderId = i * 5 + j; InvaderPlatoon.Add(controller); } else { GameObject obj = Instantiate(octopus, birthPosition, Quaternion.identity) as GameObject; OctopusController controller = obj.GetComponent <OctopusController>(); controller.invaderId = i * 5 + j; InvaderPlatoon.Add(controller); } yield return(new WaitForSeconds(0.01f)); } } movementState = MovementState.RIGHT; yield return(null); finishCreated = true; }
// When we receive an intent.... private void OnMessage(object resp, Dictionary <string, object> customData) { Log.Debug("ConversationHandler.OnMessage()", "Conversation: Message Response: {0}", customData["json"].ToString()); // Conversation: Example Message Response: // { // "intents":[ // {"intent":"idle","confidence":0.6780582904815674 // } // ], // "entities":[ // ], // "input":{"text":"stop walking "}, // "output":{ // "text":["I didn't understand can you try again"], // "nodes_visited":["node_2_1467831978407"], // "log_messages":[] // }, // "context":{ // "conversation_id":"e697dcd1-bd27-4f51-814e-a1ad083c5ef4", // "system":{ // "dialog_stack":[ // {"dialog_node":"root"} // ], // "dialog_turn_counter":1, // "dialog_request_counter":1, // "_node_output_map":{ // "node_2_1467831978407":[0] // }, // "branch_exited":true, // "branch_exited_reason":"completed"} // }, // "alternate_intents":false // } //} object _tempIntents = null; (resp as Dictionary <string, object>).TryGetValue("intents", out _tempIntents); List <object> o = (List <object>)_tempIntents; // Log.Debug("ConversationHandler.OnMessage()", "Intents: {0}", o[0].ToString()); object _tempIntent = null; try { (o[0] as Dictionary <string, object>).TryGetValue("intent", out _tempIntent); } catch (Exception) { _tempIntent = ""; } Intenta2.text = Intenta1.text; // we move the existing intents up the archive intent fields in the debug panel Intenta1.text = ResultsField.text; // we move the existing intents up the archive intent fields in the debug panel ResultsField.text = "#" + _tempIntent.ToString(); // and update the current intent field with the new Intent. OctopusController octopusLogic = gameObject.GetComponent <OctopusController>(); // We then ask the OctopusLogic class to octopusLogic.processIntent(_tempIntent.ToString()); // process the new Intent and update the appropriate GameObjects. Log.Debug("ConversationHandler.OnMessage()", "Intent: {0}", _tempIntent); // We don't need the Octopus to use the response from Watson Assistant in our conversation // but if we did, we could use this bit of code from the Watson Unity SDK Example: //fsData fsdata = null; //fsResult r = _serializer.TrySerialize(resp.GetType(), resp, out fsdata); //if (!r.Succeeded) // throw new WatsonException(r.FormattedMessages); //// Convert fsdata to MessageResponse //MessageResponse messageResponse = new MessageResponse(); //object obj = messageResponse; //r = _serializer.TryDeserialize(fsdata, obj.GetType(), ref obj); //if (!r.Succeeded) // throw new WatsonException(r.FormattedMessages); //// Set context for next round of messaging //object _tempContext = null; //Log.Debug("ConversationHandler.OnMessage()", "{0}", r); //(resp as Dictionary<string, object>).TryGetValue("context", out _tempContext); //if (_tempContext != null) // _context = _tempContext as Dictionary<string, object>; //else //Log.Debug("ConversationHandler.OnMessage()", "Failed to get context"); }
void OnTriggerEnter2D(Collider2D other) { //If player collided with coin, increase the instance point by 10 if (other.gameObject.tag == "Coin") { Player.Instance.Points += 10; Debug.Log("Collision with" + other.gameObject.tag); CoinController coin = other.gameObject.GetComponent <CoinController>(); if (coin != null) { GameObject st = Instantiate(star); st.transform.position = coin.transform.position; coin.Reset(); } } //If player collided with PowerCoin, increase the instance health by 10 if (other.gameObject.tag == "PowerCoin") { Player.Instance.Health += 10; Debug.Log("Collision with" + other.gameObject.tag); PowerCoinController powerCoin = other.gameObject.GetComponent <PowerCoinController>(); if (powerCoin != null) { GameObject sw = Instantiate(sword); sw.transform.position = powerCoin.transform.position; powerCoin.destroy(); } } //If player collided with shark, game over if (other.gameObject.tag == "Shark") { Player.Instance.Health -= 20; Debug.Log("Collision with" + other.gameObject.tag); SharkController shark = other.gameObject.GetComponent <SharkController>(); if (shark != null) { GameObject bl = Instantiate(blood); bl.transform.position = shark.transform.position; } } //If player collided with octopus, decrease the instance health by 10 else if (other.gameObject.tag == "Octopus") { Debug.Log("Collision with" + other.gameObject.tag); Player.Instance.Health -= 10; OctopusController octopus = other.gameObject.GetComponent <OctopusController>(); if (octopus != null) { GameObject bl = Instantiate(blood); bl.transform.position = octopus.transform.position; octopus.Reset(); } } //If player collided with submarine, game over else if (other.gameObject.tag == "Submarine") { Debug.Log("Collision with" + other.gameObject.tag); Player.Instance.Health -= 30; SubmarineController submarine = other.gameObject.GetComponent <SubmarineController>(); if (submarine != null) { GameObject bl = Instantiate(blood); bl.transform.position = submarine.transform.position; } } //If player collided with submarine, game end else if (other.gameObject.tag == "Bullet") { Debug.Log("Collision with" + other.gameObject.tag); Player.Instance.Health = 0; BulletController bullet = other.gameObject.GetComponent <BulletController>(); if (bullet != null) { GameObject bl = Instantiate(blood); bl.transform.position = bullet.transform.position; bullet.destroy(); } } }
// Use this for initialization void Start() { octopusController = transform.parent.GetComponent <OctopusController>(); }