Inheritance: MonoBehaviour
示例#1
0
 void Start()
 {
     inventory      = FindObjectOfType <InventorySystem>();
     animator       = GetComponent <Animator>();
     cameraPan      = FindObjectOfType <CameraPan>();
     spriteRenderer = GetComponent <SpriteRenderer>();
 }
示例#2
0
    void Start()
    {
        ChatText = FindObjectsOfType <Text>().First(x => x.name == "ChatText");

        client = FindObjectOfType <Client> ();
        player = FindObjectOfType <Player>();
        camera = FindObjectOfType <CameraPan>();
    }
 // Use this for initialization
 void Start()
 {
     // Init components.
     hotPotatoManager      = FindObjectOfType <HopBasedHotPotatoManager>();
     cameraPan             = FindObjectOfType <CameraPan>();
     timeUp                = false;
     showNormalProfOnStart = false;
     StartCoroutine(ShowProfessorMoneyAfterTime());
     StartCoroutine(MoneyAfterTime());
 }
示例#4
0
 public Tutorial(Text tutorialText, Text tapToContinueText, GameObject countryUI, GameObject tutorialArrow, Game game)
 {
     this.tutorialText      = tutorialText;
     this.tapToContinueText = tapToContinueText;
     this.countryUI         = countryUI;
     this.tutorialArrow     = tutorialArrow;
     this.exampleCountry    = GameObject.Find("Sweden");
     this.po     = exampleCountry.GetComponent <PolygonFiller>();
     this.camPan = Camera.main.GetComponent <CameraPan>();
     this.game   = game;
 }
示例#5
0
 protected void Awake()
 {
     spawner          = Camera.main.GetComponent <SpawnOnMouseClick>();
     pusher           = Camera.main.GetComponent <PushOnMouseClick>();
     panner           = Camera.main.GetComponent <CameraPan>();
     musicManager     = GetComponent <MusicManager>();
     tutorial         = GetComponent <Tutorial>();
     simulatedObjects = new List <Gravitation>();
     canvas           = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Canvas>();
     upgradePanel     = GameObject.FindGameObjectWithTag("UpgradePanel").GetComponent <UpgradePanel>();
     messageBox       = GameObject.FindGameObjectWithTag("MessageBox").GetComponent <MessageBox>();
 }
示例#6
0
        void Start()
        {
            dialogue         = FindObjectOfType <DialogueSystem>();
            inventory        = FindObjectOfType <InventorySystem>();
            cameraPan        = FindObjectOfType <CameraPan>();
            circleCollider2D = GetComponent <CircleCollider2D>();

            if (gameObject.GetComponent <Animator>())
            {
                animator = gameObject.GetComponent <Animator>();
            }

            dialogue.gameDialogue.Add(name, interactHint);
        }
示例#7
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance  = this;
         cameraPan = GetComponent <CameraPan>();
         camera    = Camera.main;
         State     = GameState.Intro;
         PlatformingPlayer1.enabled = false;
         PlatformingPlayer2.enabled = false;
         IntroAnimator.speed        = 0;
         IntroTextAnimator.speed    = 0;
         IntroTextAnimator.gameObject.SetActive(false);
         PressStartButton.SetActive(false);
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
示例#8
0
    public void NextSentence()
    {
        if (textDisplay.text == sentences[index])
        {
            audioSource.Play();
            textDisplayAnimation.SetTrigger("Change");
            continueButtons.SetActive(false);

            if (index < sentences.Length - 1)
            {
                index++;
                textDisplay.text = "";
                StartCoroutine(Type());
            }
            else
            {
                textDisplay.text = "";
                continueButtons.SetActive(false);
                textPanelAnimation.SetTrigger("Close");
                textPanelAnimation.ResetTrigger("Open");
            }

            if (index == sentences.Length - 1 && !findYourVoice && SceneManager.GetActiveScene().name == "UpdatedMap")
            {
                CameraPan pan = Camera.main.GetComponent <CameraPan>();
                pan.player = wolf;
                pan.GoTo(new Vector3(212.7f, 1, 0), 2);
                pan.distanceMargin = 0.5f;
                findYourVoice      = true;
            }
        }
        else // prevent dialogue skipping
        {
            return;
        }
    }
 void Start()
 {
     // Init components.
     greedyManager = FindObjectOfType <GreedyManager>();
     cameraPan     = FindObjectOfType <CameraPan>();
 }
 // Use this for initialization
 void Start()
 {
     cam         = (CameraPan)FindObjectOfType(typeof(CameraPan));
     character   = unit.GetComponent <CharacterBase>();
     gametracker = (GameTracker)FindObjectOfType(typeof(GameTracker));
 }
示例#11
0
 //setting instance
 void Awake()
 {
     instance = this;
 }
示例#12
0
    void Update()
    {
        if (SceneManager.GetActiveScene().name == "UpdatedMap")
        {
            if (currentHealth == 0)
            {
                MainMenu main = new MainMenu();
                main.LoadSceneByName("UpdatedMap");
            }

            isMoving = false;

            if (!dialogueActive) // Prevent input during dialogue
            {
                //Basic WASD movement
                if (Input.GetAxisRaw("Horizontal") < 0)
                {
                    transform.Translate(-Vector2.right * playerSpeed * Time.deltaTime);
                    transform.localScale = new Vector3(-2, 2, 2);
                    isMoving             = true;
                }
                if (Input.GetAxisRaw("Horizontal") > 0)
                {
                    transform.Translate(Vector2.right * playerSpeed * Time.deltaTime);
                    transform.localScale = new Vector3(2, 2, 2);
                    isMoving             = true;
                }
                if (Input.GetAxisRaw("Vertical") < 0)
                {
                    transform.Translate(-Vector2.up * playerSpeed * Time.deltaTime);
                    isMoving = true;
                }
                if (Input.GetAxisRaw("Vertical") > 0)
                {
                    transform.Translate(Vector2.up * playerSpeed * Time.deltaTime);
                    isMoving = true;
                }

                // Left-click to shear sheep, only succeeds when sufficiently close to it
                if (Input.GetMouseButtonDown(0) && !woolHeld)
                {
                    RaycastHit2D mouseHit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                    if (mouseHit.collider != null)
                    {
                        // Debug.Log(mouseHit.collider.gameObject.name);
                        if (mouseHit.collider.tag == "Unsheared")
                        {
                            if ((transform.position - mouseHit.transform.position).magnitude < 3)
                            {
                                audioSources[1].Play();
                                mouseHit.collider.tag = "Sheared";
                                woolHeld = true;
                            }
                        }
                    }
                }

                if (Input.GetMouseButtonDown(0))
                {
                    RaycastHit2D mouseHit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

                    if (mouseHit.collider != null)
                    {
                        if (mouseHit.collider.name == "Dungeon Chest")
                        {
                            if ((transform.position - mouseHit.transform.position).magnitude < 3)
                            {
                                AudioSource[] soundEffects = GameObject.Find("SheepSoundManager").GetComponent <SoundEffectManager>().soundEffectAudioSource;
                                soundEffects[1].Play();
                                audioSources[0].Play();
                                mouseHit.collider.gameObject.GetComponent <DungeonChest>().OpenChest();
                                this.howl   = true;
                                this.escape = true;
                                print("VOICE ACQUIRED");
                            }
                        }
                    }
                }

                // Right-click to throw sweater to the indicated position
                if (woolHeld)
                {
                    if (Input.GetMouseButtonDown(1))
                    {
                        audioSources[2].Play();
                        Instantiate(sweater, this.transform.position, Quaternion.identity);
                        targetPosition = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
                        woolHeld       = false;
                    }
                }

                // Press space to trigger howl if acquired and howl cooldown reaches 0
                if (howl)
                {
                    GameObject[] unshearedSheep = GameObject.FindGameObjectsWithTag("Unsheared");
                    GameObject[] shearedSheep   = GameObject.FindGameObjectsWithTag("Sheared");
                    GameObject[] clothedSheep   = GameObject.FindGameObjectsWithTag("Clothed");
                    GameObject[] goldenSheep    = GameObject.FindGameObjectsWithTag("Golden");

                    GameObject[] allSheep = unshearedSheep.Concat(shearedSheep).ToArray().Concat(clothedSheep).ToArray().Concat(goldenSheep).ToArray();

                    if (!sheepSpeedBoost)
                    {
                        foreach (GameObject sheep in allSheep) // increase all sheeps' movement speed during escape sequence
                        {
                            sheep.GetComponent <SheepBehavior>().movementSpeed *= 1.5f;
                        }
                        sheepSpeedBoost = true;
                    }
                    if (escape && escapeTimer > 0)
                    {
                        GameObject.Find("UI").transform.GetChild(4).gameObject.SetActive(true);
                        escapeTimer -= Time.deltaTime;
                        CameraPan pan = Camera.main.GetComponent <CameraPan>();
                        pan.player = this.gameObject;
                        pan.GoTo(new Vector3(219, -40, 0), 0);
                        pan.distanceMargin = 0.5f;
                    }

                    if (escapeTimer <= 0)
                    {
                        GameObject.Find("UI").transform.GetChild(4).gameObject.SetActive(false);
                    }

                    if (howlCooldown <= 0)
                    {
                        if (Input.GetKeyDown(KeyCode.Space))
                        {
                            audioSources[0].Play();
                            howlCooldown = 10;
                        }
                    }
                    else
                    {
                        howlCooldown -= Time.deltaTime;

                        if (howlCooldown >= 9)
                        {
                            foreach (GameObject sheep in allSheep)
                            {
                                if ((sheep.transform.position - this.transform.position).magnitude < 10)
                                {
                                    sheep.GetComponent <SheepBehavior>().IsNowFleeing();
                                }
                            }
                        }
                    }
                }
            }
        }

        mAnimator.SetBool("moving", isMoving);
    }
示例#13
0
 void Start()
 {
     circleCollider2D = GetComponent <CircleCollider2D>();
     dialogue         = FindObjectOfType <DialogueSystem>();
     cameraPan        = FindObjectOfType <CameraPan>();
 }