public ExplorerWindow() { _explorerStates = DependencyInjectionContainer.GetService <ExplorerStates>(); InitializeComponent(); MannschaftskaempfeExplorer.SelectedItemChanged += ((object sender, MannschaftskaempfeExplorer.SelectedItemChangedEventArgs e) => { }); }
void BeIdle() { if (timer > 2) { MyState = ExplorerStates.PATROL; } }
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; } } } }
private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "Spot") { target = col.gameObject; MyState = ExplorerStates.MARKING; } }
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; } }
private void Start() { MyState = ExplorerStates.IDLE; }