Beispiel #1
0
        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);
        }
Beispiel #2
0
    // 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();
        }
    }
Beispiel #3
0
 public void Initialize(AIPathfinder pathfinder)
 {
     pathfinder._walkSpeed      = walkSpeed;
     pathfinder._rotationSpeed  = rotationSpeed;
     pathfinder._angleFOV       = angleFOV;
     pathfinder._angleRotation  = angleRotation;
     pathfinder._targetPosition = GameObject.FindWithTag("ChristmasTree").transform;
 }
Beispiel #4
0
 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();
     }
 }
Beispiel #5
0
    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();
 }
Beispiel #7
0
		public AIBehaviourFollowPath(){
            pathFinder = new AIPathfinder();
            tolerance = 2.0f;   // by default the tolerance when following path 
                                // is 1 meter each side

		}