void OnSceneGUI()
    {
        CarryObject obj = (CarryObject)target;

        Handles.color = Color.red;
        Handles.DrawWireDisc(obj.transform.position, new Vector3(0, 1, 0), obj.radius);
    }
Beispiel #2
0
 private void Start()
 {
     _movement         = GetComponent <Movement>();
     _carryObject      = GetComponent <CarryObject>();
     _objectInteractor = GetComponent <ObjectInteractor>();
     _animator         = GetComponent <Animator>();
 }
    void UpdatePickup()
    {
        // TODO patience or forward progress check
        // similar to gather:
        if (Time.time - PickupStartTime > PickupPatience)
        {
            PopState();
            return;
        }

        if (ObjectToPickup == null)
        {
            PopState();
            return;
        }

        if (ObjectToPickup.transform != HeldObject)
        {
            // if within view of where the object was last seen
            const float PickupSourceRadius = 2f;
            if (Vector3.SqrMagnitude(moveTransform.position - PickupObjectLastKnownPosition) < PickupSourceRadius * PickupSourceRadius)
            {
                // if we can see the object is held by another character then ignore it
                if (CanSeeObject(ObjectToPickup, false))
                {
                    CarryObject swag = ObjectToPickup.GetComponent <CarryObject>();
                    if (swag != null && swag.IsHeld)
                    {
                        PopState();
                        return;
                    }
                }
            }
        }
    }
    void UpdateGather()
    {
        if (Time.time - GatherStartTime > GatherUpdatePatience)
        {
            PopState();
            return;
        }

        if (GatherObject == null)
        {
            PopState();
            return;
        }

        if (GatherObject != HeldObject)
        {
            // if within view of where the object was last seen
            const float GatherSourceRadius = 2f;
            if (Vector3.SqrMagnitude(moveTransform.position - GatherObjectLastKnownPosition) < GatherSourceRadius * GatherSourceRadius)
            {
                // if we can see the object is held by another character then ignore it
                if (CanSeeObject(GatherObject.gameObject, false))
                {
                    CarryObject swag = GatherObject.GetComponent <CarryObject>();
                    if (swag != null && swag.IsHeld)
                    {
                        PopState();
                        return;
                    }
                }
            }
        }
    }
Beispiel #5
0
    // keep, acquire, collect, possess, store on person
    public bool AcquireObject(GameObject obj)
    {
        CarryObject swg = obj.GetComponent <CarryObject>();

        if (swg != null && !swg.IsHeld)
        {
            if (swg.Item != null)
            {
                if (CanAcquireItem(swg.Item))
                {
                    GameObject go = GameObject.Instantiate(swg.Item.gameObject, moveTransform.position + Vector3.up * 0.3f, Quaternion.identity, moveTransform);
                    go.name = swg.Item.name;
                    AcquireItem(go.GetComponent <InventoryItem>());
                    GameObject.Destroy(obj);
                    return(true);
                }
            }
        }
        InventoryItem item = obj.GetComponent <InventoryItem>();

        if (item != null)
        {
            if (CanAcquireItem(item))
            {
                AcquireItem(item);
                return(true);
            }
        }
        return(false);
    }
Beispiel #6
0
    private void Start()
    {
        rb = GetComponent <Rigidbody>();
        if (controllerNumber == 0 && playerNumber > 0 && playerNumber <= 4)
        {
            controllerNumber = StaticPlayerControllerMapping.GetControllerNumberForPlayer(playerNumber);
        }

        if (controllerNumber == 0)       // Still controller not set? then disable the game object as no player possess it
        {
            gameObject.SetActive(false); // hides the player if no player has possessed this player.
        }
        else
        {
            horizontalInputString = "Horizontal" + controllerNumber;
            verticalInputString   = "Vertical" + controllerNumber;
            actionInputString     = "Action" + controllerNumber;
            pickupInputString     = "Pickup" + controllerNumber;
        }

        carryObject = GetComponentInChildren <CarryObject>();
        if (carryObject == null)
        {
            Debug.LogError("No CarryObject script in childer for " + gameObject);
        }
    }
    private void Start()
    {
        _carryObject = GetComponent <CarryObject>();

        if (_carryObject == null)
        {
            Debug.LogError("CarryObject not found on GameObject, Destroying");
            Destroy(this);
        }
    }
Beispiel #8
0
    private void Start()
    {
        horizontalInputString = "Horizontal2";
        verticalInputString   = "Vertical2";
        actionInputString     = "Action1";
        pickupInputString     = "Pickup1";

        carryObject = GetComponentInChildren <CarryObject>();

        if (carryObject == null)
        {
            Debug.LogError("No CarryObject script in children for " + gameObject.name);
        }
    }
Beispiel #9
0
 void Start()
 {
     objectCollider  = gameObject.GetComponent <Collider>();
     sp              = GameObject.FindGameObjectWithTag("Player").GetComponent <ShootPortal>();
     rb              = GetComponent <Rigidbody>();
     efc             = GetComponent <ExtendedFlycam>();
     npb             = GetComponent <NewPlayerBehaviour>();
     co              = GameObject.Find("NewPlayer").GetComponent <CarryObject>();
     targetTransform = GameObject.Find("TargetPosition").transform;
     startPosition   = Camera.main.transform.InverseTransformPoint(targetTransform.position);
     bluePortal      = GameObject.FindGameObjectWithTag("BluePortal");
     orangePortal    = GameObject.FindGameObjectWithTag("OrangePortal");
     print(startPosition);
 }
    internal void SuckUp(CarryObject carryObject)
    {
        carryObject.OnSuckedIntoTube();

        carryObject.transform
        .DOShakePosition(carryObjectShakeDuration, 0.1f)
        .OnComplete(() =>
        {
            carryObject.transform.DOMove(tubeOpening.position, carryObjectSuckUpDuration).SetEase(Ease.OutExpo);
            carryObject.transform.DOScale(0.1f, carryObjectSuckUpDuration).SetEase(Ease.OutExpo)
            .OnComplete(() =>
            {
                Destroy(carryObject.gameObject);
            });
        });
    }