GameObject FindLazer(eSensorDirection dir) { return(this.lazersObjects.Find((GameObject element ) => { sensorLazer maybeObj = element.GetComponentInChildren <sensorLazer>(); if (maybeObj && maybeObj.direction == dir) { return true; } else { return false; } })); }
public static Vector2 DirectionEnumToVector(eSensorDirection direction) { if (direction == eSensorDirection.N) { return(new Vector2(0, 1)); } else if (direction == eSensorDirection.W) { return(new Vector2(-1, 0)); } else if (direction == eSensorDirection.S) { return(new Vector2(0, -1)); } else if (direction == eSensorDirection.E) { return(new Vector2(1, 0)); } else if (direction == eSensorDirection.NW) { return(new Vector2(-1, 1).normalized); } else if (direction == eSensorDirection.NE) { return(new Vector2(1, 1).normalized); } else if (direction == eSensorDirection.SW) { return(new Vector2(-1, -1).normalized); } else if (direction == eSensorDirection.SE) { return(new Vector2(1, -1).normalized); } return(new Vector2(0, 0)); }
void ShootBulletDirection(eSensorDirection direction) { StartCoroutine(Foo(VectorHelper.DirectionEnumToVector(direction), ShootDelay)); }