public void UpdateUI(UnitScript unit)
 {
     ATKMeter.SetMeter(unit.ATK / 100f);
     DEFMeter.SetMeter(unit.DEF / 100f);
     MAGMeter.SetMeter(unit.MAG / 100f);
     NameText.text = unit.unitName;
     // LabelText.SetActive(true);
     StatPanel.SetActive(true);
 }
Пример #2
0
 public void UpdateUI(UnitScript unit)
 {
     healthMeter.SetMeter(unit.health / 100f);
     charismaMeter.SetMeter(unit.charisma / 18f);
     nameText.text = unit.unitName;
     namePanel.SetActive(true);
 }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        {
            GameObject damageObject = Instantiate(damagePrefab, transform.position, transform.rotation);
            Destroy(damageObject, 5);
            health -= 10;
            meter.SetMeter(health / 100f);

            StartCoroutine(DamageEffect());
        }
    }
    // These allow me to allow each button to call any spell depending on the value the player will assign at start, and to not have to repeat the UpdateUI and ChooseEnemyAction functions calls
    // In every player attack option.

    public void UpdateUI()
    {
        HPMeter.SetMeter(PlayerHP / 100f);
        MPMeter.SetMeter(PlayerMP / 100f);
        EnemyHPMeter.SetMeter(EnemyHP / 1000f);
        ATKText.text  = ("ATK: " + (PlayerATK));
        DEFText.text  = ("DEF: " + (PlayerDEF));
        NameText.text = PlayerName;

        HPNum.text = ("" + PlayerHP);         // it didn't like me just using a float
        MPNum.text = ("" + PlayerMP);
        if (EnemyHP > 0)
        {
            EnemyHPNum.text = ("" + EnemyHP);
        }
        else
        {
            EnemyHPNum.text = ("Dead");
        }
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (DragonFightStarted == false)
        {
            if (selected)
            {
                // Input.GetMouseButtonDown(0) is how you detect that the left mouse button has been clicked.
                //
                // The IsPointerOverGameObject makes sure the pointer is over the UI. In this case,
                // we don't want to register clicks over the UI when determining what unit is
                // selected or deselected.
                if (Input.GetMouseButton(0) && !EventSystem.current.IsPointerOverGameObject())
                {
                    // We will get in here if the Unit is selected, and the player has clicked the mouse.

                    // The following code create's a "ray" at the position that the mouse is on the screen, and performs
                    // a Raycast. This is a Physics utility function that will move in a direction and populate the
                    // values of a RaycastHit object if something was hit. If the Raycast doesn't hit anything (i.e. the
                    // player clicks into the nothingness - where there are no GameObjects), the Physics.Raycast
                    // returns null, and thus we will not go in the if statement's body.
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        // If we get in here, it means that the mouse was "over" a GameObject when the player clicked.
                        // Check to see if what we clicked on the the "Ground" via this layer check.
                        if (hit.collider.gameObject.layer == LayerMask.NameToLayer("MinePlane"))
                        {
                            // // If we get in here, the raycast has hit the ground.

                            // // Spawn a cube, and store it in a list. These will be the "waypoints" that the unit will walk toward
                            // // when the player clicks the "Go!" button.
                            // GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
                            // // Remove the default box collider that gets added when we use CreatePrimitive.
                            // Destroy(obj.GetComponent<BoxCollider>());
                            // obj.transform.position = hit.point;
                            // path.Add(obj);

                            targetPosition = hit.point;
                        }
                        if (hit.collider.gameObject.layer == LayerMask.NameToLayer("AttackMine"))
                        {
                            ATK += 1;

                            //UpdateMeter(ATK);
                            ATKMeter.SetMeter(ATK / 1000f);
                            // setting these to 1000 instead of 100 fixed the meters going up too fast.
                            // but it also caused the meters to be kinda screwy.
                            // I'd rather set ATK/DEF/MAG to go up by 0.1, but they're ints and making them floats or doubles messed up a LOT of code elsewhere somehow.

                            //Start the ATKMine animation
                            ATKMineAnimator.SetBool("ATKmining", true);
                        }
                        else
                        {
                            ATKMineAnimator.SetBool("ATKmining", false);
                        }
                        if (hit.collider.gameObject.layer == LayerMask.NameToLayer("DefenseMine"))
                        {
                            DEF += 1;

                            DEFMineAnimator.SetBool("DEFmining", true);
                            //Start the DEFMine animation

                            DEFMeter.SetMeter(DEF / 1000f);
                        }
                        else
                        {
                            DEFMineAnimator.SetBool("DEFmining", false);
                        }
                        if (hit.collider.gameObject.layer == LayerMask.NameToLayer("MagicMine"))
                        {
                            MAG += 1;

                            MAGMineAnimator.SetBool("MAGmining", true);
                            //Start the MAGMine animation

                            MAGMeter.SetMeter(MAG / 1000f);
                        }
                        else
                        {
                            MAGMineAnimator.SetBool("MAGmining", false);
                        }
                    }
                    else
                    {
                        gm.SelectUnit(null);
                    }
                }
            }
        }
        // MOVEMENT
        // If we are not close to our target position, rotate toward the targetPosition, and move forward.
        if (Vector3.Distance(transform.position, targetPosition) > 0.5f)
        {
            Vector3 vectorToTarget = targetPosition - transform.position;
            vectorToTarget = vectorToTarget.normalized;

            float step = rotateSpeed * Time.deltaTime;

            Vector3 newDirection = Vector3.RotateTowards(transform.forward, vectorToTarget, step, 1);
            transform.rotation = Quaternion.LookRotation(newDirection);

            cc.Move(transform.forward * speed * Time.deltaTime);

            unitanimator.SetBool("walking", true);

            // set walking true
        }
        else
        {
            unitanimator.SetBool("walking", false);

            /*	if (moving && path.Count > 0) {
             *              // If we get in here, we ARE close to our target position.
             *              pathIndex++;
             *              if (pathIndex == path.Count) {
             *                      // If we get in here, we have arrived at the last target. In that case, stop moving, and destroy all the
             *                      // path markers.
             *                      foreach(GameObject pathObj in path) {
             *                              Destroy(pathObj);
             *                      }
             *                      path = new List<GameObject>();
             *                      moving = false;
             *                      // set walking false
             *              } else {
             *                      // Finally, if we get in here, we are going to set our target position to the location of the path marker.
             *                      targetPosition = path[pathIndex].transform.position;
             *              }
             *      }*/
        }
    }