public void Add(ObjectInfo info, bool myPlayer = false) { GameObjectType objectType = GetObjectTypeById(info.ObjectId); if (objectType == GameObjectType.Player) { if (myPlayer == true) { GameObject go = Managers.Resource.Instantiate("Creature/MyPlayer"); go.name = info.Name; _objects.Add(info.ObjectId, go); MyPlayer = go.GetComponent <MyPlayerController>(); MyPlayer.Id = info.ObjectId; MyPlayer.PosInfo = info.PosInfo; MyPlayer.Stat = info.StatInfo; MyPlayer.SyncPos(); } else { GameObject go = Managers.Resource.Instantiate("Creature/Player"); go.name = info.Name; _objects.Add(info.ObjectId, go); PlayerController pc = go.GetComponent <PlayerController>(); pc.Id = info.ObjectId; pc.PosInfo = info.PosInfo; pc.Stat = info.StatInfo; pc.SyncPos(); } } else if (objectType == GameObjectType.Monster) { GameObject go = Managers.Resource.Instantiate("Creature/Monster"); go.name = info.Name; _objects.Add(info.ObjectId, go); MonsterController mc = go.GetComponent <MonsterController>(); mc.Id = info.ObjectId; mc.PosInfo = info.PosInfo; mc.Stat = info.StatInfo; mc.SyncPos(); } else if (objectType == GameObjectType.Projectile) { GameObject go = Managers.Resource.Instantiate("Creature/Arrow"); go.name = "Arrow"; _objects.Add(info.ObjectId, go); ArrowController ac = go.GetComponent <ArrowController>(); ac.PosInfo = info.PosInfo; ac.Stat = info.StatInfo; //ac.Dir = info.PosInfo.Movedir; //ac.CellPos = new Vector3Int(info.PosInfo.PosX, info.PosInfo.PosY, 0); ac.SyncPos(); } }
public void Add(ObjectInfo info, bool myPlayer = false) { if (MyPlayer != null && MyPlayer.id == info.ObjectId) { return; } if (_objects.ContainsKey(info.ObjectId)) { return; } GameObjectType objectType = GetObjectTypeById(info.ObjectId); if (objectType == GameObjectType.Player) { if (myPlayer) { GameObject go = Managers.Resource.Instantiate("Creature/MyPlayer"); go.name = info.Name; _objects.Add(info.ObjectId, go); MyPlayer = go.GetComponent <MyPlayerController>(); MyPlayer.id = info.ObjectId; MyPlayer.PosInfo = info.PosInfo; MyPlayer.Stat.MergeFrom(info.StatInfo); MyPlayer.SyncPos(); } else { GameObject go = Managers.Resource.Instantiate("Creature/Player"); go.name = info.Name; _objects.Add(info.ObjectId, go); PlayerController pc = go.GetComponent <PlayerController>(); pc.id = info.ObjectId; pc.PosInfo = info.PosInfo; pc.Stat.MergeFrom(info.StatInfo); pc.SyncPos(); } } else if (objectType == GameObjectType.Monster) { GameObject go = Managers.Resource.Instantiate("Creature/Monster"); go.name = info.Name; _objects.Add(info.ObjectId, go); MonsterController mc = go.GetComponent <MonsterController>(); mc.id = info.ObjectId; mc.PosInfo = info.PosInfo; mc.Stat = info.StatInfo; mc.SyncPos(); } else if (objectType == GameObjectType.Projectile) { GameObject go = Managers.Resource.Instantiate("Creature/Arrow"); go.name = "Arrow"; _objects.Add(info.ObjectId, go); ArrowController ac = go.GetComponent <ArrowController>(); ac.PosInfo = info.PosInfo; ac.Stat = info.StatInfo; ac.SyncPos(); } }
public void Add(ObjectInfo info, bool myPlayer = false) { // 이제 add 전에 타입 구하고 그 타입별로 다르게 add 해야함 GameObjectType objectType = GetObjectTypeById(info.ObjectId); if (objectType == GameObjectType.Player) { if (myPlayer) { GameObject go = Managers.Resource.Instantiate("Creature/MyPlayer"); go.name = info.Name; _objects.Add(info.ObjectId, go); MyPlayer = go.GetComponent <MyPlayerController>(); MyPlayer.Id = info.ObjectId; // 이렇게 position에 대한 클래스 하나가 있으면 코드 한줄에 모든 pos 관련 정보를 넣어줄수있다. MyPlayer.PosInfo = info.PosInfo; MyPlayer.Stat = info.StatInfo; MyPlayer.SyncPos(); // 스르륵 이동 없이 즉시 좌표이동을 반영 } else { // 내가 조작하는 플레이어가 아닌 경우 GameObject go = Managers.Resource.Instantiate("Creature/Player"); go.name = info.Name; _objects.Add(info.ObjectId, go); PlayerController pc = go.GetComponent <PlayerController>(); pc.Id = info.ObjectId; pc.PosInfo = info.PosInfo; pc.Stat = info.StatInfo; pc.SyncPos(); } } else if (objectType == GameObjectType.Monster) { // 몬스터 생성 GameObject go = Managers.Resource.Instantiate("Creature/Monster"); go.name = info.Name; _objects.Add(info.ObjectId, go); MonsterController mc = go.GetComponent <MonsterController>(); mc.Id = info.ObjectId; mc.PosInfo = info.PosInfo; mc.Stat = info.StatInfo; mc.SyncPos(); } else if (objectType == GameObjectType.Projectile) { // 이건 여러가지 종류가 있을텐데 // 일단 화살이라 치자 GameObject go = Managers.Resource.Instantiate("Creature/Arrow"); go.name = "Arrow"; _objects.Add(info.ObjectId, go); ArrowController ac = go.GetComponent <ArrowController>(); ac.PosInfo = info.PosInfo; ac.Stat = info.StatInfo; ac.SyncPos(); // 이건 좀 햇갈리네 } }