private void SpawnCreature(JointGenerator generator)
        {
            var pos = new Vector3(
                x: _size.xMin + Random.value * _size.width,
                y: 3,
                z: _size.yMin + Random.value * _size.height
                );
            var rootObject  = generator.Instantiate(pos);
            var centralBody = rootObject.transform.GetChild(0).gameObject;

            Sensor.CreateComponent(centralBody, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 100f);
            var mouth = Mouth.CreateComponent(centralBody, typeof(Food));

            var actions       = LocomotionAction.EightDirections();
            var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30);
            var brain         = new Brain(
                new FollowPointDecisionMaker(State.BasicKeys.RelativeFoodPosition),
                sequenceMaker
                );

            var agent = Agent.CreateComponent(rootObject, brain, new Body(rootObject), actions);

            agent.name = RandomName();
            var info = GameUI.AddAgent(agent);

            StartCoroutine(EntryPointUtility.Rename(info, agent, mouth));
        }
 private IEnumerator SpawnSome(JointGenerator generator)
 {
     for (int i = 0; i < 5; i++)
     {
         SpawnCreature(generator);
         yield return(new WaitForSeconds(10));
     }
 }
Пример #3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Chair"))
     {
         if (colliderEnter == false)
         {
             //other.gameObject.SetActive(false);
             if (other.transform.localPosition.y == 0.32f)
             {
                 //Debug.Log("ChairUp");
                 other.transform.localPosition = new Vector2(other.transform.localPosition.x, 0.19f);
             }
             if (other.transform.localPosition.y == -0.32f)
             {
                 //Debug.Log("ChairDown");
                 other.transform.localPosition = new Vector2(other.transform.localPosition.x, -0.19f);
             }
             score++;
             scoreDisplay.text = score.ToString();
             colliderEnter     = true;
             if (score == 20)
             {
                 /*PlayerMovement playerMovement = playerGO.GetComponent<PlayerMovement> ();
                  * playerMovement.speed = 1.4f;*/
                 JointGenerator jointGenerator = generator.GetComponent <JointGenerator> ();
                 jointGenerator.endOfRandomRange = 0.95f;
             }
             if (score == 40)
             {
                 /*PlayerMovement playerMovement = playerGO.GetComponent<PlayerMovement> ();
                  * playerMovement.speed = 1.5f;*/
                 JointGenerator jointGenerator = generator.GetComponent <JointGenerator> ();
                 jointGenerator.endOfRandomRange = 0.9f;
             }
             if (score == 60)
             {
                 /*PlayerMovement playerMovement = playerGO.GetComponent<PlayerMovement> ();
                  * playerMovement.speed = 1.6f;*/
                 JointGenerator jointGenerator = generator.GetComponent <JointGenerator> ();
                 jointGenerator.endOfRandomRange = 0.8f;
             }
             if (score == 80)
             {
                 /*PlayerMovement playerMovement = playerGO.GetComponent<PlayerMovement> ();
                  * playerMovement.speed = 1.7f;*/
                 JointGenerator jointGenerator = generator.GetComponent <JointGenerator> ();
                 jointGenerator.endOfRandomRange   = 0.7f;
                 jointGenerator.startOfRandomRange = 0.45f;
             }
             if (score == 100)
             {
                 /*PlayerMovement playerMovement = playerGO.GetComponent<PlayerMovement> ();
                  * playerMovement.speed = 1.8f;*/
                 JointGenerator jointGenerator = generator.GetComponent <JointGenerator> ();
                 jointGenerator.endOfRandomRange   = 0.65f;
                 jointGenerator.startOfRandomRange = 0.4f;
             }
             if (score == 120)
             {
                 /*PlayerMovement playerMovement = playerGO.GetComponent<PlayerMovement> ();
                  * playerMovement.speed = 1.9f;*/
                 JointGenerator jointGenerator = generator.GetComponent <JointGenerator> ();
                 jointGenerator.endOfRandomRange   = 0.6f;
                 jointGenerator.startOfRandomRange = 0.35f;
             }
             if (score == 150)
             {
                 /*PlayerMovement playerMovement = playerGO.GetComponent<PlayerMovement> ();
                  * NPCSitMovement npcSitMovement = NPC.GetComponent<NPCSitMovement> ();
                  * npcSitMovement.upSitSpeed = -0.55f;
                  * npcSitMovement.downSitSpeed = 0.55f;
                  * playerMovement.speed = 2f;*/
                 JointGenerator jointGenerator = generator.GetComponent <JointGenerator> ();
                 jointGenerator.endOfRandomRange   = 0.55f;
                 jointGenerator.startOfRandomRange = 0.3f;
             }
         }
     }
     if (other.gameObject.CompareTag("BeforeCollider"))
     {
         if (colliderEnter == false)
         {
             StartCoroutine(endGame());
             Debug.Log("Before Collider Trigger");
             colliderEnter = true;
             if (PlayerPrefs.GetInt("TipOnOff") == 1)
             {
             }
             else
             {
                 tip.text = "Too Early !!!";
             }
         }
     }
     if (other.gameObject.CompareTag("AfterCollider"))
     {
         if (colliderEnter == false)
         {
             StartCoroutine(endGame());
             // Debug.Log("After Collider Trigger");
             if (PlayerPrefs.GetInt("TipOnOff") == 1)
             {
             }
             else
             {
                 tip.text = "Too Late !!!";
             }
         }
         colliderEnter = false;
     }
 }