Пример #1
0
        public static void Life()
        {
            life l = new life();

            l.GetMammal();
            l.GetHoofed();
            l.GetAnimal();
            l.GetBird();
        }
Пример #2
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         life vidaEnemy = coll.gameObject.GetComponent <life>();
         coll.gameObject.GetComponent <Player>().charm = true;
         vidaEnemy.ApplyDamage(damage);
         DestroyObject(gameObject);
     }
 }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        playerHP = this;
        doodles  = GetComponentsInChildren <Image>();

        foreach (Image image in doodles)
        {
            image.enabled = false;
        }
    }
Пример #4
0
 /// <summary>
 /// Constructor that include a new default position
 /// </summary>
 /// <param name="nx"></param>
 /// <param name="ny"></param>
 Entity(int nx, int ny)
 {
     Status = life.alive;
     position = new POS();
     position.x = nx;
     position.y = ny;
     HP = 10;
     STM = 10;
     HPMax = 10;
     STMMax = 10;
 }
Пример #5
0
 /// <summary>
 /// Basic Constructor
 /// </summary>
 Entity()
 {
     Status = life.alive;
     position = new POS();
     position.x = 0;
     position.y = 0;
     HP = 10;
     STM = 10;
     HPMax = 10;
     STMMax = 10;
 }
Пример #6
0
 /// <summary>
 /// Constructor that include a new default position
 /// </summary>
 /// <param name="nx"></param>
 /// <param name="ny"></param>
 public Entity(int nx, int ny, string nn)
     : this(nn)
 {
     Status = life.alive;
     position = new POS();
     position.x = nx;
     position.y = ny;
     HP = 10;
     STM = 10;
     HPMax = 10;
     STMMax = 10;
 }
Пример #7
0
 /// <summary>
 /// Basic Constructor
 /// </summary>
 public Entity(string nn)
 {
     name = nn;
     Status = life.alive;
     position = new POS();
     position.x = 0;
     position.y = 0;
     HP = 10;
     STM = 10;
     HPMax = 10;
     STMMax = 10;
 }
Пример #8
0
 void OnTriggerStay2D(Collider2D coll)
 {
     if (coll.tag == "Enemy" && Enemy != null)
     {
         if (Input.GetButtonDown("Attack") && !anime.GetCurrentAnimatorStateInfo(0).IsName("Blend Tree"))
         {
             GameObject temp = Instantiate(hitPrefab) as GameObject;
             temp.transform.position = swordHit.position;
             life vidaEnemy = coll.gameObject.GetComponent <life> ();
             vidaEnemy.ApplyDamage(basicDamage);
         }
     }
 }
Пример #9
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Enemy")
     {
         foreach (ContactPoint2D contact in coll.contacts)
         {
             GameObject temp = Instantiate(hitPrefab) as GameObject;
             temp.transform.position = contact.point;
         }
         life vidaEnemy = coll.gameObject.GetComponent <life>();
         vidaEnemy.ApplyDamage(damage);
     }
 }
Пример #10
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         foreach (ContactPoint2D contact in coll.contacts)
         {
             GameObject temp = Instantiate(hitPrefab) as GameObject;
             temp.transform.position = contact.point;
         }
         if (!coll.gameObject.GetComponent <Player>().defense)
         {
             vidaEnemy = coll.gameObject.GetComponent <life>();
             vidaEnemy.ApplyDamage(damage);
         }
         DestroyObject(gameObject);
     }
 }
Пример #11
0
    void Start()
    {
// 1. 声明一个水果类,具有如下成员:颜色,名称,重量。
// 2. 声明一个苹果类继承自水果类,实例化一个1斤重的红色苹果。
        red_apple        = new apple();
        red_apple.name   = "red apple";
        red_apple.color  = "red";
        red_apple.weight = 1.0f;

//3. 随机实例化10个0.1到1.5斤重的红色苹果,求出这些苹果的总重量。
        furit[] red_apples00 = new furit[10];
        float   n            = 0f;

        for (int i = 0; i < red_apples00.Length; ++i)
        {
            red_apples00[i]        = new apple();
            red_apples00[i].name   = "red apple";
            red_apples00[i].color  = "red";
            red_apples00[i].weight = Random.Range(0.1f, 1.5f);
            n += red_apples00[i].weight;
        }
        Debug.Log("这些苹果的总重量:" + n);

//4. 已知绿色苹果8元/斤,红色苹果12元/斤,实例化5个0.5到1.8斤重的绿苹果,实例化6个0.2到1.2斤重的红苹果。求这些苹果的总价钱。
        furit[] red_apples01 = new furit[6];
        float   n1           = 0f;

        for (int i = 0; i < red_apples01.Length; ++i)
        {
            red_apples01[i]        = new apple();
            red_apples01[i].name   = "red apple";
            red_apples01[i].color  = "red";
            red_apples01[i].weight = Random.Range(0.2f, 1.2f);
            n1 += red_apples01[i].weight;
        }
        //Debug.Log(n1);
        furit[] green_apples01 = new furit[5];
        float   n2             = 0f;

        for (int i = 0; i < green_apples01.Length; ++i)
        {
            green_apples01[i]        = new apple();
            green_apples01[i].name   = "green apple";
            green_apples01[i].color  = "green";
            green_apples01[i].weight = Random.Range(0.5f, 1.8f);
            n2 += green_apples01[i].weight;
        }
        //Debug.Log(n2);
        float money = 0f;

        money = n1 * 12f + n2 * 8f;
        Debug.Log("这些苹果的总价钱:" + money);

//5. 白白喜欢吃的水果有苹果,桔子。巫巫喜欢吃的水果有苹果,西瓜。淡淡喜欢吃的水果有樱桃,哈密瓜。小猴子最喜欢吃的水果有香蕉。请声明数组存储三个人类和一只猴子。
        furit[] furits = new furit[6];
        furits[0]       = new apple();
        furits[0].name  = "apple";
        furits[0].color = "red color";
        furits[1]       = new oringe();
        furits[1].name  = "oringe";
        furits[1].color = "oringe color";
        furits[2]       = new watermelon();
        furits[2].name  = "watermelon";
        furits[2].color = "green color";
        furits[3]       = new melon();
        furits[3].name  = "melon";
        furits[3].color = "green color";
        furits[4]       = new cherry();
        furits[4].name  = "cherry";
        furits[4].color = "pink color";
        furits[5]       = new banana();
        furits[5].name  = "banana";
        furits[5].color = "yellow color";

        life[] lifes = new life[4];
        lifes[0]             = new baibai();
        lifes[0].name        = "baibai";
        lifes[0].favourite01 = furits[0];
        lifes[0].favourite02 = furits[1];
        lifes[1]             = new wuwu();
        lifes[1].name        = "wuwu";
        lifes[1].favourite01 = furits[0];
        lifes[1].favourite02 = furits[2];
        lifes[2]             = new dandan();
        lifes[2].name        = "dandan";
        lifes[2].favourite01 = furits[3];
        lifes[2].favourite02 = furits[4];
        lifes[3]             = new monkey();
        lifes[3].name        = "monkey";
        lifes[3].favourite01 = furits[5];
        lifes[3].favourite02 = furits[5];

// 6. 遍历数组,打印出白白喜欢吃的水果的名称和颜色。
// 7. 遍历数组,打印数组里非人类喜欢吃的水果的名称和颜色。
        for (int i = 0; i < lifes.Length; ++i)
        {
            if (lifes[i].name == "baibai")
            {
                Debug.Log("白白喜欢吃的水果的名称:" + lifes[i].favourite01.name + "和" + lifes[i].favourite02.name);
                Debug.Log("白白喜欢吃的水果的颜色:" + lifes[i].favourite01.color + "和" + lifes[i].favourite02.color);
            }
            if (lifes[i] is human == false)
            {
                Debug.Log("非人类喜欢吃的水果的名称:" + lifes[i].favourite01.name + "和" + lifes[i].favourite02.name);
                Debug.Log("非人类喜欢吃的水果的颜色:" + lifes[i].favourite01.color + "和" + lifes[i].favourite02.color);
            }
        }

//8. 已知白白最好的朋友是巫巫,巫巫最好的朋友是淡淡,淡淡最好的朋友是小猴子,小猴子最好的朋友是白白,打印出白白的好朋友的好朋友的好朋友喜欢吃的水果的名称和颜色。
        lifes[0].friend = lifes[1];
        lifes[1].friend = lifes[2];
        lifes[2].friend = lifes[3];
        lifes[3].friend = lifes[0];
        Debug.Log("白白的好朋友的好朋友的好朋友喜欢吃的水果的名称是:" + lifes[0].friend.friend.friend.favourite01.name + "和" + lifes[0].friend.friend.friend.favourite02.name);
        Debug.Log("白白的好朋友的好朋友的好朋友喜欢吃的水果的颜色是:" + lifes[0].friend.friend.friend.favourite01.color + "和" + lifes[0].friend.friend.friend.favourite02.color);
    }
Пример #12
0
 /// <summary>
 /// Decides weather or not the charcter is dead should probly only be called during a modHP call
 /// </summary>
 public void Kill()
 {
     if(HP <= 0)
     {
         Status = life.dead;
     }
 }
Пример #13
0
    // Start is called before the first frame update
    void Start()
    {
        //题目2
        Fruit a = new Fruit();

        a = new Apple();
        a.SetWeight(1);

        //题目3
        Fruit[] b      = new Fruit[10];
        float[] weight = new float[10];
        float   sum    = 0;

        for (int n = 0; n < b.Length; n++)
        {
            b[n]      = new Apple();
            weight[n] = Random.Range(0.1f, 1.5f);
            b[n].SetWeight((float)weight[n]);

            sum += weight[n];
        }



        Debug.Log(sum);

        //题目4
        Fruit[] c           = new Fruit[5];
        float[] weight2     = new float[5];
        float   money_green = 0;

        for (int n = 0; n < c.Length; n++)
        {
            b[n]       = new Apple();
            weight2[n] = Random.Range(0.5f, 1.8f);
            b[n].SetWeight((float)weight2[n]);
            money_green += (weight2[n] * 8);
        }

        Fruit[] d         = new Fruit[6];
        float[] weight3   = new float[6];
        float   money_red = 0;

        for (int n = 0; n < d.Length; n++)
        {
            b[n]       = new Apple();
            weight3[n] = Random.Range(0.2f, 1.2f);
            b[n].SetWeight((float)weight3[n]);

            money_red += (weight3[n] * 12);
        }
        float money_sum = money_green + money_red;

        Debug.Log(money_sum);


        life[] e = new life[4];
        e[0] = new human();
        e[1] = new human();
        e[2] = new human();
        e[3] = new animal();

        e[0].name = "Baibai";
        e[1].name = "Wuwu";
        e[2].name = "Dandan";
        e[3].name = "Houzi";

        e[0].favouritefruit    = new Fruit[2];
        e[0].favouritefruit[0] = new Apple();
        e[0].favouritefruit[1] = new Orange();

        e[1].favouritefruit    = new Fruit[2];
        e[1].favouritefruit[0] = new Apple();
        e[1].favouritefruit[1] = new Watermelon();

        e[2].favouritefruit    = new Fruit[2];
        e[2].favouritefruit[0] = new Cherry();
        e[2].favouritefruit[1] = new Hamigua();

        e[3].favouritefruit    = new Fruit[1];
        e[3].favouritefruit[0] = new Banana();

        //遍历数组 寻找出叫白白的? 打印出白白喜欢吃的水果的名称和颜色。 颜色??
        for (int n = 0; n < e[0].favouritefruit.Length; n++)
        {
            e[0].favouritefruit[n].Getname();
        }

        //遍历数组, 寻找非人类???怎么找??? 打印数组里非人类喜欢吃的水果的名称和颜色。
        for (int n = 0; n < e[3].favouritefruit.Length; n++)
        {
            e[3].favouritefruit[n].Getname();
        }

        e[0].friend = e[1];
        e[1].friend = e[2];
        e[2].friend = e[3];
        e[3].friend = e[0];

        for (int n = 0; n < e[0].friend.friend.friend.favouritefruit.Length; n++)
        {
            e[0].friend.friend.friend.favouritefruit[n].Getname();
        }
    }
Пример #14
0
 /// <summary>
 /// Decides weather or not the charcter is dead should probly only be called during a modHP call
 /// </summary>
 public void Kill()
 {
     if(HP <= 0)
     {
         Status = life.dead;
         Console.WriteLine(name + " Is Dead");
     }
 }
Пример #15
0
 void Awake()
 {
     agenteNM    = GetComponent <NavMeshAgent>();
     vida        = GetComponent <Vida>();
     vidaJogador = GameObject.FindWithTag("Player").GetComponent <Vida>();
 }