Exemplo n.º 1
0
        public void Think()
        {
            Enemy          puppet     = (Enemy)base.gameObject.GetComponent <Enemy>();
            NavigatorAgent navigation = (NavigatorAgent)base.gameObject.GetComponent <NavigatorAgent>();

            if (navigation == null)
            {
                Debug.LogError("EnemyAI component needs an navigator agent object");
                return;
            }
            if (puppet == null)
            {
                Debug.LogError("EnemyAI component needs to be a component of an enemy");
                return;
            }
            List <Vec2i> path = navigation.targetPath;

            if (path != null && path.Count != 0)
            {
                SeekMove(path, puppet.OnMove);
            }
            else
            {
                RandomMove(puppet.OnMove);
            }

            return;
        }
Exemplo n.º 2
0
        public void OnDeaggro()
        {
            NavigatorAgent navigator = (NavigatorAgent)this.gameObject.GetComponent <NavigatorAgent>();

            if (navigator != null)
            {
                navigator.Target = null;
            }
            return;
        }
Exemplo n.º 3
0
        public void OnAggro(GameObject target)
        {
            NavigatorAgent navigator = (NavigatorAgent)this.gameObject.GetComponent <NavigatorAgent>();

            if (navigator != null)
            {
                navigator.Target = target.Transform;
            }
            return;
        }
Exemplo n.º 4
0
        private void DebugDrawPath()
        {
            Player player = Player.MainPlayer();

            if (player == null)
            {
                return;
            }
            //Displays the path of the path finder.
#if DEBUG
            NavigatorAgent navigator = (NavigatorAgent)this.gameObject.GetComponent <NavigatorAgent>();
            if (navigator != null)
            {
                List <Vec2i> path = navigator.targetPath;
                if (path != null)
                {
                    Camera camera = Camera.MainCamera();
                    if (camera == null)
                    {
                        return;
                    }
                    int halfWidth  = camera.width / 2;
                    int halfHeight = camera.height / 2;

                    int playerX = player.transform.position.x;
                    int playerY = player.transform.position.y;

                    foreach (Vec2i v in path)
                    {
                        int x = v.x - playerX + halfWidth;
                        int y = v.y - playerY + halfHeight;
                        if (x < camera.width && y < camera.height)
                        {
                            ConsoleUI.Write(x, y, ".", new Color(255, 0, 255));
                        }
                    }
                }
            }
#endif
            return;
        }