public Collision CompleteAndAdd(Collision it, int inflate = 0) { buildHelper.CompleteBBox(it, inflate); buildHelper.CompletePlane(it); CollisionList.Add(it); return(it); }
public bool CollidesMultiple <T>(Vector2 position, out CollisionList <T> collisionList) where T : Entity { if (Entity == null || Shape == null) { collisionList = null; return(false); } return(Physics.Instance.QueryMultipleCollision(Shape, position, Physics.Instance.GetCollidableTags(Tags), out collisionList)); }
public bool CollidesMultiple <T>(BitTag tags, out CollisionList <T> collisionList) where T : Entity { if (Entity == null || Shape == null) { collisionList = null; return(false); } return(Physics.Instance.QueryMultipleCollision(Shape, Position, tags, out collisionList)); }
public bool CollidesMultiple(Vector2 position, BitTag tags, out CollisionList <Body> collisionList) { if (Entity == null || Shape == null) { collisionList = null; return(false); } return(Physics.Instance.QueryMultipleCollision(Shape, position, tags, out collisionList)); }
// Initialization / Setup /// <summary> /// Initializes the biped object, obtians all relevant components. /// </summary> private void Initialize() { // Set our layer, obtain appropriate components. this.gameObject.layer = Globals.BIPED_LAYER; _submergable = this.GetComponent <Submergable>(); _rigidbody2D = this.GetComponent <Rigidbody2D>(); _boxCollider2D = this.GetComponent <BoxCollider2D>(); _spriteRenderer = this.GetComponent <SpriteRenderer>(); _collisionList = this.GetComponent <CollisionList>(); }
private void generateCollision() { int lineCount = 0; int tileGap; CollisionTiles currTile, firstTile, prevTile; prevTile = new CollisionTiles(0, new Rectangle(0, 0, 32, 32), null); for (int x = 0; x < m_collisionTiles.Count; x++) { currTile = m_collisionTiles[x]; tileGap = currTile.Rectangle.X - prevTile.Rectangle.X; if (currTile.Rectangle.Y >= 4000) { } if (currTile.Rectangle.Y == prevTile.Rectangle.Y) { if (lineCount == 0) { firstTile = currTile; } if ((tileGap > 33) && (lineCount > 0)) { firstTile = m_collisionTiles[x - lineCount]; CollisionList.Add(new BoundingBox(new Vector3(firstTile.Rectangle.X - 32, firstTile.Rectangle.Y, 0), new Vector3(prevTile.Rectangle.X + prevTile.Rectangle.Width, prevTile.Rectangle.Y + prevTile.Rectangle.Height, 0))); Thread.Sleep(10); lineCount = 0; } else { lineCount++; } } else { firstTile = m_collisionTiles[x - lineCount]; CollisionList.Add(new BoundingBox(new Vector3(firstTile.Rectangle.X - 32, firstTile.Rectangle.Y, 0), new Vector3(prevTile.Rectangle.X + prevTile.Rectangle.Width, prevTile.Rectangle.Y + prevTile.Rectangle.Height, 0))); Thread.Sleep(10); lineCount = 0; } prevTile = currTile; } lineCount = 0; }
protected void CheckKillboxCollision() { if (CollisionList.Any(b => b.ID.StartsWith("k"))) { Debug.WriteLine("dies"); } foreach (var body in CollisionList) { if (body != null) { if (body is Sprite) { var sprite = body as Sprite; switch (sprite.SpriteType) { case SpriteType.Killbox: var killbox = sprite as Killbox; if (!killbox.Used) { Health -= sprite.Damageful; SetTexture(); killbox.Used = true; if (Health <= 0) { if (!this.Dead) { var status = new PlayerStatus() { Data = this.Tokens + ":" + (int)this.Center.X + ":" + (int)this.Center.Y, State = PlayerState.Kill }; (Target as Player).Status.Enqueue(status); } this.Dead = true; } } break; } } } } }
/// <summary> /// Adds a new vertex to the TTM /// </summary> /// <returns></returns> public TriVertex AddPoint(double X, double Y, double Z) { TriVertex Result = SearchForPoint(X, Y, Z, out int HashIdx); if (Result == null) { Result = CreateVertex(X, Y, Z); Add(Result); List <TriVertex> CollisionList = HashArray[HashIdx]; // Add the item to the collision list for this HashIndex, creating a new one // if no hashed item has been added to this entry. if (CollisionList == null) { CollisionList = new List <TriVertex>(); HashArray[HashIdx] = CollisionList; } CollisionList.Add(Result); } return(Result); }
public bool CollidesMultiple <T>(out CollisionList <T> collisionList) where T : Entity { return(CollidesMultiple(Position, out collisionList)); }
public bool CollidesMultiple(out CollisionList <Body> collisionList) { return(CollidesMultiple(Position, out collisionList)); }
// Start is called before the first frame update void Awake() { // Bundle all data files by participant/run List <string> fileIDs = new List <string>(); Dictionary <string, Dictionary <string, string> > filesBundledByParticipantRun = new Dictionary <string, Dictionary <string, string> >(); TextAsset[] textFiles = Resources.LoadAll <TextAsset>(""); foreach (TextAsset tf in textFiles) { //Debug.Log("Adding data for " + tf.name); string participantRun = tf.name.Split('_')[0]; string fileName = tf.name.Split('_')[1]; if (!fileIDs.Contains(participantRun) && !participantRun.Equals("")) { fileIDs.Add(participantRun); filesBundledByParticipantRun.Add(participantRun, new Dictionary <string, string>()); } if (!participantRun.Equals("")) { filesBundledByParticipantRun[participantRun][fileName] = tf.text; } } InitPlanes(); // Get tip of cone for later placement Bounds coneBounds = collisionCone.GetComponent <MeshFilter>().mesh.bounds; coneTipToPosition = Vector3.Scale(new Vector3(0f, coneBounds.extents.y, 0f), collisionCone.transform.localScale); distanceConeTipToCentroid = coneTipToPosition.magnitude; // * 0.8f; //Debug.Log("Cone tip to position: " + coneTipToPosition.ToString() + " Distance: " + distanceConeTipToCentroid); coneCollisionList = collisionCone.GetComponent <CollisionList>(); analysisResultWriter = new StreamWriter("Assets/Results/Analysis.csv", false); analysisResultWriter.WriteLine("Participant and Run, Jerk Magnitude, Hits, Misses, False Alarms, Total Targets"); foreach (string fileID in fileIDs) { Dictionary <string, Defect> defects = new Dictionary <string, Defect>(); List <CamData> camData = new List <CamData>(); List <Selection> selections = new List <Selection>(); List <FalseAlarm> falseAlarms = new List <FalseAlarm>(); List <Vector3> camPositionsAtSelection = new List <Vector3>(); defects = ParseDefectData(filesBundledByParticipantRun[fileID]["DefectData"]); camData = parseLogData(filesBundledByParticipantRun[fileID]["Log"]); ParseResults(filesBundledByParticipantRun[fileID]["Results"], defects, selections, falseAlarms, camData, camPositionsAtSelection); if (fileID == "p5r5") { angleWriter = new StreamWriter("Assets/Results/AngleDeltas_Test.csv"); vWriter = new StreamWriter("Assets/Results/VDeltas_Test.csv"); jWriter = new StreamWriter("Assets/Results/jerkRMS_Test.csv"); } else { angleWriter = null; vWriter = null; jWriter = null; } // Rectify mistakes from 1st round... for (int si = 0; si < selections.Count; si++) { selections[si].SetSelectedDefect(GetNearestVisibleDefectAtPosition(selections[si].position, defects)); } // Debug objects cdIdx = 0; GenerateOutputFile(analysisResultWriter, defects, selections, camData, falseAlarms, fileID); } analysisResultWriter.Close(); if (vWriter != null) { vWriter.Close(); jWriter.Close(); } }
void Update() { CollisionList.Clear(); }
//Basic FindTargets with no AI, just grabs a random selection public GameObject[] FindTargets(GameObject attacker, GameObject[] targetArray, Vector3 position, float range, int team, targetAIs targetAI) { //finds an appropriate target //fills and returns the passed array //needs to grab all GOs within the range, //filter out non-enemies, than choose from that to fill array List<CollisionList> targetList = new List<CollisionList>(); if(targetAI == targetAIs.Self){ targetArray = new GameObject[1]; targetArray[0] = attacker; Debug.Log(targetArray[0]+" : "+attacker); return targetArray; } Collider[] hits = Physics.OverlapSphere(position, range); if(hits.Length <= 0){ return targetArray; } if (hits.Length > 0){ for (int i = 0; i < hits.Length; i++){ var targetBody = hits[i].GetComponent<Body>(); if(targetBody != null){ if(targetBody.team != team && targetBody.curHealth > 0){ float dist = Vector3.Distance(position, hits[i].transform.position); CollisionList c = new CollisionList(i, targetBody.curHealth,dist); targetList.Add(c); } } } switch(targetAI){ case targetAIs.Weakest: targetList = targetList.OrderBy(x => x.health).ToList(); break; case targetAIs.Healthiest: targetList = targetList.OrderBy(x => -(x.health)).ToList(); break; case targetAIs.Farthest: targetList = targetList.OrderBy(x => -(x.distance)).ToList(); break; case targetAIs.Closest: targetList = targetList.OrderBy(x => x.distance).ToList(); break; case targetAIs.All: targetList = targetList; break; } int targetfill = 0; foreach(CollisionList collision in targetList){ if (targetfill < targetArray.Length){ targetArray[targetfill] = hits[collision.hitIndex].gameObject; targetfill++; } else { return targetArray; } } } return targetArray; }