private void specializeBCell(BCell bCell, BCell.TYPE newType) { bCell._type = newType; GameObjectManager.setGameObjectState(bCell.recognitionZone, false); GameObjectManager.setGameObjectState(bCell.actionZone, true); updateTypeBar(bCell, newType, 1f, 1f); }
private void updateTypeBar(BCell bCell, BCell.TYPE contactType, float progress, float maximumProgress) { float width = progress / maximumProgress; float height = bCell.recognitionBar.sizeDelta.y; bCell.recognitionBar.sizeDelta = new Vector2(width, height); UnityEngine.UI.Image typeBarImage = bCell.recognitionBar.gameObject.GetComponent <UnityEngine.UI.Image>(); typeBarImage.color = (contactType == BCell.TYPE.BACTERIAL) ? Color.yellow : Color.green; }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject go in _BCells) { BCell bCell = go.GetComponent <BCell>(); bCell.cooldown = Mathf.Clamp(bCell.cooldown - Time.deltaTime, 0, Mathf.Infinity); if (go.GetComponent <PointerOver>() != null && Input.GetKeyDown(KeyCode.Mouse0) && bCell.cooldown <= 0) { Freeze(bCell); Object.Instantiate(bCell.onClickParticleEffect, go.GetComponent <Collider>().bounds.center, Quaternion.Euler(Vector3.zero)); } } }
public DynamicMaterialSystem() { foreach (GameObject go in _dynGO) { DynamicMaterial dynMat = go.GetComponent <DynamicMaterial>(); if (dynMat.type == EDynMat.HEALTH) { WithHealth healthComp = go.GetComponent <WithHealth>(); healthComp.maxHealth = healthComp.health; dynMat.percentage = healthComp.health / healthComp.maxHealth; } else if (dynMat.type == EDynMat.FREEZE) { Frozen comp = go.GetComponent <Frozen>(); dynMat.percentage = 0; if (comp) { dynMat.percentage = comp.remainingTime / comp.totalTime; } } else if (dynMat.type == EDynMat.B_Cell) { BCell comp = go.GetComponent <BCell>(); if (comp) { dynMat.percentage = comp.cooldown / comp.delay; } } foreach (Material mat in go.GetComponent <Renderer>().materials) { if (mat.name.Contains(dynMat.materialName) || go.GetComponent <Renderer>().materials.Length == 1) { mat.color = dynMat.startingColor; } } } }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject go in _dynGO) { DynamicMaterial dynMat = go.GetComponent <DynamicMaterial>(); if (dynMat.type == EDynMat.HEALTH) { WithHealth healthComp = go.GetComponent <WithHealth>(); dynMat.percentage = healthComp.health / healthComp.maxHealth; } else if (dynMat.type == EDynMat.FREEZE) { Frozen comp = go.GetComponent <Frozen>(); dynMat.percentage = 0; if (comp) { dynMat.percentage = comp.remainingTime / comp.totalTime; } } else if (dynMat.type == EDynMat.B_Cell) { BCell comp = go.GetComponent <BCell>(); if (comp) { dynMat.percentage = comp.cooldown / comp.delay; } } foreach (Material mat in go.GetComponent <Renderer>().materials) { if (mat.name.Contains(dynMat.materialName) || go.GetComponent <Renderer>().materials.Length == 1) { mat.color = Color.Lerp(dynMat.endingColor, dynMat.startingColor, dynMat.percentage); } } } }
private void Freeze(BCell src) { Triggered3D trigerred = src.gameObject.GetComponent <Triggered3D>(); if (trigerred != null) { foreach (GameObject target in trigerred.Targets) { Eatable eatable = target.GetComponent <Eatable>(); if (eatable != null && (eatable.eatableMask & src.freezeMask) > 0 && target.GetComponent <Removed>() == null) { GameObjectManager.addComponent <Frozen>(target, new { remainingTime = src.freezeTime, totalTime = src.freezeTime }); } } if (trigerred.Targets.Length > 0) { src.cooldown = src.delay; } } }
protected void Cmd_RenderTable(RenderTreeBuilder builder) { List <BCell> table_list = (parent as CompBlazorSpreadsheet).Current_BTable.Table_List; int MaxCol = table_list.Max(x => x.Column); int MaxRow = table_list.Max(x => x.Row); int k = -1; builder.OpenElement(k++, "table"); builder.OpenElement(k++, "thead"); builder.OpenElement(k++, "tr"); builder.OpenElement(k++, "th"); builder.AddAttribute(k++, "style", "width:20px;height:35px;margin:1px;padding:2px"); builder.AddContent(k++, ""); builder.CloseElement(); //th for (int i = 0; i <= MaxCol; i++) { builder.OpenElement(k++, "th"); builder.AddAttribute(k++, "style", "text-align:center;height:35px;margin:1px;padding:2px"); builder.AddContent(k++, MyFunctions.GetLetter(i)); builder.CloseElement(); //th } builder.CloseElement(); //tr builder.CloseElement(); //thead builder.OpenElement(k++, "tbody"); for (int i = 0; i <= MaxRow; i++) { builder.OpenElement(k++, "tr"); builder.OpenElement(k++, "td"); builder.AddAttribute(k++, "style", "text-align:right;width:20px;height:35px;padding:2px;"); builder.AddContent(k++, i + 1); builder.CloseElement(); for (int j = 0; j <= MaxCol; j++) { BCell b = table_list.Single(x => x.Row == i && x.Column == j); builder.OpenComponent <CompCell>(k++); builder.AddAttribute(k++, "bcell", b); builder.AddAttribute(k++, "parent", this); builder.CloseComponent(); } builder.CloseElement(); //tr } builder.CloseElement(); //tbody builder.CloseElement(); //table }
protected override void onProcess(int currentFrame) { // gestion des zones de reconnaissances foreach (GameObject recognitionZone_go in f_recognitionZones) { Triggered2D rzTriggered = recognitionZone_go.GetComponent <Triggered2D>(); BCell bCell = recognitionZone_go.GetComponentInParent <BCell>(); // parcours des objets dans la zone de détection foreach (GameObject other in rzTriggered.Targets) { if (other.tag == "Bactery") { // progression de la détection bCell._bacteryRecognitionProgress += Time.deltaTime; updateTypeBar(bCell, BCell.TYPE.BACTERIAL, bCell._bacteryRecognitionProgress, bCell._bacteryRecognitionTime); if (bCell._bacteryRecognitionProgress >= bCell._bacteryRecognitionTime) { // transformation de la BCell en BCell bactérien specializeBCell(bCell, BCell.TYPE.BACTERIAL); } } else if (other.tag == "Virus") { // progression de la détection bCell._virusRecognitionProgress += Time.deltaTime; updateTypeBar(bCell, BCell.TYPE.VIRAL, bCell._virusRecognitionProgress, bCell._virusRecognitionTime); if (bCell._virusRecognitionProgress >= bCell._virusRecognitionTime) { // transformation de la BCell en BCell viral specializeBCell(bCell, BCell.TYPE.VIRAL); } } } } // gestion des zones d'action foreach (GameObject actionZone_go in f_actionZones) { Triggered2D azTriggered = actionZone_go.GetComponent <Triggered2D>(); BCell bCell = actionZone_go.GetComponentInParent <BCell>(); // parcours des objets dans la zone d'action foreach (GameObject other in azTriggered.Targets) { if (bCell._type == BCell.TYPE.BACTERIAL && other.tag == "Bactery") { // Si c'est une bactérie, la ralentir Speed speedC = other.GetComponent <Speed>(); speedC._speed = speedC._stuckSpeed; } else if (bCell._type == BCell.TYPE.VIRAL && other.tag == "Virus") { // Si c'est un virus, l'agglutiner Speed speedC = other.GetComponent <Speed>(); speedC._speed = speedC._stuckSpeed; GameObjectManager.removeComponent <Virus>(other); GameObjectManager.setGameObjectTag(other, "StuckVirus"); GameObjectManager.setGameObjectLayer(other, LayerMask.NameToLayer("StuckVirus")); } } } }