List <IntVector2D> PlanPathToLocForAvatar(IntVector2D goalPos, Char2D avatar, bool sendThereIfPossible) { List <IntVector2D> list = null; PlaneOrientation orientation = avatar.Orientation; if (WorldManager.g.IsInBounds2D(goalPos, orientation)) { IntVector2D lastLoc = avatar.Location; list = WorldManager.g.PlanPath(avatar, lastLoc, goalPos); if (list != null) { for (int i = list.Count - 1; i >= 0; i--) { IntVector2D nextLoc = list[i]; Vector3 a = WorldManager.g.WorldPosFromIntVec(lastLoc, orientation); Vector3 b = WorldManager.g.WorldPosFromIntVec(nextLoc, orientation); Debug.DrawLine(a, b, Color.red); lastLoc = nextLoc; } if (sendThereIfPossible) { avatar.DesiredPath = list; } } else { // Debug.Log("NO VALID PATH FOR "+orientation.ToString()+"!"); } } return(list); }
// Adapted From http://stackoverflow.com/questions/10983110/a-star-a-and-generic-find-method public List <IntVector2D> PlanPath(Char2D entity, IntVector2D start, IntVector2D destination) { PlaneOrientation orientation = entity.Orientation; List <IntVector2D> relativeLocations = entity.AbsoluteLocations(new IntVector2D(0, 0)); var closed = new HashSet <IntVector2D>(); var queue = new PriorityQueue <Path <IntVector2D>, float>(); queue.Enqueue(new Path <IntVector2D>(start), 0f); while (!queue.IsEmpty) { var path = queue.Dequeue(); if (closed.Contains(path.LastStep)) { continue; } if (path.LastStep == destination) { return(path.AsList); } IntVector2D leafNode = path.LastStep; closed.Add(leafNode); List <IntVector2D> neighbors = ConnectedNodesForRelativeLocations(relativeLocations, leafNode, orientation); for (int i = 0; i < neighbors.Count; i++) { IntVector2D n = neighbors[i]; float stepCost = CostBetween(path.LastStep, n); var newPath = path.AddStep(n, stepCost); queue.Enqueue(newPath, newPath.TotalCost + HeuristicCostEstimate(n, destination)); } } return(null); }
public void Init(GameObject player) { Hideall(); Show("Ui_play", true); GameObject ui = null; Ui_base uiBase = null; for (int i = 0; i < _uiList.Length; i++) { ui = _uiList[i]; uiBase = ui.GetComponent <Ui_base>(); uiBase.Init(); } _joystick.Init(); _rjoystick.Init(); _rjoystick.gameObject.SetActive(true); _joystick.gameObject.SetActive(false); _raycaster = GetComponent <GraphicRaycaster>(); _Char = player.GetComponent <Char2D>(); }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.name == "player") { Char2D myChar2D = FindObjectOfType <Char2D>(); myChar2D.OnDamage(_attack); //피격 이펙트 } }
public virtual void Init(Enemy owner) { _owner = owner; _con = _owner.GetComponent <Sentry_controller>(); _anim = owner.GetComponent <Animator>(); //owner의 Animator를 가져옴 GameObject playerObj = GameManager.Instance._player; _player = playerObj.GetComponent <Char2D>(); Debug.Log("스테이트 초기화 :" + GetType().ToString()); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.name == "player") { Char2D character = collision.gameObject.GetComponent <Char2D>(); character.Ondie(); Rigidbody2D rigid = collision.gameObject.GetComponent <Rigidbody2D>(); rigid.bodyType = RigidbodyType2D.Static; } }
public void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.name == "playe") { Char2D playerChar = FindObjectOfType <Char2D>(); playerChar.OnDamage(_data._attack); GameObject effectGo = Instantiate(_effectPrefab); Vector3 charPos = playerChar.transform.position; effectGo.transform.position = new Vector3(charPos.x, charPos.y, charPos.z); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.name == "player") { if (collision is CircleCollider2D) { return; } { Char2D player = collision.gameObject.GetComponent <Char2D>(); player.OnDamage(1); } } }
public void ResPawn() { GameObject spawnPoint = _startPointList[_curStage - 1]; Vector3 newpos = spawnPoint.transform.position; Vector3 charpos = _player.transform.position; _player.transform.position = new Vector3(newpos.x, newpos.y, charpos.z); Char2D playerCher = _player.GetComponent <Char2D>(); playerCher.InitHP(); // playerChar. uiManager.Instance.Show("Ui_play", true); Rigidbody2D rigid = _player.GetComponent <Rigidbody2D>(); rigid.bodyType = RigidbodyType2D.Dynamic; }
public void Init(GameObject player) { _player = player.GetComponent <Char2D>(); _con = player.GetComponent <control>(); }
// Start is called before the first frame update void Start() { character = GetComponent <Char2D>(); startPos = transform.position; currentDirection = startDirection; }