Beispiel #1
0
        public ExplorerWindow()
        {
            _explorerStates = DependencyInjectionContainer.GetService <ExplorerStates>();

            InitializeComponent();
            MannschaftskaempfeExplorer.SelectedItemChanged += ((object sender, MannschaftskaempfeExplorer.SelectedItemChangedEventArgs e) => { });
        }
Beispiel #2
0
 void BeIdle()
 {
     if (timer > 2)
     {
         MyState = ExplorerStates.PATROL;
     }
 }
Beispiel #3
0
 private void HandleMovement()
 {
     if (pathVectorList != null)
     {
         Vector3 targetPosition = pathVectorList[currentPathIndex];
         if (Vector3.Distance(transform.position, targetPosition) > 1f)
         {
             Vector3 moveDir        = (targetPosition - transform.position).normalized;
             float   distanceBefore = Vector3.Distance(transform.position, targetPosition);
             transform.position = transform.position + moveDir * speed * Time.deltaTime;
         }
         else
         {
             currentPathIndex++;
             if (currentPathIndex >= pathVectorList.Count)
             {
                 if (MyState == ExplorerStates.MARKING)
                 {
                     GameManager.Instance.RemoveSpot();
                     PathFinding.Instance.GetGrid().GetXY(new Vector3(target.transform.position.x, target.transform.position.y, 5), out int a, out int b);
                     Instantiate(mine, PathFinding.Instance.GetGrid().GetWorldPosition(a, b), Quaternion.identity);
                     Destroy(target);
                 }
                 StopMoving();
                 hasObjective = false;
                 MyState      = ExplorerStates.IDLE;
             }
         }
     }
 }
Beispiel #4
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Spot")
     {
         target  = col.gameObject;
         MyState = ExplorerStates.MARKING;
     }
 }
Beispiel #5
0
 private void Mark()
 {
     StopMoving();
     if (target != null)
     {
         PathFinding.Instance.GetGrid().GetXY(new Vector3(target.transform.position.x, target.transform.position.y, 5), out int x, out int y);
         this.SetTargetPosition(PathFinding.Instance.GetGrid().GetWorldPosition(x, y));
         HandleMovement();
         // print("target is null");
     }
     else
     {
         hasObjective = false;
         MyState      = ExplorerStates.IDLE;
     }
 }
Beispiel #6
0
 private void Start()
 {
     MyState = ExplorerStates.IDLE;
 }