void updatePath() { int x = Mathf.RoundToInt(m_pacman.transform.position.x); int y = Mathf.RoundToInt(m_pacman.transform.position.y); var dir = (new Vector2(transform.position.x, transform.position.y) - new Vector2(x, y)) * m_fleeDIstance; int newX = Mathf.RoundToInt(transform.position.x + dir.x); int newY = Mathf.RoundToInt(transform.position.y + dir.y); m_ghost.setTarget(newX, newY); if (!m_ghost.haveFinishedPath()) { return; } newX = Mathf.RoundToInt(transform.position.x - dir.y); newY = Mathf.RoundToInt(transform.position.y + dir.x); m_ghost.setTarget(newX, newY); if (!m_ghost.haveFinishedPath()) { return; } newX = Mathf.RoundToInt(transform.position.x + dir.y); newY = Mathf.RoundToInt(transform.position.y - dir.x); m_ghost.setTarget(newX, newY); }
void updateTarget() { m_time = m_updateTime; int x = Mathf.RoundToInt(m_pacman.transform.position.x); int y = Mathf.RoundToInt(m_pacman.transform.position.y); m_ghost.setTarget(x, y); }
void updateTarget() { m_time = m_updateTime; int x = Mathf.RoundToInt(m_pacman.transform.position.x); int y = Mathf.RoundToInt(m_pacman.transform.position.y); var dir = m_pacman.getDirection() * m_backDistance; x -= dir.x; y -= dir.y; m_ghost.setTarget(x, y); }
void updateTarget() { m_time = m_updateTime; int x = Mathf.RoundToInt(m_pacman.transform.position.x); int y = Mathf.RoundToInt(m_pacman.transform.position.y); var gen = new StaticRandomGenerator <DefaultRandomGenerator>(); if (new BernoulliDistribution().Next(gen)) { var dir = new UniformVector2SquareDistribution(m_radius).Next(gen); x = Mathf.RoundToInt(transform.position.x + dir.x); y = Mathf.RoundToInt(transform.position.y + dir.y); } m_ghost.setTarget(x, y); }
protected override void onEnable() { m_ghost.setTarget(m_targetX, m_targetY); }