/// <summary> /// 批量生成TaskCell到场景中,并进行初始化赋值 /// </summary> public void GenerateTaskCell() { for (int i = 0; i < commands.Count; i++) { GameObject go = Instantiate(Resources.Load <GameObject>("UI/TaskCell"), GameObject.Find("TaskShowPanel").transform); if (commands[i].commandType == CommandType.Delay) { WaitingStep step = go.AddComponent <WaitingStep>(); step.delayTime = float.Parse(commands[i].Param) / 1000f; go.transform.Find("Text").GetComponent <Text>().text = "待机指令"; } else { MovingStep step = go.AddComponent <MovingStep>(); JointsMessage jm = new JointsMessage(); jm.IKPoint = cps[commands[i].Param].point * 0.001f; string key = string.Format("{0:d3}", (StepManager.Instance.SavedPointMessage.Count + 1)); StepManager.Instance.SavedPointMessage.Add(key, jm); MechanicalControl.Instance.ShowTag(jm.IKPoint, key); step.targetPoint.IKPoint = jm.IKPoint; go.transform.Find("Text").GetComponent <Text>().text = "移动指令"; } StepManager.Instance.Steps.Add(go); } }
private IEnumerable <AstarDecoratorValues> DiscoverPossibleStepsArround(AstarDecoratorValues currentPosition, int startX, int startZ, int destinationX, int destinationZ) { List <AstarDecoratorValues> possibleSteps = new List <AstarDecoratorValues>(); for (int xOff = -1; xOff <= 1; xOff++) { for (int zOff = -1; zOff <= 1; zOff++) { var lookedX = currentPosition.PossibleStep.X + xOff; var lookedZ = currentPosition.PossibleStep.Z + zOff; if (xOff == 0 && zOff == 0) { continue; } if (NoDiagonals) { if (xOff == -1 && zOff == -1) { continue; } if (xOff == -1 && zOff == 1) { continue; } if (xOff == 1 && zOff == -1) { continue; } if (xOff == 1 && zOff == 1) { continue; } } if (!MapService.IsBlockedPosition(lookedX, lookedZ)) { if (LimitCubeType.HasValue && MapService.GetCubeType(lookedX, lookedZ) != LimitCubeType.Value) { continue; } var possibleStep = new MovingStep(lookedX, lookedZ); var aStar = new AstarDecoratorValues(possibleStep, currentPosition); CalculateCost(startX, startZ, destinationX, destinationZ, aStar); // found destination if (aStar.HCost == 0) { return(new AstarDecoratorValues[] { aStar }); } possibleSteps.Add(aStar); } } } return(possibleSteps); }
void OnMoveBtnClick() { GameObject go = Instantiate(Resources.Load <GameObject>("UI/TaskCell"), GameObject.Find("TaskShowPanel").transform); MovingStep step = go.AddComponent <MovingStep>(); //step.targetPoint = MechanicalControl.Instance.SavePoint(); go.transform.Find("Text").GetComponent <Text>().text = "移动指令" + number; Debug.Log("现在的步骤是:============>" + StepManager.Instance.CurrentMessageSequence); StepManager.Instance.Steps.Add(go); }
void Init() { s_Player = GameObject.Find("Stage5").transform.FindChild("Player").GetComponent <PlayerControl>(); s_Ove = GameObject.Find("Stage5").transform.FindChild("Ove").GetComponent <Ove>(); s_Flower1 = GameObject.Find("Stage5").transform.FindChild("SmallFlower1").GetComponent <Flower>(); s_Flower2 = GameObject.Find("Stage5").transform.FindChild("SmallFlower2").GetComponent <Flower>(); s_Flower3 = GameObject.Find("Stage5").transform.FindChild("SmallFlower3").GetComponent <Flower>(); s_Tower = GameObject.Find("Stage5").transform.FindChild("Tower").GetComponent <Tower>(); s_Switch = GameObject.Find("Stage5").transform.FindChild("Switch").GetComponent <Switch>(); s_MovingStep1 = GameObject.Find("Stage5").transform.FindChild("MovingStep1").GetComponent <MovingStep>(); s_MovingStep2 = GameObject.Find("Stage5").transform.FindChild("MovingStep2").GetComponent <MovingStep>(); s_StageManager = GameObject.Find("Stage").GetComponent <StageManager>(); s_Player.transform.position = new Vector3(4.2f, -29.2f, 0); s_Player.Init(); s_Ove.Init(); s_Ove.transform.position = new Vector3(14.8f, -31.7f, -1); s_Flower1.Init(); s_Flower2.Init(); s_Flower3.Init(); s_Switch.Init(); s_MovingStep1.Init(); s_MovingStep2.Init(); }
public AstarDecoratorValues(MovingStep possibleStep, AstarDecoratorValues parent) { PossibleStep = possibleStep; Parent = parent; }