Last active
August 29, 2015 14:21
-
-
Save Shogan/e22d2336248af28aa465 to your computer and use it in GitHub Desktop.
CharacterOperations-for-UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void LoadCharacter(CharacterEntity characterEntity) | |
{ | |
// Update the selected body component values stored as field values | |
selectedBody = characterEntity.BodySpriteName; | |
selectedFace = characterEntity.FaceSpriteName; | |
selectedHair = characterEntity.HairSpriteName; | |
selectedShirt = characterEntity.ShirtSpriteName; | |
selectedPants = characterEntity.PantsSpriteName; | |
selectedShoes = characterEntity.ShoesSpriteName; | |
// Update the character component images with those of the loaded character entity. | |
selectedHairImage.overrideSprite = allSprites.First(sprite => sprite.name == characterEntity.HairSpriteName); | |
selectedFaceImage.overrideSprite = allSprites.First(sprite => sprite.name == characterEntity.FaceSpriteName); | |
selectedBodyImage.overrideSprite = allSprites.First(sprite => sprite.name == characterEntity.BodySpriteName); | |
selectedShirtImage.overrideSprite = allSprites.First(sprite => sprite.name == characterEntity.ShirtSpriteName); | |
selectedPantsImage.overrideSprite = allSprites.First(sprite => sprite.name == characterEntity.PantsSpriteName); | |
selectedShoesImage.overrideSprite = allSprites.First(sprite => sprite.name == characterEntity.ShoesSpriteName); | |
// Update character stats with those from the loaded entity. | |
characterNameText.text = characterEntity.Name; | |
nameInput.text = characterEntity.Name; | |
ageInput.text = characterEntity.Age.ToString(); | |
strengthInput.text = characterEntity.Strength.ToString(); | |
dexterityInput.text = characterEntity.Dexterity.ToString(); | |
intelligenceInput.text = characterEntity.Intelligence.ToString(); | |
} | |
private void CycleNextCharacter() | |
{ | |
if (characterEntities.Count <= 0) return; | |
if (currentCharacterIndex < characterEntities.Count - 1) | |
{ | |
currentCharacterIndex++; | |
LoadCharacter(characterEntities[currentCharacterIndex]); | |
} | |
else | |
{ | |
LoadCharacter(characterEntities.First()); | |
currentCharacterIndex = 0; | |
} | |
} | |
private void CyclePrevCharacter() | |
{ | |
if (characterEntities.Count <= 0) return; | |
if (currentCharacterIndex > 0) | |
{ | |
currentCharacterIndex--; | |
LoadCharacter(characterEntities[currentCharacterIndex]); | |
} | |
else | |
{ | |
LoadCharacter(characterEntities.Last()); | |
currentCharacterIndex = characterEntities.Count - 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment