public Mouse(int index, MicePreset.MousePreset preset) { this.index = index; GameObject q = Instantiate(Mice.mice.bodyPrefab); body = q.GetComponent <MouseBody>(); motiveMod = preset.motiveMods; motives = new Appetite[7]; body.tform.parent = mice.transform; scale = Mice.MiceScale(preset.age, preset.maxAge, preset.maxScale); maxScale = preset.maxScale; age = preset.age; rstep = Mice.rstep; rtime = 0; maxAge = preset.maxAge; speed = (preset.energyLevel / Mice.mice.energyLevelG) * Mice.mice.speedG; relationshipsView = new List <int>(); female = preset.female; _relationships = new float[200]; motivesView = new List <int>(); protagRelationship = Mice.rmod * Mice.mice.baseProtagAffection; scale = Mice.MiceScale(age + 0.1f, this.female ? Mice.mice.pubertyf : Mice.mice.pubertym, maxScale); for (int i = 0; i < relationships.Length; ++i) { relationships[i] = Mice.rmod * Mice.mice.baseMouseAffection; } redShift = (preset.color.r / 255f) - 0.5f; greenShift = (preset.color.g / 255f) - 0.5f; blueShift = (preset.color.b / 255f) - 0.5f; affectionRate = Mice.mice.globalAffectionRate - Mice.mice.globalAffectionRate * blueShift; affinity = new Vector3(preset.color.r, preset.color.g, preset.color.b); hiAffinity = (int)Mathf.Max(affinity[0], Mathf.Max(affinity[1], affinity[2])); float hi = float.MinValue; for (int i = 0; i < 3; ++i) { if (affinity[i] > hi && i != hiAffinity) { penHiAffinity = i; hi = affinity[i]; } } body.SetupBody(scale, preset.color, index); goalPoint = MiceZone.zone.GetWanderPoint(); motives[(int)MSTIMULUS.HUNGER] = new AppHunger((int)MSTIMULUS.HUNGER, 0.5f, 0.3f, 0.7f, Mice.mice.hungerThreshold + 2 * greenShift, 10); motives[(int)MSTIMULUS.ENERGY] = new AppEnergy((int)MSTIMULUS.ENERGY, 1f, 0.1f, 0.9f, Mice.mice.energyLevelG + (greenShift + redShift), 15); motives[(int)MSTIMULUS.SOCIAL] = new AppSocial((int)MSTIMULUS.SOCIAL, 1f, 0.1f, 0.9f, Mice.mice.energyLevelG + 2 * blueShift, 8); motives[(int)MSTIMULUS.SEXDRIVE] = new AppSex((int)MSTIMULUS.SEXDRIVE, 0.5f, 0.1f, 0.9f, Mice.mice.energyLevelG + 2 * redShift, 9); motives[(int)MSTIMULUS.BATHROOM] = new AppBathroom((int)MSTIMULUS.BATHROOM, 1, 0.3f, 1, 1, 11); motives[(int)MSTIMULUS.BOREDOM] = new AppBoredom((int)MSTIMULUS.BOREDOM, 0.5f, 0.1f, 0.9f, Mice.mice.energyLevelG + 2 * redShift, 8); motives[(int)MSTIMULUS.CALL] = new AppCall((int)MSTIMULUS.CALL, 1, 0.5f, 0.75f, 1, 100); body.emo.SetNotVisible(); }
// Update is called once per frame void Update() { m_ray = m_camera.ScreenPointToRay(Input.mousePosition); bPressing = Input.GetMouseButton(0); bReleasing = Input.GetMouseButtonUp(0); if (Physics.Raycast(m_ray.origin, m_ray.direction, out m_padhit, 24f, mousepad)) { if (m_padhit.collider == null) { return; } if (bPressing) { mousepadPosition = m_padhit.point; //Debug.Log(m_padhit.collider.gameObject.name+ " mousepadPosition: "+mousepadPosition); } if (bReleasing) { mousepadPosition = Vector3.zero; } } if (Physics.Raycast(m_ray.origin, m_ray.direction, out m_mousehit, 24f, mouseBody)) { if (m_mousehit.collider == null) { Debug.Log(m_mousehit.collider.gameObject.name + " mousepadPosition: " + mousepadPosition); return; } if (bPressing) { lastMouseBody = m_mousehit.collider.GetComponent <MouseBody>(); if (lastMouseBody != null) { lastMouseBody.Raycasting(mousepadPosition); } else { Debug.Log("Pressing " + m_mousehit.collider.gameObject.name); } } } if (Physics.Raycast(m_ray.origin, m_ray.direction, out m_padhit, 24f, mouseButton)) { if (m_padhit.collider == null) { Debug.Log(m_padhit.collider.gameObject.name + " mousepadPosition: " + mousepadPosition); return; } if (bReleasing) { lastMouseButton = m_padhit.collider.GetComponent <MouseButton>(); if (lastMouseButton != null) { lastMouseButton.RaycastReleased(); } else { Debug.Log("Pressing " + m_padhit.collider.gameObject.name); } } } if (bReleasing) { if (lastMouseBody != null) { lastMouseBody.RaycastReleased(); } } }
void StateUpdate(float perHour) { switch (state) { case MSTATE.MOVE: Vector3 velocity = goalPoint - body.tform.position; velocity = velocity.normalized * speed; //velocity += BoidAdjust(velocity); body.tform.LookAt(body.tform.position + velocity); dayExercise += Time.deltaTime; print("move, motive is " + (goalMousePoint ? goalMousePoint.type : motive)); if (Vector3.Distance(body.tform.position, goalPoint) < scale * 1.5f) { velocity = Vector3.zero; if (goalMousePoint) { switch (goalMousePoint.Availability(index)) { case MPRESPONSE.AVAILABLE: goalMousePoint.Engage(this); break; case MPRESPONSE.FULL: foreach (int m in goalMousePoint.occupants) { IncreaseAffection(m, -0.2f); } ChangeState(MSTATE.WAIT); break; case MPRESPONSE.REJECTED: MouseBody mb = goalMousePoint.GetComponent <MouseBody>(); if (mb) { int i = mb.index; IncreaseAffection(i, -0.2f); } ChangeState(MSTATE.WAIT); break; } } else { print("no mouse point, change to wait"); ChangeState(MSTATE.WAIT); } } body.rbody.velocity = velocity; break; case MSTATE.HELD: body.rbody.velocity = Vector3.zero; goalMousePoint = null; break; case MSTATE.WAIT: break; case MSTATE.USEMP: if (!callbackMousePoint) { ChangeState(MSTATE.WAIT); } else { callbackMousePoint.Access(this); if (motives[(int)callbackMousePoint.type].isFull()) { DisengageMousePoint(false); ChangeState(MSTATE.WAIT); } } break; } }
public Mouse(int index, int father, int mother) { Mouse f = Mice.GetMouse(father); Mouse m = Mice.GetMouse(mother); this.father = father; this.mother = mother; motives = new Appetite[7]; this.index = index; GameObject q = Instantiate(Mice.mice.bodyPrefab); body = q.GetComponent <MouseBody>(); body.tform.parent = mice.transform; age = 0; maxAge = (m.maxAge + f.maxAge) / 2f; rstep = Mice.rstep; rtime = 0; maxScale = rbool ? m.maxScale : f.maxScale; female = rbool; scale = Mice.MiceScale(age + 0.1f, this.female ? Mice.mice.pubertyf : Mice.mice.pubertym, maxScale); Color fc = f.body.body.material.color; Color mc = m.body.body.material.color; float ccr = rbool ? fc.r : mc.r; float ccg = rbool ? fc.g : mc.g; float ccb = rbool ? fc.b : mc.b; Color cc = new Color(ccr * Mice.rmod, ccg * Mice.rmod, ccb * Mice.rmod, 255); redShift = ccr / 255f - 0.5f; greenShift = ccg / 255f - 0.5f; blueShift = ccb / 255f - 0.5f; affinity = new Vector3(cc.r, cc.g, cc.b); hiAffinity = (int)Mathf.Max(affinity[0], Mathf.Max(affinity[1], affinity[2])); float hi = float.MinValue; for (int i = 0; i < 3; ++i) { if (affinity[i] > hi && i != hiAffinity) { penHiAffinity = i; hi = affinity[i]; } } body.SetupBody(scale, cc, index); motivesView = new List <int>(); speed = (rbool ? m.speed : f.speed) * (1 + 0.5f * redShift); relationshipsView = new List <int>(); motiveMod = rbool ? m.motiveMod : f.motiveMod; _relationships = new float[200]; protagRelationship = Mice.rmod * Mice.mice.baseProtagAffection; for (int i = 0; i < relationships.Length; ++i) { relationships[i] = Mice.rmod * Mice.mice.baseMouseAffection; } relationships[father] = 6f; relationships[mother] = 6f; protagRelationship = Mice.rmod * Mice.mice.baseProtagAffection; affectionRate = rbool ? f.affectionRate : m.affectionRate; goalPoint = MiceZone.zone.GetWanderPoint(); motives[(int)MSTIMULUS.HUNGER] = new AppHunger((int)MSTIMULUS.HUNGER, 0.5f, 0.3f, 0.7f, Mice.mice.hungerThreshold + 2 * greenShift, 10); motives[(int)MSTIMULUS.ENERGY] = new AppEnergy((int)MSTIMULUS.ENERGY, 1f, 0.1f, 0.9f, Mice.mice.energyLevelG + (greenShift + redShift), 15); motives[(int)MSTIMULUS.SOCIAL] = new AppSocial((int)MSTIMULUS.SOCIAL, 0.5f, 0.1f, 0.9f, Mice.mice.energyLevelG + 2 * blueShift, 8); motives[(int)MSTIMULUS.SEXDRIVE] = new AppSex((int)MSTIMULUS.SEXDRIVE, 0.5f, 0.1f, 0.9f, Mice.mice.energyLevelG + 2 * redShift, 9); motives[(int)MSTIMULUS.BATHROOM] = new AppBathroom((int)MSTIMULUS.BATHROOM, 0.9f, 0.3f, 1, 1, 11); motives[(int)MSTIMULUS.BOREDOM] = new AppBoredom((int)MSTIMULUS.BOREDOM, 0.5f, 0.1f, 0.9f, Mice.mice.energyLevelG + 2 * redShift, 8); motives[(int)MSTIMULUS.CALL] = new AppCall((int)MSTIMULUS.CALL, 1, 1, 1, 1, 100); body.emo.SetNotVisible(); }