コード例 #1
0
    public bool AddNewAves(GameObject newAves, int father = 0, int mother = 0)
    {
        var words = newAves.name.Split('-');

        if (avesSettled.Count == 0)
        {
            // 若地块还没有任何鸟类,标记地块标识
            avesFlag = words[0];
        }
        else
        {
            if (avesFlag != words[0])
            {
                Debug.Log("该地图已被其他鸟类占领");
                return(false);
            }
        }
        avesSettled.Add(newAves);
        Aves aves = newAves.GetComponent <Aves>();

        aves.parentsIndex[0] = father;
        aves.parentsIndex[1] = mother;
        avesScriptsDic.Add(newAves, aves);
        newAves.transform.position = transform.position;
        newAves.transform.parent   = transform;
        newAves.SetActive(true);
        newAves.GetComponent <Aves>().HandlePlots();
        return(true);
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: Atthur-i/Tugas-7-abstraksi
        static void Main(string[] args)
        {
            Vertebrata vertebrata;

            vertebrata = new Mamalia();
            vertebrata.Bernapas();

            Console.WriteLine();
            vertebrata = new Pisces();
            vertebrata.Bernapas();

            Console.WriteLine();
            vertebrata = new Amphibia();
            vertebrata.Bernapas();

            Console.WriteLine();
            IVertebrata ivertebrata;

            ivertebrata = new Reptilia();
            ivertebrata.Bernapas();

            Console.WriteLine();
            ivertebrata = new Aves();
            ivertebrata.Bernapas();

            Console.ReadKey();
        }
コード例 #3
0
    private void HandleAvesCopulation()
    {
        copulationCheckTimer += Time.deltaTime;
        if (copulationCheckTimer < copulationCheckThresholdTime)
        {
            return;
        }
        // 重置计时器
        copulationCheckTimer = 0;

        if (avesSettled.Count != 2)
        {
            // 入住鸟数不等于2,不考虑交配:1不满足交配条件;3已达地块容纳最大数量
            return;
        }

        // 缓存两只鸟的信息
        Aves aves1 = avesScriptsDic[avesSettled[0]];
        Aves aves2 = avesScriptsDic[avesSettled[1]];

        // 对入住鸟类的性别进行鉴定
        if (aves1.isMale == aves2.isMale)
        {
            return;
        }
        // 对入住鸟类的成熟性进行鉴定,小鸟不宜
        if (!aves1.isMature || !aves2.isMature)
        {
            return;
        }
        // 对入住鸟类的进行伦理鉴定
        if (aves1.isFromCopulation)
        {
            if (aves1.parentsIndex[0] == aves2.ID || aves1.parentsIndex[1] == aves2.ID)
            {
                return;
            }
        }
        if (aves2.isFromCopulation)
        {
            if (aves2.parentsIndex[0] == aves1.ID || aves2.parentsIndex[1] == aves1.ID)
            {
                return;
            }
        }

        // 产出小鸟
        Debug.Log("小鸟出生");
        int fatherID, motherID;

        fatherID = aves1.isMale ? aves1.ID : aves2.ID;
        motherID = aves1.isMale ? aves2.ID : aves1.ID;
        AddNewAves(Instantiate(avesSettled[0]), fatherID, motherID);
        HandleCopulationGuide();
    }
コード例 #4
0
    public ListadeAves()
    {
        ListadeAve = new List <Aves>();

        Aves a  = new Aves("Mango", 5, "Macho", 3, true, "Verde", "Guacamaya");
        Aves a1 = new Aves("Manzana", 5, "Hembra", 3, true, "Rojo", "Guacamaya");
        Aves a2 = new Aves("Cielo", 5, "Hembra", 3, true, "Azul", "Guacamaya");

        ListadeAve.Add(a);
        ListadeAve.Add(a1);
        ListadeAve.Add(a2);
    }
コード例 #5
0
        static void Main(string[] args)
        {
            //////////////
            // Estructura normal
            Aves aguila = new Aves();

            Console.WriteLine($"Aguila: Garras:{ aguila.Garras} - Alas: {aguila.Alas} - Plumas:{aguila.Plumas} ");

            Peces salmon = new Peces();

            Console.WriteLine($"Salon: Branquias: {salmon.Branquias} - Aletas {salmon.Aletas}");

            Reptiles cocodrilo = new Reptiles();

            Console.WriteLine($"CocodriloAlien: Garras:{ cocodrilo.Garras} - Alas: {cocodrilo.Alas} - Plumas:{cocodrilo.Plumas}  - Branquias: {cocodrilo.Branquias} - Aletas {cocodrilo.Aletas}");

            ////////////////////////////////////
            IVoladores volador = aguila;

            Console.WriteLine($"Volador: Garras:{ volador.Garras} - Alas: {volador.Alas} - Plumas:{volador.Plumas} ");
            volador = cocodrilo;
            Console.WriteLine($"Volador: Garras:{ volador.Garras} - Alas: {volador.Alas} - Plumas:{volador.Plumas} ");

            ///////////////////////////////////
            IAcuaticos acuatico = salmon;

            Console.WriteLine($"acuatico: Branquias: {acuatico.Branquias} - Aletas {acuatico.Aletas}");
            acuatico = cocodrilo;
            Console.WriteLine($"acuatico: Branquias: {acuatico.Branquias} - Aletas {acuatico.Aletas}");


            // Collections and generics
            List <string> a = new List <string>();

            a.Add("a");

            List <int> b = new List <int>();

            b.Add(2);

            Testing <Reptiles> testing = new Testing <Reptiles>();

            testing.Get(cocodrilo);

            Testing <Aves> testingA = new Testing <Aves>();

            testingA.Get(aguila);
            Console.ReadKey();
        }
コード例 #6
0
 /// <summary>
 /// 迁移鸟类,成功返回ture,失败返回false
 /// </summary>
 /// <returns></returns>
 public bool TransitionAves()
 {
     if (!Check(source.avesFlag, source.GetAvesSettled().Count, dest.avesFlag, dest.GetAvesSettled().Count))
     {
         return(false);
     }
     // 迁移鸟类
     foreach (var aves in source.GetAvesSettled())
     {
         Aves a = aves.GetComponent <Aves>();
         dest.AddNewAves(aves, a.parentsIndex[0], a.parentsIndex[1]);
     }
     source.ClearAves();
     return(true);
 }
コード例 #7
0
        static void Main(string[] args)
        {
            int opcion         = 0;
            FabricaMamiferos f = new FabricaMamiferos();
            Zoologico        z = new Zoologico("SantaCruz", "3eranillo", 72855884);

            while (opcion != 7)
            {
                Console.Clear();
                Console.WriteLine("1. Ingresar mamifero");

                Console.WriteLine("2. Mostrar jaula");
                Console.WriteLine("3. Ingresar ave");
                Console.WriteLine("4. Mostrar Aviario");
                Console.WriteLine("5. Ingresar pez");
                Console.WriteLine("6. Mostrar Acuario");
                Console.WriteLine("7. Salir");

                opcion = int.Parse(Console.ReadLine());
                switch (opcion)
                {
                case 1:
                    Console.Clear();
                    Console.WriteLine("Que mamifero vaingresar (mono/oso/leon)? ");
                    string animal = Console.ReadLine();
                    Console.WriteLine("Nombre? ");
                    string nombre = Console.ReadLine();
                    Console.WriteLine("Temperatura? ");
                    double temperatura = Double.Parse(Console.ReadLine());
                    Console.WriteLine("nro patas ");
                    double ndepat = Double.Parse(Console.ReadLine());

                    Mamiferos uno = f.getMamifero(animal, nombre, temperatura, ndepat);
                    z.anadirMamifero(uno, 10, 5, 3);
                    Console.ReadKey();
                    break;

                case 2:
                    z.imprimir();
                    Console.ReadKey();
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine("Que Ave va ingresar (Condor/Aguila/Loro)? ");
                    string ave = Console.ReadLine();
                    Console.WriteLine("Nombre? ");
                    string nom = Console.ReadLine();
                    Console.WriteLine("Peso? ");
                    double peso = Double.Parse(Console.ReadLine());
                    Console.WriteLine("tamaño alas ");
                    double tamañoalas = Double.Parse(Console.ReadLine());

                    Aves dos = f.getAves(ave, nom, peso, tamañoalas);
                    z.anadirAves(dos, 10, 5, 3);
                    Console.ReadKey();
                    break;

                case 4:
                    z.imprimir();
                    Console.ReadKey();

                    break;

                case 5:
                    Console.Clear();
                    Console.WriteLine("Que Ave va ingresar (Condor/Aguila/Loro)? ");
                    string pez = Console.ReadLine();
                    Console.WriteLine("Nombre? ");
                    string nomb = Console.ReadLine();
                    Console.WriteLine("Peso? ");
                    double longitud = Double.Parse(Console.ReadLine());


                    Pezes tres = f.getPezes(pez, nomb, longitud);
                    z.anadirAcuario(tres, 10, 5, 3);
                    Console.ReadKey();
                    break;

                case 6:
                    z.imprimir();
                    Console.ReadKey();
                    break;
                }
            }
        }
コード例 #8
0
 public ActionResult Aves(Aves aves)
 {
     aves_a.Add(aves);
     return(View());
 }