void Start() { textEstimate = textEstimateComponent.GetComponent <Text>(); textFish = textFishComponent.GetComponent <Text>(); textFish2 = textFishComponent2.GetComponent <Text>(); textEstimate.text = "" + maxEstimate; curEstimate = maxEstimate; moneyText = textMoneyComponent.GetComponent <Text>(); porpular = 1f; timeDelay = 1.5f; nextTime = Time.time; restartBtn = restartButton.GetComponent <Button>(); restartBtn.onClick.AddListener(() => restart()); useMoneyBtn = useMoneyButton.GetComponent <Button>(); useMoneyBtn.onClick.AddListener(() => useMoney()); gameOverUI.SetActive(false); money = 0f; punishmentMoneyText = textPunishmentMoneyComponent.GetComponent <Text>(); rubbish = gameObject.GetComponent <Rubbish>(); }
private void OnTriggerStay2D(Collider2D collision) { PlayerMovement player = collision.GetComponent <PlayerMovement>(); // If Player is in Radius if (player) { // And carrying an item if (player.carriedItem && !player.hidden) { // Drop Current Item if (carriedItem) { carriedItem.DropMe(); carriedItem = null; } // Chase TrashPanda target = player.transform; chasing = true; chaseTimer = 3.0f; } if (target == player.transform && !player.carriedItem) { target = GetTarget(); chasing = false; } } }
public void StoreTrash(Rubbish _rubbish) { if (storeTrash != null) { storeTrash(_rubbish); SetTrashText(); } }
private void OnTriggerEnter(Collider other) { Rubbish rubbish = other.gameObject.GetComponent <Rubbish>(); if (rubbish != null) { bin.PickupRubbish(rubbish); } }
public void Destroy(Rubbish rubbish) { rubbishes.Remove(rubbish); Destroy(rubbish.gameObject); if (rubbishes.Count == 0) { screenOne.SetActive(false); screenTwo.SetActive(true); } }
public IActionResult UpdateRubbish(Rubbish rubbishToUpdate) { var isValidRubbish = _rubbishRepository.getSingleRubbish(rubbishToUpdate.RubbishId); if (isValidRubbish != null) { var updatedRubbish = _rubbishRepository.Update(rubbishToUpdate); return(Ok(rubbishToUpdate)); } return(NotFound("That rubbish does not exist and could not be deleted")); }
public void PickupRubbish(Rubbish rubbish) { rubbish.scoreMe(); rubbish.enabled = false; // disable the rubbish so that the last touching player registers as the rewarded player rubbish.gameObject.GetComponent <Collider>().enabled = false; StartCoroutine(AnimateOutline()); StartCoroutine(AnimatePickup(rubbish.gameObject)); // Trigger score Debug.Log("Bin just collected some rubbish!"); }
private void Start() { for (int i = 0; i < maxAmount; i++) { int randNum = Random.Range(0, rubbishPrefabs.Length); Rubbish rub = Instantiate(rubbishPrefabs[randNum], Environment.Instance.GetRandomTarget(), Quaternion.identity); rub.transform.parent = transform; rub.gameObject.SetActive(false); rubbish.Add(rub); } }
public Rubbish CreateRubbish(Rubbish rubbishToAdd) { var sql = @"INSERT INTO Rubbish ( Name, Description, CategoryId, IsAvailable, UserId, Price) output inserted.* VALUES(@Name, @Description, @CategoryId, @IsAvailable, @UserId, @Price);"; using (var db = new SqlConnection(connectionString)) { var results = db.QueryFirstOrDefault <Rubbish>(sql, rubbishToAdd); return(results); } }
public static bool AddRubbishToObject(GameObject addingObject, float _disgustness, float timeToClean = 5.0f) { Rubbish rubbish = addingObject.AddComponent <Rubbish>(); if (!rubbish) { return(false); } rubbish.disgustness = _disgustness; rubbish.setNeededTime(timeToClean); return(true); }
public string RubbishDispose(string rubbishName) { Rubbish rubbish = _context.Rubbish.Include(c => c.RubbishType).FirstOrDefault(c => rubbishName.Equals(c.RubbishName)); if (rubbish != null) { return(rubbishName + "是" + rubbish.RubbishType.RubbishTypeName + "哦。"); } else { return(string.Format("{0}是什么垃圾我也不知道哦,如果你知道了请告诉我把。你可以说({1}是xx垃圾)", rubbishName, rubbishName)); } }
public async Task <BaseResult> AddRubish(RubbishData model) { try { Rubbish rubbish = _mapper.Map <Rubbish>(model); _context.Rubbish.Add(rubbish); _context.SaveChanges(); return(new BaseResult()); }catch (Exception e) { _logger.LogError(e, ""); return(new BaseResult(-1, e.Message)); } }
// Get Input private void Update() { // Get Current Input horizontalInput = Input.GetAxisRaw("Horizontal"); verticalInput = Input.GetAxisRaw("Vertical"); inputVector = new Vector2(horizontalInput, verticalInput); inputVector = inputVector.normalized; // Set Idle or Moving if (inputVector == Vector2.zero) { ChangeAnimState(false); } else { ChangeAnimState(true); } // Check for Input if (Input.GetKeyDown(KeyCode.E)) { if (!carriedItem && rubbishList.Count > 0) { carriedItem = GetClosest(); carriedItem.CarryMe(this.transform); audio.Play(); } else if (!carriedItem && inRange) { CallbackHandler.instance.TakeTrash(); audio.Play(); } else if (carriedItem) { if (atBurrow) { CallbackHandler.instance.StoreTrash(carriedItem); audio.Play(); } else { carriedItem.DropMe(); audio.Play(); } carriedItem = null; } } }
// Probably Over-Engineered but Feels Better. public Rubbish GetClosest() { float dist = Mathf.Infinity; Rubbish temp = null; foreach (Rubbish n in rubbishList) { if (Vector2.Distance(n.transform.position, transform.position + xOffset) < dist) { temp = n; dist = Vector2.Distance(n.transform.position, transform.position); } } return(temp); }
protected EatPattern(BreakDownHandler howBreakdown, BreakDownsHandler howBreakdowns, EatPatternConfig config) { _howBreakDown = howBreakdown; _howBreakDowns = howBreakdowns; _config = config; _rubbish = new Rubbish(); _stomach = new OneByOnePipeline(Digest); _enzyme = new AutoResetPipeline(Breakdown); _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); _outputElapsedStopwatch = new Stopwatch(); _foods = new Compounds <F>(config.MaxFoodStock, config.ReplaceMode, _rubbish); //食物 _nutrients = new Compounds <N>(config.MaxNutrientStock, config.ReplaceMode, _rubbish); //养分 _delapyer = new MediaDelayer(); }
private void OnTriggerEnter2D(Collider2D collision) { PlayerMovement player = collision.GetComponent <PlayerMovement>(); if (player) { player.hidden = true; } Rubbish rubbish = collision.GetComponent <Rubbish>(); if (rubbish) { rubbish.hidden = true; } }
public Rubbish Update(Rubbish rubbishToUpdate) { var sql = @" update Rubbish set [name] = @Name, [Description] = @Description, [CategoryId] = @CategoryId, [Price] = @Price where RubbishId = @RubbishId; "; using (var db = new SqlConnection(connectionString)) { var parameters = new { RubbishId = rubbishToUpdate.RubbishId, Name = rubbishToUpdate.Name, Description = rubbishToUpdate.Description, CategoryId = rubbishToUpdate.CategoryId, Price = rubbishToUpdate.Price }; var result = db.QueryFirstOrDefault <Rubbish>(sql, parameters); return(result); } }
public void RemoveRubbish(Rubbish _rubbish) { rubbishList.Remove(_rubbish); }
public void AddRubbish(Rubbish _rubbish) { rubbishList.Add(_rubbish); }
public IActionResult CreateNewRubbish(Rubbish rubbishToAdd) { var newRubbish = _rubbishRepository.CreateRubbish(rubbishToAdd); return(Created("", newRubbish)); }
public void StoreTrash(Rubbish _rubbish) { CallbackHandler.instance.globalInfo.CollectTrash(); _rubbish.CleanUp(); Destroy(_rubbish.gameObject); }
public void FixedUpdate() { // No Path if (path == null) { speed = idleSpeed; ChangeAnimState(); return; } // No Target if (!target) { speed = idleSpeed; ChangeAnimState(); target = GetTarget(); currentWaypoint = 0; UpdatePath(); return; } speed = walkSpeed; ChangeAnimState(); // In Chase if (chasing) { speed = chaseSpeed; ChangeAnimState(); chaseTimer -= Time.fixedDeltaTime; // End Chase if (chaseTimer <= 0) { chasing = false; target = GetTarget(); currentWaypoint = 0; UpdatePath(); } else if (target.GetComponent <PlayerMovement>()) { if (target.GetComponent <PlayerMovement>().hidden) { return; } } } // Check if Reached End, else Move reachedEnd = currentWaypoint >= path.vectorPath.Count; if (reachedEnd) { if (chasing) { PlayerMovement player = target.GetComponent <PlayerMovement>(); // Swap items with Panda player.carriedItem.DropMe(); carriedItem = player.carriedItem; player.carriedItem = null; carriedItem.CarryMe(this.transform); // GoTo Trashcan target = trashCan; currentWaypoint = 0; UpdatePath(); // End Chase chasing = false; return; } else { // Picked up Rubbish if (target.GetComponent <Rubbish>()) { carriedItem = target.GetComponent <Rubbish>(); target.GetComponent <Rubbish>().CarryMe(this.transform); target = trashCan; } // At Bin else if (target == trashCan && carriedItem) { trashCan.GetComponent <Trashcan>().AddRubbish(carriedItem); carriedItem = null; target = GetTarget(); } reachedEnd = false; currentWaypoint = 0; UpdatePath(); return; } } if (target.GetComponent <Rubbish>()) { if (target.GetComponent <Rubbish>().hidden) { target = null; return; } } if (allowMovement) { // Move Vector2 direction = ((Vector2)path.vectorPath[currentWaypoint] - rb.position).normalized; Vector2 newPos = rb.position + direction * speed * Time.fixedDeltaTime; rb.MovePosition(newPos); // Next Waypoint float distance = Vector2.Distance(rb.position, path.vectorPath[currentWaypoint]); if (currentWaypoint >= path.vectorPath.Count - 2) { if (distance < nextWaypointDistance * 4) { currentWaypoint++; } } else if (distance < nextWaypointDistance) { currentWaypoint++; } } }
public void AddRubbish(Rubbish _rubbish) { rubbish.Add(_rubbish); _rubbish.CleanUp(); }