public void OnColourChanged(ShanghaiUtils.PaintColour colour) { Flash.ResetToBeginning(); Flash.PlayForward(); CurrentColor = colour; ColourSprite.color = ShanghaiUtils.GetColour(colour); }
public ActiveMissionViewController(ActiveMission actMission, Material material) { _Model = GameModel.Instance; _ActMission = actMission; _TrackPathMaterial = new Material(material); _ColourPathMaterial = new Material(material); _OutlinePathMaterial = new Material(material); _ColourPathPoints = ShanghaiUtils.GetScreenCoordsFromCellKeys(_ActMission.Path, _Model.CellPositions); _ColourPathMaterial.SetColor("_TintColor", ShanghaiUtils.GetColour(_ActMission.Source.PaintColour)); _ColourPath = new VectorLine("Colour Path", _ColourPathPoints.ToArray(), _ColourPathMaterial, 10.0f, LineType.Continuous, Joins.Weld); _ColourPath.Draw(); _OutlinePathMaterial.SetColor("_TintColor", Color.black); _OutlinePath = new VectorLine("Colour Path", _ColourPathPoints.ToArray(), _OutlinePathMaterial, 15.0f, LineType.Continuous, Joins.Weld); _OutlinePath.Draw(); Vector2[] linePoints = new Vector2[2]; linePoints[0] = new Vector2(0, 0); linePoints[1] = new Vector2(Screen.width, Screen.height); _TrackPathMaterial.SetColor("_TintColor", Color.black); _TrackPath = new VectorLine("Active Path", _ColourPathPoints.ToArray(), _TrackPathMaterial, 5.0f, LineType.Continuous, Joins.Weld); _TrackPath.Draw(); }
public void CreateTable(Dictionary <string, Client> clients) { _Table = gameObject.GetComponent <UITable>(); if (_Table == null) { Debug.Log("UITable not initialized "); return; } GameObject clientPrefab = Resources.Load(CLIENT_PATH) as GameObject; if (clientPrefab == null) { Debug.Log("Could not load client from path " + CLIENT_PATH); } ShanghaiUtils.RemoveAllChildren(transform); foreach (KeyValuePair <string, Client> clientPair in clients) { Client client = clientPair.Value; GameObject clientGO = GameObject.Instantiate(clientPrefab) as GameObject; ClientController clientCtr = clientGO.GetComponent <ClientController>(); clientCtr.Key = client.Key; clientGO.name = client.Key; clientGO.transform.parent = transform; clientGO.transform.localPosition = Vector3.zero; clientGO.transform.localScale = Vector3.one; } _Table.repositionNow = true; }
public void Update() { //NOTE: needs optimization - check for change if (_Model.Path != null && _Model.Path.Count > 0) { List <Vector2> pathPoints = ShanghaiUtils.GetScreenCoordsFromCellKeys(_Model.Path, _Model.CellPositions); if (pathPoints.Count >= 2) { _ColourPath.Resize(pathPoints.ToArray()); _OutlinePath.Resize(pathPoints.ToArray()); _ColourPathMaterial.SetColor("_TintColor", ShanghaiUtils.GetColour(_Model.PathColour)); _ColourPath.active = true; _ColourPath.Draw(); _OutlinePath.active = true; _OutlinePath.Draw(); } } else { _ColourPath.active = false; _ColourPath.Draw(); _OutlinePath.active = false; _OutlinePath.Draw(); } }
public void CreateTable(int size) { _Table = gameObject.GetComponent <UITable>(); if (_Table == null) { Debug.Log("UITable not initialized "); return; } GameObject sourcePrefab = Resources.Load(SOURCE_PATH) as GameObject; if (sourcePrefab == null) { Debug.Log("Could not load source from path " + SOURCE_PATH); } ShanghaiUtils.RemoveAllChildren(transform); for (int x = 0; x < size; x++) { GameObject source = GameObject.Instantiate(sourcePrefab) as GameObject; SourceController sourceCtr = source.GetComponent <SourceController>(); sourceCtr.Key = x; source.name = string.Format("{0}", x); source.transform.parent = transform; source.transform.localPosition = Vector3.zero; source.transform.localScale = Vector3.one; } _Table.repositionNow = true; }
public void CreateTable(int size) { _Table = gameObject.GetComponent <UITable>(); if (_Table == null) { Debug.Log("UITable not initialized "); return; } GameObject cellPrefab = Resources.Load(CELL_PATH) as GameObject; if (cellPrefab == null) { Debug.Log("Could not load cell from path " + CELL_PATH); } ShanghaiUtils.RemoveAllChildren(transform); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { GameObject cell = GameObject.Instantiate(cellPrefab) as GameObject; CellController cellCtr = cell.GetComponent <CellController>(); cellCtr.Key = new IntVect2(x, y); cell.name = string.Format(CELL_NAME_FORMAT, y, x); cell.transform.parent = transform; cell.transform.localPosition = Vector3.zero; cell.transform.localScale = Vector3.one; } } _Table.repositionNow = true; }
public void CreateTable(Dictionary <string, Target> targets) { _Table = gameObject.GetComponent <UITable>(); if (_Table == null) { Debug.Log("UITable not initialized "); return; } GameObject targetPrefab = Resources.Load(TARGET_PATH) as GameObject; if (targetPrefab == null) { Debug.Log("Could not load target from path " + TARGET_PATH); } ShanghaiUtils.RemoveAllChildren(transform); foreach (KeyValuePair <string, Target> targetPair in targets) { Target target = targetPair.Value; GameObject targetGO = GameObject.Instantiate(targetPrefab) as GameObject; TargetController targetCtr = targetGO.GetComponent <TargetController>(); targetCtr.Key = target.Key; targetGO.name = target.Key; targetGO.transform.parent = transform; targetGO.transform.localPosition = Vector3.zero; targetGO.transform.localScale = Vector3.one; } _Table.repositionNow = true; }
public void UpdateCell(Cell cell) { UpdateSprite(PipeSprite, PIPE_PREFIX, GetPipeString(cell.Pipe)); //Debug.Log("source: " + cell.Source + " target: " + cell.Target); UpdateColour(SourceSprite, cell.Source); UpdateColour(TargetSprite, cell.Target); if (cell.Target != null) { TargetWidget.alpha = 1.0f; if (!cell.Target.Freeze) { TargetLabel.text = cell.Target.Lives.ToString(); if (cell.Target.Lives == 2) { _Vibration = 0.1f; } else if (cell.Target.Lives == 1) { _Vibration = 1f; } else { _Vibration = 0.0f; TargetSprite.transform.localPosition = Vector3.zero; } } else { TargetLabel.text = ""; _Vibration = 0.0f; TargetSprite.transform.localPosition = Vector3.zero; } } else { TargetWidget.alpha = 0.0f; } if (cell.State == Cell.CellState.DEAD) { BackgroundSprite.color = Color.black; } else { if (cell.Colour == ShanghaiUtils.PaintColour.NONE) { BackgroundSprite.color = Color.white; } else { BackgroundSprite.color = ShanghaiUtils.GetColour(cell.Colour); } } ProgressSprite.fillAmount = cell.Progress; }
private void UpdateColour(UISprite sprite, ColouredCellAsset asset) { if (asset == null) { sprite.alpha = 0; } else { sprite.alpha = FULL_ALPHA; sprite.color = ShanghaiUtils.GetColour(asset.PaintColour); } }
private void OnCellDragged(IntVect2 cellKey) { if (cellKey == _CurrentCell) { return; } _CurrentCell = cellKey; if (_Model.Grid.ValidateCellInput(cellKey, _Path)) { _Path.Add(cellKey); if (ShanghaiUtils.IsEndPoint(_Model.Grid.GetCell(cellKey))) { _Model.CanDraw = false; } } }