Beispiel #1
0
    // Use this for initialization
    void Awake()
    {
        this.draw      = false;
        this.navMesh   = NavigationManager.Instance.NavMeshGraphs[0];
        this.character = new DynamicCharacter(this.characterAvatar);
        this.enemies   = new List <DynamicCharacter>();
        for (int i = 0; i < enemiesAvatar.Length; i++)
        {
            DynamicCharacter    enemy    = new DynamicCharacter(this.enemiesAvatar[i]);
            DynamicBackAndForth movement = new DynamicBackAndForth()
            {
                Character       = enemy.KinematicData,
                MaxAcceleration = 10.0f,
                StopRadius      = 2.0f,
                SlowRadius      = 5.0f,
                MoveDistance    = 25.0f
            };
            movement.CalculatePositions();
            enemy.Movement = movement;
            this.enemies.Add(enemy);
        }

        this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanDistanceHeuristic());
        this.aStarPathFinding.NodesPerSearch = 100;
    }
Beispiel #2
0
    private void Start()
    {
        stoppingDistance = GridMap.instance.GetCellRadius() * stoppingDistanceFactor;

        savedPath.AddFirst(GridMap.instance.CellCordFromWorldPoint(transform.position)); // in start is the actual position
        Astar = new AStarPathfinding(AStarPathfinding.UpdateMode.ON_TARGET_OR_ORIGIN_MOVE);
    }
Beispiel #3
0
    /// <summary>
    /// 寻路方法
    /// </summary>
    /// <param name="e">寻路终点</param>
    public void FindPath(Point e)
    {
        Debug.Log("sssss");
        if (pathFinding == true)
        {
            pathTweener.Kill();                      //关闭寻路动画
        }
        Point        s        = new Point((int)player.transform.position.x, (int)player.transform.position.y);
        List <Point> pathList = new List <Point>();

        if (AStarPathfinding.FindPath(s, e, pathList) == false)
        {
            //ani.SetTrigger("Why");
            //AudioManager.Instance.PlayClip(AudioManager.Instance.why);
            return;
        }
        ResetTarget();
        pathFinding = true;
        //AudioManager.Instance.PlayClip(AudioManager.Instance.move);
        //ani.SetBool("Idle", !pathFinding);
        pathTweener = player.transform.DOPath(pathList.ToVector3Array(), pathList.Count * 0.1f); //走动效果 0.1秒执行一次动画
        pathTweener.SetEase(Ease.Linear);                                                        //设置运动曲线(线性)
        pathTweener.onComplete += () => {                                                        //动画完成后回调方法
            pathFinding = false;
            // ani.SetBool("Idle", !pathFinding);
        };
        pathTweener.onKill += () => {  //关闭动画回调
            pathFinding = false;
            //ani.SetBool("Idle", !pathFinding);
        };
    }
Beispiel #4
0
 private void AStarSetup()
 {
     _aStar          = gameObject.GetComponent <AStarPathfinding>();
     _aStar.StartPos = new Vector3Int((int)transform.position.x, (int)transform.position.y, (int)transform.position.z);
     _aStar.GoalPos  = new Vector3Int(Mathf.RoundToInt(Target.transform.position.x), Mathf.RoundToInt(Target.transform.position.y), Mathf.RoundToInt(Target.transform.position.z));
     _targetPos      = _nullVector;           // null value
 }
    private void PollInput()
    {
        Vector2?prevStart = debugStart;
        Vector2?prevEnd   = debugEnd;

        if (Input.GetKey(KeyCode.LeftAlt))
        {
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                debugStart = Utility.MousePositionInWorld;
            }
            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                debugEnd = Utility.MousePositionInWorld;
            }
        }

        if ((prevStart != debugStart || prevEnd != debugEnd)
            &&
            (debugStart.HasValue && debugEnd.HasValue))
        {
            AStarPathfinding.GetRawPath(debugStart.Value, debugEnd.Value, true);

            debugStart = null;
            debugEnd   = null;
        }
    }
 public void Initialize(NavMeshPathGraph navMeshGraph, AStarPathfinding pathfindingAlgorithm)
 {
     this.draw             = true;
     this.navMesh          = navMeshGraph;
     this.AStarPathFinding = pathfindingAlgorithm;
     this.AStarPathFinding.NodesPerSearch = 100;
 }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        this.draw = false;
        this.currentClickNumber = 1;
        this.navMesh            = NavigationManager.Instance.NavMeshGraphs [0];

        this.aStarPathFinding = new AStarPathfinding(this.navMesh, new SimpleUnorderedNodeList(), new SimpleUnorderedNodeList(), new ZeroHeuristic());
    }
Beispiel #8
0
 void Start()
 {
     spriteRenderer   = GetComponent <SpriteRenderer>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     animator         = GetComponent <Animator>();
     playerShip       = GameObject.Find("PlayerShip");
     aStarPathfinding = GetComponent <AStarPathfinding>();
 }
    public void Initialize(NavMeshPathGraph navMeshGraph, AStarPathfinding pathfindingAlgorithm)
    {
        this.draw    = false;
        this.navMesh = navMeshGraph;

        this.AStarPathFinding = pathfindingAlgorithm;
        this.AStarPathFinding.NodesPerFrame = 15;
    }
 public void Initialize(NavMeshPathGraph navMeshGraph, AStarPathfinding pathfindingAlgorithm)
 {
     this.MCTSActive       = true; //change this if you want to try DL-GOAP
     this.draw             = false;
     this.navMesh          = navMeshGraph;
     this.AStarPathFinding = pathfindingAlgorithm;
     this.AStarPathFinding.NodesPerSearch = 100;
 }
Beispiel #11
0
    public override void Start()
    {
        GameManager gm = Object.FindObjectOfType <GameManager>();

        ground = gm.GetComponent <GroundGenerator>();
        aStar  = gm.GetComponent <AStarPathfinding>();

        btree = go.GetComponent <BTreeExecutor>().btRuntime;
    }
Beispiel #12
0
        public void Initialize(NavMeshPathGraph navMeshGraph, AStarPathfinding pathfindingAlgorithm)
        {
            this.draw             = true;
            this.navMesh          = navMeshGraph;
            this.AStarPathFinding = pathfindingAlgorithm;
            this.AStarPathFinding.NodesPerFrame = 100; //it was NodesPerSearch before

            this.characterAnimator = this.GetComponentInChildren <Animator> ();
        }
Beispiel #13
0
 public override void Start()
 {
     gm           = Object.FindObjectOfType <GameManager>();
     ground       = gm.GetComponent <GroundGenerator>();
     aStar        = gm.GetComponent <AStarPathfinding>();
     wanderEditor = editorNode as WanderEditor;
     btree        = go.GetComponent <BTreeExecutor>().btRuntime;
     btree.btRuntimeParams.boolParams["WanderingEnabled"] = true;
 }
Beispiel #14
0
    // Start is called before the first frame update
    #endregion

    void Start()
    {
        vie        = 3;
        pathfinder = GameObject.Find("PathFindAstar").GetComponent <AStarPathfinding>();
        anim       = this.GetComponent <Animator>();
        astargrid  = GameObject.Find("GridAStar").GetComponent <AStarGrid>();
        Player     = GameObject.Find("Heros").transform;
        startTime  = Time.time;
    }
Beispiel #15
0
        public void Initialize(NavMeshPathGraph navMeshGraph, AStarPathfinding pathfindingAlgorithm)
        {
            this.draw                       = true;
            this.navMesh                    = navMeshGraph;
            this.AStarPathfinding           = pathfindingAlgorithm;
            this.AStarPathfinding.NodeLimit = 100;

            this.characterAnimator = this.GetComponentInChildren <Animator> ();
        }
Beispiel #16
0
    // Use this for initialization
    void Awake()
    {
        this.character = new DynamicCharacter(characterAvatar);
        var clusterGraph = Resources.Load <ClusterGraph>("ClusterGraph");

        this.draw             = false;
        this.navMesh          = NavigationManager.Instance.NavMeshGraphs[0];
        this.AStarPathFinding = new NodeArrayAStarPathFinding(NavigationManager.Instance.NavMeshGraphs[0], new GatewayHeuristic(clusterGraph));
        this.AStarPathFinding.NodesPerSearch = 100;
    }
Beispiel #17
0
 void Start()
 {
     animator         = GetComponent <Animator>();
     spriteRenderer   = GetComponent <SpriteRenderer>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     playerShip       = GameObject.Find("PlayerShip");
     animator.enabled = false;
     randomPos        = pickRandPos();
     aStarPathfinding = GetComponent <AStarPathfinding>();
 }
Beispiel #18
0
    // Use this for initialization
    protected virtual void Start()
    {
        enemy           = GetComponent <Enemy>();
        movement        = GetComponent <MoveEnemy>();
        pathfinding     = GetComponent <AStarPathfinding>();
        groupable       = GetComponent <Groupable>();
        playerTransform = GameManager.singleton.Player.transform;

        movement.ReachedPathEnd += Movement_ReachedPathEnd;
    }
        public void Initialize(NavMeshPathGraph navMeshGraph, AStarPathfinding AStarPathFinding)
        {
            this.MCTSActive       = true;
            this.draw             = true;
            this.navMesh          = navMeshGraph;
            this.AStarPathFinding = AStarPathFinding;
            this.AStarPathFinding.NodesPerFrame = 100;

            this.characterAnimator = this.GetComponentInChildren <Animator> ();
        }
Beispiel #20
0
 void Start()
 {
     spriteRenderer   = GetComponent <SpriteRenderer>();
     animator         = GetComponent <Animator>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     animator.enabled = false;
     playerShip       = FindObjectOfType <PlayerScript>().gameObject;
     attackPeriod     = Random.Range(2f, 6f);
     aStarPathfinding = GetComponent <AStarPathfinding>();
 }
Beispiel #21
0
 void Start()
 {
     spriteRenderer   = GetComponent <SpriteRenderer>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     animator         = GetComponent <Animator>();
     playerShip       = GameObject.Find("PlayerShip");
     animator.enabled = false;
     pickSprite(travelAngle);
     aStarPathfinding = GetComponent <AStarPathfinding>();
 }
Beispiel #22
0
    // Use this for initialization
    void Awake()
    {
        this.draw = false;
        this.currentClickNumber = 1;
        this.navMesh            = NavigationManager.Instance.NavMeshGraphs [0];

        this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanHeuristic());
        //this.aStarPathFinding = new AStarPathfinding(this.navMesh, new NodePriorityHeap(), new NodeHashmap(), new EuclideanHeuristic());
        this.aStarPathFinding.NodesPerSearch = 100;
    }
Beispiel #23
0
 private void Start()
 {
     playerShip       = GameObject.Find("PlayerShip");
     spriteRenderer   = GetComponent <SpriteRenderer>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     camera           = Camera.main;
     animator         = GetComponent <Animator>();
     animator.enabled = false;
     aStarPathfinding = GetComponent <AStarPathfinding>();
 }
Beispiel #24
0
    public void Initialize(NavMeshPathGraph navMeshGraph, AStarPathfinding pathfindingAlgorithm)
    {
        this.draw    = false;
        this.navMesh = navMeshGraph;

        this.AStarPathFinding = pathfindingAlgorithm;
        this.AStarPathFinding.NodesPerFrame = 200;

        this.smoothedPath = new GlobalPath();
    }
Beispiel #25
0
 private void Start()
 {
     playerShip       = GameObject.Find("PlayerShip");
     spriteRenderer   = GetComponent <SpriteRenderer>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     animator         = GetComponent <Animator>();
     animator.enabled = false;
     moveTimer        = Random.Range(-1f, 0f);
     aStarPathfinding = GetComponent <AStarPathfinding>();
 }
Beispiel #26
0
 void Start()
 {
     hitBox           = GetComponent <BoxCollider2D>();
     spriteRenderer   = GetComponent <SpriteRenderer>();
     animator         = GetComponent <Animator>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     animator.enabled = false;
     playerShip       = PlayerProperties.playerShip;
     damageHitBox.SetActive(false);
     aStarPathFinding = GetComponent <AStarPathfinding>();
 }
Beispiel #27
0
 void Start()
 {
     spriteRenderer   = GetComponent <SpriteRenderer>();
     animator         = GetComponent <Animator>();
     boxCol           = GetComponent <BoxCollider2D>();
     playerShip       = GameObject.Find("PlayerShip");
     rigidBody2D      = GetComponent <Rigidbody2D>();
     aStarPathFinding = GetComponent <AStarPathfinding>();
     animator.enabled = false;
     targetPosition   = pickRandPos();
     offset           = Random.Range(0, 2) * 30;
 }
Beispiel #28
0
 void Start()
 {
     animator         = GetComponent <Animator>();
     spriteRenderer   = GetComponent <SpriteRenderer>();
     rigidBody2D      = GetComponent <Rigidbody2D>();
     playerShip       = GameObject.Find("PlayerShip");
     animator.enabled = false;
     randomPos        = transform.position;
     movePeriod       = Random.Range(2, 6);
     attackPeriod     = Random.Range(4, 7);
     aStarPathfinding = GetComponent <AStarPathfinding>();
 }
Beispiel #29
0
    public override void Start()
    {
        GameManager gm = Object.FindObjectOfType <GameManager>();

        aStar         = gm.GetComponent <AStarPathfinding>();
        hungerManager = go.GetComponent <HungerManager>();
        hideEditor    = editorNode as HideEditor;

        hidingTime = hideEditor.hidingTime;

        btree = go.GetComponent <BTreeExecutor>().btRuntime;
    }
    // Use this for initialization
    void Awake()
    {
        this.character = new DynamicCharacter(characterAvatar);
        var clusterGraph = Resources.Load <ClusterGraph>("ClusterGraph");

        this.draw    = false;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs[0];
        //this.AStarPathFinding = new AStarPathfinding(this.navMesh, new NodePriorityHeap(), new NodeHashTable(), new EuclidianHeuristic());
        //this.AStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclidianHeuristic());
        this.AStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new GatewayHeuristic(clusterGraph));

        this.AStarPathFinding.NodesPerSearch = 100;
    }
    // Use this for initialization
    void Awake()
    {
        this.draw = false;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs[0];
        this.character = new DynamicCharacter(this.characterAvatar)
        {
            Drag = DRAG,
            MaxSpeed = MAX_SPEED

        };

        aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanDistanceHeuristic());
        aStarPathFinding.NodesPerSearch = 100;
    }
    // Use this for initialization
    void Awake()
    {
        this.draw = false;
        this.currentClickNumber = 1;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs [0];

        this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh,new ZeroHeuristic());
        //this.aStarPathFinding = new AStarPathfinding(this.navMesh, new NodePriorityHeap(), new DictionaryData(), new ZeroHeuristic());
        this.aStarPathFinding.NodesPerSearch = 100;
    }
    // Update is called once per frame
    void Update()
    {
        //        NavigationGraphNode node;
        if (Input.GetKeyDown("z"))
        {
            this.aStarPathFinding = aStarPathFindingZero;
            currentAStar = "A* Zero Heuristic";
        }
        else if (Input.GetKeyDown("x"))
        {
            this.aStarPathFinding = aStarPathFindingEuclidean;
            currentAStar = "A* Euclidean Distance";
        }
        else if (Input.GetKeyDown("c"))
        {
            this.aStarPathFinding = aStarPathFindingGBZero;
            currentAStar = "A* GoalBounding Zero Heuristic";
        }
        if (Input.GetKeyDown("v"))
        {
            this.aStarPathFinding = aStarPathFindingGBEuclidean;
            currentAStar = "A* GoalBounding Euclidean Distance";
        }

        if (Input.GetMouseButtonDown(0))
        {
            //if there is a valid position
            if (this.MouseClickPosition(out position))
            {
                //we're setting the end point
                //this is just a small adjustment to better see the debug sphere
                this.endDebugSphere.transform.position = position + Vector3.up;
                this.endDebugSphere.SetActive(true);
                //this.currentClickNumber = 1;
                this.endPosition = position;
                this.draw = true;
                //initialize the search algorithm
                this.aStarPathFinding.InitializePathfindingSearch(this.character.KinematicData.position, this.endPosition);
            }
        }

        if (Input.GetKeyDown("space"))
        {
            //we're setting the end point
            //this is just a small adjustment to better see the debug sphere
            this.endDebugSphere.transform.position = position + Vector3.up;
            this.endDebugSphere.SetActive(true);
            //this.currentClickNumber = 1;
            this.endPosition = position;
            this.draw = true;
            //initialize the search algorithm
            this.aStarPathFinding.InitializePathfindingSearch(this.character.KinematicData.position, this.endPosition);

        }

        //call the pathfinding method if the user specified a new goal
        if (this.aStarPathFinding.InProgress)
        {
            var finished = this.aStarPathFinding.Search(out this.currentSolution);
            if (finished && this.currentSolution != null)
            {
                //lets smooth out the Path
                this.startPosition = this.character.KinematicData.position;
                this.currentSmoothedSolution = StringPullingPathSmoothing.SmoothPath(this.character.KinematicData, this.currentSolution);
                this.currentSmoothedSolution.CalculateLocalPathsFromPathPositions(this.character.KinematicData.position);
                this.character.Movement = new DynamicFollowPath(this.character.KinematicData, this.currentSmoothedSolution)
                {
                    MaxAcceleration = 40.0f,
                    PathOffset = 0.1f,
                    MovementDebugColor = Color.blue
                };

            }
        }

        this.character.Update();
    }
    // Use this for initialization
    void Awake()
    {
        this.draw = false;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs[0];
        this.character = new DynamicCharacter(this.characterAvatar);
        this.character.Drag = 0.3f;
        StringPullingPathSmoothing.MinWidth = 0.1f;

        this.aStarPathFindingEuclidean = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanDistanceHeuristic());
        this.aStarPathFindingGBEuclidean = new GoalBoundingNodeArrayAStarPathFinding(this.navMesh, new EuclideanDistanceHeuristic());
        this.aStarPathFindingZero = new NodeArrayAStarPathFinding(this.navMesh, new ZeroHeuristic());
        this.aStarPathFindingGBZero = new GoalBoundingNodeArrayAStarPathFinding(this.navMesh, new ZeroHeuristic());
        this.aStarPathFindingEuclidean.NodesPerSearch = 100;
        this.aStarPathFindingZero.NodesPerSearch = 100;
        this.aStarPathFindingGBEuclidean.NodesPerSearch = 100;
        this.aStarPathFindingGBEuclidean.NodesPerSearch = 100;

        //default
        this.aStarPathFinding = this.aStarPathFindingGBEuclidean;
        currentAStar = "A* GoalBounding Euclidean Distance";
    }
    // Use this for initialization
    void Start()
    {
        this.draw = false;
        this.currentClickNumber = 1;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs [0];

        IHeuristic heuristic = null;

        switch (Heuristic)
        {
            case HeuristicType.Zero:
                heuristic = new ZeroHeuristic();
                break;
            case HeuristicType.Euclidean:
                heuristic = new EuclideanHeuristic();
                break;
            default:
                break;
        }

        this.aStarPathFinding = new AStarPathfinding(this.navMesh, new SimpleUnorderedNodeList(), new HashTableNodeList(), heuristic);
    }
Beispiel #36
0
 void Awake()
 {
     instance = this;
     pathfinding = GetComponent<AStarPathfinding>();
 }
    // Use this for initialization
    void Awake()
    {
        this.draw = false;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs [0];
        this.character = new DynamicCharacter(this.characterAvatar);
        this.character.Drag = 0.5f;
        StringPullingPathSmoothing.MinWidth = 0.1f;

        this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanHeuristic());
        //this.aStarPathFinding = new AStarPathfinding(this.navMesh, new SimpleUnorderedNodeList(), new SimpleUnorderedNodeList(), new EuclideanDistanceHeuristic());
        this.aStarPathFinding.NodesPerSearch = 100;
    }
 void Awake()
 {
     movement = GetComponent<Movement> ();
     Pathfinding = GetComponent<AStarPathfinding> ();
 }
Beispiel #39
0
    // Use this for initialization
    void Awake()
    {
        this.draw = false;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs[0];
        this.character = new DynamicCharacter(this.characterAvatar);
        this.enemies = new List<DynamicCharacter>();
        for (int i = 0; i < enemiesAvatar.Length; i++)
        {
            DynamicCharacter enemy = new DynamicCharacter(this.enemiesAvatar[i]);
            DynamicBackAndForth movement = new DynamicBackAndForth()
            {
                Character = enemy.KinematicData,
                MaxAcceleration = 10.0f,
                StopRadius = 2.0f,
                SlowRadius = 5.0f,
                MoveDistance = 25.0f
            };
            movement.CalculatePositions();
            enemy.Movement = movement;
            this.enemies.Add(enemy);
        }

        this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanDistanceHeuristic());
        this.aStarPathFinding.NodesPerSearch = 100;
    }
    // Use this for initialization
    void Start()
    {
        this.draw = false;
        this.currentClickNumber = 1;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs [0];

        this.aStarPathFinding = new AStarPathfinding(this.navMesh, new SimpleUnorderedNodeList(), new DictionaryData(), new ZeroHeuristic());
    }
    // Use this for initialization
    void Awake()
    {
        this.draw = false;
        this.currentClickNumber = 1;
        this.navMesh = NavigationManager.Instance.NavMeshGraphs [0];

        this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh, new EuclideanHeuristic());
        //this.aStarPathFinding = new AStarPathfinding(this.navMesh, new RightPriorityList(), new HashTableNodeList(), new EuclideanHeuristic());
        this.aStarPathFinding.NodesPerSearch = 50;
    }