Exemplo n.º 1
0
 public void DoRun(SimpleAI sAI, string code)
 {
     if (code == "Generate")
     {
         if (sAI.GetComponent <WhiteComponent> ().firWhite != null && sAI.GetComponent <WhiteComponent>().mather)
         {
             Vector3  genepos = (sAI.mAIRT.transform.position + sAI.GetComponent <WhiteComponent> ().firWhite.mAIRT.transform.position) / 2;
             SimpleAI tAI     = new SimpleAI();
             sAI.mWorld.registerEntityAfterInit(tAI);
             tAI.Init(sAI.mSimpleAIRunner, sAI.mSimpleAIStateJudger, sAI.mAITemplate, sAI.mPlayer, genepos);
             tAI.AddComponent <WhiteComponent> (new WhiteComponent());
             tAI.GetComponent <WhiteComponent> ().mather = (Random.Range(0, 2) % 2 == 0) ? true : false;
         }
     }
     else
     {
         if (sAI.GetComponent <WhiteComponent> ().timer2 >= 5.0f)
         {
             sAI.GetComponent <WhiteComponent> ().timer2 = 0.0f;
             sAI.GetComponent <WhiteComponent> ().target = sAI.GeneratePos + new Vector3(Random.Range(-15, 15), 0, Random.Range(-15, 15));
         }
         else
         {
             sAI.GetComponent <WhiteComponent> ().timer2 += Time.deltaTime;
         }
         sAI.GetComponent <AIMove> ().mDirection = sAI.GetComponent <WhiteComponent> ().target - sAI.mAIRT.transform.position;
         sAI.GetComponent <AIMove> ().mVelocity  = 5.0f;
     }
 }
Exemplo n.º 2
0
//	blackAndWhiteWorld bwWorld = new blackAndWhiteWorld();

    void Start()
    {
        //	bwWorld.Init ();
        for (int i = 0; i < blackcount; i++)
        {
            SimpleAI blackAI = new SimpleAI();
            ECSWorld.MainWorld.registerEntityAfterInit(blackAI);
            blackAI.Init(new BlackRunner(), new BlackJudge(), black, null, instance.transform.position + new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)));
            blackAI.AddComponent <BlackComponent> (new BlackComponent());
        }
        for (int i = 0; i < whitecount; i++)
        {
            SimpleAI whiteAI = new SimpleAI();
            ECSWorld.MainWorld.registerEntityAfterInit(whiteAI);
            whiteAI.Init(new WhiteRunner(), new WhiteJudge(), white, null, instance.transform.position + new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)));
            whiteAI.AddComponent <WhiteComponent> (new WhiteComponent());
            whiteAI.GetComponent <WhiteComponent> ().mather = (i % 2 == 0) ? true : false;
        }
    }