private void OnTriggerEnter(Collider c) { if (c.CompareTag("Corner Trigger")) { if (c.gameObject.GetComponent <CornerTrigger>().isAutomatic) { if (canMove) { TurnCorner(new AvailableAction(PossibleAction.Action_TurnCorner, KeyCode.W, c.gameObject)); } } else { currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_TurnCorner, KeyCode.W, c.gameObject)); } } if (c.CompareTag("Door Trigger")) { currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_EnterShop, KeyCode.W, c.gameObject)); } if (c.CompareTag("Cross Street Trigger")) { currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_CrossStreet, KeyCode.S, c.gameObject)); currentCrosswalk = c.gameObject.GetComponent <CrossWalk>(); } if (c.CompareTag("Talk Trigger")) { currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_Talk, KeyCode.W)); } }
private WorldObject CreateWorldObject(JsonWorldObject jsonWorldObject, JsonPolygon jsonPolygon, JsonReferences jsonReferences) { WorldObject currentObject = null; string type = jsonWorldObject.Filename; if (isRoadWith3Polygons(type)) { currentObject = new Road(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (isSign(type)) { currentObject = new Sign(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "road_2lane_tjunctionleft" || type == "road_2lane_tjunctionright") { currentObject = new TjunctionRoad(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "2_crossroad_1") { currentObject = new CrossRoad18(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "2_crossroad_2") { currentObject = new CrossRoad16(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "road_2lane_rotary") { currentObject = new RotaryRoad(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "parking_space_parallel") { currentObject = new ParallelParking(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "parking_90") { currentObject = new CrossParking(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "garage") { currentObject = new Garage(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "tree") { currentObject = new Tree(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix, jsonPolygon.PolyPoints); } else if (type == "crosswalk") { currentObject = new CrossWalk(jsonWorldObject.X, jsonWorldObject.Y, type, jsonWorldObject.Width, jsonWorldObject.Height, jsonReferences.ReferenceOffsetX, jsonReferences.ReferenceOffsetY, jsonWorldObject.Rotmatrix); } return(currentObject); }
public void UpdateState(CrossWalk.CrosswalkState _newState) { _currentState = _newState; if(_currentState == CrossWalk.CrosswalkState.CWS_Green) { if(OnGreenLight != null) OnGreenLight(); } if(_currentState == CrossWalk.CrosswalkState.CWS_Orange) { if(OnOrangeLight != null) OnOrangeLight(); } if(_currentState == CrossWalk.CrosswalkState.CWS_Red) { if(OnRedLight != null) OnRedLight(); } }
protected virtual void OnTriggerEnter(Collider c) { if(c.CompareTag("Corner Trigger")) { if(c.GetComponent<CornerTrigger>().isImpassible) { direction *= -1; return; } //Turn Corner GameObject newCamPoint = c.GetComponent<CornerTrigger>().GetCitizenCamerapoint(currentCamPoint); currentCamPoint = newCamPoint; StartCoroutine (TurnCorner()); } if(c.CompareTag("Door Trigger")) { //UnityEngine.Random chance to enter shop if(currentState != CurrentState.CS_Walking) return; if(currentShoppingAmount < 1) { return; } if(UnityEngine.Random.Range(0, 101) < shoppingChance) { //enter Shop currentState = CurrentState.CS_Shopping; StartCoroutine(EnterBuilding(c, false)); --currentShoppingAmount; } } if(c.CompareTag("Cross Street Trigger")) { if(isCrossing) Invoke("StopCrossing", UnityEngine.Random.Range (0.35f, 0.55f)); //UnityEngine.Random chance to cross street if(currentState != CurrentState.CS_Walking) return; if(UnityEngine.Random.Range (0,101) < triggerRefusalChance) { currentCrossWalk = c.gameObject.GetComponent<CrossWalk>(); if(currentCrossWalk.currentCWState == CrossWalk.CrosswalkState.CWS_Green) { isCrossing = true; StartCoroutine(CrossStreet(c.gameObject)); } else { if(!IsInvoking("WaitForGreenLight")) { InvokeRepeating("WaitForGreenLight", UnityEngine.Random.Range(0.35f, 0.55f), UnityEngine.Random.Range(0.5f, 1.0f)); } } } } if(c.CompareTag("House Trigger")) { //check if time to go back home if(isGoingHome) { if(currentState == CurrentState.CS_Walking) { currentState = CurrentState.CS_Sleeping; StartCoroutine(EnterBuilding(c, true)); } } } if(c.CompareTag("Citizen")) { if(UnityEngine.Random.Range(0, 101) < talkingChance && currentState == CurrentState.CS_Walking && !isGoingHome) { if(c.GetComponent<AIParent>().StartTalking()) { currentState = CurrentState.CS_Talking; StartCoroutine(Talking()); } } } }
private void OnTriggerEnter(Collider c) { if (c.CompareTag ("Corner Trigger")) { if(c.gameObject.GetComponent<CornerTrigger>().isAutomatic) { if(canMove) TurnCorner(new AvailableAction(PossibleAction.Action_TurnCorner, KeyCode.W, c.gameObject)); } else currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_TurnCorner, KeyCode.W, c.gameObject)); } if(c.CompareTag("Door Trigger")) { currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_EnterShop, KeyCode.W, c.gameObject)); } if(c.CompareTag("Cross Street Trigger")) { currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_CrossStreet, KeyCode.S, c.gameObject)); currentCrosswalk = c.gameObject.GetComponent<CrossWalk>(); } if(c.CompareTag("Talk Trigger")) { currentAvailableActions.Add(new AvailableAction(PossibleAction.Action_Talk, KeyCode.W)); } }
virtual protected void OnTriggerEnter(Collider c) { if (c.CompareTag("Corner Trigger")) { if (c.GetComponent <CornerTrigger>().isImpassible) { direction *= -1; return; } //Turn Corner GameObject newCamPoint = c.GetComponent <CornerTrigger>().GetCitizenCamerapoint(currentCamPoint); currentCamPoint = newCamPoint; StartCoroutine(TurnCorner()); } if (c.CompareTag("Door Trigger")) { //UnityEngine.Random chance to enter shop if (currentState != CurrentState.CS_Walking) { return; } if (currentShoppingAmount < 1) { return; } if (UnityEngine.Random.Range(0, 101) < shoppingChance) { //enter Shop currentState = CurrentState.CS_Shopping; StartCoroutine(EnterBuilding(c, false)); --currentShoppingAmount; } } if (c.CompareTag("Cross Street Trigger")) { if (isCrossing) { Invoke("StopCrossing", UnityEngine.Random.Range(0.35f, 0.55f)); } //UnityEngine.Random chance to cross street if (currentState != CurrentState.CS_Walking) { return; } if (UnityEngine.Random.Range(0, 101) < triggerRefusalChance) { currentCrossWalk = c.gameObject.GetComponent <CrossWalk>(); if (currentCrossWalk.currentCWState == CrossWalk.CrosswalkState.CWS_Green) { isCrossing = true; StartCoroutine(CrossStreet(c.gameObject)); } else { if (!IsInvoking("WaitForGreenLight")) { InvokeRepeating("WaitForGreenLight", UnityEngine.Random.Range(0.35f, 0.55f), UnityEngine.Random.Range(0.5f, 1.0f)); } } } } if (c.CompareTag("House Trigger")) { //check if time to go back home if (isGoingHome) { if (currentState == CurrentState.CS_Walking) { currentState = CurrentState.CS_Sleeping; StartCoroutine(EnterBuilding(c, true)); } } } if (c.CompareTag("Citizen")) { if (UnityEngine.Random.Range(0, 101) < talkingChance && currentState == CurrentState.CS_Walking && !isGoingHome) { if (c.GetComponent <AIParent>().StartTalking()) { currentState = CurrentState.CS_Talking; StartCoroutine(Talking()); } } } }