// 룸 안에 적을 만든다. public T createRoomEnemy <T>(RoomController room, string name) where T : chrBehaviorEnemy { chrController chr = null; T enemy = null; do { string[] tokens = name.Split('.'); string enemy_kind = name; if (tokens.Length > 1) { enemy_kind = tokens[0]; } // 룸 안에 적을 만들 만들 수 있다(적의 수 제한 체크)?. if (!this.canCreateRoomEnemy(room)) { break; } if ((chr = EnemyRoot.get().createEnemy(enemy_kind)) == null) { break; } if ((enemy = chr.behavior as T) == null) { break; } enemy.setRoom(room); Room level_room = this.rooms[room.getIndex().x, room.getIndex().z]; if (GameRoot.get().isHost() && tokens.Length == 1) { enemy.name += "." + level_room.enemy_index.ToString("D3"); } else { enemy.name = name; } level_room.enemies.Add(chr); dbwin.console().print("**EnemyName" + enemy.name); //Debug.Log("**EnemyName" + enemy.name); var as_lair = chr.behavior as chrBehaviorEnemy_Lair; if (as_lair != null) { level_room.lairs.Add(as_lair); } level_room.enemy_index++; } while(false); return(enemy); }
// 소환수를 소환 public void summonBeast(string beast_name) { do { if (this.beast != null) { break; } if (beast_name == "") { break; } string avator_name = "Beast_" + beast_name; string behavior_name = "chrBehaviorBeast_" + beast_name; chrController chr = CharacterRoot.getInstance().summonBeast(avator_name, behavior_name); if (chr == null) { break; } this.beast = chr.behavior; this.beast.control.cmdSetPositionAnon(this.getLocalPlayer().control.getPosition() + Vector3.back * 4.0f); this.summon_time = 0.0f; this.state = SUMMON_STATE.APPEAR; //Debug.Log("[CLIENT] Summon beast:" + beast_name); } while(false); }
// HP 통지 정보 수신 함수. public void OnReceiveHitPointPacket(int node, PacketId id, byte[] data) { HitPointPacket packet = new HitPointPacket(data); HpData hpData = packet.GetPacket(); //Debug.Log("[CLIENT] Receive hitpoint packet:" + hpData.characterId); chrBehaviorBase behavior = findCharacter <chrBehaviorBase>(hpData.characterId); if (behavior == null) { return; } chrController controller = behavior.control; if (controller == null) { return; } if (controller.global_index < 0) { return; } //string log = "[CLIENT] Set HP:" + hpData.characterId + " HP:" + hpData.hp; //Debug.Log(log); // 캐릭터의 HP 반영. controller.setHitPoint(hpData.hp); }
public void OnReceiveUseItemPacket(int node, PacketId id, byte[] data) { ItemUsePacket packet = new ItemUsePacket(data); ItemUseData useData = packet.GetPacket(); Debug.Log("Receive UseItemPacket:" + useData.userId + " -> " + useData.targetId + " (" + useData.itemCategory + ")"); chrController user = CharacterRoot.getInstance().findPlayer(useData.userId); AccountData account_data = AccountManager.get().getAccountData(GlobalParam.getInstance().global_account_id); if (user != null && account_data.avator_id != useData.userId) { Debug.Log("use item. favor:" + useData.itemFavor); Item.Favor favor = new Item.Favor(); favor.category = (Item.CATEGORY)useData.itemCategory; this.useItem(-1, favor, useData.userId, useData.targetId, false); } else { Debug.Log("Receive packet is already done."); } }
public static BulletShooter createShooter(chrController chr, SHOT_TYPE type) { BulletShooter bullet_shooter = null; switch(type) { case SHOT_TYPE.EMPTY: { bullet_shooter = chr.gameObject.AddComponent<BulletShooter>(); } break; case SHOT_TYPE.NEGI: { bullet_shooter = chr.gameObject.AddComponent<BulletShooter_negi>(); } break; case SHOT_TYPE.YUZU: { bullet_shooter = chr.gameObject.AddComponent<BulletShooter_yuzu>(); } break; } bullet_shooter.player = chr; return(bullet_shooter); }
public static BulletShooter createShooter(chrController chr, SHOT_TYPE type) { BulletShooter bullet_shooter = null; switch (type) { case SHOT_TYPE.EMPTY: { bullet_shooter = chr.gameObject.AddComponent <BulletShooter>(); } break; case SHOT_TYPE.NEGI: { bullet_shooter = chr.gameObject.AddComponent <BulletShooter_negi>(); } break; case SHOT_TYPE.YUZU: { bullet_shooter = chr.gameObject.AddComponent <BulletShooter_yuzu>(); } break; } bullet_shooter.player = chr; return(bullet_shooter); }
// 상대가 공격할 수 있는 범위에 있는가?. public bool isInAttackRange(chrController target) { bool ret = false; do { chrController mine = this.control; Vector3 to_enemy = target.getPosition() - mine.getPosition(); to_enemy.y = 0.0f; if (to_enemy.magnitude >= mine.vital.getAttackDistance()) { break; } to_enemy.Normalize(); Vector3 heading = Quaternion.AngleAxis(mine.getDirection(), Vector3.up) * Vector3.forward; heading.y = 0.0f; heading.Normalize(); float dp = Vector3.Dot(to_enemy, heading); if (dp < Mathf.Cos(Mathf.PI / 4.0f)) { break; } ret = true; } while(false); return(ret); }
public void OnReceiveAttackPacket(int node, PacketId id, byte[] data) { AttackPacket packet = new AttackPacket(data); AttackData attack = packet.GetPacket(); //Debug.Log("[CLIENT] Receive Attack packet:" + attack.characterId); chrController controller = findPlayer(attack.characterId); if (controller == null) { return; } // 캐릭터 좌표 보간. chrBehaviorNet behavior = controller.behavior as chrBehaviorNet; if (behavior != null) { if (attack.attackKind == 0) { behavior.cmdShotAttack(); } else { behavior.cmdMeleeAttack(); } } }
public void runAllExperiments() { if (agent == null || endPoint == Vector3.zero) { EditorUtility.DisplayDialog("Error", "Missing either the start point or end point", "ok"); return; } charC = agent.GetComponent <chrController>(); charC.endVector = endPoint; charC.startVector = charC.transform.localPosition; charC.obstacles = new List <Vector3>(obstacleList); charC.dynamicObstacles = new List <Vector3>(dobsList); Toggle useAvoidance = GameObject.Find("Toggle").GetComponent <Toggle>(); Toggle isoptimalcheck = GameObject.Find("AstarToggle").GetComponent <Toggle>(); if (isoptimalcheck.isOn) { foreach (Vector3 v in dobsList) { charC.obstacles.Add(v); } } charC.avoidance = useAvoidance.isOn; charC.runAll(); }
// 아바타 이름으로 플레이어 캐릭터를 찾는다. public chrController findPlayer(string avator_id) { GameObject[] charactors = GameObject.FindGameObjectsWithTag("Player"); chrController charactor = null; foreach (GameObject go in charactors) { chrController chr = go.GetComponent <chrController>(); if (chr.global_index < 0) { break; } AccountData account_data = AccountManager.get().getAccountData(chr.global_index); if (account_data.avator_id == avator_id) { charactor = chr; break; } } return(charactor); }
// 적 캐릭터를 만든다. public chrController createEnemy(string chr_name) { string behavior_class_name = "chrBehavior" + chr_name; chrController chr_control = this.create_chr_common(chr_name, "", behavior_class_name); return(chr_control); }
// 적 캐릭터 제네레이터를 만든다. public chrController createEnemyLair() { chrController enemy = CharacterRoot.getInstance().createEnemy("EnemyLairMinato"); this.enemies.Add(enemy); return(enemy); }
// 적 캐릭터를 만든다. public chrController createEnemy(string chr_name, string controller_class_name, string behavior_class_name) { chrController enemy = CharacterRoot.getInstance().createEnemy(chr_name, controller_class_name, behavior_class_name); this.enemies.Add(enemy); return(enemy); }
// 적 캐릭터를 만든다. public chrController createEnemy(string enemy_name) { chrController enemy = CharacterRoot.getInstance().createEnemy(enemy_name); this.enemies.Add(enemy); return(enemy); }
// ================================================================ // #if false // 적 캐릭터를 만든다. public chrController createEnemy() { // 일시적으로 항구 버전の적 캐릭터를 생성하도록 변경. // chrController enemy = CharacterRoot.getInstance().createEnemy("Enemy1"); chrController enemy = CharacterRoot.getInstance().createEnemy("EnemyMinato"); this.enemies.Add(enemy); return(enemy); }
// 로컬 플레이어의 캐릭터를 만든다. public chrController createPlayerAsLocal(string chr_name) { chrController chr_control = this.create_chr_common(chr_name, "chrBehaviorLocal"); CameraControl.getInstance().setPlayer(chr_control); this.player = chr_control; return(chr_control); }
// 트리거에 충돌한 순간만 호출되는 메소드. void OnTriggerEnter(Collider other) { // 이벤트 박스에 들어간 플레이어를 리스트에 추가한다. do { if (other.tag != "Player") { break; } chrController player = other.gameObject.GetComponent <chrController>(); if (player == null) { break; } if (player.local_index < 0) { break; } if (this.entered_players.Contains(player.local_index)) { break; } this.entered_players.Add(player.local_index); // 게임 서버에 알림. if (this.step.get_current() == STEP.WAIT_ENTER && player.global_index == GlobalParam.get().global_account_id) { CharDoorState door = new CharDoorState(); door.globalId = player.global_index; door.keyId = (this.keyItemName != null)? this.keyItemName : "NONE"; door.isInTrigger = true; door.hasKey = (this.keyItemName != null)? PartyControl.getInstance().hasKey(player.local_index, door.keyId) : true; string log = "DoorId:" + door.keyId + " trigger:" + door.isInTrigger + " hasKey:" + door.hasKey; Debug.Log(log); DoorPacket packet = new DoorPacket(door); if (m_network != null) { int server_node = m_network.GetServerNode(); m_network.SendReliable <CharDoorState>(server_node, packet); } else { PartyControl.get().cmdMoveRoom(door.keyId); } } } while(false); }
// 적이 삭제되기 직전에 (chrBehaviorEnemy.deleteSelf)호출. public void onDeleteEnemy(RoomController room, chrController enemy) { Room level_room = this.rooms[room.getIndex().x, room.getIndex().z]; chrBehaviorEnemy_Lair as_lair = enemy.behavior as chrBehaviorEnemy_Lair; if (as_lair != null) { level_room.lairs.Remove(as_lair); } level_room.enemies.Remove(enemy); }
public void charRunAStar() { // Get the class object in chrController charC = agent.GetComponent <chrController>(); charC.endVector = endPoint; // Create a clone so that references aren't copied when mixed charC.obstacles = new List <Vector3>(obstacleList); charC.dynamicObstacles = new List <Vector3>(dobsList); //charC.agentState = chrController.state.moving; }
// 트리거로부터 뭔가가 부딪힌 순간만 호출되는 메소드. void OnTriggerExit(Collider other) { // 이벤트 박스에서 나온 플레이어를 리스트에서 제거. do { if (other.tag != "Player") { break; } chrController player = other.gameObject.GetComponent <chrController>(); if (player == null) { break; } if (!this.entered_players.Contains(player.local_index)) { break; } this.entered_players.Remove(player.local_index); // 게임 서버에 알림. if (player.global_index == GlobalParam.get().global_account_id) { CharDoorState door = new CharDoorState(); door.globalId = player.global_index; door.keyId = (this.keyItemName != null)? this.keyItemName : "NONE"; door.isInTrigger = false; door.hasKey = PartyControl.getInstance().hasKey(player.local_index, door.keyId); string log = "DoorId:" + door.keyId + " trigger:" + door.isInTrigger + " hasKey:" + door.hasKey; Debug.Log(log); DoorPacket packet = new DoorPacket(door); if (m_network != null) { int serer_node = m_network.GetServerNode(); m_network.SendReliable <CharDoorState>(serer_node, packet); } else { PartyControl.get().clearDoorState(door.keyId); } } } while(false); }
// 캐릭터를 만듭니다. protected void create_character(string[] words, string local_account, string net_account, bool create_npc) { string chr_name = words[0]; chr_name = chr_name.Remove(0, "ChrModel_".Length); chrController chr = null; Vector3 pos; float direction; if (chr_name == local_account) { chr = CharacterRoot.getInstance().createPlayerAsLocal(chr_name); } else if (chr_name == net_account) { if (create_npc) { chr = CharacterRoot.getInstance().createPlayerAsNet(chr_name); } } else { chr = CharacterRoot.getInstance().createNPC(chr_name); } if (chr != null) { pos.x = float.Parse(words[1]); pos.y = 0.0f; pos.z = float.Parse(words[2]); if (words.Length >= 4) { direction = float.Parse(words[3]); } else { direction = 0.0f; } chr.cmdSetPosition(pos); chr.cmdSetDirection(direction); } }
// 캐릭터를 찾습니다. public T findCharacter <T>(string name) where T : chrBehaviorBase { T behavior = null; do { chrController character = this.findCharacter(name); if (character == null) { break; } behavior = character.behavior as T; } while(false); return(behavior); }
public void OnReceiveMovingPacket(PacketId id, byte[] data) { Debug.Log("OnReceiveMovingPacket"); MovingPacket packet = new MovingPacket(data); MovingData moving = packet.GetPacket(); Debug.Log("[CharId]" + moving.characterId); Debug.Log("[HouseName]" + moving.houseId); Debug.Log("[Moving]" + moving.moving); chrController remote = CharacterRoot.get().findCharacter(moving.characterId); // 이사 쿼리 발행. if (remote != null) { if (moving.moving) { Debug.Log("cmdQueryHouseMoveStart"); QueryHouseMoveStart query = remote.cmdQueryHouseMoveStart(moving.houseId, false); if (query != null) { query.set_done(true); query.set_success(true); } } else { Debug.Log("cmdQueryHouseMoveEnd"); QueryHouseMoveEnd query = remote.cmdQueryHouseMoveEnd(false); if (query != null) { query.set_done(true); query.set_success(true); } } } // 이사 정보 보존. GlobalParam.get().remote_moving = moving; }
// ---------------------------------------------------------------- // public void OnReceiveCharacterPacket(int node, PacketId id, byte[] data) { CharacterDataPacket packet = new CharacterDataPacket(data); CharacterData charData = packet.GetPacket(); chrController controller = findPlayer(charData.characterId); if (controller == null) { return; } // 캐릭터 좌표 보간. chrBehaviorNet behavior = controller.behavior as chrBehaviorNet; if (behavior != null) { behavior.CalcCoordinates(charData.index, charData.coordinates); } }
// 아이템을 사용했다(동려가 자신에게). // // in: friend 아이템을 사용한 동료. // public void onUseItemByFriend(Item.Favor favor, chrController friend) { // 이 부분은 실제로 아이템을 사용할 때 아이템 매니저에서. // 호출되는 메소드다. var player = this.behavior as chrBehaviorPlayer; switch (favor.category) { case Item.CATEGORY.SODA_ICE: { //this.vital.healFull(); if (player != null) { player.onUseItemByFriend(favor, friend.behavior as chrBehaviorPlayer); } } break; } }
// 캐릭터를 찾습니다. public chrController findCharacter(string name) { chrController character = null; do { GameObject[] characters = GameObject.FindGameObjectsWithTag("Charactor"); if (characters.Length == 0) { break; } GameObject go; go = System.Array.Find(characters, x => x.name == name); if (go == null) { break; } character = go.GetComponent <chrController>(); if (character == null) { Debug.Log("Cannot find character:" + name); go = GameObject.Find(name); if (go != null) { break; } character = go.GetComponent <chrController>(); } } while(false); return(character); }
// ================================================================ // // GameObject에 추가된 비헤이비어를 가져옵니다. public static T getBehaviorFromGameObject <T>(GameObject go) where T : chrBehaviorBase { T behavior = null; do { chrController control = go.GetComponent <chrController>(); if (control == null) { continue; } behavior = control.behavior as T; if (behavior == null) { continue; } } while(false); return(behavior); }
public void OnReceiveChatMessage(int node, PacketId id, byte[] data) { Debug.Log("OnReceiveChatMessage"); ChatPacket packet = new ChatPacket(data); ChatMessage chat = packet.GetPacket(); Debug.Log("[CharId]" + chat.characterId); Debug.Log("[CharMsg]" + chat.message); chrController controller = findPlayer(chat.characterId); // 채팅 메시지 표시 쿼리 발행. if (controller != null) { QueryTalk talk = queryTalk(chat.characterId, chat.message, false); if (talk != null) { talk.set_done(true); talk.set_success(true); } } }
public void OnReceiveChatMessage(PacketId id, byte[] data) { Debug.Log("OnReceiveChatMessage"); ChatPacket packet = new ChatPacket(data); ChatMessage chat = packet.GetPacket(); Debug.Log("{CharId]" + chat.characterId); Debug.Log("[CharMsg]" + chat.message); chrController remote = CharacterRoot.get().findCharacter(chat.characterId); // 채팅 메시지 표시 쿼리 발행. if (remote != null) { QueryTalk talk = remote.cmdQueryTalk(chat.message); if (talk != null) { talk.set_done(true); talk.set_success(true); } } }
// 아이템 사용. public void useItem(int slot_index, Item.Favor item_favor, string user_name, string target_name, bool is_local) { do { chrController user = CharacterRoot.getInstance().findPlayer(user_name); if (user == null) { break; } chrController target = CharacterRoot.getInstance().findPlayer(target_name); if (target == null) { break; } // if (user_name == PartyControl.get().getLocalPlayer().getAcountID()) { user.onUseItemSelf(slot_index, item_favor); } else { target.onUseItemByFriend(item_favor, user); } // 아이템 사용을 알림. if (is_local) { SendItemUseData(item_favor, user_name, target_name); } } while(false); }
public override void execute() { BasicAction basic_action = this.behavior.basic_action; if (this.finish_child()) { this.step.set_next(STEP.MOVE); } // ---------------------------------------------------------------- // // 다음 상태로 전환할지 체크합니다. switch (this.step.do_transition()) { // 걷는 중. case STEP.MOVE: { } break; // 멈춤. case STEP.REST: { if (this.step.get_time() > 1.0f) { this.step.set_next(STEP.MOVE); } chrBehaviorLocal player = PartyControl.get().getLocalPlayer(); if (this.behavior.isInAttackRange(player.control)) { this.push(this.melee_attack); this.step.sleep(); } } break; } // ---------------------------------------------------------------- // // 상태가 전환됐을 때의 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { // 걷는 중. case STEP.MOVE: { } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // 걷는 중. case STEP.MOVE: { var coli = basic_action.control.collision_results.Find(x => x.object1.tag == "Wall" || x.object1.tag == "Player"); // 벽(또는 플레이어)에 부딪히면 반사해서 방향을 바꿉니다. do { if (coli == null) { break; } if (coli.option0 == null) { break; } ContactPoint cp = (ContactPoint)coli.option0; // 벽의 법선 방향을 90도 단위로 합니다. Vector3 normal = cp.normal; float normal_angle = Mathf.Atan2(normal.x, normal.z) * Mathf.Rad2Deg; normal_angle = MathUtility.unormDegree(normal_angle); normal_angle = Mathf.Round(normal_angle / 90.0f) * 90.0f; normal = Quaternion.AngleAxis(normal_angle, Vector3.up) * Vector3.forward; Vector3 v = basic_action.getMoveVector(); if (Vector3.Dot(v, normal) >= 0.0f) { break; } v -= 2.0f * Vector3.Dot(v, normal) * normal; basic_action.setMoveDirByVector(v); // 플레이어에게 부딪혔으면 대미지를 줍니다. do { if (coli.object1.tag != "Player") { break; } chrController chr = coli.object1.GetComponent <chrController>(); if (chr == null) { break; } if (!(chr.behavior is chrBehaviorLocal)) { break; } chr.causeDamage(this.control.vital.getAttackPower(), -1); } while(false); } while(false); basic_action.setMoveSpeed(4.0f); basic_action.setMoveMotionSpeed(0.0f); basic_action.executeMove(); // this.model.transform.Rotate(new Vector3(7.0f, 0.0f, 0.0f)); } break; // 멈춤. case STEP.REST: { basic_action.setMoveMotionSpeed(0.0f); } break; } // ---------------------------------------------------------------- // this.execute_child(); }
void Update() { this.scene_timer += Time.deltaTime; this.disp_timer -= Time.deltaTime; // ---------------------------------------------------------------- // // 다음 상태로 이동할지 체크합니다. switch(this.step.do_transition()) { case STEP.GAME: { } break; } // ---------------------------------------------------------------- // // 상태가 전환될 때 초기화. while(this.step.get_next() != STEP.NONE) { switch(this.step.do_initialize()) { case STEP.CHARACTER_CHANGE: { GlobalParam.get().account_name = this.account_name_net; GlobalParam.get().skip_enter_event = true; Application.LoadLevel("GameScene 1"); } break; case STEP.GAME: { this.account_name_local = GlobalParam.get().account_name; this.account_name_net = GameRoot.getPartnerAcountName(this.account_name_local); if(this.owner == this.account_name_local) { this.is_host = true; } else { // 다른 플레이어의 마을에 갔을 때. this.is_host = false; } // 플레이어를 만듭니다. this.local_player = CharacterRoot.get().createPlayerAsLocal(this.account_name_local); this.local_player.cmdSetPosition(Vector3.zero); if(GlobalParam.get().is_in_my_home == GlobalParam.get().is_remote_in_my_home) { this.net_player = CharacterRoot.get().createPlayerAsNet(this.account_name_net); this.net_player.cmdSetPosition(Vector3.left*1.0f); } // 레벨 데이터(level_data.txt)를 읽고 NPC/아이템을 배치합니다. MapCreator.get().loadLevel(this.account_name_local, this.account_name_net, !this.is_host); SoundManager.get().playBGM(Sound.ID.TFT_BGM01); // if(!GlobalParam.get().skip_enter_event) { EnterEvent enter_event = EventRoot.get().startEvent<EnterEvent>(); if(enter_event != null) { enter_event.setPrincipal(this.local_player.behavior as chrBehaviorPlayer); enter_event.setIsLocalPlayer(true); } } foreach (ItemManager.ItemState istate in GlobalParam.get().item_table.Values) { if (istate.state == ItemController.State.Picked) { // 이미 아이템을 획득했다면 가져갈 수 있게 합니다. ItemManager.get().finishGrowingItem(istate.item_id); chrController controll = CharacterRoot.getInstance().findPlayer(istate.owner); if (controll != null) { QueryItemPick query = controll.cmdItemQueryPick(istate.item_id, false, true); if (query != null) { query.is_anon = true; query.set_done(true); query.set_success(true); } } } } } break; // 다른 플레이어가 찾아왔습니다. case STEP.WELCOME: { if(this.net_player == null) { EnterEvent enter_event = EventRoot.get().startEvent<EnterEvent>(); if(enter_event != null) { this.net_player = CharacterRoot.getInstance().createPlayerAsNet(this.account_name_net); this.net_player.cmdSetPosition(Vector3.left); enter_event.setPrincipal(this.net_player.behavior as chrBehaviorPlayer); enter_event.setIsLocalPlayer(false); } } } break; // 다른 플레이어가 돌아갑니다. case STEP.BYEBYE: { if(this.net_player != null) { LeaveEvent leave_event = EventRoot.get().startEvent<LeaveEvent>(); if(leave_event != null) { leave_event.setPrincipal(this.net_player.behavior as chrBehaviorPlayer); leave_event.setIsLocalPlayer(false); } } } break; case STEP.VISIT: { GlobalParam.get().is_in_my_home = false; Application.LoadLevel("GameScene 1"); } break; case STEP.GO_HOME: { // 자기 마을로 돌아옵니다. GlobalParam.get().is_in_my_home = true; Application.LoadLevel("GameScene 1"); } break; case STEP.TO_TITLE: { Application.LoadLevel("TitleScene"); } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch(this.step.do_execution(Time.deltaTime)) { case STEP.GAME: { } break; } // ---------------------------------------------------------------- // // 통신에 의한 이벤트 처리. // Network 클래스의 컴포넌트 획득. GameObject go = GameObject.Find("Network"); Network network = go.GetComponent<Network>(); if (network != null) { if (network.IsCommunicating() == true) { if (request_connet_event) { // 접속 이벤트를 발동합니다. GlobalParam.get().is_connected = true; request_connet_event = false; } else if (GlobalParam.get().is_connected == false) { // 접속했습니다. Debug.Log("Guest connected."); request_connet_event = true; disp_timer = 5.0f; } } } // 접속 종료 이벤트를 발동합니다. if (request_disconnet_event) { GlobalParam.get().is_disconnected = true; request_disconnet_event = false; // 접속 종료 시 이벤트. disconnect_event(); } // ---------------------------------------------------------------- // if(Input.GetKeyDown(KeyCode.Z)) { dbwin.console().print("로그 테스트 " + this.log_test_count); this.log_test_count++; } }
// 다른 캐릭터에 터치되었을 때(옆에서 클릭)호출됩니다. public virtual void touchedBy(chrController toucher) { }
/*public void parallelMoveByInterst(Vector3 interest) { Vector3 eye_vector = this.calcGroundLevelInterest() - this.transform.position; this.transform.position = interest - eye_vector; }*/ // ================================================================ // // 로컬 플레이어 설정. public void setPlayer(chrController player) { this.player = player; }
// ================================================================ // // MonoBehaviour에서 상속. void Start() { this.player = this.GetComponent<chrController>(); }
// 적 캐릭터를 삭제한다. public void deleteEnemy(chrController enemy) { this.enemies.Remove(enemy); GameObject.Destroy(enemy.gameObject); }
// 아이템을 사용했다(동려가 자신에게). // // in: friend 아이템을 사용한 동료. // public void onUseItemByFriend(Item.Favor favor, chrController friend) { // 이 부분은 실제로 아이템을 사용할 때 아이템 매니저에서. // 호출되는 메소드다. var player = this.behavior as chrBehaviorPlayer; switch(favor.category) { case Item.CATEGORY.SODA_ICE: { //this.vital.healFull(); if(player != null) { player.onUseItemByFriend(favor, friend.behavior as chrBehaviorPlayer); } } break; } }
// ================================================================ // // 생성합니다. public virtual void create(chrBehaviorEnemy behavior, ActionBase.DescBase desc_base = null) { this.behavior = behavior; this.control = behavior.control; }
// ================================================================ // public ItemCarrier(chrController character) { this.character = character; }
// 상대가 공격할 수 있는 범위에 있는가?. public bool isInAttackRange(chrController target) { bool ret = false; do { chrController mine = this.control; Vector3 to_enemy = target.getPosition() - mine.getPosition(); to_enemy.y = 0.0f; if(to_enemy.magnitude >= mine.vital.getAttackDistance()) { break; } to_enemy.Normalize(); Vector3 heading = Quaternion.AngleAxis(mine.getDirection(), Vector3.up)*Vector3.forward; heading.y = 0.0f; heading.Normalize(); float dp = Vector3.Dot(to_enemy, heading); if(dp < Mathf.Cos(Mathf.PI/4.0f)) { break; } ret = true; } while(false); return(ret); }