public Led(LedColor color, LedPosition position) : base($"leds/ev3:{position.ToString().ToLower()}:{color.ToString().ToLower()}:ev3dev") { Color = color; Position = position; brightness = new ClassProperty(Folder, "brightness"); }
//// Finds the closest LED to a position //LedPosition ClosestToPosition(Vector3 pos) { // LedPosition closestLed = null; // float closetDistanceSquared = float.PositiveInfinity; // foreach (LedPosition ledPosition in ledPositions) { // if ((ledPosition.transform.position - pos).sqrMagnitude < closetDistanceSquared) { // closestLed = ledPosition; // closetDistanceSquared = (ledPosition.transform.position - pos).sqrMagnitude; // } // } // return closestLed; //} /// <summary> /// Get the position of the led corresponding to a position of an entity /// </summary> /// <param name="pos">Position of the entity</param> /// <returns>Led corresponding to position of entity</returns> LedPosition FindLed(Vector3 pos) { LedPosition led = null; for (int i = 0; i < ledZones.Length; i++) { led = ledZones[i].IsEntityInZone(pos); if (led != null) { i = ledZones.Length; } } return(led); //throw new System.ArgumentOutOfRangeException("Entity not in any ledzone. Entity position:" + pos); }
void Start() { led = GetComponent <LedPosition>(); collider = GetComponent <BoxCollider>(); //float leftBound = leftBorder.position.x; //float rightBound = rightBorder.position.x; //float topBound = topBorder.position.y; //float bottomBound = bottomBorder.position.y; ////If the bounds of the zone are placed incorrectly, throw an exception. //if(leftBound >= rightBound) //{ // throw new System.ArgumentException("Left bound of Led Zone cannot be to the right of Right bound of Led Zone"); //} //if(bottomBound >= topBound) //{ // throw new System.ArgumentException("Bottom bound of Led Zone cannot be higher than of Top bound of Led Zone"); //} }
// Update void Update() { // Finds the closest LED to the player LedPosition closestLed; try { closestLed = FindLed(GameController.Instance.player.transform.position); if (closestLed != null) { if (closestLed != playerLed) { playerLed = closestLed; GameController.Instance.arduinoHandler.WritePlayerPosition(closestLed.col, closestLed.row); } } } catch (Exception e) { } // Finds the closest LED for each enemy for (int i = 0; i < enemyLeds.Length; i++) { try { closestLed = FindLed(GameController.Instance.enemyControllers[i].transform.position); if (closestLed != null) { if (closestLed != enemyLeds[i]) { enemyLeds[i] = closestLed; GameController.Instance.arduinoHandler.WriteMonsterPosition(i, closestLed.col, closestLed.row); } } } catch (Exception e) { } } }
public LED(string serial, LedPosition ledPosition, LedStatus red, LedStatus green, LedStatus blue) : this(serial, ledPosition) { this.Red = red; this.Green = green; this.Blue = blue; }
public LED(string serial, LedPosition ledPosition) { this.Serial = serial; this.LedPosition = ledPosition; }
public LedSet(LedPosition position) { Green = new Led(LedColor.Green, position); Red = new Led(LedColor.Red, position); }