public void SpawnCharacter(int[] damageDeck, int cardNum, int cardLevel, CharacterProperties.UnitType unit, CharacterProperties.Team tempOwner = CharacterProperties.Team.LEFT) { Vector3 spawnPosition = tempOwner == CharacterProperties.Team.LEFT ? spawnPointLeft.transform.position : spawnPointRight.transform.position; CharacterProperties.CategoryColour colour = characterSettingsObj.characterProperties[cardNum].category; CharacterProperties.SkillType skill = characterSettingsObj.characterProperties[cardNum].skillType; int rankLevel = cardNum; if (unit != CharacterProperties.UnitType.DRAGON) { GameObject go = Instantiate(characterPrefab, spawnPosition, Quaternion.identity) as GameObject; go.transform.parent = defenseParent.transform; go.transform.localScale = Vector3.one * 1000; switch (unit) { case CharacterProperties.UnitType.ARCHER: case CharacterProperties.UnitType.CANNON: Archer rangeObj = go.AddComponent <Archer>(); rangeObj.characterSettings = characterSettingsObj; rangeObj.skillSettings = skillSettingsObj; rangeObj.indicatorPrefab = indicatorPrefab; rangeObj.damageEffectPrefab = damageEffectPrefab; rangeObj.bonusDamageDeck = damageDeck; rangeObj.unitLevel = cardLevel; rangeObj.rank = rankLevel; rangeObj.Category = colour; rangeObj.SkillType = skill; rangeObj.UnitType = unit; rangeObj.Team = tempOwner; rangeObj.effectSettings = skillEffects; break; case CharacterProperties.UnitType.ONE_HANDED_WARRIOR: case CharacterProperties.UnitType.TWO_HANDED_WARRIOR: case CharacterProperties.UnitType.SPEAR_WARRIOR: Warrior meleeObj = go.AddComponent <Warrior>(); meleeObj.characterSettings = characterSettingsObj; meleeObj.skillSettings = skillSettingsObj; meleeObj.indicatorPrefab = indicatorPrefab; meleeObj.damageEffectPrefab = damageEffectPrefab; meleeObj.bonusDamageDeck = damageDeck; meleeObj.unitLevel = cardLevel; meleeObj.rank = rankLevel; meleeObj.Category = colour; meleeObj.SkillType = skill; meleeObj.UnitType = unit; meleeObj.Team = tempOwner; meleeObj.effectSettings = skillEffects; break; case CharacterProperties.UnitType.HEALER: Healer healerObj = go.AddComponent <Healer>(); healerObj.characterSettings = characterSettingsObj; healerObj.skillSettings = skillSettingsObj; healerObj.indicatorPrefab = indicatorPrefab; healerObj.damageEffectPrefab = damageEffectPrefab; healerObj.bonusDamageDeck = damageDeck; healerObj.unitLevel = cardLevel; healerObj.rank = rankLevel; healerObj.Category = colour; healerObj.SkillType = skill; healerObj.UnitType = unit; healerObj.Team = tempOwner; healerObj.effectSettings = skillEffects; break; } } else if (unit == CharacterProperties.UnitType.DRAGON) { GameObject go = Instantiate(riderPrefab, spawnPosition, Quaternion.identity) as GameObject; go.transform.parent = defenseParent.transform; go.GetComponent <DragonRider>().characterSettings = characterSettingsObj; go.GetComponent <DragonRider>().skillSettings = skillSettingsObj; go.GetComponent <DragonRider>().indicatorPrefab = indicatorPrefab; go.GetComponent <DragonRider>().damageEffectPrefab = damageEffectPrefab; go.GetComponent <DragonRider>().bonusDamageDeck = damageDeck; go.GetComponent <DragonRider>().unitLevel = cardLevel; go.GetComponent <DragonRider>().rank = rankLevel; go.GetComponent <DragonRider>().Category = colour; go.GetComponent <DragonRider>().SkillType = skill; go.GetComponent <DragonRider>().Team = tempOwner; go.GetComponent <DragonRider>().effectSettings = skillEffects; } }
private void InitSkillButton() { string buttonName = ""; string spriteName = ""; int limit = 8; int val = 0; int tempReferenceNumber = 0; int buttonNumber = -1; CharacterProperties.CategoryColour category = CharacterProperties.CategoryColour.RED; CharacterProperties.UnitType unitType = CharacterProperties.UnitType.ARCHER; int unitLevel = 0; CharacterProperties.SkillType skillType = CharacterProperties.SkillType.NONE; int skillLevel = 0; int settingsAmt = 0; //int offset = 0; float buttonXPos = 0; for (int i = 0; i < skillButtonArray.Length; i++) { val = i; if (GlobalManager.UICard.localUserCardDeck[i] != null) { int deckValue = settingsAmt = GlobalManager.UICard.localUserCardDeck[i].cardNumber - 1; UIEventListener.Get(skillButtonArray[i]).onClick += ButtonHandler; // character deck if (GlobalManager.UICard.localUserCardDeck[i].cardNumber > 0) { buttonName = spriteName = characterSettingsPrefab.GetComponent <CharacterSettings>().characterProperties[deckValue].iconSpriteName; tempReferenceNumber = i + 1; category = characterSettingsPrefab.GetComponent <CharacterSettings>().characterProperties[deckValue].category; unitType = characterSettingsPrefab.GetComponent <CharacterSettings>().characterProperties[deckValue].unitType; unitLevel = 1; skillType = characterSettingsPrefab.GetComponent <CharacterSettings>().characterProperties[deckValue].skillType; skillLevel = (int)characterSettingsPrefab.GetComponent <CharacterSettings>().characterProperties[deckValue].skillLevel; settingsAmt = deckValue; buttonNumber = i; if (skillType == CharacterProperties.SkillType.FIRE_BOOST) { int skillIndex = (int)CharacterProperties.SkillType.FIRE_BOOST - 1; bonusDamageDeck[0] += (int)skillSettings.skillProperties[skillIndex].damageBoost[skillLevel]; Debug.Log(bonusDamageDeck[0]); } else if (skillType == CharacterProperties.SkillType.WATER_BOOST) { int skillIndex = (int)CharacterProperties.SkillType.WATER_BOOST - 1; bonusDamageDeck[1] += (int)skillSettings.skillProperties[skillIndex].damageBoost[skillLevel]; } else if (skillType == CharacterProperties.SkillType.NATURE_BOOST) { int skillIndex = (int)CharacterProperties.SkillType.NATURE_BOOST - 1; bonusDamageDeck[2] += (int)skillSettings.skillProperties[skillIndex].damageBoost[skillLevel]; } else if (skillType == CharacterProperties.SkillType.GROUND_BOOST) { int skillIndex = (int)CharacterProperties.SkillType.GROUND_BOOST - 1; bonusDamageDeck[3] += (int)skillSettings.skillProperties[skillIndex].damageBoost[skillLevel]; } else if (skillType == CharacterProperties.SkillType.DARK_BOOST) { int skillIndex = (int)CharacterProperties.SkillType.DARK_BOOST - 1; bonusDamageDeck[4] += (int)skillSettings.skillProperties[skillIndex].damageBoost[skillLevel]; } else if (skillType == CharacterProperties.SkillType.LIGHT_BOOST) { int skillIndex = (int)CharacterProperties.SkillType.LIGHT_BOOST - 1; bonusDamageDeck[5] += (int)skillSettings.skillProperties[skillIndex].damageBoost[skillLevel]; } skillButtonArray[i].transform.Find("Background").GetComponent <UISprite>().spriteName = spriteName; skillButtonArray[i].GetComponent <UIButton>().normalSprite = spriteName; skillButtonArray[i].GetComponent <UIButton>().hoverSprite = spriteName; skillButtonArray[i].GetComponent <UIButton>().pressedSprite = spriteName; skillButtonArray[i].GetComponent <UIButton>().disabledSprite = spriteName; UnitButtonHandler obj = skillButtonArray[i].GetComponent <UnitButtonHandler>(); obj.referenceNumber = tempReferenceNumber; obj.element = category; obj.unitType = unitType; obj.unitLevel = unitLevel; obj.skillType = skillType; obj.skillLevel = skillLevel; obj.buttonNumber = buttonNumber; obj.settingsReferer = settingsAmt; } else { //skillButtonArray[i].collider.enabled = false; skillButtonArray[i].GetComponent <UIButton>().isEnabled = false; skillButtonArray[i].GetComponent <UnitButtonHandler>().DisableSelf(); } } } }