void PushObject() { targetObj = target.GetComponent <MovingObj>(); targetObj.isRunning = !targetObj.isRunning; target.transform.GetChild(1).gameObject.SetActive(false); //invisible footprints when moving targetObj.setPushForce(slider.value); CloseGaugeUI(); isTargetPushed = true; isInFrontOfObj = false; }
public static string HarvesterRescue(int[][] data) { const string success = "The spice must flow! Rescue the harvester!"; const string fail = "Damn the spice! I'll rescue the miners!"; var harvester = new Harvester(data[0][0], data[0][1]); var worm = new MovingObj(data[1][0], data[1][1], data[1][2]); var carryall = new MovingObj(data[2][0], data[2][1], data[2][2]); double w2hTime = Time(Distance(harvester.Location(), worm.Location()), worm.Speed()); double c2hTime = Time(Distance(harvester.Location(), carryall.Location()), carryall.Speed()); return(w2hTime - c2hTime > 1 ? success : fail); }
public static void AddObj(MovingObj obj) { if (movingObjs == null) { movingObjs = new Dictionary <string, MovingObj>(); } if (movingObjs.ContainsKey(obj.name)) { MyDebug.LogWarning($"Object with key {obj.name} already exists in list"); return; } movingObjs.Add(obj.name, obj); }
private async void Awake() { MovingObjList.AddObj(this); startPos = transform.localPosition; MovingObj obj = this; await Task.Delay(1); if (obj == null) { return; } obj?.gameObject?.SetActive(!hideOnAwake); }
void checkObjectStatus() { CloseGaugeUI(); FeedBackUI.SetActive(true); targetObj = target.GetComponent <MovingObj>(); if (targetObj.hasExitedDestination) { FeedBackText.text = "You pushed too hard. Try again"; retryBtn.onClick.AddListener(Putback); } else if (targetObj.hasEnteredDestination) { FeedBackText.text = "Great, You made it! Now move to the next."; retryBtn.onClick.AddListener(SolveOne); } else if (!targetObj.hasExitedDestination && !targetObj.hasEnteredDestination) { FeedBackText.text = "You need to push harder. Keep pushing"; retryBtn.onClick.AddListener(KeepPush); } }