예제 #1
0
 public Cow()
 {
     cowController  = new CowController();
     this.name      = "";
     this.age       = 0;
     this.breed     = "";
     this.happiness = 0;
     this.health    = 0;
     this.pregnant  = false;
     this.gender    = false;
     this.weight    = 0;
     this.currScene = "Mart";
 }
예제 #2
0
 public Cow(string name, int age, string breed, int happiness, int health, bool pregnant, bool gender, int weight, string currScene)
 {
     cowController  = new CowController();
     this.name      = name;
     this.age       = age;
     this.breed     = breed;
     this.happiness = happiness;
     this.health    = health;
     this.pregnant  = pregnant;
     this.gender    = gender;
     this.weight    = weight;
     this.currScene = currScene;
 }
예제 #3
0
        public static int SpawnCow(Cow cow, float PosA, float PosB, Vector3 forward)
        {
            Vector3 spawnLocation;
            int     count = 0;

            do
            {
                if (count++ > 100)
                {
                    print("Failed to Spawn Cow!");
                    return(0);
                }

                // Setting location to spawn & getting the y position from the terrain
                Debug.Log("Test A: " + PosA);
                Debug.Log("Test B: " + PosB);
                spawnLocation   = new Vector3(PosA, 0f, PosB);
                spawnLocation.y = Terrain.activeTerrain.SampleHeight(spawnLocation) + 0.5f;
            } while (Physics.CheckSphere(spawnLocation + new Vector3(0f, 4f, 0f), 2));

            GameObject cowGameObject = Instantiate(Resources.Load(cow.breed) as GameObject);

            if (forward != Vector3.zero)
            {
                cowGameObject.transform.forward = forward;
            }

            cowGameObject.transform.position   = spawnLocation;
            cowGameObject.transform.localScale = new Vector3(Mathf.Pow(cow.weight, .125f), Mathf.Pow(cow.weight, .125f), Mathf.Pow(cow.weight, .125f));

            CowController cowController = cowGameObject.GetComponent <CowController>();

            cow.cowController = cowController;
            cowController.cow = cow;

            // Spawned cow OK, returning 1
            return(1);
        }