public void RpcUnitAttributesSetup(GameObject manager, GameObject playerObject, int colorValue) { Debug.Log("Setting up unit attributes."); GameUnit playerUnit = playerObject.GetComponent <GameUnit>(); if (playerUnit != null) { playerUnit.SetTeamColor(colorValue); } UnitAttributes attributes = manager.GetComponent <UnitAttributes>(); if (attributes != null && attributes.hasAuthority) { //CanvasSwitch canvasSwitch = GameObject.FindObjectOfType<CanvasSwitch>() as CanvasSwitch; //if (canvasSwitch != null) { // canvasSwitch.unitAttributes = attributes; //} GameObject content = GameObject.FindGameObjectWithTag("Content"); if (content != null) { Attributes attr = content.GetComponent <Attributes>(); if (attr != null) { attr.unitAttributes = attributes; } } if (playerUnit != null) { playerUnit.unitAttributes = attributes; } } }
private static void Copy(GameUnit original, GameUnit copy) { copy.isSelected = original.isSelected; copy.isSplitting = original.isSplitting; copy.isMerging = original.isMerging; copy.transform.position = original.transform.position; copy.transform.rotation = original.transform.rotation; copy.transform.localScale = original.transform.localScale; copy.oldTargetPosition = original.oldTargetPosition = -Vector3.one * 9999f; copy.isDirected = original.isDirected = false; copy.level = original.level; copy.previousLevel = original.previousLevel; copy.currentHealth = original.currentHealth; copy.maxHealth = original.maxHealth; if (copy.currentHealth > copy.maxHealth) { copy.currentHealth = copy.maxHealth; } if (original.currentHealth > original.maxHealth) { original.currentHealth = original.maxHealth; } //copy.recoverCooldown = original.recoverCooldown; copy.recoverCounter = original.recoverCounter = 1f; copy.speed = original.speed; copy.attackCooldown = original.attackCooldown; copy.attackCooldownCounter = original.attackCooldownCounter = 0; copy.attackPower = original.attackPower; copy.unitAttributes = original.unitAttributes; copy.teamColorValue = original.teamColorValue; original.SetTeamColor(original.teamColorValue); copy.SetTeamColor(copy.teamColorValue); copy.teamFaction = original.teamFaction; }
public void RpcUnitAttributesSetup(GameObject manager, GameObject playerObject, int colorValue) { Debug.Log("Setting up unit attributes."); GameUnit playerUnit = playerObject.GetComponent <GameUnit>(); if (playerUnit != null) { playerUnit.SetTeamColor(colorValue); } UnitAttributes attributes = manager.GetComponent <UnitAttributes>(); if (attributes != null && attributes.hasAuthority) { //CanvasSwitch canvasSwitch = GameObject.FindObjectOfType<CanvasSwitch>() as CanvasSwitch; //if (canvasSwitch != null) { // canvasSwitch.unitAttributes = attributes; //} GameObject content = GameObject.FindGameObjectWithTag("Content"); if (content != null) { Attributes attr = content.GetComponent <Attributes>(); if (attr != null) { attr.unitAttributes = attributes; } } if (playerUnit != null) { playerUnit.unitAttributes = attributes; AttributePanelUI attributePanelUI = GameObject.FindObjectOfType <AttributePanelUI>(); if (attributePanelUI != null) { foreach (Category cat in Category.Values) { List <LevelRate> levelRate = attributePanelUI.levelingRatesObject.allAttributes[cat.value]; switch (cat.value) { case 0: for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++) { playerUnit.unitAttributes.healthPrefabList[i] = levelRate[i].rate; } break; case 1: for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++) { playerUnit.unitAttributes.attackPrefabList[i] = levelRate[i].rate; } break; case 2: for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++) { playerUnit.unitAttributes.speedPrefabList[i] = levelRate[i].rate; } break; case 3: playerUnit.unitAttributes.splitPrefabFactor = levelRate[0].rate; break; case 4: for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++) { playerUnit.unitAttributes.mergePrefabList[i] = levelRate[i].rate; } break; case 5: for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++) { playerUnit.unitAttributes.attackCooldownPrefabList[i] = levelRate[i].rate; } break; default: Debug.LogError("Cannot process what's going on. Please check code execution flow using debugger and breakpoints set to here."); break; } } playerUnit.UpdateUnitAttributes(); } } } }