public GameObject GetPrefabFromEnum(BodyEnum part) { switch (part) { case BodyEnum.NONE: return(null); case BodyEnum.FULL_MOON: return(fullMoon); case BodyEnum.REGULAR_SQUARE: return(regularSquare); case BodyEnum.SIMPLE_SPHERE: return(simpleSphere); case BodyEnum.CUBIC_CUBE: return(cubicCube); case BodyEnum.LONG_CUBE: return(longCube); case BodyEnum.CAPSULE_PILL: return(capsulePill); default: Debug.Log("Missing Prefab for " + part + " in ScriptableObject"); return(null); } }
public void SetBody(BodyEnum bodyEnum) { if (body == null) { body = Instantiate(_entitiesPrefabs.GetPrefabFromEnum(bodyEnum), transform).GetComponent <PartComponent>(); body.SetPrimaryColor(primaryColor); //GOD FORGIVE KILLING SPREE body.SetAuthor(author); } else { ChangeBody(bodyEnum); } }
private void ChangeBody(BodyEnum newBody) { DetachPartsFromBody(topPart, bottomPart, frontPart, leftPart, rightPart); Destroy(body.gameObject); body = Instantiate(_entitiesPrefabs.GetPrefabFromEnum(newBody), transform).GetComponent <PartComponent>(); body.SetPrimaryColor(primaryColor); //GOD FORGIVE KILLING SPREE body.SetAuthor(author); AttachPartToBody(topPart, CommandArg.TOP); AttachPartToBody(frontPart, CommandArg.FRONT); AttachPartToBody(bottomPart, CommandArg.BOTTOM); AttachPartToBody(leftPart, CommandArg.LEFT); AttachPartToBody(rightPart, CommandArg.RIGHT); }
public void SetBody(BodyEnum bodyEnum) { PlayerAction(); decoration.SetBody(bodyEnum); }
private void CommandReceived(TwitchCommand twitchcommand) { PlayerSlot userPS; switch (twitchcommand.argument) { case CommandArg.JOIN: if (_playerSlots.GetEmptySlot(out userPS)) { if (_playerSlots.GetPlayerSlotByName(twitchcommand.username)) { return; } userPS.userJoin(twitchcommand.username); } break; case CommandArg.LEAVE: if (_playerSlots.GetPlayerSlotByName(out userPS, twitchcommand.username)) { userPS.UserLeave(); } break; case CommandArg.BODYCOLOR: case CommandArg.BODY: if (_playerSlots.GetPlayerSlotByName(out userPS, twitchcommand.username)) { if (!string.IsNullOrEmpty(twitchcommand.message)) { if (Int32.TryParse(twitchcommand.message, out int bodyNumber)) { if (bodyNumber > 0 && bodyNumber < Enum.GetValues(typeof(BodyEnum)).Length) { BodyEnum bodyEnum = (BodyEnum)bodyNumber; userPS.SetBody(bodyEnum); } } if (customColors.TryGetValue(twitchcommand.message.ToUpper(), out string hexColor)) { twitchcommand.message = hexColor; } if (ColorUtility.TryParseHtmlString(twitchcommand.message, out Color pcol)) { userPS.SetPrimaryColor(pcol); } } } break; case CommandArg.PARTCOLOR: case CommandArg.TOP: case CommandArg.FRONT: case CommandArg.LEFT: case CommandArg.RIGHT: case CommandArg.BOTTOM: if (_playerSlots.GetPlayerSlotByName(out userPS, twitchcommand.username)) { if (!string.IsNullOrEmpty(twitchcommand.message)) { if (Int32.TryParse(twitchcommand.message, out int partNumber)) { if (partNumber >= 0 && partNumber < Enum.GetValues(typeof(PartEnum)).Length) { PartEnum partEnum = (PartEnum)partNumber; userPS.SetPart(partEnum, twitchcommand.argument); } } if (customColors.TryGetValue(twitchcommand.message.ToUpper(), out string hexColor)) { twitchcommand.message = hexColor; } if (ColorUtility.TryParseHtmlString(twitchcommand.message, out Color scol)) { userPS.SetSecondaryColor(scol); } } } break; case CommandArg.COMMIT: case CommandArg.READY: if (_playerSlots.GetPlayerSlotByName(out userPS, twitchcommand.username)) { userPS.UserReady(); } break; case CommandArg.RANDOMIZE: if (_playerSlots.GetPlayerSlotByName(out userPS, twitchcommand.username)) { userPS.Randomize(); } break; default: break; } }