Inheritance: MonoBehaviour
Beispiel #1
0
    public override void Down(Ray interactRay)
    {
        RaycastHit hitt;

        if (Physics.Raycast(interactRay, out hitt, PlayerInteraction.interactRange, LayerMask.GetMask("Harvestable")))
        {
            Harvestable obj = hitt.collider.GetComponent <Harvestable>();
            if (obj != null)
            {
                //maybe 2 different types?
                //  one that pops off
                //  one that you can just grab
                Sample newSample = SampleDatabase.Instance.GetSampleByID(obj.sampleId);
                if (obj.destroy)
                {
                    Object.Destroy(obj.gameObject);
                    SampleBehaviour.SpawnInWorld(newSample, hitt.point);
                    //GameObject newObj = Object.Instantiate(newSample.worldPrefab, obj.transform.position, Quaternion.identity);
                    //newObj.transform.localScale = obj.transform.localScale;
                }
                else
                {
                    SampleBehaviour.SpawnInWorld(newSample, hitt.point);
                }
            }
        }
    }
Beispiel #2
0
    void OnTriggerEnter(Collider other)
    {
        SampleBehaviour sample = other.GetComponent <SampleBehaviour>();

        if (sample != null)
        {
            curSample = sample.sample;
        }
    }
Beispiel #3
0
 public void NewSample()
 {
     if (hold != null)
     {
         SampleBehaviour.SpawnInWorld(hold, outZone.position);
         hold     = null;
         inSample = null;
     }
 }
Beispiel #4
0
    public void SpawnInWorld()
    {
        //remove from inv
        //this will need to change
        InventoryPanel.Instance.inventory.RemoveSampleAt(curSlotTransform.GetComponent <SlotData>().SlotIndex);

        //finding component for player isn't great
        PlayerMaster player = gameObject.GetComponentInParent <PlayerMaster>();

        SampleBehaviour.SpawnInWorld(sample, player.transform.position + player.transform.forward);
    }
    void OnTriggerEnter(Collider other)
    {
        //TO DO
        // add a check so a second collision doesn't overwrite/wipe
        SampleBehaviour sample = other.GetComponent <SampleBehaviour>();

        if (sample != null)
        {
            curSample   = sample;
            sampleScale = curSample.transform.localScale;
        }
    }
Beispiel #6
0
    private void OnTriggerEnter(Collider other)
    {
        animator.Play("Crush");
        SampleBehaviour sample = other.GetComponent <SampleBehaviour>();

        if (sample != null)
        {
            if (!sample.fresh)
            {
                inSample = sample;
            }
        }
    }
    void OnTriggerEnter(Collider collider)
    {
        if (collider.tag.Equals("Sample"))
        {
            SampleBehaviour sampleBhv = collider.gameObject.GetComponent <SampleBehaviour>();

            if (sampleBhv.state == SampleBehaviour.SampleState.Picked)
            {
                Debug.Log("Dropping sample into : " + this.name);

                MainBehaviour.Instance.pincet.state = PincetBehaviour.PincetState.Dropped;
                tube.Dissolve(sampleBhv);
            }
        }
    }
Beispiel #8
0
    public static void _NCSDKWidgetPostAriticleWithImageCallback()
    {
        //		_ShowMessageToast ("Post Article With Image" );

        string     name = "CafeSdkController";
        GameObject obj  = GameObject.Find(name);

        if (obj == null)
        {
            obj = new GameObject("CafeSdkController");
            obj.AddComponent <SampleBehaviour> ();
        }

        SampleBehaviour behaviour = obj.GetComponent <SampleBehaviour> ();

        behaviour.OnClickScreenShotButton();
    }
Beispiel #9
0
    void FulfilTest()
    {
        //can use layer mask here (probably should)
        Collider[] hits = Physics.OverlapSphere(outZone.position, castRadius);

        foreach (Collider hit in hits)
        {
            SampleBehaviour sample = hit.GetComponent <SampleBehaviour>();
            if (sample != null)
            {
                Sample hold = tester.TestSample(sample.sample);
                if (hold != null)
                {
                    sample.GetComponent <SceneObject>().DestroySceneObj();
                    SampleBehaviour.SpawnInWorld(hold, outZone.position);
                }
            }
        }
    }
 void OnTriggerExit(Collider other)
 {
     curSample   = null;
     sampleScale = Vector3.zero;
 }
Beispiel #11
0
 public void SetPickedSample(SampleBehaviour sample)
 {
     this.sample = sample;
     this.state = PincetState.Picked;
 }
Beispiel #12
0
    public static List <Vector2> GetRandomPoints(Polygon boundingArea, float density, float avoidRadius, List <Vector2> avoidPoints, SampleBehaviour behaviour, bool testInsideBounds, SeededRandom rnd, bool doShuffle = true, bool testAvoidPoints = true)
    {
        float          num  = boundingArea.bounds.width;
        float          num2 = boundingArea.bounds.height;
        float          num3 = num / 2f;
        float          num4 = num2 / 2f;
        int            num5 = (int)Mathf.Floor(num * num2 / density);
        uint           num6 = (uint)Mathf.Sqrt((float)num5);
        int            pointsPerIteration = 10;
        uint           num7 = (uint)((float)num5 * 0.98f);
        Vector2        min  = boundingArea.bounds.min;
        Vector2        max  = boundingArea.bounds.max;
        List <Vector2> list = new List <Vector2>();

        switch (behaviour)
        {
        case SampleBehaviour.PoissonDisk:
            list = new UniformPoissonDiskSampler(rnd).SampleRectangle(min, max, density, pointsPerIteration);
            break;

        case SampleBehaviour.UniformSquare:
            for (float num25 = 0f - num4 + density; num25 < num4 - density; num25 += density)
            {
                for (float num26 = 0f - num3 + density; num26 < num3 - density; num26 += density)
                {
                    list.Add(boundingArea.Centroid() + new Vector2(num26, num25));
                }
            }
            break;

        case SampleBehaviour.UniformHex:
            for (uint num10 = 0u; num10 < num6; num10++)
            {
                for (uint num11 = 0u; num11 < num6; num11++)
                {
                    list.Add(boundingArea.Centroid() + new Vector2(0f - num3 + (0.5f + (float)(double)num10) / (float)(double)num6 * num, 0f - num4 + (0.25f + 0.5f * (float)(double)(num10 % 2u) + (float)(double)num11) / (float)(double)num6 * num2));
                }
            }
            break;

        case SampleBehaviour.UniformSpiral:
            for (uint num19 = 0u; num19 < num7; num19++)
            {
                double num20 = (double)num19 / (32.0 * (double)density * 8.0);
                double num21 = Math.Sqrt(num20 * 512.0 * (double)density);
                double num22 = Math.Sqrt(num20);
                double num23 = Math.Sin(num21) * num22;
                double num24 = Math.Cos(num21) * num22;
                list.Add(boundingArea.bounds.center + new Vector2((float)num23 * boundingArea.bounds.width, (float)num24 * boundingArea.bounds.height));
            }
            break;

        case SampleBehaviour.UniformCircle:
        {
            float num12 = 6.28318548f * avoidRadius;
            float num13 = num12 / density;
            float num14 = rnd.RandomValue();
            for (uint num15 = 1u; (float)(double)num15 < num13; num15++)
            {
                float  num16 = num14 + (float)(double)num15 / num13 * 3.14159274f * 2f;
                double num17 = Math.Cos((double)num16) * (double)avoidRadius;
                double num18 = Math.Sin((double)num16) * (double)avoidRadius;
                list.Add(boundingArea.bounds.center + new Vector2((float)num17, (float)num18));
            }
            break;
        }

        default:
            for (float num8 = 0f - num4 + avoidRadius * 0.3f + rnd.RandomValue() * 2f; num8 < num4 - (avoidRadius * 0.3f + rnd.RandomValue() * 2f); num8 += density + rnd.RandomValue())
            {
                for (float num9 = 0f - num3 + avoidRadius * 0.3f + rnd.RandomValue() * 2f + rnd.RandomValue() * 2f; num9 < num3 - (avoidRadius * 0.3f + rnd.RandomValue() * 2f); num9 += density + rnd.RandomValue())
                {
                    list.Add(boundingArea.Centroid() + new Vector2(num9, num8 + rnd.RandomValue() - 0.5f));
                }
            }
            break;
        }
        List <Vector2> list2 = new List <Vector2>();

        for (int i = 0; i < list.Count; i++)
        {
            if (!testInsideBounds || boundingArea.Contains(list[i]))
            {
                bool flag = false;
                if (testAvoidPoints && avoidPoints != null)
                {
                    for (int j = 0; j < avoidPoints.Count; j++)
                    {
                        if (Mathf.Abs((avoidPoints[j] - list[i]).magnitude) < avoidRadius)
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    list2.Add(list[i]);
                }
            }
        }
        if (doShuffle)
        {
            list2.ShuffleSeeded(rnd.RandomSource());
        }
        return(list2);
    }
Beispiel #13
0
 public void SetPickedSample(SampleBehaviour sample)
 {
     this.sample = sample;
     this.state  = PincetState.Picked;
 }
Beispiel #14
0
 public void Dissolve(SampleBehaviour sample)
 {
     this.sample = sample;
     sample.state = SampleBehaviour.SampleState.Dissolving;
     state = TubeState.Dissolving;
 }
Beispiel #15
0
    // Update is called once per frame
    public void Tick(float delta)
    {
        //Input lock
        if (input.inputOn)
        {
            //Interaction Cast
            RaycastHit hitt;
            interactRay = new Ray(camera.camInstance.transform.position, camera.camInstance.transform.forward);

            if (Physics.Raycast(interactRay, out hitt, interactRange, LayerMask.GetMask("Interactable")))
            {
                IInteractable obj = hitt.collider.GetComponent <IInteractable>();
                if (obj != null)
                {
                    //Hovering on interactables
                    if (obj == hitLastFrame)
                    {
                        obj.OnHover();
                    }
                    else
                    {
                        obj.OnHoverEnter();
                        if (hitLastFrame != null)
                        {
                            hitLastFrame.OnHoverExit();
                            hitLastFrame = null;
                        }
                    }

                    //Interaction on interactables
                    if (Input.GetKeyDown(input.Interact.key))
                    {
                        obj.Interact(master);
                    }
                    else if (carrying)
                    {
                        if (input.Pocket.Down)
                        {
                            SampleBehaviour sampleIn = hitt.collider.GetComponent <SampleBehaviour>();
                            if (sampleIn != null)
                            {
                                //Add sample to inv if possible then destroy
                                if (inv.AddSample(sampleIn.sample))
                                {
                                    sampleIn.GetComponent <SceneObject>().DestroySceneObj();

                                    //Object.Destroy(hitt.collider.gameObject);
                                    carrying = false;
                                }
                            }
                        }
                    }
                    hitLastFrame = obj;
                }
                else if (hitLastFrame != null)
                {
                    Cleanup();
                }
            }
            else if (hitLastFrame != null)
            {
                Cleanup();
            }
        }
    }
Beispiel #16
0
 public void Dissolve(SampleBehaviour sample)
 {
     this.sample  = sample;
     sample.state = SampleBehaviour.SampleState.Dissolving;
     state        = TubeState.Dissolving;
 }