// Update is called once per frame protected override void Update() { base.Update(); if (_updateResults.Where(x => x.transform.position.y > transform.position.y && _pseudoParents.Contains(x.transform.GetComponent <BaseCircuit>())).Any()) { if (_pseudoParents.Where(x => x.transform.position.y > transform.position.y).First().Current > 0f) { List <RaycastHit2D> conns = _updateResults.Where(x => x.transform.position.y < transform.position.y).ToList(); if (conns.Count > 0) { BaseCircuit botSideConnection = conns.First().transform.GetComponent <BaseCircuit>(); Current = botSideConnection.Current; } else { _pseudoParents = new List <BaseCircuit>(); _sourceNames = new List <string>(); Current = 0f; } } } else { Current = 0f; } }
void Update() { _components.RemoveAll(x => x == null); if (_components.Where(x => x.name == "EndGoal" && x.Connected == true).Any()) { if (_components.Where(x => x.name.ToUpper().Contains("START")).Count() > 1) { if (_components.Where(x => x.name.ToUpper().Contains("SISTOR") && x.Connected == true).Count() == 0) { return; } } EngComponent block = _components.Where(x => x.name == "EndGoal").First(); if (block.GetType().IsAssignableFrom(typeof(BaseCircuit))) { BaseCircuit actualBlock = (BaseCircuit)block; if (actualBlock.Current >= RequiredPower) { PuzzleDone(CarriagePuzzleController.PuzzleType.T2D); UI.ShowMessage("The circuit appears to be conducting electricity once more!"); TwoDimensionalUIController.UI.ValidateInventory(); UI.Hide2DPuzzle(); } } } }
protected void VerifyCurrent(List <RaycastHit2D> rayCollection) { foreach (RaycastHit2D result in rayCollection) { if (!_oldResults.Contains(result)) { BaseCircuit component = result.transform.gameObject.GetComponent <BaseCircuit>(); if (component.Current == 0 && !_pseudoChildren.Contains(component)) { _pseudoChildren.Add(component); } else if (!_pseudoParents.Contains(component)) { _pseudoParents.Add(component); } } } }
void Update() { _components.RemoveAll(x => x == null); if (_components.Where(x => x.name == "EndGoal" && x.Connected == true).Any()) { if (_components.Where(x => x.name.ToUpper().Contains("START")).Count() > 1) { if (_components.Where(x => x.name.ToUpper().Contains("SISTOR") && x.Connected == true).Count() == 0) { return; } } EngComponent block = _components.Where(x => x.name == "EndGoal").First(); if (block.GetType().IsAssignableFrom(typeof(BaseCircuit))) { BaseCircuit actualBlock = (BaseCircuit)block; if (actualBlock.Current >= RequiredPower) { Destroy(gameObject); } } } }