Beispiel #1
0
    void Start()
    {
        brush       = GameObject.Find("brush");
        stick       = GameObject.Find("Cylinder");
        ARbutton    = GameObject.Find("BuildButton");
        Titlebar    = GameObject.Find("TitleBar");
        paintButton = GameObject.Find("paintButton");


        blue   = GameObject.Find("blueColor");
        green  = GameObject.Find("greenColor");
        red    = GameObject.Find("redColor");
        eraser = GameObject.Find("eraser");


        brush.SetActive(false);
        stick.SetActive(false);
        paintButton.SetActive(false);
        blue.SetActive(false);
        green.SetActive(false);
        red.SetActive(false);
        eraser.SetActive(false);

        m_TargetBuildingBehaviour = GetComponent <UserDefinedTargetBuildingBehaviour>();

        if (m_TargetBuildingBehaviour)
        {
            m_TargetBuildingBehaviour.RegisterEventHandler(this);
            Debug.Log("Registering User Defined Target event handler.");
        }

        m_FrameQualityMeter = FindObjectOfType <FrameQualityMeter>();
        m_TrackableSettings = FindObjectOfType <TrackableSettings>();
        m_QualityDialog     = FindObjectOfType <QualityDialog>();
        m_InfoMesssage      = FindObjectOfType <InfoMessage>();
        // titlebar = GameObject.Find("TitleBar");

        frameLow  = GameObject.Find("Low");
        frameMed  = GameObject.Find("Med");
        frameHigh = GameObject.Find("High");

        qualityTitle = GameObject.Find("Title");

        if (qualityTitle)
        {
            qualityTitle.SetActive(true);
        }

        if (m_InfoMesssage)
        {
            m_InfoMesssage.GetComponent <CanvasGroup>().alpha = 1;
        }

        if (m_QualityDialog)
        {
            m_QualityDialog.GetComponent <CanvasGroup>().alpha = 0;
        }
    }
Beispiel #2
0
    /// <summary>
    /// Instantiates a new user-defined target and is also responsible for dispatching callback to
    /// IUserDefinedTargetEventHandler::OnNewTrackableSource
    /// </summary>
    public void BuildNewTarget()
    {
        //================Info Message=====================
        m_InfoMesssage.GetComponent <CanvasGroup>().alpha = 0;
        //================Info Message=========================

        brush.SetActive(true);
        stick.SetActive(true);

        ARbutton.SetActive(false);


        qualityTitle.SetActive(false);
        // titlebar.SetActive(false);

        Titlebar.SetActive(false);
        paintButton.SetActive(true);

        blue.SetActive(true);
        green.SetActive(true);
        red.SetActive(true);
        eraser.SetActive(true);


        frameLow.SetActive(false);
        frameMed.SetActive(false);
        frameHigh.SetActive(false);



        if (m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM ||
            m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH)
        {
            // create the name of the next target.
            // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names
            string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, m_TargetCounter);

            // generate a new target:
            m_TargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x);
        }
        else
        {
            Debug.Log("Cannot build new target, due to poor camera image quality");
            if (m_QualityDialog)
            {
                StopAllCoroutines();
                m_QualityDialog.GetComponent <CanvasGroup>().alpha = 1;
                StartCoroutine(FadeOutQualityDialog());
            }
        }
    }
    //Αναβάθμιση πύργου
    public void UpgradeTower()
    {
        int cost = TowerCost.getUpgradeCost(ttype, tlevel);

        if (this.GetComponent <Player>().Money >= cost)
        {
            if (tlevel < 3)
            {
                SelectedTower.GetComponentInChildren <Tower>().Towerlevel = tlevel + 1;

                //Γίνεται η αφαίρεση των χρημάτων για την αναβάθμιση και
                this.GetComponent <Player>().UpdateGold(-cost);

                //Eνημερώνονται οι μεταβλητές για τις ιδιότητες του πύργου
                int   damage;
                float atk_cool;
                float proj_sp;
                int   eff_val;
                float range;

                damage   = TowerUpgrades.Damage;
                atk_cool = TowerUpgrades.Atk_cool;
                proj_sp  = TowerUpgrades.Proj_sp;
                eff_val  = TowerUpgrades.Eff_val;
                range    = TowerUpgrades.Range;

                if (damage != 0)
                {
                    SelectedTower.GetComponentInChildren <Tower>().Damage = damage;
                }

                if (atk_cool != 0)
                {
                    SelectedTower.GetComponentInChildren <Tower>().AttackCooldown = atk_cool;
                }

                if (proj_sp != 0)
                {
                    SelectedTower.GetComponentInChildren <Tower>().ProjectileSpeed = proj_sp;
                }

                if (eff_val != 0)
                {
                    SelectedTower.GetComponentInChildren <Tower>().EffectValue = eff_val;
                }


                if (range != 0)
                {
                    SelectedTower.transform.Find("Range").transform.localScale = new Vector3(range, range, 1);
                    SelectedTower.GetComponentInChildren <Tower>().UpdateRange();
                }

                CancelTowerMenu();
            }

            else
            {
                InfoMessage.GetComponent <ShowInfoText>().displayMessage(4);
            }
        }
    }