void create(BloodPartProduction prod) { if (prod == null) { return; } BloodPart p = GameObject.Instantiate(prod.prefab); p.name = prod.prefab.name; p.transform.SetParent(anchorParts); p.transform.position = createPos.position + rangeCreation * Random.insideUnitSphere; p.transform.rotation = Quaternion.Euler(Random.Range(-180f, 180f), Random.Range(-180f, 180f), Random.Range(-180f, 180f)); p.mainDirection = data.bloodVelocity; p.parent = this; currentParts.Add(p); Rigidbody r = p.GetComponent <Rigidbody>(); if (r != null) { r.velocity = data.bloodVelocity * (1f + (Random.Range(-1f, 1f) * 0.2f * data.bloodVelocity.magnitude)); r.angularVelocity = new Vector3( Random.Range(0f, p.data.startAngularVelocity), Random.Range(0f, p.data.startAngularVelocity), Random.Range(0f, p.data.startAngularVelocity)); } //infedcted if (prod.infectedRateMin > Random.Range(0f, 1f)) { p.setInfected(); } }
void LaunchProjectil(Projectile prefab, BloodPart target) { Projectile p = GameObject.Instantiate(prefab); p.Part = target; p.transform.position = lauchMissilePos.position; target.markAsSelected(Color.cyan); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { App.Instance.gameView.IsPausing = !App.Instance.gameView.IsPausing; } if (isPausing) { return; } scores.update(Time.deltaTime); if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100f, maskBloodPart)) { BloodPart p = hit.collider.GetComponent <BloodPart>(); if (p != null) { if (p.data.infected) { config.onCellSelected.activate(p.transform.position); } else { config.onCellSelectedNotInfected.activate(p.transform.position); } onClickOnBloodPart(p); } } } captureAbilityPress(KeyCode.Alpha1, 0); captureAbilityPress(KeyCode.Alpha2, 1); captureAbilityPress(KeyCode.Alpha3, 2); captureAbilityPress(KeyCode.Alpha4, 3); if (waitingsParts.Count > 0 && getRobotsAvailablesCount() > 0) { BloodPart p = waitingsParts.Peek(); if (p != null) { if (robotsManager.affectRobotToCollect(p)) { p.markAsSelected(config.colorSelected); waitingsParts.Dequeue(); } } } }
void onPartAtEnd(BloodPart p) { switch (p.data.endMode) { case BloodPartData.END_MODE.DESTROY: App.Instance.evtMgr.Trigger(new Events.BloodPartDestroyed(p, DESTROY_CAUSE.END_LEVEL)); destroyBloodPart(p); break; case BloodPartData.END_MODE.RESTART: p.transform.position = createPos.position + rangeCreation * Random.insideUnitSphere; break; } }
public bool affectRobotToCollect(BloodPart p) { Robot r = GetNextAvailable(); if (r == null) { return(false); } r.CancelAllProcess(); Proc.GotoDest d = new Proc.GotoDest(r, r.robotBase.exit.position); d.attachProcess(new Proc.CatchPart(r, p)); r.processMgr.Launch(d); return(true); }
public void onClickOnBloodPart(BloodPart p) { if (p.isMarked) { return; } /*if (robotsManager.affectRobotToCollect(p)) { * p.markAsSelected(config.colorSelected); * config.onCellSelected.activate(p.transform.position); * }else {*/ waitingsParts.Enqueue(p); p.markAsSelected(config.colorFuture); config.onCellSelectedWaiting.activate(p.transform.position); //} }
public override void tickBuilding() { BloodPart part = null; Collider[] colls = Physics.OverlapSphere(transform.position, data.range, data.maskBloodPart); for (int i = 0; i < colls.Length; ++i) { BloodPart p = colls[i].GetComponent <BloodPart>(); if (p != null && p.data.infected && !p.isMarked) { part = p; break; } } if (part != null) { LaunchProjectil(projectilePrefab, part); data.fxOnScanned.activate(part.transform.position); } base.tickBuilding(); }
public override void tickBuilding() { BloodPart part = null; Collider[] colls = Physics.OverlapSphere(transform.position, data.range, data.maskBloodPart); for (int i = 0; i < colls.Length; ++i) { BloodPart p = colls[i].GetComponent <BloodPart>(); if (p != null && p.data.infected && !p.isMarked) { part = p; break; } } if (part != null) { App.Instance.gameView.humanView.onClickOnBloodPart(part); data.fxOnScanned.activate(part.transform.position); } base.tickBuilding(); }
public void destroyBloodPart(BloodPart p) { currentParts.Remove(p); GameObject.Destroy(p.gameObject); }