Exemple #1
0
    protected override void EndDrag(MoveObject otherObject)
    {
        Cow otherCow = (Cow)otherObject;

        if (!otherCow)
        {
            return;
        }
        if (otherCow.Level != 1 || Level != 1)
        {
            return;
        }
        if (Genetics.Count < 2 || otherCow.Genetics.Count < 2)
        {
            return;
        }

        List <GeneticProps> newList = new List <GeneticProps>();

        foreach (GeneticProps props in Genetics)
        {
            newList.Add(props);
        }
        foreach (GeneticProps props in otherCow.Genetics)
        {
            newList.Add(props);
        }

        newList.Shuffle();

        Cow newCow = Cow.Create(transform.position + Quaternion.Euler(0, Random.value * 360f, 0) * new Vector3(Random.value, 0, Random.value) * 4f);

        if (newCow)
        {
            newCow.Level = Level + 1;
            foreach (GeneticProps props in newList)
            {
                newCow.Genetics.Add(props);
            }
            newCow.RecalculateGenetic();
        }
    }