public string DoJudge(SimpleAI sAI) { float maxdis = 3.0f; SimpleAI gALL = SimpleAISetSingleton.getInstance().GetComponent <SimpleAISet> ().FindWithRiaus(sAI.mAIRT.transform.position, maxdis, 1 << LayerMask.NameToLayer("Default"), "White"); // sAI.GetComponent<BlackComponent> ().firWhite = gALL; sAI.GetComponent <WhiteComponent> ().timer1 += Time.deltaTime; if (sAI.GetComponent <WhiteComponent> ().timer1 >= 15.0f) { if (gALL != null) { sAI.GetComponent <WhiteComponent> ().timer1 = 0.0f; sAI.GetComponent <WhiteComponent> ().firWhite = gALL; return("Generate"); } else { return("Run"); } } else { return("Run"); } }
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; } }
public void DoRun(SimpleAI sAI, string code) { if (code == "Attack") { sAI.GetComponent <BlackComponent> ().timer1 = 0.0f; if (sAI.GetComponent <BlackComponent> ().firWhite != null) { SimpleAISetSingleton.getInstance().GetComponent <SimpleAISet> ().Delete(sAI.GetComponent <BlackComponent> ().firWhite); } } else { if (sAI.GetComponent <BlackComponent> ().timer2 >= 7.0f) { sAI.GetComponent <BlackComponent> ().timer2 = 0.0f; sAI.GetComponent <BlackComponent> ().target = sAI.GeneratePos + new Vector3(Random.Range(-15, 15), 0, Random.Range(-15, 15)); } else { sAI.GetComponent <BlackComponent> ().timer2 += Time.deltaTime; } sAI.GetComponent <AIMove> ().mDirection = sAI.GetComponent <BlackComponent> ().target - sAI.mAIRT.transform.position; sAI.GetComponent <AIMove> ().mVelocity = 5.0f; } }
// 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; } }