IEnumerator CreateTool(bool horizontal, int direction)
{
if (this.toolType.Length > 0 && !this.locked) {
Destroy (this.tool);
this.elapsed = 0;
this.untilUnlocked = this.delay;
this.locked = true;
float toolAnimationDelay = .18f;
if (this.toolType == "Rope") {
toolAnimationDelay = .48f;
}
yield return new WaitForSeconds(toolAnimationDelay);
this.tool = new GameObject ();
tool.name = this.toolType;
tool.tag = this.toolType;
tool.transform.parent = this.gameObject.transform;
tool.transform.position = this.gameObject.transform.position;
BoxCollider2D collider = tool.AddComponent<BoxCollider2D> ();
collider.isTrigger = true;
Vector2 playerSize = this.Size;
collider.size = playerSize;
float verticalAdjustment = -playerSize.y / 4;
if (this.toolType == "Shovel") {
verticalAdjustment = -playerSize.y / 4;
} else if (this.toolType == "Lockpick") {
verticalAdjustment = 0f;
}
if (horizontal) {
collider.size = new Vector2 (.05f, this.range);
collider.transform.Translate (0f, (playerSize.y / 2 + this.range / 2) * direction, 0);
} else {
collider.size = new Vector2 (this.range, .05f);
collider.transform.Translate ((playerSize.x / 2 + this.range / 2) * direction, verticalAdjustment, 0);
}
}
}