/// <summary> /// 工作 /// </summary> /// <param name="styleIndex"></param> /// <returns></returns> public float[] goToWork(int styleIndex) { WorkStyle workStyle = designData.workStyleArray[styleIndex]; // 根据索引获取数据 if (subHealthPoint(workStyle.consumeHP)) // subHealthPoint:减少体力 返回值true:变化后的体力值>=0, false: 小于0 { playerData.workCount[styleIndex] += 1; // 相对应的打工次数加一 float coins = workStyle.minCoins + Mathf.Floor(getWorkLevel(styleIndex) * (workStyle.maxCoins - workStyle.minCoins + 0f) / workStyle.maxLevel); //根据打工次数计算出当前增加的金币 // Debug.Log(coins); if (coins > workStyle.maxCoins) { coins = workStyle.maxCoins; } addCoins(coins); // 增加金币 //Debug.Log("---"+coins); return(new float[] { 1f, getHealthPoint(), getCoinCount(), workStyle.consumeHP, coins });//打工返回,状态码 / 变化后的体力 / 变化后的金币数 / 体力差值 / 金币差值/ } return(new float[] { 0f }); }
public async Task <IActionResult> DeleteConfirmed(int id) { WorkStyle workStyle = await db.WorkStyles.FirstOrDefaultAsync(w => w.ID == id); db.WorkStyles.Remove(workStyle); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(WorkStyle workStyle) { if (ModelState.IsValid) { db.Entry(workStyle).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(workStyle)); }
public async Task <IActionResult> Create(WorkStyle workStyle) { if (ModelState.IsValid) { db.WorkStyles.Add(workStyle); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(workStyle)); }
// GET: WorkStyles/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } WorkStyle workStyle = await db.WorkStyles.FirstOrDefaultAsync(w => w.ID == id); if (workStyle == null) { return(NotFound()); } return(View(workStyle)); }