public TestGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; this.graphics.PreferredBackBufferWidth = 640; this.graphics.PreferredBackBufferHeight = 480; // Game should run as fast as possible. IsFixedTimeStep = true; graphics.SynchronizeWithVerticalRetrace = true; aiEngine = new AIEngine((Game)this); this.Components.Add(aiEngine); AIWorld newWorld = new DrawableAIWorld(); aiEngine.AddWorld(ref newWorld); pathFinder = new AIPathfinder(); sEngine = new SEngine((Game)this, graphics); //this.Components.Add(sEngine); }
// Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.A)) { if (m_Tester == null) { m_Tester = (GameObject)GameObject.Instantiate((Object)m_AIPather); m_Tester.name = "_AITester"; m_Pather = m_Tester.GetComponent<AIPathfinder>(); m_Pather.m_Unit = GameObject.Find("TestUnit"); m_Pather.m_Target = GameObject.Find("TestTarget"); } } else if (Input.GetKey(KeyCode.B) && m_Path.Count == 0) { if(m_Pather.Step()) { m_Path = m_Pather.GetPath(); } } else if(Input.GetKeyUp(KeyCode.C)) { m_Pather.CleanPath(); } }
public void Initialize(AIPathfinder pathfinder) { pathfinder._walkSpeed = walkSpeed; pathfinder._rotationSpeed = rotationSpeed; pathfinder._angleFOV = angleFOV; pathfinder._angleRotation = angleRotation; pathfinder._targetPosition = GameObject.FindWithTag("ChristmasTree").transform; }
private void Awake() { aiPathfinder = GetComponent <AIPathfinder>(); healthBar = GetComponentInChildren <HealthBar>(); fieldOfView = GetComponentInChildren <FieldOfView>(); rb = GetComponent <Rigidbody2D>(); if (maxHealth <= 0f || aiPathfinder == null || healthBar == null || fieldOfView == null || rb == null) { Debug.Log("Error during unit initialization : " + gameObject.name); Die(); } }
public void MakeNewAction() { // never change direction mid-jump if (m_pawn.IsJumping()) { return; } var hotspot = m_heatmap.GetNextHotspot(); m_farTarget = hotspot.pos; m_action = hotspot.action; m_path = AIPathfinder.Pathfind(m_pawn.GetMapPos(), m_farTarget); }
public AIBehaviourFindPath() { pathfinder = new AIPathfinder(); }
public AIBehaviourFollowPath(){ pathFinder = new AIPathfinder(); tolerance = 2.0f; // by default the tolerance when following path // is 1 meter each side }