public void Awake() { Debug.Log("Initializing AI attribute manager."); this.maxTiersLimit = Attributes.MAX_NUM_OF_LEVELS; this.tiers = new List <TierUpgrade>(); for (int i = 0; i < this.maxTiersLimit; i++) { TierUpgrade tier = new TierUpgrade(); if (i == 0) { tier.level = i + 1; tier.health = 3f; tier.attack = 1f; tier.speed = 1.2f; tier.split = 2f; tier.merge = 2f; tier.attackCooldown = 3f; } else { TierUpgrade previous = this.tiers[i - 1]; tier.level = i + 1; tier.health = previous.health * 2f; tier.attack = previous.attack * 1.2f; tier.speed = previous.speed * 1.2f; tier.split = previous.split * 2f; tier.merge = previous.merge * 2f; tier.attackCooldown = previous.attackCooldown; } this.tiers.Add(tier); } GameObject tempAttribute = GameObject.FindGameObjectWithTag("AIAttributePanel"); if (tempAttribute != null) { this.attributePanelUI = tempAttribute.GetComponent <AttributePanelUI>(); if (this.attributePanelUI == null) { Debug.LogError("Something is not right."); } } //If tempAttribute is null, then it means the game does not allow the player to do customizations. //This means, the only scenario that doesn't allow the player to make customizations would be in //the menu screen, where the AI players are duking out without player's interventions. }
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(); } } } }