public void CheckGroundClick(RaycastHit hit) { if (Input.GetMouseButtonDown(0)) { //remove the rightclickmenu from the screen when moving itemDropdownMenuScript.gameObject.SetActive(false); /** * set the inventory currentUsedItem to null (This is when using items from the inventory). * if the item isn't used on an obstruction, we want movement commands to cancel using an item. * otherwise, we want to check if the item used on the obstruction makes sense (and then set the current used to null as well) * */ if (inventory.currentUsedSlot != null) { if (hit.collider.tag.Equals("Obstruction")) { //Don't call this yet, since it's not implemented yet... obstruction = hit.collider.gameObject.GetComponent <Obstruction>(); interactedOnce = false; usedOnObstructionReference = inventory.currentUsedReference; //Debug.Log("itemUsed:" + inventory.currentUsedReference); Debug.Log("Moving to the obstruction..."); } //inventory.currentUsedItem = null; inventory.currentUsedSlot.GetComponent <Image>().color = Color.white; inventory.SetCurrentUsed(null, -1, null); //setting slot to null may have caused problems previously? Might still cause unkown bugs. //inventory.currentUsedSlot = null; //return; } else if (hit.collider.gameObject.tag == "Item" || hit.collider.gameObject.tag == "CarryingOne" || hit.collider.gameObject.tag == "CarryingTwo") { itemClicked = hit.collider.gameObject.GetComponent <Item>(); StartCoroutine(DisplayMouseClick(clickItemCursor)); Vector3 temp = new Vector3(hit.point.x, playerTransform.position.y, hit.point.z); itemClickedDestination = temp; } else { itemClicked = null; itemClickedDestination = Vector3.negativeInfinity; StartCoroutine(DisplayMouseClick(clickDefaultCursor)); } if (agent.enabled == false) { agent.enabled = true; } agent.SetDestination(hit.point); } //right click - bring up the menu else if (Input.GetMouseButtonDown(1)) { Vector3 temp = new Vector3(hit.point.x, playerTransform.position.y, hit.point.z); itemClickedDestination = temp; itemDropdownMenuScript.Dropdown(itemsPlayersObstructionsMask); } }
public Asteroid(Vector2 initialPosition) : base(initialPosition, Allegiance.Neutral) { int radius = Global.mAsteroidRadius; mObstruction = new Obstruction(initialPosition, radius); mVisibility = new Visibility(this); }
public void Add(Obstruction obstruction) { if (Obstructions.ContainsKey(obstruction.Identifier)) { throw new ArgumentException(string.Format("Obstruction identifier already exist: {0}", obstruction.Identifier)); } Obstructions.Add(obstruction.Identifier, obstruction); }
/// <summary> /// Required to prevent redundancy in the obstructions list. /// </summary> bool ObstructionExists(Obstruction o) { foreach (Obstruction obstruction in obstructions) { if (obstruction.obj == o.obj) { return(true); } } return(false); }
//void CoalHasCleared () { // Drawer.DrawerMoveToStairButton (); //} public void ShardHit() { /* Now you cannot shovel, still can't draw or aim, but you can move and look around. * Obstruction disappears. */ // 4 Shovel.Deactivate(); //LookAround.Activate (ShowDrawerCutScene); LookAround.instance.Look(ShowDrawerCutScene); //movementScript.enabled = true; Obstruction.RemoveObstruction(); }
protected void INSERT(object sender, EventArgs e) { Obstruction.Evacuation_Area_ID = (Convert.ToInt32(Evacuation_Area_ID_TextBox.Text)); Obstruction.Location_ID = (Convert.ToInt32(Location_ID_TextBox.Text)); Obstruction.Date_Reported = DateTime.Now; Obstruction.Expected_Recovery_Date = DateTime.Now; Obstruction.Type = Type_TextBox.Text; Obstruction.Severity = Severity_TextBox.Text; Obstruction = Obstruction.Insert(Obstruction); GridView1.DataBind(); }
public Obstruction Insert_Obstruction_select(int ID) { Obstruction = Obstruction.Select(ID); Insert_Evacuation_Area_ID_txt.Text = Convert.ToString(Obstruction.Evacuation_Area_ID); Insert_Location_ID_txt.Text = Convert.ToString(Obstruction.Location_ID); Insert_Date_Reported_txt.Text = Convert.ToString(Obstruction.Date_Reported); Insert_Expected_Recovery_Date_txt.Text = Convert.ToString(Obstruction.Expected_Recovery_Date); Insert_Type_txt.Text = Convert.ToString(Obstruction.Type); Insert_Severity_txt.Text = Convert.ToString(Obstruction.Severity); return Obstruction; }
protected void Select_Record(object sender, EventArgs e) { Obstruction = Obstruction.Select(Convert.ToInt32(GridView1.SelectedValue)); Obstruction_ID_TextBox.Text = Convert.ToString(Obstruction.Obstruction_ID); Evacuation_Area_ID_TextBox.Text = Convert.ToString(Obstruction.Evacuation_Area_ID); Location_ID_TextBox.Text = Convert.ToString(Obstruction.Location_ID); Date_Reported_TextBox.Text = Convert.ToString(Obstruction.Date_Reported); Expected_Recovery_Date_TextBox.Text = Convert.ToString(Obstruction.Expected_Recovery_Date); Type_TextBox.Text = Convert.ToString(Obstruction.Type); Severity_TextBox.Text = Convert.ToString(Obstruction.Severity); }
public Planet(Vector2 initialPosition, Allegiance allegiance, PlanetSize size, int numberOfMinions) : base(initialPosition, allegiance) { MinionIncrementPerSecond = Global.MinionIncrementPerSecond[size]; mSize = size; Shield = 0; MinionCount = numberOfMinions; mObstruction = new Obstruction(initialPosition, CollisionRadius); mVisibility = new Visibility(this); }
public Obstruction Insert_Obstruction_select(int ID) { Obstruction = Obstruction.Select(ID); Insert_Evacuation_Area_ID_txt.Text = Convert.ToString(Obstruction.Evacuation_Area_ID); Insert_Location_ID_txt.Text = Convert.ToString(Obstruction.Location_ID); Insert_Date_Reported_txt.Text = Convert.ToString(Obstruction.Date_Reported); Insert_Expected_Recovery_Date_txt.Text = Convert.ToString(Obstruction.Expected_Recovery_Date); Insert_Type_txt.Text = Convert.ToString(Obstruction.Type); Insert_Severity_txt.Text = Convert.ToString(Obstruction.Severity); return(Obstruction); }
Obstruction GenerateObstruction(Goal parent) { var obstruction = new Obstruction(_model); obstruction.ObstructedGoalIdentifier = parent.Identifier; var obstacle = GenerateObstacle(); obstruction.ObstacleIdentifier = obstacle.Identifier; _model.Add(obstruction); return(obstruction); }
public Obstruction Obstruction_insert() { Obstruction.Evacuation_Area_ID = Convert.ToInt32(Insert_Evacuation_Area_ID_txt.Text); Obstruction.Location_ID = Convert.ToInt32(Insert_Location_ID_txt.Text); Obstruction.Date_Reported = Convert.ToDateTime(Insert_Date_Reported_txt.Text); Obstruction.Expected_Recovery_Date = Convert.ToDateTime(Insert_Expected_Recovery_Date_txt.Text); Obstruction.Type = Insert_Type_txt.Text; Obstruction.Severity = Insert_Severity_txt.Text; Obstruction = Obstruction.Insert(Obstruction); Insert_Obstruction_GridView.DataBind(); Update_Obstruction_GridView.DataBind(); Delete_Obstruction_GridView.DataBind(); return(Obstruction); }
void CheckForObstructions() { Ray ray = new Ray(Camera.main.transform.position, transform.position - Camera.main.transform.position); obstructionHits = Physics.RaycastAll(ray, Vector3.Distance(Camera.main.transform.position, transform.position), obstructionSetting.obstructionLayer); foreach (RaycastHit hit in obstructionHits) { Obstruction o = new Obstruction(hit.collider.gameObject); SetMaterialBlendMode(o.material, "Fade"); if (!ObstructionExists(o)) obstructions.Add(o); } }
void CheckForObstructions() { Ray ray = new Ray(Camera.main.transform.position, transform.position - Camera.main.transform.position); obstructionHits = Physics.RaycastAll(ray, Vector3.Distance(Camera.main.transform.position, transform.position), obstructionSetting.obstructionLayer); foreach (RaycastHit hit in obstructionHits) { Obstruction o = new Obstruction(hit.collider.gameObject); SetMaterialBlendMode(o.material, "Fade"); if (!ObstructionExists(o)) { obstructions.Add(o); } } }
public Obstruction Obstruction_update(int ID) { Obstruction = Obstruction.Select(ID); Obstruction.Obstruction_ID = Convert.ToInt32(Update_Obstruction_ID_txt.Text); Obstruction.Evacuation_Area_ID = Convert.ToInt32(Update_Evacuation_Area_ID_txt.Text); Obstruction.Location_ID = Convert.ToInt32(Update_Location_ID_txt.Text); Obstruction.Date_Reported = Convert.ToDateTime(Update_Date_Reported_txt.Text); Obstruction.Expected_Recovery_Date = Convert.ToDateTime(Update_Expected_Recovery_Date_txt.Text); Obstruction.Type = Update_Type_txt.Text; Obstruction.Severity = Update_Severity_txt.Text; Obstruction.Update(Obstruction); Insert_Obstruction_GridView.DataBind(); Update_Obstruction_GridView.DataBind(); Delete_Obstruction_GridView.DataBind(); return(Obstruction); }
private IEnumerator SpawnObstruction(Platform parentPlatform) { yield return(new WaitForEndOfFrame()); if (parentPlatform) { Obstruction toSpawn = Instantiate(obstructions[Random.Range(0, obstructions.Length)]); // Obstruction we want to spawn on our platform. toSpawn.transform.SetParent(parentPlatform.transform); Vector3 bounds = parentPlatform.gameObject.GetComponent <MeshCollider>().bounds.size; Vector3 spawnedTransform = new Vector3(0, 0, 0); spawnedTransform.x = Random.Range(parentPlatform.transform.position.x - (bounds.x / 2), parentPlatform.transform.position.x + (bounds.x / 2)); spawnedTransform.z = Random.Range(parentPlatform.transform.position.z - (bounds.z / 2), parentPlatform.transform.position.z + (bounds.z / 2)); toSpawn.transform.position = spawnedTransform; } yield return(new WaitForEndOfFrame()); }
public void OnTriggerEnter(Collider other) { switch (other.gameObject.layer) { case Globals.LayerNumWorldItemActive: Obstruction obstruction = null; if (other.gameObject.HasComponent <Obstruction>(out obstruction)) { mObstructions.Add(obstruction); } break; case Globals.LayerNumSolidTerrain: break; } }
internal Obstruction AddObstruction( Obstruction prefab, GridTile tile, float coverValue, Transform model = null ) { Obstruction o = Instantiate( prefab, tile.transform.position, prefab.transform.rotation ) as Obstruction; if( o != null ) { o.transform.parent = worldContainer.obstructionsHolder; o.height = coverValue; o.currentTile = tile; tile.SetObstruction( o ); if( model ) { o.decor = AddDecor( model, tile ); } return o; } return null; }
protected void Render(Obstruction obstruction) { if (!shapes.ContainsKey(obstruction.ObstacleIdentifier)) { return; } if (!shapes.ContainsKey(obstruction.ObstructedGoalIdentifier)) { return; } var obstacleGraphic = shapes [obstruction.ObstacleIdentifier].First(); var goalGraphic = shapes [obstruction.ObstructedGoalIdentifier].First(); var topArrow = GetSharpBackCrossArrow(obstacleGraphic, goalGraphic); Add(obstruction.Identifier, topArrow); }
public void AddObstruction(Obstruction obstruction) { if (!mObstructions.Contains(obstruction)) { mObstructions.Add(obstruction); // Add obstruction to mBlocked: for (int i = 0; i < 3; i++ ) BlockCircularArea(mBlocked[i], GlobalValues.GetInstance().MeshScale, obstruction.mPosition, obstruction.mRadius + mRadiusToAdd[i]); if (mMesh != null) { // We added an obstruction when there already existed a mesh. // Now we have to recalculate the changed parts around the obstruction: Stopwatch watch = Stopwatch.StartNew(); PrepareRecalculatingMesh(obstruction, true); watch.Stop(); Debug.WriteLine("Recalculating the mesh done in "+watch.ElapsedMilliseconds+" ms."); } } }
private void OnTriggerStay2D(Collider2D collision) { // *** If we hit a creep... Creep c = collision.gameObject.GetComponent <Creep>(); if (c != null) { c.GetShot(this); } else { if (!incorporeal) { Obstruction o = collision.gameObject.GetComponent <Obstruction>(); if (o != null) { // c.GetShot(this); OnMiss(o); // Despawn(); } } } }
public override void Handle(Goal element, ParsedObstructedByAttribute attribute, KAOSModel model) { var obstruction = new Obstruction(model); obstruction.SetObstructedGoal(element); if (attribute.Value is IdentifierExpression) { var id = ((IdentifierExpression)attribute.Value).Value; Obstacle obstacle; if ((obstacle = model.obstacleRepository.GetObstacle(id)) == null) { obstacle = new Obstacle(model, id) { Implicit = true }; model.obstacleRepository.Add(obstacle); } obstruction.SetObstacle(obstacle); } else { throw new UnsupportedValue(element, attribute, attribute.Value); } model.Add(obstruction); }
void viewObstruction() { RaycastHit hit; if (Physics.Raycast(transform.position, Target.position - transform.position, out hit, 4.5f)) { if (hit.collider.gameObject.tag != "Player") { Obstruction.GetComponent <MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; if (Vector3.Distance(Obstruction.position, transform.position) >= 3f && Vector3.Distance(transform.position, Target.position) >= 1.5f) { transform.Translate(Vector3.forward * zoomSpeed * Time.deltaTime); } } else { Obstruction.GetComponent <MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; if (Vector3.Distance(transform.position, Target.position) < 4.5f) { transform.Translate(Vector3.forward * zoomSpeed * Time.deltaTime); } } } }
protected void UPDATE(object sender, EventArgs e) { Obstruction = Obstruction_update(Convert.ToInt32(Update_Obstruction_GridView.SelectedValue)); }
protected void Update_Select_Record(object sender, EventArgs e) { Obstruction = Update_Obstruction_select(Convert.ToInt32(Update_Obstruction_GridView.SelectedValue)); }
public void Remove(Obstruction obstruction) { Obstructions.Remove(obstruction.Identifier); }
/// <summary> /// Called when colliding with an obstruction. /// </summary> /// <param name="c"></param> public virtual void OnMiss(Obstruction c) { }
protected void INSERT(object sender, EventArgs e) { Obstruction = Obstruction_insert(); }
/// <summary> /// MODIFICATIONS /// </summary> internal void SetObstruction( Obstruction obstruction ) { this.obstruction = obstruction; }
public override void OnMiss(Obstruction c) { base.OnMiss(c); // Sounder.Instance().PlaySound("pellet_hit_wall"); }
ISatisfactionRate GetESR(Obstruction o) { return(GetESR(o.Obstacle())); }
internal void ClearObstruction() { obstruction = null; }
public Obstruction Obstruction_update(int ID) { Obstruction = Obstruction.Select(ID); Obstruction.Obstruction_ID = Convert.ToInt32(Update_Obstruction_ID_txt.Text); Obstruction.Evacuation_Area_ID = Convert.ToInt32(Update_Evacuation_Area_ID_txt.Text); Obstruction.Location_ID = Convert.ToInt32(Update_Location_ID_txt.Text); Obstruction.Date_Reported = Convert.ToDateTime(Update_Date_Reported_txt.Text); Obstruction.Expected_Recovery_Date = Convert.ToDateTime(Update_Expected_Recovery_Date_txt.Text); Obstruction.Type = Update_Type_txt.Text; Obstruction.Severity = Update_Severity_txt.Text; Obstruction.Update(Obstruction); Insert_Obstruction_GridView.DataBind(); Update_Obstruction_GridView.DataBind(); Delete_Obstruction_GridView.DataBind(); return Obstruction; }
/// <summary> /// Required to prevent redundancy in the obstructions list. /// </summary> bool ObstructionExists(Obstruction o) { foreach (Obstruction obstruction in obstructions) { if (obstruction.obj == o.obj) return true; } return false; }
public BDDNode GetObstructionSet(Obstruction obstruction) { return(GetObstructionSet(obstruction.Obstacle())); }
public void RemoveObstruction(Obstruction obstruction) { if (mObstructions.Contains(obstruction)) { mObstructions.Remove(obstruction); // Adjust mBlocked: for (int i = 0; i < 3; i++ ) { BlockCircularArea(mBlocked[i], GlobalValues.GetInstance().MeshScale, obstruction.mPosition, obstruction.mRadius + mRadiusToAdd[i], true); foreach (Obstruction o in mObstructions) { if (HelperMethods.RectanglesIntersect(obstruction.GetBoundingBox(mRadiusToAdd[i]), o.GetBoundingBox(mRadiusToAdd[i]))) BlockCircularArea(mBlocked[i], GlobalValues.GetInstance().MeshScale, o.mPosition, o.mRadius + mRadiusToAdd[i]); } } if (mMesh != null) { // We removed an obstruction when there already existed a mesh. // Now we have to recalculate the changed parts: Stopwatch watch = Stopwatch.StartNew(); PrepareRecalculatingMesh(obstruction, false); watch.Stop(); Debug.WriteLine("Recalculating the mesh done in " + watch.ElapsedMilliseconds + " ms."); } } }
public Obstruction Obstruction_insert() { Obstruction.Evacuation_Area_ID = Convert.ToInt32(Insert_Evacuation_Area_ID_txt.Text); Obstruction.Location_ID = Convert.ToInt32(Insert_Location_ID_txt.Text); Obstruction.Date_Reported = Convert.ToDateTime(Insert_Date_Reported_txt.Text); Obstruction.Expected_Recovery_Date = Convert.ToDateTime(Insert_Expected_Recovery_Date_txt.Text); Obstruction.Type = Insert_Type_txt.Text; Obstruction.Severity = Insert_Severity_txt.Text; Obstruction = Obstruction.Insert(Obstruction); Insert_Obstruction_GridView.DataBind(); Update_Obstruction_GridView.DataBind(); Delete_Obstruction_GridView.DataBind(); return Obstruction; }
/// <summary> /// Called by PathFinder.AddObstruction() / .RemoveObstruction(). /// Calling this method requires that the mesh(es) already exist and /// will only calculate a part of it, namely where the given obstruction was /// added / removed. /// </summary> /// <param name="obstruction">the obstruction that has been added /removed</param> /// <param name="doAdd">if true, assumes addition, else removal</param> private void PrepareRecalculatingMesh(Obstruction obstruction, bool doAdd) { // Do the following recalculations for each one of our three meshes for (int i = 0; i < 3; i++) { Rectangle obstructionBoundingBox = obstruction.GetBoundingBox(mRadiusToAdd[i]); Rectangle? extremaBoundingBox; List<Polygon> polygonsToRecalculate = mMesh[i].FindCoveredPolygons(obstructionBoundingBox, out extremaBoundingBox, true, true); int meshScale = GlobalValues.GetInstance().MeshScale; int width = mMesh[i].mWidth; // actually all of the three meshes have int height = mMesh[i].mHeight; // the same, so this is kind of a waste int xMinObb = Math.Max(obstructionBoundingBox.X - meshScale, 0); int yMinObb = Math.Max(obstructionBoundingBox.Y - meshScale, 0); int xMaxObb = Math.Min(obstructionBoundingBox.X + obstructionBoundingBox.Width + meshScale, width); int yMaxObb = Math.Min(obstructionBoundingBox.Y + obstructionBoundingBox.Height + meshScale, height); Rectangle extremaBoundingBox3; if (extremaBoundingBox != null) { Rectangle ebb2 = (Rectangle) extremaBoundingBox; // Make sure that extremaBoundingBox contains obstructionBoundingBox on all accounts, // but more importantly does not exceed the mesh dimensions int xMinEbb2 = ebb2.X; int yMinEbb2 = ebb2.Y; int xMaxEbb2 = ebb2.X + ebb2.Width; int yMaxEbb2 = ebb2.Y + ebb2.Height; // We name our failsafe extrema simply extremaBoundingBox3: int xMinEbb3 = Math.Min(xMinEbb2, xMinObb); int yMinEbb3 = Math.Min(yMinEbb2, yMinObb); int xMaxEbb3 = Math.Max(xMaxEbb2, xMaxObb); int yMaxEbb3 = Math.Max(yMaxEbb2, yMaxObb); extremaBoundingBox3 = new Rectangle(xMinEbb3, yMinEbb3, xMaxEbb3 - xMinEbb3, yMaxEbb3 - yMinEbb3); } else if (!doAdd) { // if there are no polygons to calculate and no // extremaBoundingBox, but we want to remove an obstruction, // we just choose the Obb as extrema. extremaBoundingBox3 = new Rectangle(xMinObb, yMinObb, xMaxObb - xMinObb, yMaxObb - yMinObb); } else { // we add an obstruction, but there are no polygons to recalculate, // so we do nothing return; } mMesh[i].Recalculate(mBlocked[i], polygonsToRecalculate, extremaBoundingBox3, GlobalValues.GetInstance().MeshScale); } }
void OnDrawGizmos() { // Make list List <Obstruction> obs = new List <Obstruction>(); obs.Add(new Obstruction(camMin.x, camMax.x)); /*/ Skip the enemies, they don't collide with each other anyway * if (entityMargin > 0) { * foreach (BaseAI enemy in FindObjectsOfType<BaseAI>()) { * if (!enemy.dead) * obs.Add(new Obstruction(enemy.transform.position.x - entityMargin, enemy.transform.position.x + entityMargin)); * } * } */ // Compress bool change; do { change = obs.RemoveAll(delegate(Obstruction a) { // Outside area if (a.left > rightEdge.x || a.right < leftEdge.x) { return(true); } for (int i = 0; i < obs.Count; i++) { Obstruction b = obs[i]; if (a.right >= b.left && a.right < b.right) { // Combine b.left = Mathf.Min(a.left, b.left); b.right = Mathf.Max(a.right, b.right); return(true); } } if (obs.Exists(delegate(Obstruction b) { return(a.left == b.left && a.right == b.right && a != b && !b.dying); })) { a.dying = true; return(true); } return(false); }) > 0; } while (change); // Sort obs.Sort(delegate(Obstruction a, Obstruction b) { return(a.left.CompareTo(b.left)); }); bool green = true; List <float> points = new List <float>(); points.Add(leftEdge.x); foreach (var a in obs) { // Left float l = Mathf.Max(a.left, leftEdge.x); float r = Mathf.Min(a.right, rightEdge.x); if (Mathf.Approximately(l, leftEdge.x)) { green = false; } else if (!points.Contains(l)) { points.Add(l); } if (!points.Contains(r)) { points.Add(r); } } if (points[points.Count - 1] < rightEdge.x) { points.Add(rightEdge.x); } // Draw float left = leftEdge.x; foreach (float point in points) { if (point == left) { continue; } Gizmos.color = left == leftEdge.x && green ? Color.green : Color.red; Gizmos.DrawRay(new Vector3(left, .5f), Vector3.down); Gizmos.color = green ? Color.green : Color.red; Gizmos.DrawLine(new Vector3(left, 0), new Vector3(point, 0)); left = point; green = !green; } Gizmos.color = !green ? Color.green : Color.red; Gizmos.DrawRay(new Vector3(left, .5f), Vector3.down); }
protected void Insert_Select_Record(object sender, EventArgs e) { Obstruction = Insert_Obstruction_select(Convert.ToInt32(Insert_Obstruction_GridView.SelectedValue)); }