//所有资源收集完成,转换成对应的建筑 public void Complete() { if (isComplete) { return; } isComplete = true; Debug.Log("Complete"); Destroy(gameObject); GChess chess = GridManager.instance.InstansiateChessAt(PrefabManager.instance.GetTowerPrefab(ownResource ? ownResource.type : ResourceType.None), location); chess.GetComponent <GShooterTower>()._color = GetComponent <GBuildingBase>()._color; }
//void FixedUpdate() //{ //取消弹性 // this.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0); //} private void Update() { ////postion锁定 //foreach (Transform _transform in GetAllChilds()) //{ // _transform.localPosition = new Vector3(0, _transform.localPosition.y, 0); //} if (playerInput.Dis > 0.02f) { //旋转 Vector3 targetForward = Vector3.Slerp(this.transform.forward, playerInput.Dright * DirTran.right + playerInput.Dup * DirTran.forward, 0.4f); this.transform.forward = targetForward; //位移 velocity = this.transform.forward * runSpeed; this.transform.position += velocity * Time.deltaTime; //location更新 location = GridManager.instance.Vector3ToVector2Int(this.transform.position); //Direction朝向更新 if (this.transform.eulerAngles.y >= 315 || this.transform.eulerAngles.y < 45) { direction = Direction.up; } else if (this.transform.eulerAngles.y >= 45 && this.transform.eulerAngles.y < 135) { direction = Direction.right; } else if (this.transform.eulerAngles.y >= 135 && this.transform.eulerAngles.y < 225) { direction = Direction.down; } else if (this.transform.eulerAngles.y >= 225 && this.transform.eulerAngles.y < 315) { direction = Direction.left; } } HighLightHandle(); if (Input.GetKeyDown(playerInput.KeyPickUp)) { GTower targetTower = GridManager.instance.GetTower(GetSelectLocation()); if (targetTower != null) { targetTower.BePickUp(this); } else { GResource targetResource = GridManager.instance.GetResources(GetSelectLocation()); if (targetResource != null) { targetResource.BePickUp(this); } } } if (Input.GetKeyDown(playerInput.KeyPutDown)) { if (conveyObject != null) { Putdown(); } } if (Input.GetKeyDown(playerInput.KeyRotation)) { Vector2Int select = GetSelectLocation(); Debug.Log(select); GChess chess = GridManager.instance.GetTower(select); if (chess) { Debug.Log(chess); if (chess.chessType == ChessType.shooterTower) { chess.GetComponent <GShooterTower>().direction = chess.GetComponent <GShooterTower>().direction.ClockwiseNext(); } } } //更新动画 animator.SetBool("isConvey", conveyObject != null); }
void Build(Vector2Int targetLocation, _Color color) { GChess chess = GridManager.instance.InstansiateChessAt(PrefabManager.instance.GetBuildingBasePrefab(), targetLocation); chess.GetComponent <GBuildingBase>()._color = color; }
public void Select(GChess target) { selectedChess = target; selectedChess.GetComponent <CAgentComponent>().eSelect.Invoke(); }