private IEnumerator GenerateBoard() { #region Generate Rocks Floor for (int j = 0; j < RockHeight; j++) { for (int i = 0; i < Width; i++) { transform.position = new Vector3(rockTileSize * i - offset, rockTileSize * j, 0); CreateRockFloor(); } } #endregion #region Generate Rocks Border for (int i = 0; i < Width; i++) { transform.position = new Vector3(rockTileSize * i - offset, 0, 0); CreateRockBorder(); } for (int i = 0; i < Width; i++) { transform.position = new Vector3(rockTileSize * i - offset, rockTileSize * (RockHeight - 1), 0); CreateRockBorder(); } #endregion //Spawns our weapon. subject to change. DamageEnemies.SetupWeapon(Instance, weapon); // Yield allows this to be non-blocking. This is the preferred method in Unity, over async functions yield return(0); }
void OnEnemyCollision(GameObject other, Vector3 normal) { Dev.Where(); HitInstance hit = ImpactHit; hit.DamageDealt = (int)(blowVelocity.magnitude * .25f); //1011 //if( ( other.layer & 11 ) > 0 ) { Rigidbody2D rb = other.GetComponentInParent <Rigidbody2D>(); if (rb != null) { bool isEnemy = rb.gameObject.IsGameEnemy(); if (!isEnemy) { return; } blowVelocity = normal * blowVelocity.magnitude; rb.gameObject.GetOrAddComponent <TakeDamageFromImpact>().blowVelocity = blowVelocity; rb.gameObject.GetOrAddComponent <PreventOutOfBounds>(); DamageEnemies dme = rb.gameObject.GetOrAddComponent <DamageEnemies>(); dme.damageDealt = (int)blowVelocity.magnitude; HealthManager.Hit(hit); } } }
//static PhysicsMaterial2D hbMat; static void DebugPrintObjectOnHit(Collider2D otherCollider, GameObject gameObject) { //if(once) //{ // once = false; // HeroController.instance.superDash.WriteComponentTree( HeroController.instance.gameObject.name +"_Superdash" ); //} //Dev.Where(); if (otherCollider.gameObject.name != debugRecentHit) { //Dev.Log( "Hero at " + HeroController.instance.transform.position + " HIT: " + otherCollider.gameObject.name + " at (" + otherCollider.gameObject.transform.position + ")" + " with layer (" + otherCollider.gameObject.layer + ")" ); debugRecentHit = otherCollider.gameObject.name; } //TODO: something in here throws a nullref if (!HeroController.instance.playerData.equippedCharm_15) { return; } Rigidbody2D body = otherCollider.GetComponentInParent <Rigidbody2D>(); if (body == null) { return; } bool isEnemy = body.gameObject.IsGameEnemy(); if (!isEnemy) { return; } TakeDamageFromImpact dmgOnImpact = body.gameObject.GetOrAddComponent <TakeDamageFromImpact>(); PreventOutOfBounds poob = body.gameObject.GetOrAddComponent <PreventOutOfBounds>(); DamageEnemies dmgEnemies = body.gameObject.GetOrAddComponent <DamageEnemies>(); Vector2 blowDirection = otherCollider.transform.position - HeroController.instance.transform.position; //blowDirection.y = 0f; float blowPower = 40f; dmgOnImpact.blowVelocity = blowDirection.normalized * blowPower; dmgEnemies.damageDealt = (int)blowPower; }