public void OnPressedMaleFemale(int index) { if (index == newSkinIndex) { return; } newSkinIndex = index; var newSkin = gameData.Skins[newSkinIndex]; var tmpSkinData = newSkinData; newSkinData = new CurrentSkinData(newSkin); newSkinData.HeadColor = tmpSkinData.HeadColor; newSkinData.Costume1Color = tmpSkinData.Costume1Color; newSkinData.Costume2Color = tmpSkinData.Costume2Color; contentFactory.SetupPlayerPersonFor(newSkinData); GameObject newPerson = contentFactory.GetPlayerPerson(newSkinData.SkinId); foreach (var cr in charRotators) { cr.SetCharacter(newPerson.transform); } UpdateView(); }
public override void OnEndState() { base.OnEndState(); // setup user person CurrentSkinData skinData = userData.GetSkin(); GameObject skinPerson = contentFactory.GetPlayerPerson(skinData.SkinId); contentFactory.SetupPlayerPersonFor(skinData); foreach (var cr in charRotators) { cr.SetCharacter(skinPerson.transform); } }
public bool SetupPlayerPersonFor(CurrentSkinData skinData) { GameObject personObj = GetPlayerPerson(skinData.SkinId); if (personObj == null) { return(false); } CharactersBindData charBindData = personObj.GetComponent <CharactersBindData>(); if (charBindData == null) { return(false); } charBindData.SetSkinData(skinData); return(true); }
private void SetupCurrentPerson() { UserSkinData[] skins = gameData.Skins; CurrentSkinData curSkin = userData.GetSkin(); newSkinData = new CurrentSkinData(curSkin); currentSkinIndex = Array.FindIndex <UserSkinData>(skins, f => f.SkinId == curSkin.SkinId); newSkinIndex = currentSkinIndex; currentSkin = skins[currentSkinIndex]; skinPartIndexes[0] = curSkin.HeadIndex; skinPartIndexes[1] = curSkin.BodyIndex; skinPartIndexes[2] = curSkin.PantsIndex; //newSkinData.HeadColor = imagePartColors[ 0 ].color; //newSkinData.BodyColor = imagePartColors[ 1 ].color; //newSkinData.PantsColor = imagePartColors[ 2 ].color; imagePartColors[0].color = newSkinData.HeadColor; imagePartColors[1].color = newSkinData.Costume1Color; imagePartColors[2].color = newSkinData.Costume2Color; }
public void SetSkinData(CurrentSkinData skinData) { SetSkinPart(SkinPart.Head, skinData.HeadIndex, skinData.HeadColor); SetSkinPart(SkinPart.Body, skinData.BodyIndex, skinData.Costume1Color, skinData.Costume2Color); SetSkinPart(SkinPart.Pants, skinData.PantsIndex, skinData.Costume1Color, skinData.Costume2Color); }
public GameObject GetPlayerPerson() { CurrentSkinData skinData = userData.GetSkin(); return(GetPlayerPerson(skinData.SkinId)); }
protected override void OnUpdate() { var spawners = _query.ToEntityArray(Allocator.TempJob); Entities.WithNone <SendRpcCommandRequestComponent>() .ForEach((Entity reqEnt, ref PlayerSpawnRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) => { var characterInfo = _appConfig.Characters[0]; var userId = req.userId.ToString(); var mainSkillId = req.skillId; var attackSkillId = req.skill2Id; var defenceSkillId = req.skill3Id; var utilsSkillId = req.skill4Id; var characterNameId = req.characterId; var skinId = req.skinId; NativeString64 skinSetting = ""; if (!string.IsNullOrEmpty(userId)) { var character = _globalSession.CharactersInGame.First(c => c.user_id == userId); var skinData = new CurrentSkinData(character); mainSkillId = (short)_appConfig.Skills.FindIndex(s => s.Id == character.skill_set.main_skill); attackSkillId = (short)_appConfig.Skills.FindIndex(s => s.Id == character.skill_set.attack_skill); defenceSkillId = (short)_appConfig.Skills.FindIndex(s => s.Id == character.skill_set.defence_skill); utilsSkillId = (short)_appConfig.Skills.FindIndex(s => s.Id == character.skill_set.utils_skill); characterNameId = _mainConfig.GetNameId(character.sex == "male" ? "ID_MALE" : "ID_FEMALE").Id; skinSetting = new CurrentSkinData(character).ToString(); } UnityEngine.Debug.Log( $"Server setting connection {EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value} to in game"); PostUpdateCommands.AddComponent <NetworkStreamInGame>(reqSrc.SourceConnection); var ghostCollection = GetSingleton <GhostPrefabCollectionComponent>(); var ghostId = DOTSGhostSerializerCollection.FindGhostType <CharacterSnapshotData>(); var prefab = EntityManager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value; var player = EntityManager.Instantiate(prefab); var spawnPoint = spawners.OrderBy(s => EntityManager.GetComponentData <SpawnPoint>(s).spawnCount) .First(); var spawnComponent = EntityManager.GetComponentData <SpawnPoint>(spawnPoint); var spawnPosition = EntityManager.GetComponentData <Translation>(spawnPoint); EntityManager.SetComponentData(spawnPoint, new SpawnPoint { radius = spawnComponent.radius, spawnCount = spawnComponent.spawnCount + 1 }); EntityManager.SetComponentData(player, new Translation { Value = spawnPosition.Value }); EntityManager.SetComponentData(player, new PlayerData { maxHealth = characterInfo.Health, health = characterInfo.Health, power = characterInfo.Power, magic = characterInfo.Magic, primarySkillId = mainSkillId, attackSkillId = attackSkillId, defenceSkillId = defenceSkillId, utilsSkillId = utilsSkillId, speedMod = 0.0f }); EntityManager.SetComponentData(player, new PrefabCreator { NameId = characterNameId, SkinId = skinId, SkinSetting = skinSetting }); EntityManager.SetComponentData(player, new MovableCharacterComponent { PlayerId = EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value }); PostUpdateCommands.AddBuffer <PlayerInput>(player); PostUpdateCommands.SetComponent(reqSrc.SourceConnection, new CommandTargetComponent { targetEntity = player }); PostUpdateCommands.DestroyEntity(reqEnt); }); spawners.Dispose(); }