Beispiel #1
0
    //扩散感染自己临近的植物
    public void SpreadInfect()
    {
        List <MyPoint> points = FindNearPlant();

        //Debug.Log(points.Count);
        foreach (GameObject i in gameController.GetComponent <GameController>().plantList)
        {
            Plant p = i.GetComponent <Plant>();
            foreach (MyPoint point in points)
            {
                if (p.GetPoint().equal(point))
                {
                    int r = Random.Range(1, 10);
                    //有一定概率感染周围植物
                    if (r > spreadPercent)
                    {
                        Bug newBug = new Bug();
                        if (newBug.Infect(point))
                        {
                            GameObject.Find("Main Camera").GetComponent <BugController>().SendMessageUpwards("AddBug", newBug);
                        }
                    }
                }
            }
        }
    }
Beispiel #2
0
 //感染植物
 public void Infect()
 {
     round = GetRound();
     if (round >= 4)
     {
         List <MyPoint> points    = FindPlant();
         int            randomNum = Random.Range(0, points.Count);
         //Debug.Log(points.Count);
         if (points.Count != 0)
         {
             Bug bug = new Bug();
             //Debug.Log(points[randomNum].ToString());
             if (bug.Infect(points[randomNum]))
             {
                 bugList.Add(bug);
             }
         }
     }
 }