Пример #1
0
    protected override bool OnActivate()
    {
        ammo--;

        Vector3 position = player.transform.position;

        position.x -= placementDelta * player.transform.localScale.x;

        GameObject obj = GameObject.Instantiate(prefab, position, Quaternion.identity);

        Throwable throwable = obj.GetComponent <Throwable>();

        if (throwable)
        {
            throwable.SetDirection(player.transform.localScale.x);
        }

        TrashBag trashBag = obj.GetComponent <TrashBag>();

        if (trashBag)
        {
            trashBag.SetDirection(player.transform.localScale.x);
        }

        if (ammo <= 0)
        {
            OnDeactivate();
        }

        return(ammo <= 0);
    }
        // ====================================================================== Helper methods

        private void RedirectSafely(TrashBag bag, string targetPath)
        {
            if (bag == null)
            {
                CallDone(false);
                return;
            }

            var bagName = bag.Name;
            var back    = PortalContext.Current.BackUrl;

            if (string.IsNullOrEmpty(back))
            {
                HttpContext.Current.Response.Redirect(TrashBin.TrashBinPath);
            }

            if (back.Contains(bagName))
            {
                // Redirect to the original location
                HttpContext.Current.Response.Redirect(targetPath);
            }
            else
            {
                CallDone(false);
            }
        }
Пример #3
0
    //Open fridge and play opening animation
    public void Interact(PlayerController pController)
    {
        GrabableObject handPlayer = pController.pDatas.objectInHand;

        if (handPlayer != null)
        {
            TrashBag trashBag = handPlayer.GetComponent <TrashBag>();
            if (trashBag != null)
            {
                GrabableObject grabableReceived = pController.pInteract.ReleaseObject(false, false, false);
                Destroy(grabableReceived.gameObject);

                photonView.RPC("DestroyTrashBagOnline", RpcTarget.Others, pController.photonView.OwnerActorNr);
            }
            else
            {
                Poolable food = handPlayer.GetComponent <Poolable>();

                if (food != null)
                {
                    GameManager.Instance.Audio.PlaySound("Trash", AudioManager.Canal.SoundEffect);
                    pController.pInteract.ReleaseObject(true);
                    food.photonView.RPC("DelObjectOnline", RpcTarget.Others);
                    food.DelObject();
                }
            }
        }
    }
Пример #4
0
    private void OnTriggerEnter(Collider other)
    {
        TrashBag          trash = other.gameObject.GetComponentInParent <TrashBag>();
        jellyfishbehavior jelly = other.gameObject.GetComponentInParent <jellyfishbehavior>();

        if (trash != null)
        {
            Debug.Log("eat trash not null");
            this.gameObject.GetComponent <PlayerHealth>().eatTrash();
        }
        else if (jelly != null)
        {
            Debug.Log("ate jelly");
            this.gameObject.GetComponent <PlayerHealth>().eatJelly();
        }
        Destroy(other.gameObject);
    }
Пример #5
0
        //====================================================================== Helper methods

        private void RedirectSafely(TrashBag bag, string targetPath)
        {
            if (bag == null)
            {
                CallDone(false);
                return;
            }

            var bagName = bag.Name;
            var back    = PortalContext.Current.BackUrl;

            if (string.IsNullOrEmpty(back))
            {
                HttpContext.Current.Response.Redirect(TrashBin.TrashBinPath);
            }

            if (back.Contains(bagName))
            {
                //Redirect to the original location
                HttpContext.Current.Response.Redirect(targetPath);

                //ALTERNATIVE BEHAVIOR: redirect to the back url that is stored in the current back url...
                //if (back.Contains(PortalContext.BackUrlParamName))
                //{

                //var nextBack = back.Substring(back.IndexOf(PortalContext.BackUrlParamName + "=")).Remove(0, PortalContext.BackUrlParamName.Length + 1);
                //if (nextBack.Contains("&"))
                //    nextBack = nextBack.Remove(nextBack.IndexOf("&"));

                //HttpContext.Current.Response.Redirect(HttpUtility.UrlDecode(nextBack));
                //}
                //else
                //{
                //    HttpContext.Current.Response.Redirect(TrashBin.TrashBinPath);
                //}
            }
            else
            {
                CallDone(false);
            }
        }