Inheritance: MonoBehaviour
Exemplo n.º 1
0
    void BeAttacked(SimpleAI attacker)
    {
        if (IsDie())
        {
            return;
        }
        if (target == null)
        {
            target = attacker;
            aiType = AIType.BATTLE;
        }

        //Debug.Log("hp " + hp);
        if (hp <= 0)
        {
            DoAction("die", true);
        }
        else
        {
            if (attacker.IsActionDone())
            {
                float hurt = attacker.GetAttack() - defend;
                hp = hp - hurt;
                //if(id == 2)
                //Debug.Log("hurt Time.."+Time.time);
            }
            DoAction("getHit", !IsBeAttacked());
        }
    }
Exemplo n.º 2
0
        public shootMup()
        {
            InitializeComponent();

            try
            {
                SuspendLayout();

                // initial setup
                AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
                AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
                ClientSize          = new System.Drawing.Size(1484, 1075);
                Name           = "shootMup";
                Text           = "shootMup";
                DoubleBuffered = true;

                // generate players
                var human = new ShootMPlayer()
                {
                    Name = "You"
                };
                var players = new Player[100];
                for (int i = 0; i < players.Length; i++)
                {
                    players[i] = new SimpleAI()
                    {
                        Name = string.Format("ai{0}", i)
                    }
                }
                ;

                // generate the world
                World = WorldGenerator.Generate(WorldType.Random, PlayerPlacement.Borders, human, ref players);

                // if we are training for AI, then capture telemetry
                World.OnBeforeAction += AITraining.CaptureBefore;
                World.OnAfterAction  += AITraining.CaptureAfter;
                World.OnDeath        += (elem) =>
                {
                    if (elem is Player)
                    {
                        var winners = new List <string>();

                        // capture the winners
                        foreach (var player in players)
                        {
                            winners.Add(string.Format("{0} [{1}]", player.Name, player.Kills));
                        }

                        AITraining.CaptureWinners(winners);
                    }
                };

                UI = new UIHookup(this, World);
            }
            finally
            {
                ResumeLayout(false);
            }
        }
Exemplo n.º 3
0
    public void GenerateEntriesByPos(Vector3 pos)
    {
        SimpleAI footAI = GenerateEntries();

        footAI.transform.position = pos;
        footAI.SetEntyColor(SimpleAI.EntyColor.BLUE);
    }
Exemplo n.º 4
0
 // battle logic
 // search enemy
 public bool FindTarget(bool resetSearchNum = false)
 {
     Debug.LogWarning(id + " : search Target -num: " + searchNum + "  force Search" + resetSearchNum + " die:" + IsDie());
     if (resetSearchNum)
     {
         searchNum = 0;
     }
     if (searchNum > MaxSearchCount)
     {
         Patrol();
         return(false);
     }
     else
     {
         searchNum += 1;
     }
     if (target == null)
     {
         target = battleManager.FindTarget(this);
         if (target)
         {
             searchNum = 0;
             aiType    = AIType.BATTLE;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
    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");
        }
    }
    void InitBrain()
    {
        Type type = Type.GetType(World.aISelected);

        activeAI = Activator.CreateInstance(type, this, GetBody(), GetDriveSystem(), GetMotorSystem(), GetSensorySystem(), GetPhenotype());
        simpleAI = new SimpleAI(this, GetBody(), GetDriveSystem(), GetMotorSystem(), GetSensorySystem(), GetPhenotype());
    }
Exemplo n.º 7
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.º 8
0
 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;
     }
 }
Exemplo n.º 9
0
        private void PutAIsInDatabase()
        {
            var simpleAI = new SimpleAI();

            ais.Add(simpleAI);
            aiByName.Add("Simple AI", simpleAI);
        }
    public Unit(int x, int y, int level) : base(x, y)
    {
        brain          = new SimpleAI(this);
        Map_position_x = x;
        Map_position_y = y;

        if (level < 0)
        {
            level = 0;
        }

        Max_Health = level - ((float)level) / 1.2f + 1;
        if (Max_Health < 0)
        {
            Max_Health = 1;
        }
        Health = Max_Health;
        Money  = level / 2;
        if (Money < 1)
        {
            Money = 12;
        }
        name = MainColour.ToString() + " unit";

        MainSpell = SpellGenerator.GetInstance().GetClosestSingleSpell(level / 4);
        Debug.Log("enemy hp: " + Max_Health + MainSpell.ToString());
    }
Exemplo n.º 11
0
 public void getHospitalServices(GameObject obj)
 {
     if (obj.tag == "Player") //Logic for player
     {
         Player p = obj.GetComponent <Player>();
         //Check if they are tested or not
         if (p.getVirusTest() == false && p.getCash() >= testingCost)
         {
             //Pay for the virus test
             p.deductCash(testingCost);
             //Apply test
             p.setVirusTest(p.isInfected());
         }
         else if (p.getVirusTest() == true && p.getCash() >= treatmentCost) //tested positive
         {
             //Pay for treatment
             p.deductCash(treatmentCost);
             //apply immune services
             if (Random.Range(0, 10) <= 7)
             {
                 p.setInfected(false);
                 p.setImmuneSystem(100);
             }
         }
         hospitalPanel.SetActive(false);
         p.unlockMovement();
     }
     else if (obj.tag == "AI") //Logic for AI
     {
         SimpleAI sai = obj.GetComponent <SimpleAI>();
         //Check if ai is infected
         if (sai.getVirusTest() == false)
         {
             if (sai.getCash() >= testingCost)
             {
                 //Deduct AI cash
                 sai.deductCash(testingCost);
                 sai.setVirusTest(sai.isInfected());
             }
         }
         while (sai.getVirusTest() == true)
         {
             if (sai.getCash() >= treatmentCost)
             {
                 //Deduct AI cash
                 sai.deductCash(treatmentCost);
                 //apply immune services
                 if (Random.Range(0, 10) <= 7)
                 {
                     sai.setInfected(false);
                     sai.setImmuneSystem(100);
                 }
             }
             else
             {
                 break;
             }
         }
     }
 }
Exemplo n.º 12
0
 public void Attack(SimpleAI defender)
 {
     if (defender == null)
     {
         return;
     }
     if (IsBeAttacked() && !IsActionDone())
     {
         return;
     }
     if (IsActionDone() || !IsAttacking())
     {
         if (IsActionDone() && IsAttacking())
         {
             defender.BeAttacked(this);
             attackBeginTime = Time.time;
             DoAction("attack_01");
         }
         //Debug.Log("is Attacking..." + IsAttacking()+" "+status);
         if (!IsAttacking())
         {
             DoAction("attack_01", true);
         }
     }
 }
Exemplo n.º 13
0
 public void SetPlayer(SimpleAI pl)
 {
     if (pl != null)
     {
         player = pl;
         player.LoadPlayerSetting();
     }
 }
Exemplo n.º 14
0
    public SimpleAI GenerateEntries()
    {
        GameObject footMan = Instantiate(footmanPrefab);//Resources.LoadAssetAtPath<GameObject>("Assets/Footman/Prefabs/Footman_Unlit_Green.prefab");// GameObject.Instantiate("Footman_Unlit_Green.prefab");
        SimpleAI   footAI  = footMan.AddComponent <SimpleAI>();

        footAI.BindBattleManager(this);
        entries.Add(footAI);
        return(footAI);
    }
Exemplo n.º 15
0
    void Start()
    {
        // load data from GameData:
        chanceToSpread = GameData.instance.npcSpreadChance;

        simpleAI        = GetComponent <SimpleAI>();
        spreadAbilities = GetComponent <npcSpreadAbilities>();
        float rand = Random.Range(5f, 7f);

        InvokeRepeating("AttemptToSpread", 1f, rand);  //1s delay, repeat every x seconds
    }
 private void SpawnEnemies()
 {
     Debug.Log("enemiesInRadius " + enemiesInRadius + " enemiesToSpawn " + enemiesToSpawn);
     if (enemiesInRadius <= 0 && enemiesToSpawn > 0)
     {
         GameObject   newEnemy        = GameObject.Instantiate(enemyProtoype);
         EnemyVehicle newEnemyVehicle = newEnemy.GetComponent <EnemyVehicle>();
         newEnemyVehicle.SpawnPoint = this;
         AddEnemyInRadius(newEnemyVehicle);
         SimpleAI enemyAI = newEnemy.GetComponent <SimpleAI>();
         enemyAI.SetPlayer(playerPlane);
     }
 }
Exemplo n.º 17
0
    private SimpleAI RePair(SimpleAIRePairer pRePairer, SimpleAIRunner pRunner, SimpleAIStateJudger pJudger,
                            GameObject pPrefab, GameObject pPlayer, SimpleAIDestroyer pDestroyer, string pType, GAObject pGAObject, int index)
    {
        SimpleAI sAI = new SimpleAI();

        sAI.Init(pRunner, pJudger, pPrefab, pPlayer, pGAObject.mPosition);
        sAI.mSimpleAIRepairer  = pRePairer;
        sAI.mSimpleAIDestroyer = pDestroyer;
        sAI.mType      = pType;
        sAI.mCharacter = pGAObject;
        sAI.mSimpleAIRepairer.DoRePair(sAI);
        sAI.mName = pType + "index" + index;
        return(sAI);
    }
Exemplo n.º 18
0
 public Game(BasicGame other) :
     base(new Simulation.Board(other.Board),
          (other.Player0 == null) ? null : other.Player0.Clone(),
          (other.Player1 == null) ? null : other.Player1.Clone())
 {
     if (Player0.IsOfType <Human>())
     {
         Player0 = new SimpleAI(other.Player0);
     }
     if (Player1.IsOfType <Human>())
     {
         Player1 = new SimpleAI(other.Player1);
     }
 }
Exemplo n.º 19
0
    public SimpleAI FindAIByRayCast(string tag)
    {
        Vector3    ScreenPoint = Input.mousePosition;
        Ray        myRay       = Camera.main.ScreenPointToRay(ScreenPoint);
        RaycastHit hit;

        if (Physics.Raycast(myRay, out hit, 100.0f, 1 << LayerMask.NameToLayer("Default")))
        {
            if (hit.collider.tag == tag)
            {
                SimpleAI my = SimpleAISetSingleton.getInstance().GetComponent <SimpleAISet> ().FindByGameObject(hit.collider.gameObject);
                return(my);
            }
        }
        return(null);
    }
Exemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     Camera.main.transform.LookAt(GameObject.Find("Cube").transform);
     joyPad = GameObject.Find("JoyPad").GetComponent <JoyPad>();
     if (footmanPrefab != null)
     {
         for (int i = 0; i < 2; i++)
         {
             SimpleAI footAI = GenerateEntries();
             footAI.transform.position = new Vector3((i - 1) * 20, 0, 0);
         }
         player          = GenerateEntries();
         roleCamera.role = player.gameObject;
         joyPad.SetPlayer(player);
     }
 }
Exemplo n.º 21
0
    public SimpleAI FindTarget(SimpleAI seeker)
    {
        SimpleAI target    = null;
        Vector3  seekerPos = seeker.transform.position;
        float    scope     = seeker.searchScope;

        foreach (SimpleAI iter in entries)
        {
            if (iter != seeker && !iter.IsDie())
            {
                Vector3 iterPos = iter.transform.position;
                if (scope < Vector3.Distance(seekerPos, iterPos))
                {
                    return(iter);
                }
            }
        }
        return(target);
    }
Exemplo n.º 22
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;
        }
    }
Exemplo n.º 23
0
 public void goToWork(GameObject obj)
 {
     if (obj.tag == "Player") //Logic for player
     {
         Player p = obj.GetComponent <Player>();
         if (p.canWorkCheck())         //Check if player can work
         {
             p.addCash(p.getIncome()); //Set it so they get their money
             p.setCanWork(false);      //Set it so they can't work again
         }
         workPanel.SetActive(false);
         p.unlockMovement();
     }
     else if (obj.tag == "AI")  //Logic for AI
     {
         SimpleAI sai = obj.GetComponent <SimpleAI>();
         sai.addCash(sai.getIncome());
         sai.setCanWork(false); //Set it so they can't work again
     }
 }
Exemplo n.º 24
0
 /// <summary>
 /// Start the game as soon as the initial unit is created.
 /// </summary>
 public void StartTheGame()
 {
     PlayerState.Get(playerControllerId).Population = 1;
     if (!IsHuman)
     {
         AIPlayer aiPlayer = factory.CreateAIPlayer();
         SimpleAI AI       = factory.CreateAI();
         aiPlayer.playerState = PlayerState.Get(playerControllerId);
         aiPlayer.gameState   = GameState.Instance;
         AI.aiPlayer          = aiPlayer;
     }
     else
     {
         endGameCanvas = GameObject.Find("EndGameCanvas");
         CustomLobbyManager manager = FindObjectOfType <CustomLobbyManager>();
         endGameCanvas.transform.Find("MenuButton").GetComponent <Button>().onClick.AddListener(manager.GoBack);
         endGameCanvas.SetActive(false);
     }
     CmdChangeInGame(true);
 }
Exemplo n.º 25
0
    private string brain2String(GameObject car)
    {
        string   temp  = "";
        SimpleAI carai = car.GetComponent <SimpleAI>();

        for (int i = 0; i < carai.weights.Length; i++)
        {
            for (int j = 0; j < carai.weights[i].Length; j++)
            {
                for (int k = 0; k < carai.weights[i][j].Length; k++)
                {
                    temp += "\t";
                    temp += carai.weights[i][j][k].ToString("f7");
                    temp += ",";
                }
            }
        }

        return(temp);
    }
Exemplo n.º 26
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            await Parser.Default.ParseArguments <StartupOptions>(e.Args).MapResult(async opts =>
            {
                if (!string.IsNullOrEmpty(opts.Hostname) &&
                    !string.IsNullOrEmpty(opts.Nickname) &&
                    opts.Port.HasValue)
                {
                    if (opts.UseAi)
                    {
                        var id     = Guid.NewGuid();
                        var client = new Client($"https://{opts.Hostname}:{opts.Port}/hub", opts.Nickname, id);

                        try
                        {
                            if (await client.ConnectAsync())
                            {
                                var ai                 = new SimpleAI();
                                client.ClientUI        = ai;
                                MainWindow.WindowState = WindowState.Minimized;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show($"Could not connect. {ex.Message}");
                        }
                    }
                    else
                    {
                        var home        = (HomeViewModel)ShellViewModel.Instance.MainRegion;
                        home.PortNumber = Convert.ToUInt16(opts.Port.Value);
                        home.Hostname   = opts.Hostname;
                        home.Nickname   = opts.Nickname;
                        await home.StartAsync();
                    }
                }
            }, err => throw new Exception());
        }
Exemplo n.º 27
0
 public void buyFood(GameObject obj)
 {
     if (obj.tag == "Player") //Logic for player
     {
         Player p = obj.GetComponent <Player>();
         if (p.getCash() >= foodCost)       //Check if player can afford food
         {
             p.deductCash(foodCost);        //Pay for food
             p.decreaseHunger(foodRestore); //Decrease hunger
         }
         foodPanel.SetActive(false);
         p.unlockMovement();
     }
     else if (obj.tag == "AI") //Logic for AI
     {
         SimpleAI sai = obj.GetComponent <SimpleAI>();
         if (sai.getCash() >= foodCost)
         {
             sai.deductCash(foodCost);        //pay for food
             sai.decreaseHunger(foodRestore); //Decrease hunger
         }
     }
 }
Exemplo n.º 28
0
    public override void PlaceInRoom(Room placeRoom)
    {
        base.PlaceInRoom(placeRoom);
        this.AI = new  SimpleAI(this);
        //遍历所有触手
        Vector2 middleOfBody = this.MiddleOfBody;

        for (int index = 0; index < this.tentacles.Length; ++index)
        {
            IntVector2 connectedTile = this.room.GetTilePosition(this.tentacles[index].connectedChunk.pos);
            //生物质心 到 触手连接Chunk的方向
            Vector2 dir = Utils.DirVec(middleOfBody, this.tentacles[index].connectedChunk.pos);
            //远方距离 = 方向 * 理想长度
            IntVector2 dist = this.room.GetTilePosition(this.tentacles[index].connectedChunk.pos + dir * this.tentacles[index].idealLength);
            //获取触手基座 到 顶尖的所有Tile,移除碰撞到Solid的
            List <IntVector2> vecLst = this.room.RayTraceTilesList(connectedTile.x, connectedTile.y, dist.x, dist.y);
            for (int i = 1; i < vecLst.Count; ++i)
            {
                if (this.room.GetTile(vecLst[i]).Solid)
                {
                    vecLst.RemoveRange(i, vecLst.Count - i);
                    break;
                }
            }
            //赋值触手的Segment
            this.tentacles[index].segments = vecLst;
            //Reset触手的所有Chunk
            for (int i = 0; i < this.tentacles[index].tChunks.Length; ++i)
            {
                this.tentacles[index].tChunks[i].Reset();
            }
            //触手抓取最后一个最后一个Tile
            this.tentacles[index].MoveGrabDest(this.room.MiddleOfTile(vecLst[vecLst.Count - 1]));
        }
        //初始化变量:无条件的支持力
        this.unconditionalSupport = 1f;
    }
Exemplo n.º 29
0
        public static void ShouldFindAllValidMoveDestinations()
        {
            //Unlike all other pieces, King requires an existing game in order to compute its available moves,
            //since it will potentially need to eliminate some moves as possibilities based on the state of the game
            //and the positions of the opponent's pieces
            Piece king  = new King(Color.white);
            var   board = new Board(squares: Board.DefaultEmptySquares());

            board['e', 4].Piece = king;
            var whitePlayer = new SimpleAI(Color.white);
            var blackPlayer = new SimpleAI(Color.black);
            var unused      = new Game.Simulation.Game(board, whitePlayer, blackPlayer);

            List <Chess.Game.Square> possibleMoves = king.FindAllPossibleLegalMoveDestinations();

            AssertContains(actual: possibleMoves, board['d', 5],
                           board['e', 5],
                           board['f', 5],
                           board['f', 4],
                           board['f', 3],
                           board['e', 3],
                           board['d', 3],
                           board['d', 4]);
        }
Exemplo n.º 30
0
    void Update()
    {
        if (temp != null)
        {
            GameObject.Destroy(temp);
        }
        if (sAI_ != null && sAI_.mAIRT != null)
        {
            sAI_.mAIRT.GetComponent <MeshRenderer> ().material.color = mSrc;
            sAI_ = null;
        }
        switch (mEnumType)
        {
        case TESTZOOLOGYMOUSE.NONE:
            break;

        case TESTZOOLOGYMOUSE.DELETECOW:
            SimpleAI sAI = FindAIByRayCast("Cow");
            if (sAI != null)
            {
                sAI_ = sAI;
                mSrc = sAI.mAIRT.GetComponent <MeshRenderer> ().material.color;
                sAI.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f);

                if (Input.GetMouseButton(0))
                {
                    sAI.Destroy();
                }
            }
            break;

        case TESTZOOLOGYMOUSE.DELETEGRASS:
            SimpleAI sAI1 = FindAIByRayCast("Glass");
            if (sAI1 != null)
            {
                sAI_ = sAI1;
                mSrc = sAI1.mAIRT.GetComponent <MeshRenderer> ().material.color;
                sAI1.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f);
                if (Input.GetMouseButton(0))
                {
                    sAI1.Destroy();
                }
            }
            break;

        case TESTZOOLOGYMOUSE.DELETETREE:
            SimpleAI sAI2 = FindAIByRayCast("Tree");
            if (sAI2 != null)
            {
                sAI_ = sAI2;
                mSrc = sAI2.mAIRT.GetComponent <MeshRenderer> ().material.color;
                sAI2.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f);
                if (Input.GetMouseButton(0))
                {
                    sAI2.Destroy();
                }
            }
            break;

        case TESTZOOLOGYMOUSE.ADDCOW:
            Vector3 pos = FindPointByRayCast();
            if (pos != Vector3.zero)
            {
                temp = GameObject.Instantiate(Cow, pos, Quaternion.identity) as GameObject;
                temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f);
                if (Input.GetMouseButton(0))
                {
                    CowObject co = new CowObject();
                    co.RandomData();
                    co.Type      = true;
                    co.mPosition = pos;
                    co.Encode();
                    co.InitBreakPoint();
                    SimpleAI scow = RePair(new CowRePairer(), new CowRunner(), new CowJudger(), Cow,
                                           Player, new CowDestroyer(), "Cow", co, GAPopulation.allDic["Cow"].mTempCount);
                    scow.mCharacter = co;
                    GAPopulation.allDic ["Cow"].Add(scow);
                }
                else if (Input.GetMouseButton(1))
                {
                    CowObject co = new CowObject();
                    co.RandomData();
                    co.Type      = false;
                    co.mPosition = pos;
                    co.Encode();
                    co.InitBreakPoint();
                    SimpleAI scow = RePair(new CowRePairer(), new CowRunner(), new CowJudger(), Cow,
                                           Player, new CowDestroyer(), "Cow", co, GAPopulation.allDic["Cow"].mTempCount);
                    scow.mCharacter = co;
                    GAPopulation.allDic ["Cow"].Add(scow);
                }
            }
            break;

        case TESTZOOLOGYMOUSE.ADDGRASS:
            Vector3 pos1 = FindPointByRayCast();
            if (pos1 != Vector3.zero)
            {
                temp = GameObject.Instantiate(Grass, pos1, Quaternion.identity) as GameObject;
                temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f);
                if (Input.GetMouseButton(0))
                {
                    glassObject go = new glassObject();
                    go.RandomData();
                    go.mColor    = 0.9f;
                    go.mPosition = pos1;
                    go.Encode();
                    go.InitBreakPoint();
                    SimpleAI sglass = RePair(new GlassRePairer(), new GlassRunner(), new GlassJudger(), Grass,
                                             Player, new CowDestroyer(), "Glass", go, GAPopulation.allDic["Glass"].mTempCount);
                    sglass.mCharacter = go;
                    //Debug.Log (FreedomAIEncoderAndDecoder.bitbunch2String(FreedomAIEncoderAndDecoder.float2BitBunch(0.2f,0.0f,1.0f,11)));
                    GAPopulation.allDic ["Glass"].Add(sglass);
                }
                else if (Input.GetMouseButton(1))
                {
                    glassObject go = new glassObject();
                    go.RandomData();
                    go.mColor    = Random.Range(0.1f, 0.4f);
                    go.mPosition = pos1;
                    go.Encode();
                    go.InitBreakPoint();
                    SimpleAI sglass = RePair(new GlassRePairer(), new GlassRunner(), new GlassJudger(), Grass,
                                             Player, new CowDestroyer(), "Glass", go, GAPopulation.allDic["Glass"].mTempCount);
                    sglass.mCharacter = go;
                    GAPopulation.allDic ["Glass"].Add(sglass);
                }
            }
            break;

        case TESTZOOLOGYMOUSE.ADDTREE:
            Vector3 pos2 = FindPointByRayCast();
            if (pos2 != Vector3.zero)
            {
                temp = GameObject.Instantiate(Tree, pos2, Quaternion.identity) as GameObject;
                temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f);
                if (Input.GetMouseButton(0))
                {
                    TreeObject to = new TreeObject();
                    to.RandomData();
                    to.mStrongRate = Random.Range(0.0f, 0.5f);
                    to.mPosition   = pos2;
                    //	go.mHeight = Random.Range (1.0f,1.5f);
                    to.Encode();
                    to.InitBreakPoint();
                    SimpleAI sTree = RePair(new TreeRePairer(), new TreeRunner(), new TreeJudger(), Tree,
                                            Player, new CowDestroyer(), "Tree", to, GAPopulation.allDic["Tree"].mTempCount);
                    sTree.mCharacter = to;
                    GAPopulation.allDic ["Tree"].Add(sTree);
                }
                else if (Input.GetMouseButton(1))
                {
                    TreeObject to = new TreeObject();
                    to.RandomData();
                    to.mStrongRate = Random.Range(0.5f, 1.0f);
                    to.mPosition   = pos2;

                    to.Encode();
                    to.InitBreakPoint();
                    SimpleAI sTree = RePair(new TreeRePairer(), new TreeRunner(), new TreeJudger(), Tree,
                                            Player, new CowDestroyer(), "Tree", to, GAPopulation.allDic["Tree"].mTempCount);
                    sTree.mCharacter = to;
                    GAPopulation.allDic ["Tree"].Add(sTree);
                }
            }
            break;
        }
    }