コード例 #1
0
ファイル: DogReaction.cs プロジェクト: TurboFen/Kursach
 void Start()
 {
     AUdio   = GetComponent <AudioSource>();
     grandma = grandma_gm.GetComponent <GrandmaAI>();
     boy     = boy_gm.GetComponent <BoyMove>();
     time_go = Time.time;
 }
コード例 #2
0
ファイル: Door_Teleport.cs プロジェクト: TurboFen/Kursach
    public void OnTriggerEnter2D(Collider2D collider2D)
    {
        if (collider2D.tag == "Player" || collider2D.tag == "Babyshka")

        {
            if (collider2D.tag == "Babyshka")
            {
                currentBab = collider2D.gameObject;
                gr         = currentBab.GetComponent <GrandmaAI>();
            }
            if (collider2D.tag == "Player")
            {
                bm = Player.gameObject.GetComponent <BoyMove>();
            }
            StartCoroutine(Teleport(collider2D.tag));
        }
    }
コード例 #3
0
ファイル: Baby.cs プロジェクト: snowboat/BVWRound1-Squarrel
    private void Start()
    {
        babyAnimator = GetComponent <Animator>();
        babySound    = GetComponent <AudioSource>();

        // assign y value
        float tempY = transform.position.y;

        pos1.y = tempY;
        pos2.y = tempY;
        pos3.y = tempY;
        pos4.y = tempY;

        // get sound source script
        soundScript = soundSource.GetComponent <BoyMove>();

        // initial position of baby
        currentPosition    = 1;
        transform.position = pos1;
        beforeTarget       = transform.position;
        StartCoroutine(DelayUpdateNextAttack());
        AttackRecord.handAttackCount++;
    }
コード例 #4
0
    void Update()
    {
        if (!Game_over)
        {
            Time_Game -= Time.deltaTime;
            Time_Update(Time_Game);

            if (trys)
            {
                if (armComp.animation.isPlaying)
                {
                    armComp.animation.Stop("MakeSmtGrandma");
                    armComp.animation.Stop("WalkGrandma");
                }
                boy = for_boy.GetComponent <BoyMove>();
                if (!armComp.animation.isPlaying)
                {
                    //КОНЕЦ ИГРЫ - ВЫ ПРОИГРАЛИ

                    armComp.animation.Play("AngryGrandma");
                    AUdio.PlayOneShot(voice[0]);
                }
                boy.is_game_over = true;
            }
            else
            {
                if (Vector3.Distance(transform.position, currentPatrolPoint.position) < .35f)
                {
                    if (currentInterObjScript.isAlreadyUsed && !currentInterObjScript.isAlreadyCheck && currentIntObj != null)
                    {
                        if (!flag_angry)
                        {
                            //Здесь она увидит испорченную вещь
                            rage++;
                            rage_slider.value = rage / maxRage;
                            if (count_of_mood == 4)
                            {
                                count_of_mood = 3;
                            }
                            mood.sprite = grandmaMood[count_of_mood];
                            count_of_mood++;
                            last_time = Time.time + 4;
                            if (rage == maxRage)
                            {     //КОНЕЦ ИГРЫ - ВЫ ВЫИГРАЛИ}
                                gamewin.instance.isEndGame();
                                Invoke("Win", 2f);
                            }
                        }
                        if (Time.time <= last_time)
                        {
                            if (armComp.animation.isPlaying)
                            {
                                armComp.animation.Stop("MakeSmtGrandma");
                                armComp.animation.Stop("WalkGrandma");
                            }
                            if (!armComp.animation.isPlaying)
                            {
                                armComp.animation.Play("AngryGrandma");
                                AUdio.PlayOneShot(voice[0]);
                            }
                            flag_angry = true;
                        }
                        else
                        {
                            AUdio.PlayOneShot(voice[1]);
                            currentInterObjScript.isAlreadyCheck = true;
                            currentInterObjScript.changed();
                            flag_angry = false;
                        }
                    }
                    else
                    {
                        if (flag_move == false)
                        {
                            last_time = Time.time + 4;
                        }
                        if (Time.time <= last_time)
                        {
                            if (armComp.animation.isPlaying)
                            {
                                armComp.animation.Stop("AngryGrandma");
                                armComp.animation.Stop("WalkGrandma");
                            }
                            if (!armComp.animation.isPlaying)
                            {
                                armComp.animation.Play("MakeSmtGrandma");
                            }
                            flag_move = true;
                        }
                        else
                        {
                            flag_move = false;
                            armComp.animation.Play("WalkGrandma");
                            GoToAnotherPatrol();
                            Flip();
                        }
                    }
                }
                else
                {
                    transform.Translate(Vector3.right * Time.deltaTime * speed);
                }
            }
        }
        else
        {     //Здесь будет игра окончена
            if (armComp.animation.isPlaying)
            {
                armComp.animation.Stop("MakeSmtGrandma");
                armComp.animation.Stop("WalkGrandma");
            }
            if (!armComp.animation.isPlaying)
            {
                armComp.animation.Play("AngryGrandma");
            }
            Invoke("Lose", 2f);
            Debug.Log("GameOver is true");
        }
    }