public void ExecuteAttack() { GameObject attackObj = DGameSystem.LoadPool(stat.attackObjectName, transform.position); attackObj.transform.rotation = Quaternion.Euler(0, 0, 0); DHitParam hitParam = new DHitParam(); hitParam.dame = current.dame; hitParam.owner = gameObject; hitParam.ownerTag = gameObject.tag; if (gameObject.tag == "Player") { hitParam.direction = GetComponent <DMovement>().Facing; } else { hitParam.target = GetComponent <DFollow>().enemy; hitParam.direction = GetComponent <DFollow>().direction; } attackObj.SendMessage("ReceiveParam", hitParam, SendMessageOptions.DontRequireReceiver); }
public IEnumerator WildPokemonAppear() { rb2d.velocity = Vector2.zero; GetComponent <DControlByJoystick>().enabled = false; GameObject effect = DGameSystem.LoadPool("BlackScreenEffect", transform.position); effect.transform.SetParent(DGameSystem.cameraMain.transform); yield return(new WaitForSeconds(2)); //DGameSystem.SwitchControlToPokemon(); DGameSystem.pokemonControl.SetActive(true); DGameSystem.cameraScript.MoveTo(DGameSystem.pokemonEnemy.transform); DGameSystem.cameraScript.target = DGameSystem.pokemonEnemy; DScriptDialog dialog = new DScriptDialog(); dialog.sentences = new List <string> { "A wild pokemon appeared!" }; DGamePauser.StartScripts(new DScriptDialog[] { dialog }); yield return(new WaitForSeconds(2)); dialog = new DScriptDialog(); dialog.sentences = new List <string> { "Go my pokemon!" }; DGamePauser.StartScripts(new DScriptDialog[] { dialog }); DGameSystem.cameraScript.target = DGameSystem.pokemonControl; yield return(new WaitForSeconds(1)); DGamePauser.state = DGamePauser.STATE.FREE; }
void UpdatePool() { if (DGameSystem.player == null) { return; } List <int> seen = new List <int>(); List <int> unseen = new List <int>(); for (int i = 0; i < mapObjects.Count; i++) { if (Vector3.Distance(mapObjects[i].position, DGameSystem.player.transform.position) < SEEN_RANGE) { seen.Add(i); } else { unseen.Add(i); } } // Scan poolIndexs để biết được object nào seen, object nào unseen for (int i = 0; i < poolIndexs.Count; i++) { if (seen.Contains(poolIndexs[i])) { poolSeens[i] = "seen"; } else { poolSeens[i] = "unseen"; } } for (int i = 0; i < seen.Count; i++) { // Nếu poolIndexs không chứa seen[i] (xuất hiện mới), tìm trong unseen object có name tương tự // để change vị trí cho vật xuất hiện mới // Trường hợp không tìm thấy thì tạo object mới và thêm vào pool if (!poolIndexs.Contains(seen[i])) { int index = seen[i]; bool found = false; for (int j = 0; j < poolSeens.Count; j++) { if (poolSeens[j] == "unseen" && pools[j].objectName == mapObjects[index].objectName) { pools[j].gameObject.transform.position = mapObjects[index].position; poolSeens[j] = "seen"; poolIndexs[j] = index; found = true; break; } } if (!found) { GameObject obj = DGameSystem.LoadPool(mapObjects[index].objectName, mapObjects[index].position); MapObject mapObj = mapObjects[index]; mapObj.gameObject = obj; pools.Add(mapObj); poolIndexs.Add(index); poolSeens.Add("seen"); } } } }