Пример #1
0
        public void TwoParts()
        {
            var sut      = new PartSystem();
            var p1       = new Part("A", "1");
            var p2       = new Part("B", "2");
            var vd       = new Accountability(p1, p2, "VD");
            var employer = new Accountability(p2, p1, "Arbetsgivare");

            sut.AddPart(p1);
            sut.AddPart(p2);
            sut.AddAccountability(vd);
            sut.AddAccountability(employer);
            int actual = sut.NumberOfParts;

            Assert.AreEqual(2, actual);
            actual = sut.NumberOfAccountabilites;
            Assert.AreEqual(2, actual);
        }
Пример #2
0
        public void ResponsibilitiesForGivenPart()
        {
            var sut      = new PartSystem();
            var p1       = new Part("A", "1");
            var p2       = new Part("B", "2");
            var vd       = new Accountability(p1, p2, "VD");
            var employer = new Accountability(p2, p1, "Arbetsgivare");

            sut.AddPart(p1);
            sut.AddPart(p2);
            sut.AddAccountability(vd);
            sut.AddAccountability(employer);
            List <Accountability> accountabilites = sut.ResponsibilitesByParty(p2);

            foreach (var acc in accountabilites)
            {
                Debug.WriteLine(acc.ToString());
            }
            Assert.AreEqual(1, accountabilites.Count);
        }
Пример #3
0
    public void InstantiateLoot()
    {
        PartSystem[] part = GetComponentsInChildren <PartSystem>();

        for (int i = 0; i < part.Length; i++)
        {
            GameObject newObject = Instantiate(PickUp, transform.position, transform.rotation) as GameObject;
            Instantiate(deadParticle, newObject.transform.position, Quaternion.Euler(-90, 0, Random.Range(0f, 360f)), newObject.transform);
            newObject.transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z);
            newObject.AddComponent <PartSystem>();
            PartSystem newPart = newObject.GetComponentInChildren <PartSystem>();
            newPart.partBody = part[i].partBody;
            newPart.InitiatePartBody();
            newPart.gameObject.AddComponent <PolygonCollider2D>();

            float   random_x  = Random.Range(-1f, 1f);
            Vector2 randomDir = new Vector2(random_x, 0.5f);

            newPart.GetComponent <Rigidbody2D>().AddForce(randomDir * 300);
        }
    }
Пример #4
0
    public void GoToLoot()
    {
        PartSystem partSyst = GetComponent <PartSystem>();

        if (partSyst.partBody != null)
        {
            float posX = transform.position.x;
            posX = (posX / 20f);
            float random = 0;
            random = Random.Range(-1f, 1f) + posX;

            if (random < 0f)
            {
                lootManager.stockPart_P1.Add(partSyst.partBody);
            }
            else
            {
                lootManager.stockPart_P2.Add(partSyst.partBody);
            }
        }
        Destroy(gameObject);
    }