public void SpawnFromPortal(Vector3 startPosition, Vector3 up) { GameObject newJoeJeff = Instantiate <GameObject>(crowdEntityPrefab.gameObject, startPosition, Quaternion.Euler(0, Random.value * 360, 0)); Rigidbody newJeffRigidbody = newJoeJeff.GetComponent <Rigidbody>(); newJeffRigidbody.detectCollisions = false; JoeJeffAgent newJoeJeffAgent = newJoeJeff.GetComponent <JoeJeffAgent>(); newJoeJeffAgent.Ascend(false); // tell the joejeff he's getting thrown into the air Vector3 portalVector = up; portalVector.x += Random.value * 0.2f; portalVector.z += Random.value * 0.2f; newJeffRigidbody.velocity = portalVector * respawnVelocity; CrowdEntity crowdEntity = newJoeJeff.GetComponent <CrowdEntity>(); crowdEntity.crowd = this; crowd.Add(crowdEntity); StartCoroutine(DoEnableJeffCollider(newJeffRigidbody, 0.5f)); }
void CheckEntityTargets(CrowdEntity ent) { float currentTargetDist = 1000; if (ent.currentTarget != null) { currentTargetDist = SqrDist(ent.transform.position, ent.currentTarget.transform.position); } for (int i = 0; i < targets.Count; i++) { if (targets[i].active == false) { continue; // ignore this one, it's inactive } //if target in range if (CheckRange(ent.transform.position, targets[i].transform.position, targets[i].radius)) { //if closer than current target if (SqrDist(ent.transform.position, targets[i].transform.position) < currentTargetDist) { //make this the current target ent.currentTarget = targets[i]; } } } }
void Start() { rigidbody = GetComponent <Rigidbody>(); anim = GetComponent <Animator>(); nav = GetComponent <NavMeshAgent>(); crowdEntity = GetComponent <CrowdEntity>(); skinColor = GetComponent <RandomSkinColor>(); }
void SpawnJoeJeff() { // spawn new JJ at random spot Vector3 position = SampleNavMesh(RandomPointInBounds(spawnVolume)); CrowdEntity crowdEntity = Instantiate(crowdEntityPrefab.gameObject, position, Quaternion.Euler(0, Random.value * 360, 0)).GetComponent <CrowdEntity>(); crowdEntity.crowd = this; crowd.Add(crowdEntity); }
public CrowdEntity Update(CrowdEntity entity) { try { _crowdRepository.Update(entity); return(entity); } catch (Exception e) { _log.Error(e, "数据库操作出错"); return(null); } }
public bool Delete(CrowdEntity entity) { try { _crowdRepository.Delete(entity); return(true); } catch (Exception e) { _log.Error(e, "数据库操作出错"); return(false); } }
public HttpResponseMessage AddCrowdInfo([FromBody] CrowdModel crowdModel) { if (crowdModel != null) { var entity = new CrowdEntity { Uptime = DateTime.Now, Addtime = DateTime.Now, Adduser = 1, Upuser = 1, Ttitle = crowdModel.Ttitle, Intro = crowdModel.Intro, Starttime = DateTime.Now, Endtime = DateTime.Now, Status = 1, crowdUrl = crowdModel.crowdUrl }; var entityImg = new PartImageEntity { Orderby = 1, Imgurl = "", Adduser = 2, Addtime = DateTime.Now, Uptime = DateTime.Now, Upuser = 2, Crowd = null }; try { int id; if (crowdModel.Id > 0) //修改众筹 { id = crowdModel.Id; entity = _crowdService.GetCrowdById(id); entity.Intro = crowdModel.Intro; entity.Ttitle = crowdModel.Ttitle; entity.crowdUrl = crowdModel.crowdUrl; _crowdService.Update(entity);//更新众筹表crowd var enImg = new PartImageSearchCondition { OrderBy = EnumPartImageSearchOrderBy.OrderById, CrowdId = id }; var model = _partImageService.GetPartImagesByCondition(enImg);//根据众筹id查询众筹图片 foreach (var p in model) { _partImageService.Delete(p);//删除众筹图片 } if (crowdModel.ImgList1.Count > 0) { entityImg.Crowd = _crowdService.GetCrowdById(id); for (int i = 0; i < crowdModel.ImgList1.Count; i++)//添加众筹图片 { entityImg.Imgurl = crowdModel.ImgList1[i]; _partImageService.Create(entityImg); } } return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据保存成功!"))); } else//新增众筹 { id = _crowdService.Create(entity).Id; //插入众筹图片 if (crowdModel.ImgList1.Count > 0) { entityImg.Crowd = _crowdService.GetCrowdById(id); for (int i = 0; i < crowdModel.ImgList1.Count; i++) { entityImg.Imgurl = crowdModel.ImgList1[i]; _partImageService.Create(entityImg); } } return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!"))); } } catch { return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!"))); } } return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!"))); }