예제 #1
0
 private void changeChild()
 {
     numberOfAttributes = random.Next(1, 5);
     child        = this.getRandomLostChildWithNAttributes(numberOfAttributes);
     pointsToGive = numberOfAttributes * POINTS_PER_ATTRIBUTE;
     CreateInfo(getChild());
 }
예제 #2
0
    private void setToddlerProperties(GameObject kid, LostChild properties)
    {
        var renderers = kid.GetComponentsInChildren <Renderer>();

        foreach (var renderer in renderers)
        {
            renderer.material.SetColor("_Color", picker.GetColor(properties.getColor()));
        }

        var size = picker.GetSize(properties.getSize());

        kid.transform.localScale = new Vector3(size, 1, size);

        var positions = kid.GetComponent <ToddlerPositions>();

        var hatParent = positions.hatTransform;
        var hat       = Instantiate(picker.GetHat(properties.getHat()));

        hat.transform.position   = hatParent.transform.position;
        hat.transform.localScale = new Vector3(size, 1, size);
        hat.transform.parent     = hatParent;

        var handParent = positions.handTransform;
        var item       = Instantiate(picker.GetItem(properties.getStolenItem()));

        item.transform.position = handParent.transform.position;
        item.transform.parent   = handParent;
    }
예제 #3
0
    private void CreateInfo(LostChild childToFind)
    {
        string childSize;

        if (childToFind.getSize().ToString() == "ThiccOhhLordHeComing")
        {
            childSize = "Thicc";
        }
        else
        {
            childSize = childToFind.getSize().ToString();
        }
        var infoText = childToFind.getColor() + "\n" + childSize + "\n" + childToFind.getHat() + "\n" + childToFind.getStolenItem();

        info.text = infoText;
    }
예제 #4
0
    public bool offerChild(LostChild offeredChild, string playerName)
    {
        int matchingAttributes = 0;

        if (child.getSize() != null && child.getSize() == offeredChild.getSize())
        {
            matchingAttributes = matchingAttributes + 1;
        }

        if (child.getHat() != null && child.getHat() == offeredChild.getHat())
        {
            matchingAttributes = matchingAttributes + 1;
        }

        if (child.getColor() != null && child.getColor() == offeredChild.getColor())
        {
            matchingAttributes = matchingAttributes + 1;
        }

        if (child.getStolenItem() != null && child.getStolenItem() == offeredChild.getStolenItem())
        {
            matchingAttributes = matchingAttributes + 1;
        }

        int scoreNeededToPass = random.Next(1, numberOfAttributes + 1);

        if (matchingAttributes >= scoreNeededToPass)
        {
            //Debug.Log("passed");
            sounds.AcceptSound();
            changeChild();

            /* Give player points */
            //Debug.Log("Give player: " + playerName + " " + pointsToGive + " points.");
            gameController.givePoints(playerName, pointsToGive);
            int newScore = gameController.getPlayerScore(playerName);
            //Debug.Log("New points: " + newScore);
            scoreController.GetComponent <ScoresController>().updateStatusText(playerName, newScore);

            return(true);
        }

        Debug.Log("failed");
        sounds.RejectSound();
        return(false);
    }
예제 #5
0
    public void spawnChild(LostChild properties, bool forceSpawn = false)
    {
        var freeSpawnPoints = getSpawnPoints(forceSpawn);

        if (freeSpawnPoints.Count == 0)
        {
            return;
        }
        var index = Random.Range(0, freeSpawnPoints.Count);

        var position = freeSpawnPoints[index].transform.position;

        var newToddler = Instantiate(toddler, position, new Quaternion());

        newToddler.GetComponent <ToddlerInfo>().toddlerInfo = properties;
        setToddlerProperties(newToddler, properties);
    }
예제 #6
0
    private static void spawnLostChild(bool noLimit = false)
    {
        if (Instance.childCount > Instance.maxChilds && noLimit == false)
        {
            return;
        }
        LostChild child = getRandomLostChild();

        Instance.spawner.spawnChild(child, noLimit);

        /*
         * Debug.Log(child.getSize());
         * Debug.Log(child.getStolenItem());
         * Debug.Log(child.getHat());
         * Debug.Log(child.getColor());
         */

        Instance.childCount = Instance.childCount + 1;
    }
예제 #7
0
    private LostChild getRandomLostChildWithNAttributes(int pNumberOfAttributes)
    {
        int numberOfAttributes = pNumberOfAttributes;

        if (numberOfAttributes < 1)
        {
            numberOfAttributes = 1;
        }
        else if (numberOfAttributes > 4)
        {
            numberOfAttributes = 4;
        }

        Array sizeValues       = Enum.GetValues(typeof(LostChild.Size));
        Array hatValues        = Enum.GetValues(typeof(LostChild.Hat));
        Array colorValues      = Enum.GetValues(typeof(LostChild.Color));
        Array stolenItemValues = Enum.GetValues(typeof(LostChild.StolenItem));

        LostChild randomChild = new LostChild(
            (LostChild.Size)sizeValues.GetValue(random.Next(sizeValues.Length)),
            (LostChild.Hat)hatValues.GetValue(random.Next(hatValues.Length)),
            (LostChild.Color)colorValues.GetValue(random.Next(colorValues.Length)),
            (LostChild.StolenItem)stolenItemValues.GetValue(random.Next(stolenItemValues.Length))
            );

        for (int i = 0; i < 4 - numberOfAttributes; i++)
        {
            bool fieldRemoved = false;

            while (fieldRemoved != true)
            {
                int randomInt = random.Next(0, 4);

                switch (randomInt)
                {
                case 0:
                    if (randomChild.getSize() != null)
                    {
                        randomChild.setSize(null);
                        fieldRemoved = true;
                    }
                    break;

                case 1:
                    if (randomChild.getHat() != null)
                    {
                        randomChild.setHat(null);
                        fieldRemoved = true;
                    }
                    break;

                case 2:
                    if (randomChild.getColor() != null)
                    {
                        randomChild.setColor(null);
                        fieldRemoved = true;
                    }
                    break;

                case 3:
                    if (randomChild.getStolenItem() != null)
                    {
                        randomChild.setStolenItem(null);
                        fieldRemoved = true;
                    }
                    break;

                default:
                    break;
                }
            }
        }


        /*
         * Debug.Log(randomChild.getSize());
         * Debug.Log(randomChild.getStolenItem());
         * Debug.Log(randomChild.getHat());
         * Debug.Log(randomChild.getColor());
         */


        return(randomChild);
    }
예제 #8
0
 internal void _OnLostChild(ITreeNode <T> child)
 {
     LostChild?.Invoke(this, child);
 }