private void InstantiateEntityIcon(EntityMovementHandler enm) { GameObject _entityIcon = Instantiate(EntityIconPrefab, Vector2.zero, Quaternion.identity) as GameObject; _entityIcon.GetComponent <EntityIcon>().Target = enm; _entityIcon.transform.parent = UICanvas.transform.FindChild("Background").transform; RectTransform _rTransform = _entityIcon.GetComponent <RectTransform>(); _rTransform.anchoredPosition = new Vector2((GameSceneManager.TOTAL_PLAYERS * 150.0f) + 50, 0); }
protected virtual void CollisionEnter(Collision2D col) { if (col.gameObject.GetComponent <EntityMovementHandler>() != null) { EntityMovementHandler _thisObject = this; EntityMovementHandler _otherObject = col.gameObject.GetComponent <EntityMovementHandler>(); Rigidbody2D _otherRigidBody = col.gameObject.GetComponent <Rigidbody2D>(); float _differenceForce = Mathf.Abs(Mathf.Abs(_thisObject.Velocity) - Mathf.Abs(_otherObject.Velocity)); if (Mathf.Abs(_thisObject.Velocity) > Mathf.Abs(_otherObject.Velocity)) { _otherObject.DoDamage((_differenceForce / 1000.0f) * 25.0f); } else { _thisObject.DoDamage((_differenceForce / 1000.0f) * 25.0f); } } }