コード例 #1
0
ファイル: ChangeProcessor.cs プロジェクト: FireGrey/PollLifx
        public (bool success, string message) GetChanges(Lightbulb oldState, Lightbulb newState)
        {
            List <string> changes = new List <string>();

            if (oldState.power != newState.power)
            {
                changes.Add($"turned {newState.power}");
            }

            if (oldState.connected != newState.connected)
            {
                changes.Add(newState.connected ? "connected" : "disconnected");
            }

            var oldColour = CalculateColour(oldState.color);
            var newColour = CalculateColour(newState.color);

            if (oldColour != newColour)
            {
                changes.Add($"changed to the colour {newColour}");
            }

            if (!changes.Any())
            {
                return(false, "");
            }

            string changeString = ConcatChanges(changes);

            string message = $"{newState.label} light has been {changeString}";

            return(true, message);
        }
コード例 #2
0
    //This will be used to set either the starting position or ending position of the rectangle
    public void SetPos()
    {
        //Set the currently selected light's Lightbulb script to the temp variable
        Lightbulb tempLight = EventSystem.current.currentSelectedGameObject.GetComponent <Lightbulb>();

        //If this click is to set the first position
        if (!firstPosSet)
        {
            //Reset the previous rectangle for insurance
            resetRect();
            //Set firstPos to the temp variable
            firstPos = tempLight;
            //Highlight the selected light in green
            firstPos.highlight();
            //Update the bool for the second click
            firstPosSet = true;
        }
        //If this click is to set the second position
        else
        {
            //Set lastPos to the temp variable
            lastPos = tempLight;
            //Form the rectangle from the points between first and last pos
            formRectangle(firstPos, lastPos);
            //Update the bool for the first click
            firstPosSet = false;
        }
    }
コード例 #3
0
    private IEnumerator Respawn(Lightbulb lightbulb)
    {
        yield return(new WaitForSeconds(Random.Range(1f, 2f)));

        lightbulb.Spawn();

        yield return(null);
    }
コード例 #4
0
 //This function forms the rectangle between the selected points
 private void formRectangle(Lightbulb firstPos, Lightbulb lastPos)
 {
     //For sake of ease, swap the first/last positions when going to the left
     if (lastPos.xPos < firstPos.xPos)
     {
         Lightbulb temp = firstPos;
         firstPos = lastPos;
         lastPos  = temp;
     }
     //This loop only accounts for if lastPos.yPos >= firstPos.yPos (so down and to the right from starting pos)
     if (lastPos.yPos >= firstPos.yPos)
     {
         for (int i = firstPos.yPos; i <= lastPos.yPos; i++)
         {
             for (int j = firstPos.xPos; j <= lastPos.xPos; j++)
             {
                 //Loop through the grid array, and add the lights between the first and last positions to the rectangle List
                 rectangle.Add(grid[i, j]);
             }
         }
     }
     //This loop accounts for if lastPos.yPos < firstPos.yPos (so up and to the right from starting pos)
     else if (lastPos.yPos < firstPos.yPos)
     {
         for (int i = firstPos.yPos; i >= lastPos.yPos; i--)
         {
             for (int j = firstPos.xPos; j <= lastPos.xPos; j++)
             {
                 //Loop through the grid array, and add the lights between the first and last positions to the rectangle List
                 rectangle.Add(grid[i, j]);
             }
         }
     }
     //For the selected list, toggle the lights between the states
     toggleLights();
 }
コード例 #5
0
ファイル: Strand.cs プロジェクト: garretthedman/MoodLighting
 private void RequestColorChange(Lightbulb lb, float start)
 {
     ColorChangeHash[lb] = new float[] { start };
 }
コード例 #6
0
ファイル: Strand.cs プロジェクト: garretthedman/MoodLighting
 private void RequestJump(Lightbulb lb, float start)
 {
     JumpHash[lb] = new float[] { start, 1.0f };
 }
コード例 #7
0
ファイル: Strand.cs プロジェクト: garretthedman/MoodLighting
 // UTILITIES
 private void RequestLightChange(Lightbulb lb, float start, float end, float goal)
 {
     LightChangeHash[lb] = new float[] { start, end, goal };
 }
コード例 #8
0
 public void ShatteredLightbulb(Lightbulb lightbulb)
 {
     StartCoroutine(Respawn(lightbulb));
 }
コード例 #9
0
 /* Replaces my lightbulb with LIGHTBULB.
  */
 public void ReplaceLightBulb(Lightbulb lightbulb)
 {
     _lightbulb = lightbulb;
 }
コード例 #10
0
 //Creates a fully functioning headlight with a new fully functioning lightbulb.
 public Headlight()
 {
     _lightbulb = new Lightbulb();
     _isDamaged = false;
 }