public void RefreshInfoListsCells() { //CellsEnergized CellLogic cell = null; for (int i = 0; i < ManagerGrids.I.MatrixLength.x; i++) { for (int j = 0; j < ManagerGrids.I.MatrixLength.y; j++) { cell = ManagerGrids.I.GridMain[i, j]; // Initial Energy Amount at the start of Round TotalEnergy += Mathf.Clamp(cell.Data.EnergyCurrent, 0, cell.Data.CellStateFormT.EnergyMaxStored); ClearCellData(cell); ClearCellNeighbors(cell); if (cell.Data.CellStateFormT.EnergyMaxStored <= cell.Data.EnergyCurrent) { CellsEnergized.Add(cell); } if (cell.Data.StateColor == ManagerGrids.I.GridOriginal[i, j].Data.StateColor) { CellsWithCorrectState.Add(cell); } } } }
private void VisualizeCellForm(CellLogic logic) { SelectionFormVisualEffect.transform.position = logic.transform.position; SelectionFormVisualEffect.gameObject.SetActive(true); SelectionFormVisualEffect.MoveEffects(logic.transform); }
private void Start() { if (_cellLogic == null) { _cellLogic = GetComponent <CellLogic>(); } //Row = _cellLogic.Data.Row; //Column = _cellLogic.Data.Column; }
private void ClearCellNeighbors(CellLogic cell) { cell.CellNeighborsThatSentEnergy.Clear(); cell.CellNeighborsThatDidntSentEnergy.Clear(); foreach (var neighbor in cell.CellNeighbors) { cell.CellNeighborsThatDidntSentEnergy.Add(neighbor); } }
public void IndicateValues() { foreach (var uiIndicator in UIIndicators) { if (Logic == null) { Logic = gameObject.GetComponent <CellLogic>(); } uiIndicator.Indicate(Logic); } }
private void Start() { if (Logic == null) { Logic = GetComponent <CellLogic>(); } if (Data == null) { Data = Logic.Data; } }
private IEnumerator StartWaveActually() { VisualizeWave(); yield return(WaitTimer); CellLogic cell = null; if (VerticalWave) { for (int i = 0; i < ManagerGrids.I.MatrixLength.x; i++) { int max = Random.Range(0, ManagerGrids.I.MatrixLength.y); int coefficientedMax = (int)(max * Coefficient); int howManyToWipe = Random.Range(0, coefficientedMax); int tilesLeft = howManyToWipe; float sumFromWiping = 0f; // Now go over elements and change for (int j = 0; j < ManagerGrids.I.MatrixLength.y; j++) { cell = ManagerGrids.I.GridMain[i, j]; if (Random.Range(0, 2) == 1) { tilesLeft--; if (!(cell.Data.EnergyCurrent > 0)) { continue; } ManagerClockScore.I.AddScoreBonusWave(cell.Data.EnergyCurrent); //Debug.Log("sumFromWiing: " + sumFromWiping, this); sumFromWiping += cell.Data.EnergyCurrent; cell.WipeEnergy(); } } // TODO: TEMPORARILY CALLING A METHOD INSTEAD OF CHECK IN ManagerChecks ManagerChecks.I.PlayerDidSomethingGood(sumFromWiping); yield return(WaitTimerPauseBetweenLines); } } else if (HorizontalWave) { } }
//private void Awake() { //} private void Start() { if (_spriteRenderer == null) { _spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); } if (_spriteRenderer == null) { Debug.LogError("Cell's _spriteRenderer is null", this); } if (_backgroundSpriteRenderer == null) { _backgroundSpriteRenderer = GetComponentInChildren <SpriteRenderer>(); } if (_backgroundSpriteRenderer == null) { Debug.Log("Cell's _backgroundSpriteRenderer is null", this); } if (Logic == null) { Logic = gameObject.GetComponent <CellLogic>(); } if (EffectTouched == null) { Debug.LogError("EffecTouched is null", this); } if (EffectReceivingExternal == null) { Debug.LogError("EffectReceivingExternal is null", this); } if (EffectEnergized == null) { Debug.LogError("EffectEnergized is null", this); } if (EffectCharging == null) { Debug.LogError("EffectCharging is null", this); } // UI Indication if (UIIndication) { UIIndicators = GetComponentsInChildren <UICellIndication>().ToList(); } Initialize(); }
public void SelectCellColor(CellLogic logic) { if (!ListLogicColor.Contains(logic)) { return; } SelectedCellLogicColor = logic; SelectedCellDataColor = SelectedCellLogicColor.Data; SelectedCellStateColor = SelectedCellDataColor.StateColor; DrawData.StateColor = SelectedCellStateColor; VisualizeCellColor(logic); }
/// <summary> /// TODO: All kinds of effects! /// </summary> public void UpdateAuVisualsEndOfTurn() { CellLogic cell = null; for (int i = 0; i < ManagerGrids.I.MatrixLength.x; i++) { for (int j = 0; j < ManagerGrids.I.MatrixLength.y; j++) { cell = ManagerGrids.I.GridMain[i, j]; // NOTE: Messy! TODO: Improve something? cell.AuVisuals.UpdateCellEndOfTurn(cell.Data); } } }
public void SelectCellForm(CellLogic logic) { if (!ListLogicForm.Contains(logic)) { return; } SelectedCellLogicForm = logic; SelectedCellDataForm = SelectedCellLogicForm.Data; SelectedCellStateForm = SelectedCellDataForm.CellStateFormT; DrawData.CellStateFormT = SelectedCellStateForm; VisualizeCellForm(logic); }
public override void RespondToInput(CellLogic logic) { if (logic.Data == null) { Debug.LogError("This cell doesn't have CellData", this); } if (logic.Data.StateColor.NextStateColorWhenClicked != null) { logic.Data.StateColor = logic.Data.StateColor.NextStateColorWhenClicked; //logic.CellVisuals. //yield break; logic.AuVisuals.ShowClicked(); } }
public override void RespondToInput(CellLogic logic) { if (logic.Data == null) { Debug.LogError("This cell doesn't have CellData", this); } var paletteData = ManagerPalette.I.GetCurrentData(); if (paletteData == null) { return; } if (logic.Data.StateColor != paletteData.StateColor || logic.Data.CellStateFormT != paletteData.CellStateFormT) { logic.Data.StateColor = paletteData.StateColor; logic.Data.CellStateFormT = paletteData.CellStateFormT; logic.AuVisuals.ShowClicked(); } }
public void EnergyshouldFlow() { if (Debugging) { Debug.Log("Clock at StartRound starts the CheckForMatchScript at: " + Time.realtimeSinceStartup + " CurrentTurn: " + ManagerClockScore.I.CurrentTurn); } CellLogic cell = null; // First iteration по всем клеткам в этом ходу с целью логики обработки получения клетками EnergyExternal // Defining if received External Energy for (int i = 0; i < ManagerGrids.I.MatrixLength.x; i++) { for (int j = 0; j < ManagerGrids.I.MatrixLength.y; j++) { cell = ManagerGrids.I.GridMain[i, j]; //// Cleaning stuff because new Round //cell.CellNeighborsThatSentEnergy.Clear(); //cell.CellNeighborsThatDidntSentEnergy.Clear(); //foreach (var neighbor in cell.CellNeighbors) { // cell.CellNeighborsThatDidntSentEnergy.Add(neighbor); //} // Iterating Logic, to learn if it received external input bool externalEnergyReceivedThisTurn = ManagerClockScore.I.CurrentTurn == cell.Data.EnergyReceived.LastTurnWhenEnergyExternal; bool stateIsRight = cell.Data.StateColor == ManagerGrids.I.GridOriginal[i, j].Data.StateColor; if (externalEnergyReceivedThisTurn && stateIsRight) { //if(Debugging) //Debug.Log("State is right! Main cell: " + cell.name+" " + cell.Data.State + " Original: " + cell.name + " " + ManagerGrids.I.GridOriginal[i, j].Data.State, this); CellsReceivedExternal.Add(cell); } } } // Second iteration only over cells that received External Energy so it could be propagated foreach (var cellReceived in CellsReceivedExternal) { float howMuchEnergyToEachNeighbor = 0f; if (cellReceived.Data.EnergyReceived.EnergyExcess < 0) { return; } if (!CellsEnergized.Contains(cellReceived)) { CellsEnergized.Add(cellReceived); } //cell.SpreadExcessenergy(); if (cellReceived.CellNeighbors.Count > 0) { howMuchEnergyToEachNeighbor = cellReceived.Data.EnergyReceived.EnergyExcess / cellReceived.CellNeighbors.Count; } // Because we distributed External Energy Excess, currently it's 0 cellReceived.Data.EnergyReceived.EnergyExcess = 0f; foreach (var neighbor in cellReceived.CellNeighbors) { var originalCell = ManagerGrids.I.GridOriginal[neighbor.Data.Row, neighbor.Data.Column]; bool stateIsRight = neighbor.Data.StateColor == originalCell.Data.StateColor; if (stateIsRight) { neighbor.ReceiveEnergyInternal(howMuchEnergyToEachNeighbor, cellReceived, 0); } } } }
public void VisualizeInternalEnergyTransfer(CellLogic otherCell) { }
public void ClearCellData(CellLogic cell) { cell.Data.EnergyReceived.EnergyExcess = 0f; cell.Data.EnergyReceived.EnergyFlowInExternal = 0f; cell.Data.EnergyReceived.EnergyFlowInInternal = 0f; }
/// <summary> /// /// </summary> /// <param name="howMuchEnergyFromNeighbor"></param> /// <param name="neighbor"></param> /// <param name="chainLength">How far from Cell received External Energy this Cell located</param> public void ReceiveEnergyInternal(float howMuchEnergyFromNeighbor, CellLogic neighbor, int chainLength) { if (howMuchEnergyFromNeighbor < 0.00000f) { Debug.Log("Not really receiving energy", this); return; } float howMuchEnergyToEachNeighbor = 0f; chainLength++; // We received energy internal if (ManagerChecks.I.Debugging) { Debug.Log(this.gameObject.name + " receiving Internal Energy from " + neighbor.gameObject.name + " at: " + Time.realtimeSinceStartup + " Current Turn: " + ManagerClockScore.I.CurrentTurn + " Chain length: " + chainLength, this); } Data.ReceiveEnergyInternal(howMuchEnergyFromNeighbor); CellNeighborsThatSentEnergy.Add(neighbor); // maintaining List ManagerChecks.I.CellsReceivedInternal.Add(this); // maintaining List //CellNeighborsThatDidntSentEnergy = CellNeighbors.Except(CellNeighborsThatSentEnergy).ToList(); CellNeighborsThatDidntSentEnergy.RemoveAll(x => CellNeighborsThatSentEnergy.Contains(x)); // If we didn't yet received more energy than we can hold - do nothing else if (Data.EnergyReceived.EnergyExcess <= 0) { return; } if (!ManagerChecks.I.CellsEnergized.Contains(this)) // maintaining List { ManagerChecks.I.CellsEnergized.Add(this); } // We received energy and if cell is too far away from original energy source - stop sending energy through cell chain if (ManagerCGridGame.I.ActualEnergyChainLength == chainLength) // <= { return; } // --- Sending energy through chain if (CellNeighborsThatDidntSentEnergy.Count > 0) { howMuchEnergyToEachNeighbor = Data.EnergyReceived.EnergyExcess / CellNeighborsThatDidntSentEnergy.Count; // GAME DESIGN DECISION: we split energy among all neighbors, but send it only to the ones that are able to receive due to State //foreach (var otherNeighbor in CellNeighborsThatDidntSentEnergy) { // bool stateIsRight = otherNeighbor.Data.State == // ManagerGrids.I.GridOriginal[otherNeighbor.Data.Row, otherNeighbor.Data.Column].Data.State; // if(stateIsRight) // otherNeighbor.ReceiveEnergyInternal(howMuchEnergyToEachNeighbor, this, chainLength++); //} // Copy for this cycle List <CellLogic> list = new List <CellLogic>(CellNeighborsThatDidntSentEnergy); while (list.Count > 0) { bool stateIsRight = list[0].Data.StateColor == ManagerGrids.I.GridOriginal[list[0].Data.Row, list[0].Data.Column].Data.StateColor; if (stateIsRight) { list[0].ReceiveEnergyInternal(howMuchEnergyToEachNeighbor, this, chainLength); } list.RemoveAt(0); } } }
public abstract void Act(CellLogic logic);
public override void Initialize(CellLogic logic) { base.Initialize(logic); }
public override void Reset(CellLogic logic) { }
public override void Act(CellLogic tank) { }
public abstract void RespondToInput(CellLogic logic); //IEnumerator
public abstract void RespondToInput(CellLogic logic); //IEnumerator public abstract void Reset(CellLogic logic);
public virtual void Initialize(CellLogic logic) { }
public override void RespondToInput(CellLogic logic) { }