public bool MoveState(PROTAGSTATE st) { return(st == PROTAGSTATE.NORMAL); }
public void AnimEnd() { state = _heldItem > -1 ? PROTAGSTATE.HOLD : PROTAGSTATE.NORMAL; }
public void EnStand() { state = PROTAGSTATE.NORMAL; }
public void EnSit() { state = PROTAGSTATE.SIT; }
public void SetHold(int item) { _heldItem = item; //Items.GetItem(item).SetHeld(Vector3.zero, attachBone); state = item == -1 ? PROTAGSTATE.NORMAL : PROTAGSTATE.HOLD; }
// Update is called once per frame protected override void NVUpdate() { if (state == PROTAGSTATE.HOLD && _heldItem == -1) { state = PROTAGSTATE.NORMAL; } if (state == PROTAGSTATE.NORMAL && _heldItem > -1) { state = PROTAGSTATE.HOLD; } switch (state) { case PROTAGSTATE.NORMAL: YTYPE ystate = room == ILOC.HOUSE || room == ILOC.VOID ? YTYPE.SIT : YTYPE.CALL; ActionDisplay.yButton.SetState((int)ystate); LookForInteractive(); if (targetInteractive) { adx = targetInteractive.xTYPE; adb = targetInteractive.bTYPE; if ((int)targetInteractive.bTYPE >= 0 && Input.GetButtonDown("B")) { print("b"); float f = tform.position.y - targetInteractive.tform.position.y; string trigger = f > 2 ? loPickupTrigger : (f < -2 ? hiPickupTrigger : midPickupTrigger); if (targetInteractive.GetComponent <MouseBody>()) { trigger = mousePickupTrigger; } FacePosition(tform.position); anim.SetTrigger(trigger); state = PROTAGSTATE.ANIMATION; } if ((int)targetInteractive.xTYPE >= 0 && Input.GetButtonDown("X")) { print("x"); FacePosition(tform.position); string trigger = xKey(targetInteractive.xTYPE); if (trigger.Length > 0) { anim.SetTrigger(trigger); state = PROTAGSTATE.ANIMATION; } } } if (Input.GetButtonDown("Y")) { anim.SetTrigger(ystate == YTYPE.SIT ? sitTrigger : callTrigger); state = PROTAGSTATE.ANIMATION; } ActionDisplay.xButton.SetState((int)adx); ActionDisplay.bButton.SetState((int)adb); //check for interactives; /*Interactive[] iact = FindObjectsOfType<Interactive>(); * float minDist = Mathf.Infinity; * int closest=-1; * for(int i = 0; i < iact.Length; ++i){ * float dist = Vector3.Distance(tform.position, iact[i].tform.position); * if(dist < minDist){ * minDist = dist; * closest = i; * } * } * if(minDist<interactSphere && closest > -1){ * InteractTarget.itar.target = * }*/ UpdateInventory(); break; case PROTAGSTATE.HOLD: UpdateInventory(); Vector3 dropPoint = tform.position - dropOffset * tform.forward; RaycastHit rae = default(RaycastHit); if (Physics.Raycast(new Ray(dropPoint, Vector3.down), out rae)) { dropPoint = rae.point; } InteractTarget.itar.target = dropPoint; //ActionDisplay.yButton.SetState((int)YTYPE.CALL); if (Items.GetItem(_heldItem).mouseIndex > -1) { //ActionDisplay.xButton.SetState(inventory[ins] == -1 ? (int)XTYPE.PET : (int)Items.GetItem(inventory[ins]).mouseAction); //ActionDisplay.yButton.SetState(DayCycle.dnc.sunday ? (int)YTYPE.MARK : -2); if (Input.GetButtonDown(xbtn)) { if (inventory[ins] > -1 && (int)Items.GetItem(inventory[ins]).mouseAction > -1) { Mice.GetMouse(Items.GetItem(_heldItem).mouseIndex).UseItemOn(inventory[ins]); inventory[ins] = -1; } else { anim.SetTrigger(petTrigger); } } if (Input.GetButtonDown(ybtn)) { Mice.GetMouse(Items.GetItem(_heldItem).mouseIndex).Mark(); } } else { } if (Input.GetButtonDown(bbtn)) { state = PROTAGSTATE.ANIMATION; anim.SetTrigger(dropTrigger); } break; case PROTAGSTATE.ANIMATION: rbody.velocity = Vector3.zero; break; case PROTAGSTATE.SIT: ActionDisplay.xButton.SetState(anim.GetBool(reachTrigger) ? (int)XTYPE.STORE : (int)XTYPE.REACH); ActionDisplay.yButton.SetState((int)YTYPE.STAND); if (Input.GetButtonDown("X")) { anim.SetBool(reachTrigger, !anim.GetBool(reachTrigger)); } if (Input.GetButtonDown("Y")) { anim.SetTrigger(standTrigger); state = PROTAGSTATE.ANIMATION; } break; } if (state != PROTAGSTATE.SIT && state != PROTAGSTATE.ANIMATION) { float lsx = Input.GetAxis(lsticku); float lsy = Input.GetAxis(lstickv); if (Mathf.Abs(lsx) < 0.1f && Mathf.Abs(lsy) < 0.1f) { rbody.velocity = new Vector3(0, rbody.velocity.y, 0); anim.SetBool(moveAnim, false); anim.SetFloat(speedFloat, 0); } else { Vector3 dirc = lsx * SPCam.cam.tform.right + lsy * SPCam.cam.tform.forward; dirc.y = 0; float dirmag = new Vector2(lsx, lsy).magnitude; Vector3 dirf = Vector3.RotateTowards(-tform.forward, dirc, 1, acceleration * Time.deltaTime); tform.LookAt(tform.position - dirf); speed = Mathf.Lerp(speed, dirmag * speedMax, acceleration * Time.deltaTime); rbody.velocity = speed * dirf; anim.SetBool(moveAnim, true); anim.SetFloat(speedFloat, speed / speedMax); } } }