Exemplo n.º 1
0
    public void Hit(SourceImageHandler src)
    {
        if (src.Index == this.CurrentTargetIndex)
        {
            this.Combo++;
            this.HealthBar.value += this.IncreaseHPAmount;
            this.Points          += this.scene.Points() * this.Combo;
            this.PointsText.text  = this.Points.ToString("D9");
            this.MaxCombo         = this.MaxCombo > this.Combo ? this.MaxCombo : this.Combo;
        }
        else
        {
            this.MaxCombo = this.MaxCombo > this.Combo ? this.MaxCombo : this.Combo;
            this.MissCount++;
            this.Combo            = 0;
            this.HealthBar.value -= this.DecreaseHPAmount;
        }

        float PassedSecs = this.scene.SceneLength - this.LeftSceneSecs;

        if (PassedSecs > 0)
        {
            this.Speed = this.TurnCount / PassedSecs * 60f;
        }

        this.LoadTarget();
    }
    public void LoadImages(List <Sprite> imgs)
    {
        this.ClearImages();

        bool useUpperPanel = imgs.Count > Constants.MAX_SOURCE_IMAGES / 2;

        this.upperImages.gameObject.SetActive(useUpperPanel);

        int i = 0;

        foreach (Sprite img in imgs)
        {
            GameObject         sourceImagePrefab = (GameObject)Instantiate(Resources.Load("Prefabs/SourceImage"));
            SourceImageHandler handler           = (SourceImageHandler)sourceImagePrefab.GetComponentInChildren(typeof(SourceImageHandler));
            handler.Index             = i;
            handler.childImage.sprite = img;
            sourceImagePrefab.name    = String.Format("sourceImage_{0}", i);
            if (useUpperPanel)
            {
                if (i < Constants.MAX_SOURCE_IMAGES / 2)
                {
                    sourceImagePrefab.transform.SetParent(upperImages.transform, false);
                }
                else
                {
                    sourceImagePrefab.transform.SetParent(lowerImages.transform, false);
                }
            }
            else
            {
                sourceImagePrefab.transform.SetParent(lowerImages.transform, false);
            }


            Images.Add(handler.childImage);
            i++;
        }
    }