Example #1
0
    string xKey(XTYPE x)
    {
        string r = "";

        switch (x)
        {
        case XTYPE.PET:
            r = petTrigger;
            break;

        case XTYPE.HEAL:
        case XTYPE.FEED:
            r = feedTrigger;
            break;

        case XTYPE.PLACE:
            r = dropTrigger;
            break;

        case XTYPE.REACH:
            r = reachTrigger;
            break;

        case XTYPE.STORE:
        case XTYPE.USE:
        case XTYPE.MIDPRESS:
            r = midInteractTrigger;
            break;

        case XTYPE.LOPRESS:
            r = loInteractTrigger;
            break;
        }
        return(r);
    }
Example #2
0
        public static Type ToSystemType(this XTYPE xtype)
        {
            Type type = null;

            switch (xtype)
            {
            case XTYPE.DEFAULT:                     //should it be string?
                type = typeof(string);
                break;

            case XTYPE.BOOLEAN:
                type = typeof(bool);
                break;

            case XTYPE.BYTE:
                type = typeof(byte);
                break;

            case XTYPE.CURRENCY:
                type = typeof(decimal);
                break;

            case XTYPE.DATE:
                type = typeof(DateTime);
                break;

            case XTYPE.DOUBLE:
                type = typeof(double);
                break;

            case XTYPE.INTEGER:
                type = typeof(int);
                break;

            case XTYPE.LONG:
                type = typeof(long);
                break;

            case XTYPE.SINGLE:
                type = typeof(float);
                break;

            case XTYPE.STRING:
                type = typeof(string);
                break;

            case XTYPE.STRINGCASESENSITIVE:
                type = typeof(string);
                break;

            case XTYPE.NUMBER:                     // should it be int?
                type = typeof(int);
                break;
            }

            return(type);
        }
Example #3
0
    // 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);
            }
        }
    }