예제 #1
0
        private async void LoadButtons()
        {
            if (Stories.Count > 0) //a hack, have to refactor at some point
            {
                var a = IMG2Sprite.Instance(Stories.Values.ElementAt(0).SnakeCase() + "spriter");
                var b = IMG2Sprite.Instance(Stories.Values.ElementAt(1).SnakeCase() + "spriter");

                var ImageStory1 = FindImage.Named("ImageStory1");
                ImageStory1.sprite = await a.LoadNewSprite(Stories.Values.ElementAt(0).ImageUrl);

                ImageStory1.name = Stories.Values.ElementAt(0).SnakeCase();
                VisualEffects.SetImageTransparent(ImageStory1);
                ElementsToCrossfade.Add(ImageStory1.gameObject);



                var ImageStory2 = FindImage.Named("ImageStory2");
                ImageStory2.sprite = await b.LoadNewSprite(Stories.Values.ElementAt(1).ImageUrl);

                ImageStory2.name = Stories.Values.ElementAt(1).SnakeCase();
                VisualEffects.SetImageTransparent(ImageStory2);
                ElementsToCrossfade.Add(ImageStory2.gameObject);

                var x = true;
                foreach (var story in Stories.Values)
                {
                    if (x)
                    {
                        _cabinInTheWoods = new CabinInTheWoods(story.ToString(), story.Description, story.ImageUrl);
                        x = false;
                    }
                    FindImage.Named(story.SnakeCase()).gameObject.AddComponent <LaunchGame>();
                }
            }
        }
예제 #2
0
    protected virtual void Pick(Character _whoPicks)
    {
        VisualEffects.CreateVisualEffect(pickVfx, transform);

        Destroy(gameObject);

        return;
    }
예제 #3
0
    private void Start()
    {
        _fx = GetComponent <VisualEffects>();
        ChangeToDormant();

        Hammer.AnimationCallbackEvent += ChangeToChasing;
        Hammer.TriggerCallbackEvent   += InflictPhysicalDamage;
        Attention.CallbackEvent       += ChangeToAwakened;
    }
예제 #4
0
    private static void CreateInstance()
    {
        var prefab   = Resources.Load <GameObject>(_ResourceName);
        var instance = Instantiate(prefab);

        instance.name = "_" + _ResourceName;
        instance.transform.SetAsFirstSibling();
        _Instance = instance.GetComponent <VisualEffects>();
    }
예제 #5
0
        // Use this for initialization
        private void Start()
        {
            //Initialazing lists
            _canvases           = new Dictionary <string, Canvas>();
            _stories            = new Dictionary <string, Story>();
            _panels             = new List <GameObject>();
            ElementsToCrossfade = new List <GameObject>();

            //add panels to the list
            FillPanels();

            //show the main menu control bar
            ShowPanel(FindPanel.GO("ControlBar"));

            //get stories from internet
            _stories = Resources.GetStoriesFromInternet();

            // add ExitGame callback to ExitButton listener
            FindButton.Named("ExitButton").onClick.AddListener(ExitGame);

            //Testing text transition (fade in)
            var text = FindText.Named("TextGameTitle");

            VisualEffects.SetTextTransparent(text);
            ElementsToCrossfade.Add(text.gameObject);



            //Canvas initialization
            var mainMenuCanvas = FindCanvas.Named("MainMenuCanvas");

            mainMenuCanvas.transform.SetAsLastSibling();
            _canvases["mainMenuCanvas"] = mainMenuCanvas;



            foreach (var story in Stories.Values)
            {
                var cnv = Instantiate(FindCanvas.Named("StoryCanvas"));
                cnv.name = story.SnakeCase() + "_canvas";
                _canvases[story.SnakeCase()] = cnv;
            }



            /*Button initialization
             * _exitButton = GameObject.Find("btnExit").GetComponent<Button>();
             *
             *
             * //Assigning Methods to Unity actions
             * _exit += ExitGame;
             *
             *
             * //Assigning Unity actions to button Events
             * _exitButton.onClick.AddListener(_exit);
             */
        }
예제 #6
0
        public void UpdateVisuals()
        {
            foreach (TimeSkipVisual ts in VisualEffects)
            {
                ts.Update();
            }

            VisualEffects.RemoveAll(x => x.Animation.CurrentFrame == x.Animation.FrameCount - 1);
        }
예제 #7
0
 protected virtual void OnCollisionEnter(Collision _collision)
 {
     foreach (string tag in damageComponent.DamageTags)
     {
         if (_collision.gameObject.CompareTag(tag))
         {
             VisualEffects.CreateVisualEffect(hitVfx, transform);
             PoolsManager.ReturnObjectToPools(this);
         }
     }
 }
예제 #8
0
파일: StealCorn.cs 프로젝트: mono26/Spooky
    protected override IEnumerator Action()
    {
        VisualEffects.CreateVisualEffect(actionVfx, character.transform);

        yield return(new WaitForSecondsRealtime(
                         character.CharacterAnimator.GetCurrentAnimatorStateInfo(0).length + delayAfterAnimationIsFinished
                         ));

        stoleValue = Mathf.Abs(Random.Range(minStealValue, maxStealValue));
        LevelManager.Instance.LoseCrop(stoleValue);
        hasDrop = true;

        yield break;
    }
예제 #9
0
 public void UpgradePlant()
 {
     if (currentBlueprint.upgradePlant != null)
     {
         // Pool plant
         Destroy(currentPlant.gameObject);
         // Manejarlo con eventos
         if (upgradeSound != null)
         {
             SoundManager.Instance.PlaySfx(soundSource, upgradeSound);
         }
         currentPlant = Instantiate(currentBlueprint.upgradePlant, transform.position, transform.rotation);
         isUpgraded   = true;
         VisualEffects.CreateVisualEffect(upgradeVfx, transform);
     }
 }
예제 #10
0
    public void PlantPlant(PlantBlueprint blueprint)
    {
        if (blueprint.plant != null)
        {
            // LevelManager.Instance.TakeMoney(blueprint.price);
            // LevelManager.Instance.UpdateMoneyDisplay();
            if (buySound != null)
            {
                SoundManager.Instance.PlaySfx(soundSource, buySound);
            }
            currentPlant     = Instantiate(blueprint.plant, transform.position, transform.rotation);
            currentBlueprint = blueprint;
            //PlantStore.Instance.DeselectCurrentActiveEmptyPlantpoint();
            VisualEffects.CreateVisualEffect(buyVfx, transform);
        }

        return;
    }
예제 #11
0
    public IEnumerator Kill()
    {
        PoolableObject poolableCharacter = GetComponent <PoolableObject>();

        if (poolableCharacter != null)
        {
            yield return(CharacterDeath());

            PoolsManager.ReturnObjectToPools(poolableCharacter);
        }
        else if (poolableCharacter == null)
        {
            yield return(CharacterDeath());

            Destroy(gameObject);
        }

        VisualEffects.CreateVisualEffect(deathVfx, transform);
        yield break;
    }
예제 #12
0
    // Update is called once per frame
    void Update()
    {
        if (SceneManager.GetActiveScene().buildIndex != 0)
        {
            if (Input.GetKeyDown("q"))
            {
                ++curentKeyIndex;
                setTop();
                setVisualEffect();
            }
            if (Input.GetKeyDown("1"))
            {
                curentKeyIndex = 0;
                setTop();
                setVisualEffect();
            }
            if (Input.GetKeyDown("2"))
            {
                curentKeyIndex = 1;
                setTop();
                setVisualEffect();
            }
            if (Input.GetKeyDown("3"))
            {
                curentKeyIndex = 2;
                setTop();
                setVisualEffect();
            }
        }

        if (Input.GetKeyDown("z"))
        {
            int veValue = (((int)ve + 1) % numVe);
            ve = (VisualEffects)veValue;
            print("z + " + ve + " : " + veValue);

            setVisualEffect();
        }
    }
예제 #13
0
        private void CrossFadeElements()
        {
            //container of items to remove from crossfade list once the item completes the transition
            var itemsToRemove = new List <GameObject>();

            //go through the crossfade list
            foreach (var element in ElementsToCrossfade)
            {
                //try to get an image from the gameObject element
                var image = element.GetComponent <Image>();
                //try to get a text from the gameObject element
                var text = element.GetComponent <Text>();

                //test if the element is image
                if (image)
                {
                    VisualEffects.ImageFadeIn(image, 1.0f, 0.8f);
                    if (Math.Abs(image.color.a - 1.0f) < 0.0001)
                    {
                        itemsToRemove.Add(element);
                    }
                }//test if the element is text
                else if (text)
                {
                    VisualEffects.TextFadeIn(text, 1.0f, 0.8f);
                    if (Math.Abs(text.color.a - 1.0f) < 0.0001)
                    {
                        itemsToRemove.Add(element);
                    }
                }
            }
            //cleanup the elements which completed transition
            foreach (var item in itemsToRemove)
            {
                ElementsToCrossfade.Remove(item);
                Debug.Log("object removed from fade list");
            }
        }
예제 #14
0
    public void TakeDamage(float _damage)
    {
        // We are laready dead.
        if (currentHealth == 0)
        {
            return;
        }

        StartCoroutine(ToggleHealthBar());
        currentHealth -= _damage;

        VisualEffects.CreateVisualEffect(damageVfx, transform);
        PlayHitSfx();

        currentHealth        = Mathf.Max(0, currentHealth);
        healthBar.fillAmount = currentHealth / maxHealth;

        if (currentHealth == 0)
        {
            StartCoroutine(Kill());
        }
        return;
    }
예제 #15
0
 public void setVisualEffect(int index)
 {
     ve = (VisualEffects)index;
 }