Exemplo n.º 1
0
 private void Start()
 {
     player          = GameObject.Find("Player");
     initialPosition = transform.position;
     targetPosition  = player.transform.position;
     // Checking for the existence of the shooter is necessary when
     // inside a not-sandbox scene.
     if (Shooter)
     {
         witchScript = Shooter.GetComponent <WitchScript>();
     }
 }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D collision) //checks for collision, this section works EXACTLY the same as a regular bullet
    {
        if (collision.gameObject.tag == "Enemy")
        {
            if (collision.gameObject.name == "SkeletonPrefab(Clone)")
            {
                SkeletonScript skeletonScript = collision.gameObject.GetComponent <SkeletonScript>();
                skeletonScript.health = skeletonScript.health - bulletDamage;
            }

            if (collision.gameObject.name == "VampirePrefab(Clone)")
            {
                VampireScript vampireScript = collision.gameObject.GetComponent <VampireScript>();
                vampireScript.health = vampireScript.health - bulletDamage;
            }

            if (collision.gameObject.name == "WitchPrefab(Clone)")
            {
                WitchScript witchScript = collision.gameObject.GetComponent <WitchScript>();
                witchScript.health = witchScript.health - bulletDamage;
            }
        }
    }
Exemplo n.º 3
0
 void OnTriggerEnter2D(Collider2D collision)                                                       //detect collision
 {
     if (collision.gameObject.tag == "Enemy")                                                      //check to see if what we are colliding with is an enemy
     {
         if (collision.gameObject.name == "SkeletonPrefab(Clone)")                                 //if it's a Skeleton
         {
             SkeletonScript skeletonScript = collision.gameObject.GetComponent <SkeletonScript>(); //get the Skeleton's script
             skeletonScript.health = skeletonScript.health - bulletDamage;                         //subtract the bullet's damage from the Skeleton's health
             Destroy(gameObject);                                                                  //destroy the bullet
         }
         else if (collision.gameObject.name == "VampirePrefab(Clone)")                             //if it's a Vampire
         {
             VampireScript vampireScript = collision.gameObject.GetComponent <VampireScript>();    //get the Vampire's script
             vampireScript.health = vampireScript.health - bulletDamage;                           //subtract the bullet's damage from the Vampire's health
             Destroy(gameObject);                                                                  //destroy the bullet
         }
         else if (collision.gameObject.name == "WitchPrefab(Clone)")                               //if it's a Witch
         {
             WitchScript witchScript = collision.gameObject.GetComponent <WitchScript>();          //get the Witch's script
             witchScript.health = witchScript.health - bulletDamage;                               //subtract the bullet's damage from the Witch's health
             Destroy(gameObject);                                                                  //destroy the bullet
         }
     }
 }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        //instantiate weather effects and music
        deathTollText      = GameObject.Find("DeathTollText").GetComponent <Text> ();
        deathTollText.text = "0 have died";
        winterWeather      = GameObject.Find("WinterWeather");
        winterWeather.SetActive(false);
        springWeather = GameObject.Find("SpringWeather");
        springWeather.SetActive(false);
        summerWeather = GameObject.Find("SummerWeather");
        summerWeather.SetActive(false);
        fallWeather = GameObject.Find("FallWeather");
        fallWeather.SetActive(false);
        fallMusicBoxObject   = GameObject.Find("FallMusicBox");
        springMusicBoxObject = GameObject.Find("SpringMusicBox");
        summerMusicBoxObject = GameObject.Find("SummerMusicBox");
        winterMusicBoxObject = GameObject.Find("WinterMusicBox");
        nightMusicBoxObject  = GameObject.Find("NightMusicBox");
        springMusicBoxScript = springMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        summerMusicBoxScript = summerMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        fallMusicBoxScript   = fallMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        winterMusicBoxScript = winterMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        nightMusicBoxScript  = nightMusicBoxObject.GetComponent <SpringMusicBoxScript> ();

        //find advisors
        guardScript = GameObject.Find("Guard").GetComponent <GuardScript>();
        witchScript = GameObject.Find("Witch").GetComponent <WitchScript>();

        //find notification text
        notificationText      = GameObject.Find("NotificationText").GetComponent <Text> ();
        notificationText.text = "";

        //Load in txt files to word lists
        loadWordLists();

        //find the screen fader
        screenFader       = GameObject.Find("ScreenFader");
        screenFaderScript = screenFader.gameObject.GetComponent <ScreenFaderScript> ();

        //write season text
        seasonText      = GameObject.Find("SeasonText").GetComponent <Text> ();
        seasonText.text = "spring";

        //set us to night
        isDay = false;

        //create list fo opponents
        opponentList = new List <GameObject>();

        //find the day counter in UI
        dayNumberText = GameObject.Find("DayNumberText").GetComponent <Text>();

        //create the world with opponents, player, and decorations (cursor too)
        CreateWorld();

        //establish reference to well
        well       = GameObject.FindGameObjectWithTag("Well");
        wellScript = well.GetComponent <WellScript> ();

        //establish reference to player village
        myPlayerVillage       = GameObject.FindGameObjectWithTag("PlayerVillage");
        myPlayerVillageScript = myPlayerVillage.gameObject.GetComponent <PlayerVillageScript> ();

        //Camera background
        camera.clearFlags = CameraClearFlags.SolidColor;
        destroyWordLists();
        nightMusicBoxScript.FadeInMusic();

        //color trees
        for (int i = 0; i < trees.Length; i++)
        {
            trees [i].GetComponent <Renderer>().material.color = springSummerTreeColor;
        }

        //set day number
        dayNumberText.text = "night " + dayNumber;
        origOpponents      = opponents;
    }