Ejemplo n.º 1
0
    void HandleMazeMinigame()
    {
        MazeExit exit      = currentInteractive.GetComponent <MazeExit>();
        Vector2  direction = exit.direction;

        MazeController.instance.ChangeNode(direction);
        playingInteraction = false;
    }
Ejemplo n.º 2
0
    public override bool CanInteract(Interactive interactive)
    {
        Transform c = Manager.Get <VirtualCameraManager>().transform;

        SphereCollider collider = interactive.GetComponent <SphereCollider>();

        if (collider == null)
        {
            return(false);
        }

        RaycastHit hit;

        if (Physics.Raycast(new Ray(c.position, c.forward), out hit, ((ARUIInteractive)interactive).MaxDistance, LayerMask.GetMask(Layer)))
        {
            return(hit.collider == collider);
        }
        return(false);
    }
Ejemplo n.º 3
0
    public void Interact()
    {
        Telephone telephone = interactive.GetComponent <Telephone>();

        if (telephone)
        {
            telephone.PickupPhone();
        }
        else if (interactive.CompareTag("Ball"))
        {
            if (player.grenadeSystem.magazine.CurrentAmmo == player.grenadeSystem.magazine.maxAmmo)
            {
                return;
            }

            Transform ball = interactive.gameObject.transform;
            if (ball.parent != null)
            {
                Transform parent = ball.transform.parent;
                if (parent)
                {
                    Doggo doggo = parent.GetComponentInParent <Doggo>();
                    doggo.ReturnBall();
                }
            }
            Destroy(ball.gameObject);
            player.AddGrenade();
        }
        else if (interactive.CompareTag("FoodSack"))
        {
            if (player.CurrentWeaponIsTreatGun())
            {
                player.CurrentEquipedWeapon.AddAmmo(int.MaxValue);
                player.UpdateWeaponUI();
            }
        }
        else if (interactive.CompareTag("Door"))
        {
            TimerManager tm = FindObjectOfType <TimerManager>();
            tm.ResolveClientsAtTheDoor();
        }
    }
Ejemplo n.º 4
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);
            }
        }
    }
        public static EgoComponent GenerateLaserGun()
        {
            EntityBuilder entity = EntityBuilder.Generate().WithPhysics(typeof(BoxCollider2D), .5f).WithGraphics("Images/gun");
            Interactive   c      = Ego.AddComponent <Interactive>(entity);

            c.InteractAction = e => EgoEvents <AttachEvent> .AddEvent(new AttachEvent(c.GetComponent <EgoComponent>(), e));

            Ego.AddComponent <Mountpoint>(entity);
            Useable u = Ego.AddComponent <Useable>(entity);

            u.UseAction = e => {
                //RaycastHit2D clicked = Physics2D.Raycast (transform.position, transform.right);
                Transform transform = u.transform;
                Debug.DrawRay(transform.position, transform.right, Color.red, 100, false);
            };
            return(entity);
        }
        public static EgoComponent GenerateGun()
        {
            EntityBuilder entity = EntityBuilder.Generate().WithPhysics(typeof(BoxCollider2D), .5f).WithGraphics("Images/gun");
            Interactive   c      = Ego.AddComponent <Interactive>(entity);

            c.InteractAction = e => EgoEvents <AttachEvent> .AddEvent(new AttachEvent(c.GetComponent <EgoComponent>(), e));

            Ego.AddComponent <Mountpoint>(entity);
            Useable u = Ego.AddComponent <Useable>(entity);

            u.UseAction = e => {
                Transform transform = u.transform;
                double    theta     = transform.rotation.eulerAngles.z * Mathf.Deg2Rad;
                Vector2   force     = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta));
                force.Normalize();
                // generate new projectile, add motion in direction at speed

                EgoComponent bullet = Ego.AddGameObject(GenerateBullet().gameObject);
                bullet.transform.rotation = transform.rotation;
                bullet.transform.position = transform.position;
                bullet.gameObject.SetActive(true);
                EgoEvents <SetVelocityByEvent> .AddEvent(new SetVelocityByEvent(bullet, force));
            };
            return(entity);
        }