public Monster GetMonster(MonsterClass monsterClass, MonsterBehavior monsterBehavior) { var key = GetKey(monsterClass, monsterBehavior); if (_flyweights.Any(x => x.Item2 == key)) { return(_flyweights.FirstOrDefault(t => t.Item2 == key)?.Item1); } Monster monster; switch (monsterBehavior) { case MonsterBehavior.Fire: monster = new Monster(new FireBehavior(), monsterClass); break; default: monster = new Monster(new WaterBehavior(), monsterClass); break; } _flyweights.Add(new Tuple <Monster, int>(monster, key)); return(_flyweights.FirstOrDefault(t => t.Item2 == key)?.Item1); }
// Start is called before the first frame update void Start() { player = GameObject.Find("Player"); InvokeRepeating("Trace", 0, 1.0f); //방향전환1초마다 MonsterClass.GetInstance().enemys.Add(this); animator.SetTrigger("Walk"); }
private static int GetKey(MonsterClass monsterClass, MonsterBehavior monsterBehavior) { unchecked { var hash = 13; hash = (hash * 7) + monsterClass.GetHashCode(); hash = (hash * 7) + (monsterBehavior.GetHashCode()); return(hash); } }
private void Awake() { if (instance) { DestroyImmediate(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); }
public GameObject FindMonsterByID(int id) { for (int i = 0; i < monsterdatabase.Length; i++) { GameObject newmonster = monsterdatabase[i]; MonsterClass newmonsterScript = newmonster.GetComponent <MonsterClass>(); if (newmonsterScript.monsterID == id) { return(newmonster); } } return(monsterdatabase[1]); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) //마우스 좌측 버튼을 누름. { bool attackStart = false; clickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); foreach (var enemy in MonsterClass.GetInstance().enemys) { if (Vector2.Distance(enemy.transform.localPosition, clickPosition) < 1.0f) { if (Vector2.Distance(enemy.transform.position, transform.position) < 2.0f) { attackStart = true; break; } } } if (attackStart) { eState = STATE.ATTACK; animator.SetTrigger("Attack"); } eState = STATE.WALK; animator.SetTrigger("Walk"); if (clickPosition.x < transform.position.x) { transform.localScale = new Vector3(-1, 1, 1); } else { transform.localScale = new Vector3(1, 1, 1); } } if (eState == STATE.WALK) { float dis = Vector2.Distance(transform.position, clickPosition); if (dis <= 0.01f) //클릭한 지점에 다왔다면 { eState = STATE.IDLE; animator.SetTrigger("Idle"); clickPosition = Vector3.zero; } } }
public void Possession(PlayerManager player, MonsterClass monster) { if (player.PlayerStats.Level >= monster.Level && monster.Player == null) { if (Vector3.Distance(player.transform.position, monster.transform.position) <= 5) { player.MonstrePossede = monster; monster.Player = player; monster.DisableAI(); this.transform.position = monster.transform.position; player.PlayerStats.addExp(player.MonstrePossede.ExpToPossess); } } }
public ActionResult AllSearch(string jobName, string jobLocation) { Dictionary <string, object> model = new Dictionary <string, object>(); List <GlassdoorClass> glassdoor = GlassdoorClass.RunSearch(jobName, jobLocation); List <CraigslistClass> craigslist = CraigslistClass.RunSearch(jobName, jobLocation); List <MonsterClass> monster = MonsterClass.RunSearch(jobName, jobLocation); List <StackOverflow> stackoverflow = StackOverflow.RunSearch(jobName, jobLocation); List <IndeedClass> indeed = IndeedClass.RunSearch(jobName, jobLocation); model.Add("glassdoor", glassdoor); model.Add("craigslist", craigslist); model.Add("monster", monster); model.Add("stackoverflow", stackoverflow); model.Add("indeed", indeed); return(View("All", model)); }
//fonction principale public int Attack(MonsterClass target,int force,MonsterClass agresseur) { //si on ne dépasse pas la range print(this.gameObject.name + " " + this.transform.position + " " + this.transform.localPosition); if(Vector3.Distance(this.transform.position, target.transform.position) <= this.Range) { //on regarde si le monstre est controlé par un joueur if(target.Player == null && agresseur != null) target.TakeDamage(force,target.Defense, agresseur); else if(target.Player == null && agresseur == null) target.TakeDamage(force, target.Defense); else target.Player.TakeDamage(force); //cooldown this._timer = 0; this._ready = false; return 0; } else { return -1; } }
public void Respawn() { this._isAlive = true; EnableAI(); if(this.MyIA.EstAgresse) this.MyIA.changeStat(); this._sante = this._santeMax; this.transform.position = this._startPos; this._myMesh.enabled = true; this._myCollier.enabled = true; this._target = null; }
public void TakeDamage(int damage,int def=0,MonsterClass agresseur = null) { this._sante -= damage - (def/3); if(this._target == null && agresseur != null) { this._target = agresseur; this.MyIA.changeStat(); } if (this._sante <= 0) { this.DisableAI(); this._isAlive = false; this._myMesh.enabled = false; this._myCollier.enabled = false; } }
public void AttackTarget(MonsterClass target, int force) { this._attack.Attack(target,force,this); target.IsHunted = true; if (!target.IsAlive) { target = null; if (MyIA.EstAgresse) MyIA.changeStat (); } }
public MonsterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); Image = (Monster)reader.ReadUInt16(); AI = reader.ReadByte(); if (Envir.LoadVersion > 81) { Class = (MonsterClass)reader.ReadByte(); } Effect = reader.ReadByte(); if (Envir.LoadVersion < 62) { Level = (ushort)reader.ReadByte(); } else { Level = reader.ReadUInt16(); } if (Envir.LoadVersion > 80) { Scale = reader.ReadByte(); } else { Scale = 100; } ViewRange = reader.ReadByte(); if (Envir.LoadVersion >= 3) { CoolEye = reader.ReadByte(); } HP = reader.ReadUInt32(); if (Envir.LoadVersion < 62) { MinAC = (ushort)reader.ReadByte(); MaxAC = (ushort)reader.ReadByte(); MinMAC = (ushort)reader.ReadByte(); MaxMAC = (ushort)reader.ReadByte(); MinDC = (ushort)reader.ReadByte(); MaxDC = (ushort)reader.ReadByte(); MinMC = (ushort)reader.ReadByte(); MaxMC = (ushort)reader.ReadByte(); MinSC = (ushort)reader.ReadByte(); MaxSC = (ushort)reader.ReadByte(); } else { MinAC = reader.ReadUInt16(); MaxAC = reader.ReadUInt16(); MinMAC = reader.ReadUInt16(); MaxMAC = reader.ReadUInt16(); MinDC = reader.ReadUInt16(); MaxDC = reader.ReadUInt16(); MinMC = reader.ReadUInt16(); MaxMC = reader.ReadUInt16(); MinSC = reader.ReadUInt16(); MaxSC = reader.ReadUInt16(); } Accuracy = reader.ReadByte(); Agility = reader.ReadByte(); Light = reader.ReadByte(); AttackSpeed = reader.ReadUInt16(); MoveSpeed = reader.ReadUInt16(); Experience = reader.ReadUInt32(); if (Envir.LoadVersion < 6) { reader.BaseStream.Seek(8, SeekOrigin.Current); int count = reader.ReadInt32(); reader.BaseStream.Seek(count * 12, SeekOrigin.Current); } CanPush = reader.ReadBoolean(); CanTame = reader.ReadBoolean(); if (Envir.LoadVersion < 18) { return; } AutoRev = reader.ReadBoolean(); Undead = reader.ReadBoolean(); }
void Update() { _ray = _cam.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast (_ray, out _hit, Mathf.Infinity, this._monstreLayer)) { _target = _hit.collider.GetComponent<MonsterClass> (); managerUI.DisplayTargetStatus (_target); managerUI.UpdateStatusTarget (_target); } else if (Physics.Raycast (_ray, out _hit, Mathf.Infinity, this._questerLayer)) { Quester q = _hit.collider.GetComponent<Quester> (); if (quester != null && quester.QuestId == 2) { quester.Talk(); } } } if (inPossession) { //this._myUI.HealthBarUpdate(); if (this._target != null) { //faire apparaitre bouton attaque et barre de vie enemy UIManager.instance.DisplayAttackButton(); UIManager.instance.DisplayTargetStatus(Target); } if (this._monstrePossede.Sante <= 0) { noBody(); } } else if (_target != null && !inPossession) { //faire apparaitre bouton possession UIManager.instance.DisplayPossessButton(); UIManager.instance.HideAttackButton(); } else if (_target != null && !inPossession) { UIManager.instance.HidePossessButton(); } if (MonstrePossede != null) { this.MonstrePossede.transform.position = playerPosition.position; this.MonstrePossede.transform.rotation = playerPosition.rotation; rangeProjector.orthographicSize = MonstrePossede.Attack.Range; UIManager.instance.UpdateAttackButton(MonstrePossede.Attack._timer / MonstrePossede.Attack.Cooldown); } if(Input.GetKeyDown(KeyCode.K)) TakeDamage(1); if (Input.GetKeyDown(KeyCode.L)) AddExp(100); }
public void DisplayTargetStatus(MonsterClass target) { mainUI.LifeTargetEnable(target); }
public void Depossession() { this._playerStats.addExp(this._monstrePossede.ExpToPossess); //Attribuer le transform this._monstrePossede.transform.parent = null; this._monstrePossede.EnableAI(); this._monstrePossede.transform.Translate(this._monstrePossede.Player.transform.up.normalized * 3); //this._monstrePossede.transform.LookAt(this._monstrePossede.Player.transform); this._monstrePossede.GetComponent<CapsuleCollider>().enabled = true; this._monstrePossede.Player = null; this._monstrePossede = null; this.inPossession = false; playerRenderer.SetActive(true); this.VieTotal = PlayerStats.Sante; this.VieMaxTotal = PlayerStats.SanteMax; this.ForceTotal = PlayerStats.Force; this.ConsTotal = PlayerStats.Defense; this.IntTotal = PlayerStats.Intel; this.VolTotal = PlayerStats.Volonte; if (quester != null && quester.QuestId == 3) quester.QuestFinish (); //UI UIManager.instance.HidePossessButton(); UIManager.instance.HideReleaseButton(); }
public void essaiPossession() { if (Vector3.Distance(this.transform.position, _target.transform.position) <= 5) { if (PlayerStats.Level >= _target.Level && _target.Player == null && MonstrePossede == null) { this.MonstrePossede = this._target; this._target = null; this.MonstrePossede.Player = this; this.inPossession = true; //playerPosition.position = this.MonstrePossede.transform.position; this.MonstrePossede.transform.position = playerPosition.position+ new Vector3(0,22,0); this.MonstrePossede.transform.rotation = playerPosition.rotation; this.MonstrePossede.transform.parent = playerPosition; this._playerStats.addExp(this._monstrePossede.ExpToPossess); this._monstrePossede.DisableAI(); this._monstrePossede.GetComponent<CapsuleCollider>().enabled = false; playerRenderer.SetActive(false); StatUpdateWithMonster(); rangeProjector.gameObject.SetActive(true); //UI UIManager.instance.StartPossessAniamtion(); UIManager.instance.UpdateInfoText(""); UIManager.instance.UpdateStatusExp(); UIManager.instance.HidePossessButton(); UIManager.instance.DisplayReleaseButton(); this._monstrePossede.transform.parent = PlayerStats.transform; } else if (PlayerStats.Level < this._target.Level) { UIManager.instance.UpdateInfoText("Niveau du monstre trop élevé!"); } } else { UIManager.instance.UpdateInfoText("Créature trop loin."); } /* //ajouter la condition dans le if du dessus else if(monster.PlayerId != null) { this._myUI.InfoTextUpdate("Créature déjà possédée!"); } */ }
public void healthBarTargetInfo(MonsterClass target) { if (target.Player == null) { this._healthTargetText.text = target.Sante.ToString(); float itlife = (float)target.Sante / (float)target.SanteMax; //<== valeur entre 0 et 1 _healthTargetBar.fillAmount = Mathf.Lerp(_healthTargetBar.fillAmount, itlife, 5 * Time.deltaTime); //this._healthTargetBar.transform.localScale = new Vector3(Mathf.Clamp(itlife, 0f, 1f), this._healthTargetBar.transform.localScale.y, this._healthTargetBar.transform.localScale.z); } else { var targetPlayer = this._player.Target.Player; this._healthTargetText.text = targetPlayer.VieTotal.ToString(); float itlife = (float)targetPlayer.VieTotal / (float)targetPlayer.VieMaxTotal; //<== valeur entre 0 et 1 _healthTargetBar.fillAmount = Mathf.Clamp(itlife, 0f, 1f); //this._healthTargetBar.transform.localScale = new Vector3(Mathf.Clamp(itlife, 0f, 1f), this._healthTargetBar.transform.localScale.y, this._healthTargetBar.transform.localScale.z); } }
public Monster(IBehavior behavior, MonsterClass monsterClass = MonsterClass.Warrior) { _behavior = behavior; MonsterClass = monsterClass; }
public ActionResult MonsterSearch(string jobName, string jobLocation) { List <MonsterClass> model = MonsterClass.RunSearch(jobName, jobLocation); return(View("Monster", model)); }
public void Attack() { if (Vector3.Distance(this.transform.position, _target.transform.position) <= this._monstrePossede.Attack.Range && this._monstrePossede.Attack.Ready) { _monstrePossede.AttackTarget(_target,_forceTotal); if (_target.Sante <= 0) { //Victoire contre un monstre AddExp(_target.Exp); //Déréférencement du monstre dans le script _target = null; UIManager.instance.HideAttackButton(); UIManager.instance.UpdateStatusExp(); UIManager.instance.HideTargetStatus(); } } else if(!this._monstrePossede.Attack.Ready) { UIManager.instance.UpdateInfoText("Attaque non prête!"); } else { UIManager.instance.UpdateInfoText("Cible trop loin!"); } }
public void LifeTargetEnable(MonsterClass target) { this._healthTargetObject.gameObject.SetActive(true); this.healthBarTargetInfo(target); if (target.Player == null) this._targetName.text = target.Name; else this._targetName.text = target.Player.PlayerStats.Name; }
// Use this for initialization void Start() { print("make monster"); gameManager = GameObject.FindObjectOfType <Sc_GameManager>(); GameObject newMonster = (GameObject)Instantiate(gameManager.currentMonster, transform.position, transform.rotation); Vector3 monsterPosition = new Vector3(-0.57f, 1.96f, 0); newMonster.transform.position = monsterPosition; monster = GameObject.FindObjectOfType <MonsterClass>(); saveDataManager.saveData.currentScene = "Battle"; currentDeck.Clear(); currentBanished.Clear(); currentDiscard.Clear(); currentHandObjects.Clear(); currentEquipmentArmor.Clear(); currentEquipmentMelee.Clear(); // set op some basic variables maxHandSize = 5; currentApUsed = 0; currentStage = 0; currentUtilityAP = gameManager.utilityAP; currentTotalDefence = gameManager.startingDefence; currentToughness = 0; currentNormalAttack = 0; currentBluntAttack = 0; currentPiercingAttack = 0; currentPoisonttack = 0; currentSpiked = 0; currentNumberOfAttacks = 1; currentPermenentSpiked = 0; currentRage = 0; if (gameManager.isLoading == true) { Load(); } else { for (int i = 0; i < gameManager.fullDeck.Count; i++) { currentDeck.Add(gameManager.fullDeck[i]); } currentApMax = 2; } // Create Ap Icons for (int i = 0; i < currentApMax; i++) { GameObject apIcon = (GameObject)Instantiate(standardApIcon, this.gameObject.transform.position, this.gameObject.transform.rotation); Sc_ApIcon newscript = apIcon.GetComponent <Sc_ApIcon>(); newscript.isStandard = true; } for (int i = 0; i < gameManager.utilityAP; i++) { GameObject apIcon = (GameObject)Instantiate(standardApIcon, this.gameObject.transform.position, this.gameObject.transform.rotation); Sc_ApIcon newscript = apIcon.GetComponent <Sc_ApIcon>(); newscript.isUtility = true; } // effect realted varibles mayPlayUtility = true; mayPlayMelee = true; mayPlayArmor = true; HasLostTurn = false; // Setting player related text defenceText.text = "" + currentTotalDefence; // Add some random cards to deck ShuffleDeck(); }
public void ProcessPacket(int size, int type, byte[] recvPacket) { if (type == Game.Protocol.Protocol.SC_ID) { ByteBuffer recv_buf = new ByteBuffer(recvPacket); var get_all_data = Init_Collection_IM.GetRootAsInit_Collection_IM(recv_buf); product_complete[0] = get_all_data.Complete1; product_complete[1] = get_all_data.Complete2; product_complete[2] = get_all_data.Complete3; product_complete[3] = get_all_data.Complete4; product_complete[4] = get_all_data.Complete5; for (int i = 0; i < get_all_data.ItemDataLength; ++i) { //데이터 접근 get_all_data.Data(i).Value.변수 int item_id = get_all_data.ItemData(i).Value.Id; int item_t = get_all_data.ItemData(i).Value.Type; Vector3 item_p = new Vector3(get_all_data.ItemData(i).Value.Position.Value.X, get_all_data.ItemData(i).Value.Position.Value.Y, get_all_data.ItemData(i).Value.Position.Value.Z); int d = get_all_data.ItemData(i).Value.Draw; if (item_data.ContainsKey(item_id)) { ItemClass iter = item_data[item_id]; iter.set_id(item_id); iter.set_type(item_t); iter.set_pos(item_p); if (d == 1) { iter.set_draw(true); } else { iter.set_draw(false); } } else { item_data.Add(item_id, new ItemClass(item_id, item_t, item_p)); if (d == 1) { item_data[item_id].set_draw(true); } else { item_data[item_id].set_draw(false); } } } for (int i = 0; i < get_all_data.MonsterDataLength; ++i) { int monster_id = get_all_data.MonsterData(i).Value.Id; int monster_hp = get_all_data.MonsterData(i).Value.Hp; Vector3 monster_p = new Vector3(get_all_data.MonsterData(i).Value.Position.Value.X, get_all_data.MonsterData(i).Value.Position.Value.Y, get_all_data.MonsterData(i).Value.Position.Value.Z); Vector3 monster_r = new Vector3(get_all_data.MonsterData(i).Value.Rotation.Value.X, get_all_data.MonsterData(i).Value.Rotation.Value.Y, get_all_data.MonsterData(i).Value.Rotation.Value.Z); int monster_target = get_all_data.MonsterData(i).Value.Target; float monster_x = get_all_data.MonsterData(i).Value.DirX; float monster_z = get_all_data.MonsterData(i).Value.DirZ; int monster_cal = get_all_data.MonsterData(i).Value.Calculate; int monster_ani = get_all_data.MonsterData(i).Value.Animator; if (monster_data.ContainsKey(monster_id)) { MonsterClass iter = monster_data[monster_id]; iter.set_id(monster_id); iter.set_hp(monster_hp); iter.set_pos(monster_p); iter.set_rot(monster_r); iter.set_chase_id(monster_target); iter.set_dirX(monster_x); iter.set_dirZ(monster_z); iter.set_calculate_id(monster_cal); iter.set_animator(monster_hp); iter.set_draw(true); } else { monster_data.Add(monster_id, new MonsterClass(monster_id, monster_hp, monster_hp, monster_x, monster_z, monster_p, monster_r, monster_target, monster_cal)); monster_data[monster_id].set_draw(true); //spawner.Spawn(id, p, monster_data[id]); } } Client_id = get_all_data.MyData.Value.Id; new_player_id = get_all_data.MyData.Value.Id; int id = get_all_data.MyData.Value.Id; string n = get_all_data.MyData.Value.Name; Vector3 p = new Vector3(get_all_data.MyData.Value.Position.Value.X, get_all_data.MyData.Value.Position.Value.Y, get_all_data.MyData.Value.Position.Value.Z); int hp = get_all_data.MyData.Value.Hp; int mhp = get_all_data.MyData.Value.MaxHp; int i1 = get_all_data.MyData.Value.Item1; int i2 = get_all_data.MyData.Value.Item2; int i3 = get_all_data.MyData.Value.Item3; int i4 = get_all_data.MyData.Value.Item4; int character = get_all_data.MyData.Value.Character; int ic1 = get_all_data.MyData.Value.Ic1; int ic2 = get_all_data.MyData.Value.Ic2; int ic3 = get_all_data.MyData.Value.Ic3; int ic4 = get_all_data.MyData.Value.IC4; if (client_data.ContainsKey(id)) { ClientClass iter = client_data[id]; iter.set_name(n); iter.set_pos(p); iter.set_hp(hp); iter.set_item(i1, 0); iter.set_item(i2, 1); iter.set_item(i3, 2); iter.set_item(i4, 3); iter.set_char(character); iter.set_item_count(ic1, 0); iter.set_item_count(ic2, 1); iter.set_item_count(ic3, 2); iter.set_item_count(ic4, 3); iter.set_draw(true); } else { client_data.Add(id, new ClientClass(id, n, p, hp, i1, i2, i3, i4, character, ic1, ic2, ic3, ic4)); client_data[id].set_draw(true); } SceneNum = 2; } else if (type == Game.Protocol.Protocol.SC_PUT_PLAYER) // 다른 클라가 접속했을 때 { ByteBuffer recv_buf = new ByteBuffer(recvPacket); Client_info get_data = Client_info.GetRootAsClient_info(recv_buf); new_player_id = get_data.Id; int id = get_data.Id; int character = get_data.Type; int hp = get_data.Hp; int ani = get_data.Animator; float x = get_data.DirX; float z = get_data.DirZ; float h = get_data.Horizontal; float v = get_data.Vertical; string n = get_data.Name; Vector3 p = new Vector3(get_data.Position.Value.X, get_data.Position.Value.Y, get_data.Position.Value.Z); Vector3 r = new Vector3(get_data.Rotation.Value.X, get_data.Rotation.Value.Y, get_data.Rotation.Value.Z); if (client_data.ContainsKey(id)) { ClientClass iter = client_data[id]; iter.set_char(character); iter.set_hp(hp); iter.set_pos(p); iter.set_rot(r); iter.set_vertical(v); iter.set_horizontal(h); iter.set_animator(ani); iter.set_dirX(x); iter.set_dirZ(z); iter.set_draw(true); } else { client_data.Add(id, new ClientClass(id, character, hp, ani, x, z, h, v, n, p, r)); client_data[id].set_draw(true); } Debug.Log("새로 접속한 아이디 : " + new_player_id); } else if (type == Game.Protocol.Protocol.SC_ALL_PLAYER_DATA) // 이 클라가 처음 접속했을 때 다른 모든 클라들의 데이터 { ByteBuffer recv_buf = new ByteBuffer(recvPacket); var get_all_data = Client_Collection.GetRootAsClient_Collection(recv_buf); for (int i = 0; i < get_all_data.DataLength; ++i) { //데이터 접근 get_all_data.Data(i).Value.변수 int id = get_all_data.Data(i).Value.Id; int character = get_all_data.Data(i).Value.Type; int hp = get_all_data.Data(i).Value.Hp; int ani = get_all_data.Data(i).Value.Animator; float x = get_all_data.Data(i).Value.DirX; float z = get_all_data.Data(i).Value.DirZ; float h = get_all_data.Data(i).Value.Horizontal; float v = get_all_data.Data(i).Value.Vertical; string n = get_all_data.Data(i).Value.Name; Vector3 p = new Vector3(get_all_data.Data(i).Value.Position.Value.X, get_all_data.Data(i).Value.Position.Value.Y, get_all_data.Data(i).Value.Position.Value.Z); Vector3 r = new Vector3(get_all_data.Data(i).Value.Rotation.Value.X, get_all_data.Data(i).Value.Rotation.Value.Y, get_all_data.Data(i).Value.Rotation.Value.Z); if (client_data.ContainsKey(id)) { ClientClass iter = client_data[id]; iter.set_hp(hp); iter.set_char(character); iter.set_pos(p); iter.set_rot(r); iter.set_vertical(v); iter.set_horizontal(h); iter.set_animator(ani); iter.set_dirX(x); iter.set_dirZ(z); iter.set_draw(true); } else { client_data.Add(id, new ClientClass(id, character, hp, ani, x, z, h, v, n, p, r)); client_data[id].set_draw(true); } } } else if (type == Game.Protocol.Protocol.SC_PLAYER_STATUS) // 클라가 움직였을때 그 클라 데이터 { ByteBuffer recv_buf = new ByteBuffer(recvPacket); Client_info get_data = Client_info.GetRootAsClient_info(recv_buf); int id = get_data.Id; int character = get_data.Type; int hp = get_data.Hp; int ani = get_data.Animator; float x = get_data.DirX; float z = get_data.DirZ; float h = get_data.Horizontal; float v = get_data.Vertical; string n = get_data.Name; Vector3 p = new Vector3(get_data.Position.Value.X, get_data.Position.Value.Y, get_data.Position.Value.Z); Vector3 r = new Vector3(get_data.Rotation.Value.X, get_data.Rotation.Value.Y, get_data.Rotation.Value.Z); if (client_data.ContainsKey(id)) { ClientClass iter = client_data[id]; iter.set_char(character); iter.set_hp(hp); iter.set_pos(p); iter.set_rot(r); iter.set_vertical(v); iter.set_horizontal(h); iter.set_animator(ani); iter.set_dirX(x); iter.set_dirZ(z); iter.set_draw(true); } else { client_data.Add(id, new ClientClass(id, character, hp, ani, x, z, h, v, n, p, r)); client_data[id].set_draw(true); } } else if (type == Game.Protocol.Protocol.SC_REMOVE_PLAYER) { int id = recvPacket[0]; client_data[id].set_draw(false); } else if (type == Game.Protocol.Protocol.SC_PUT_MONSTER) { //ByteBuffer recv_buf = new ByteBuffer(recvPacket); //Monster_info get_data = Monster_info.GetRootAsMonster_info(recv_buf); //int id = get_data.Id; //int hp = get_data.Hp; //int ani = get_data.Animator; //float x = get_data.DirX; //float z = get_data.DirZ; //Vector3 p = new Vector3(get_data.Position.Value.X, get_data.Position.Value.Y, get_data.Position.Value.Z); //Vector3 r = new Vector3(get_data.Rotation.Value.X, get_data.Rotation.Value.Y, get_data.Rotation.Value.Z); //if (monster_data.ContainsKey(id)) //{ // MonsterClass iter = monster_data[id]; // iter.set_hp(hp); // iter.set_pos(p); // iter.set_rot(r); // iter.set_animator(ani); // iter.set_dirX(x); // iter.set_dirZ(z); // iter.set_draw(true); //} //else //{ // monster_data.Add(id, new MonsterClass(id, hp, ani, x, z, p, r)); // monster_data[id].set_draw(true); //} //Debug.Log("몬스터 생성 아이디 : " + id); } else if (type == Game.Protocol.Protocol.SC_REMOVE_MONSTER) { int remove_monster = recvPacket[0]; monster_data[remove_monster].set_hp(0); monster_data[remove_monster].set_animator(0); //monster_data.Remove(remove_monster); } else if (type == Game.Protocol.Protocol.SC_PUT_ITEM) { ByteBuffer recv_buf = new ByteBuffer(recvPacket); var get_all_data = Item_Collection.GetRootAsItem_Collection(recv_buf); for (int i = 0; i < get_all_data.DataLength; ++i) { //데이터 접근 get_all_data.Data(i).Value.변수 int id = get_all_data.Data(i).Value.Id; int t = get_all_data.Data(i).Value.Type; Vector3 p = new Vector3(get_all_data.Data(i).Value.Position.Value.X, get_all_data.Data(i).Value.Position.Value.Y, get_all_data.Data(i).Value.Position.Value.Z); int d = get_all_data.Data(i).Value.Draw; if (item_data.ContainsKey(id)) { ItemClass iter = item_data[id]; iter.set_id(id); iter.set_type(t); iter.set_pos(p); if (d == 0) { iter.set_draw(false); } else if (d == 1) { iter.set_draw(true); } } else { item_data.Add(id, new ItemClass(id, t, p)); if (d == 0) { item_data[id].set_draw(false); } else if (d == 1) { item_data[id].set_draw(true); } } } } else if (type == Game.Protocol.Protocol.SC_REMOVE_ITEM) { int remove_item = recvPacket[0]; item_data[remove_item].set_draw(false); } else if (type == Game.Protocol.Protocol.SC_INIT_DATA) { ByteBuffer recv_buf = new ByteBuffer(recvPacket); var get_all_data = Init_Collection.GetRootAsInit_Collection(recv_buf); product_complete[0] = get_all_data.Complete1; product_complete[1] = get_all_data.Complete2; product_complete[2] = get_all_data.Complete3; product_complete[3] = get_all_data.Complete4; product_complete[4] = get_all_data.Complete5; for (int i = 0; i < get_all_data.ClientDataLength; ++i) { int c_id = get_all_data.ClientData(i).Value.Id; int c_hp = get_all_data.ClientData(i).Value.Hp; int c_ani = get_all_data.ClientData(i).Value.Animator; float c_x = get_all_data.ClientData(i).Value.DirX; float c_z = get_all_data.ClientData(i).Value.DirZ; float c_h = get_all_data.ClientData(i).Value.Horizontal; float c_v = get_all_data.ClientData(i).Value.Vertical; string c_n = get_all_data.ClientData(i).Value.Name; Vector3 c_p = new Vector3(get_all_data.ClientData(i).Value.Position.Value.X, get_all_data.ClientData(i).Value.Position.Value.Y, get_all_data.ClientData(i).Value.Position.Value.Z); Vector3 c_r = new Vector3(get_all_data.ClientData(i).Value.Rotation.Value.X, get_all_data.ClientData(i).Value.Rotation.Value.Y, get_all_data.ClientData(i).Value.Rotation.Value.Z); if (client_data.ContainsKey(c_id)) { ClientClass iter = client_data[c_id]; iter.set_char(get_all_data.ClientData(i).Value.Type); iter.set_hp(c_hp); iter.set_pos(c_p); iter.set_rot(c_r); iter.set_vertical(c_v); iter.set_horizontal(c_h); iter.set_animator(c_ani); iter.set_dirX(c_x); iter.set_dirZ(c_z); iter.set_draw(true); } else { client_data.Add(c_id, new ClientClass(c_id, get_all_data.ClientData(i).Value.Type, c_hp, c_ani, c_x, c_z, c_h, c_v, c_n, c_p, c_r)); ClientClass iter = client_data[c_id]; client_data[c_id].set_draw(true); } } for (int i = 0; i < get_all_data.ItemDataLength; ++i) { //데이터 접근 get_all_data.Data(i).Value.변수 int item_id = get_all_data.ItemData(i).Value.Id; int item_t = get_all_data.ItemData(i).Value.Type; Vector3 item_p = new Vector3(get_all_data.ItemData(i).Value.Position.Value.X, get_all_data.ItemData(i).Value.Position.Value.Y, get_all_data.ItemData(i).Value.Position.Value.Z); int d = get_all_data.ItemData(i).Value.Draw; if (item_data.ContainsKey(item_id)) { ItemClass iter = item_data[item_id]; iter.set_id(item_id); iter.set_type(item_t); iter.set_pos(item_p); if (d == 1) { iter.set_draw(true); } else { iter.set_draw(false); } } else { item_data.Add(item_id, new ItemClass(item_id, item_t, item_p)); if (d == 1) { item_data[item_id].set_draw(true); } else { item_data[item_id].set_draw(false); } } } for (int i = 0; i < get_all_data.MonsterDataLength; ++i) { int monster_id = get_all_data.MonsterData(i).Value.Id; int monster_hp = get_all_data.MonsterData(i).Value.Hp; Vector3 monster_p = new Vector3(get_all_data.MonsterData(i).Value.Position.Value.X, get_all_data.MonsterData(i).Value.Position.Value.Y, get_all_data.MonsterData(i).Value.Position.Value.Z); Vector3 monster_r = new Vector3(get_all_data.MonsterData(i).Value.Rotation.Value.X, get_all_data.MonsterData(i).Value.Rotation.Value.Y, get_all_data.MonsterData(i).Value.Rotation.Value.Z); int monster_target = get_all_data.MonsterData(i).Value.Target; float monster_x = get_all_data.MonsterData(i).Value.DirX; float monster_z = get_all_data.MonsterData(i).Value.DirZ; int monster_cal = get_all_data.MonsterData(i).Value.Calculate; int monster_ani = get_all_data.MonsterData(i).Value.Animator; if (monster_data.ContainsKey(monster_id)) { MonsterClass iter = monster_data[monster_id]; iter.set_id(monster_id); iter.set_hp(monster_hp); iter.set_pos(monster_p); iter.set_rot(monster_r); iter.set_chase_id(monster_target); iter.set_dirX(monster_x); iter.set_dirZ(monster_z); iter.set_calculate_id(monster_cal); iter.set_animator(monster_hp); iter.set_draw(true); } else { monster_data.Add(monster_id, new MonsterClass(monster_id, monster_hp, monster_hp, monster_x, monster_z, monster_p, monster_r, monster_target, monster_cal)); monster_data[monster_id].set_draw(true); //spawner.Spawn(id, p, monster_data[id]); } } Client_id = get_all_data.MyData.Value.Id; new_player_id = get_all_data.MyData.Value.Id; int id = get_all_data.MyData.Value.Id; string n = get_all_data.MyData.Value.Name; Vector3 p = new Vector3(get_all_data.MyData.Value.Position.Value.X, get_all_data.MyData.Value.Position.Value.Y, get_all_data.MyData.Value.Position.Value.Z); int hp = get_all_data.MyData.Value.Hp; int mhp = get_all_data.MyData.Value.MaxHp; int i1 = get_all_data.MyData.Value.Item1; int i2 = get_all_data.MyData.Value.Item2; int i3 = get_all_data.MyData.Value.Item3; int i4 = get_all_data.MyData.Value.Item4; int character = get_all_data.MyData.Value.Character; int ic1 = get_all_data.MyData.Value.Ic1; int ic2 = get_all_data.MyData.Value.Ic2; int ic3 = get_all_data.MyData.Value.Ic3; int ic4 = get_all_data.MyData.Value.IC4; if (client_data.ContainsKey(id)) { ClientClass iter = client_data[id]; iter.set_name(n); iter.set_pos(p); iter.set_hp(hp); iter.set_item(i1, 0); iter.set_item(i2, 1); iter.set_item(i3, 2); iter.set_item(i4, 3); iter.set_char(character); iter.set_item_count(ic1, 0); iter.set_item_count(ic2, 1); iter.set_item_count(ic3, 2); iter.set_item_count(ic4, 3); iter.set_draw(true); } else { client_data.Add(id, new ClientClass(id, n, p, hp, i1, i2, i3, i4, character, ic1, ic2, ic3, ic4)); client_data[id].set_draw(true); } SceneNum = 2; } else if (type == Game.Protocol.Protocol.SC_LOGIN_SUCCESS) { } else if (type == Game.Protocol.Protocol.SC_LOGIN_FAIL) { } else if (type == Game.Protocol.Protocol.SC_SIGNUP) { SceneNum = 1; } else if (type == Game.Protocol.Protocol.SC_REVIVE_MONSTER) { ByteBuffer recv_buf = new ByteBuffer(recvPacket); Monster_info get_all_data = Monster_info.GetRootAsMonster_info(recv_buf); int id = get_all_data.Id; int hp = get_all_data.Hp; Vector3 p = new Vector3(get_all_data.Position.Value.X, get_all_data.Position.Value.Y, get_all_data.Position.Value.Z); Vector3 r = new Vector3(get_all_data.Rotation.Value.X, get_all_data.Rotation.Value.Y, get_all_data.Rotation.Value.Z); int target = get_all_data.Target; float x = get_all_data.DirX; float z = get_all_data.DirZ; int cal = get_all_data.Calculate; int ani = get_all_data.Animator; if (monster_data.ContainsKey(id)) { MonsterClass iter = monster_data[id]; iter.set_id(id); iter.set_hp(hp); iter.set_pos(p); iter.set_rot(r); iter.set_chase_id(target); iter.set_dirX(x); iter.set_dirZ(z); iter.set_calculate_id(cal); iter.set_animator(ani); iter.set_draw(true); } else { monster_data.Add(id, new MonsterClass(id, hp, ani, x, z, p, r, target, cal)); monster_data[id].set_draw(true); //spawner.Spawn(id, p, monster_data[id]); } } else if (type == Game.Protocol.Protocol.SC_MONSTER_INFO) { ByteBuffer recv_buf = new ByteBuffer(recvPacket); Monster_info get_all_data = Monster_info.GetRootAsMonster_info(recv_buf); int id = get_all_data.Id; int hp = get_all_data.Hp; Vector3 p = new Vector3(get_all_data.Position.Value.X, get_all_data.Position.Value.Y, get_all_data.Position.Value.Z); Vector3 r = new Vector3(get_all_data.Rotation.Value.X, get_all_data.Rotation.Value.Y, get_all_data.Rotation.Value.Z); int target = get_all_data.Target; float x = get_all_data.DirX; float z = get_all_data.DirZ; int cal = get_all_data.Calculate; int ani = get_all_data.Animator; if (monster_data.ContainsKey(id)) { MonsterClass iter = monster_data[id]; iter.set_id(id); iter.set_hp(hp); iter.set_pos(p); iter.set_rot(r); iter.set_chase_id(target); iter.set_dirX(x); iter.set_dirZ(z); iter.set_calculate_id(cal); iter.set_animator(ani); iter.set_draw(true); } else { monster_data.Add(id, new MonsterClass(id, hp, ani, x, z, p, r, target, cal)); monster_data[id].set_draw(true); //spawner.Spawn(id, p, monster_data[id]); } } else if (type == Game.Protocol.Protocol.SC_MONSTER_TARGET) { ByteBuffer recv_buf = new ByteBuffer(recvPacket); Eat_Item get_data = Eat_Item.GetRootAsEat_Item(recv_buf); int monster_id = get_data.ItemID; int target = get_data.PlayerID; monster_data[monster_id].set_chase_id(target); } else if (type == Game.Protocol.Protocol.SC_MONSTER_CALCULATE) { ByteBuffer recv_buf = new ByteBuffer(recvPacket); Eat_Item get_data = Eat_Item.GetRootAsEat_Item(recv_buf); int monster_id = get_data.ItemID; int cal = get_data.PlayerID; monster_data[monster_id].set_calculate_id(cal); } else if (type == Game.Protocol.Protocol.SC_COMPLETE_MAKING) { int complete = recvPacket[0]; product_complete[complete] = 1; } else if (type == Game.Protocol.Protocol.SC_END_GAME) { SceneNum = 3; } }
public void UpdateStatusTarget(MonsterClass target) { mainUI.healthBarTargetInfo(target); }