Ejemplo n.º 1
0
 private void OnValidate()
 {
     if (character == null)
     {
         character = GetComponent <SkeletonMecanim>();
     }
     if (animator == null)
     {
         animator = GetComponent <Animator>();
     }
 }
        public override void ComponentAwake()
        {
            timer          = GetRequiredComponent <IntervalTimerComponent>();
            timer.IsActive = false;
            fadeAnimator   = GetRequiredComponent <Animator>(fadeObject);

            antagonistAnimator  = GetRequiredComponent <Animator>(antagonistActor);
            protagonistAnimator = GetRequiredComponent <Animator>(protagonistActor);
            femaleAnimator      = GetRequiredComponent <Animator>(femaleActor);

            antagSkeleton  = GetRequiredComponent <SkeletonMecanim>(antagonistActor);
            antagRigidBody = GetRequiredComponent <Rigidbody2D>(antagonistActor);

            // Localize and prepare the dynamic menu
            // Load the dialog menu strings
            stringLoader.Load("Intro/intro_05_protagOptions.xml");

            dynamicMenuComponent = GetRequiredComponent <DynamicMenuComponent>(dynamicMenuObject);
            dynamicMenuObject.SetActive(false);

            var allMenuItems = new DynamicMenuComponent.MenuItem[] {
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_scared"], OnItemSelected = new UnityEvent()
                },
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_smart"], OnItemSelected = new UnityEvent()
                },
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_brave"], OnItemSelected = new UnityEvent()
                },
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_silent"], OnItemSelected = new UnityEvent()
                }
            };

            allMenuItems[0].OnItemSelected.AddListener(() => ChooseOption(0));
            allMenuItems[1].OnItemSelected.AddListener(() => ChooseOption(1));
            allMenuItems[2].OnItemSelected.AddListener(() => ChooseOption(2));
            allMenuItems[3].OnItemSelected.AddListener(() => ChooseOption(3));

            dynamicMenuComponent.InitializeMenu(allMenuItems);

            femaleBrainParticleSystem = GetRequiredComponent <ParticleSystem>(GetRequiredChild("BrainChunkEmitter", femaleActor));
            protagBrainParticleSystem = GetRequiredComponent <ParticleSystem>(GetRequiredChild("BrainChunkEmitter", protagonistActor));


            base.ComponentAwake();
        }