Ejemplo n.º 1
0
 void Update()
 {
     if (HealthBarActive && targetType >= 2) // Actor or combatable
     {
         TargetHealthBar.value = TargetCombatable.getPercentHealth();
         TargetHealthNum.text  = Mathf.Round(TargetCombatable.getCurrentHealth()).ToString();
         if (EnergyBarActive)
         {
             TargetEnergyBar.value = TargetActor.getPercentEnergy();
             TargetEnergyNum.text  = Mathf.Round(TargetActor.getCurrentEnergy()).ToString();
         }
     }
 }
Ejemplo n.º 2
0
    private void Update()
    {
        //selection handler
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            Object             ObjectHit             = hit.collider.GetComponent <Object>();
            ObjectInteractable interactableObjectHit = hit.collider.GetComponent <ObjectInteractable>();
            ObjectCombatable   CombatableObjectHit   = hit.collider.GetComponent <ObjectCombatable>();
            ObjectActor        ActorObjectHit        = hit.collider.GetComponent <ObjectActor>();
            if ((interactableObjectHit != null) && !EventSystem.current.IsPointerOverGameObject())
            {
                /*
                 * Really need to start documenting this earlier in the process.
                 *
                 *
                 * This bit is handling highlighting and dehighlighting as the mouse passes over something.
                 */
                if (interactableObjectHit != selectedObject)
                {
                    if (highlightedObject == null)
                    {
                        interactableObjectHit.beingHighlighted(true);
                        highlightedObject = interactableObjectHit;
                    }
                    else
                    {
                        highlightedObject.beingHighlighted(false);
                        highlightedObject = interactableObjectHit;
                        highlightedObject.beingHighlighted(true);
                    }
                }

                /*
                 * This handles the player's selection and reselection system.
                 */
                if (Input.GetMouseButtonDown(0))
                {
                    if (selectedObject != interactableObjectHit)
                    {
                        if (selectedObject != null)
                        {
                            selectedObject.beingSelected(false);
                        }
                        interactableObjectHit.beingSelected(true);
                        selectedObject    = interactableObjectHit;
                        highlightedObject = null;
                        string name = ObjectHit.name;
                        if (ActorObjectHit != null)
                        {
                            TargetPanel.Instance.newActorTarget(ActorObjectHit, name);
                        }
                        else if (CombatableObjectHit != null)
                        {
                            TargetPanel.Instance.newCombatableTarget(CombatableObjectHit, name);
                        }
                        else
                        {
                            TargetPanel.Instance.newInteractableTarget(interactableObjectHit, name);
                        }
                    }
                }
            }
            else if (highlightedObject != null && (EventSystem.current.IsPointerOverGameObject() || hit.collider.tag == "Terrain"))
            {
                highlightedObject.beingHighlighted(false);
                highlightedObject = null;
            }

            //movement
            if (Input.GetMouseButton(0) && hit.collider.gameObject.tag == "Terrain" &&
                !EventSystem.current.IsPointerOverGameObject() &&
                !actorSelf.getDeathState() && !dragAndDrop)
            {
                navAgent.stoppingDistance = defaultStoppingDist;
                navAgent.SetDestination(hit.point);
                if (Input.GetButton("Shift"))
                {
                    //MoveAction newAction = new MoveAction(hit.point);
                    //ActionQueue.Instance.Enqueue(newAction);
                }
            }
        }

        else if (highlightedObject != null)
        {
            highlightedObject.beingHighlighted(false);
            highlightedObject = null;
        }


        PlayerHealthBar.value = actorSelf.getPercentHealth();
        PlayerHealthNum.text  = Mathf.Round(actorSelf.getCurrentHealth()).ToString();
        PlayerEnergyBar.value = actorSelf.getPercentEnergy();
        PlayerEnergyNum.text  = Mathf.Round(actorSelf.getCurrentEnergy()).ToString();

        if (actorSelf.getSkillActivating() && !lastUpdateActivationState)
        {
            PlayerProgressBar.setActive(true);
            PlayerProgressBar.setName(actorSelf.getNameOfSkillInProgress());
            PlayerProgressBar.placeIcon(actorSelf.getReferenceToSkillInProgress());
        }
        else if (actorSelf.getSkillActivating() && lastUpdateActivationState)
        {
            PlayerProgressBar.setPercent(actorSelf.getSkillProgress());
        }
        else
        {
            PlayerProgressBar.removeIcon();
            PlayerProgressBar.setActive(false);
        }
        lastUpdateActivationState = actorSelf.getSkillActivating();



        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            playerTriggerSkill(0);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            playerTriggerSkill(1);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            playerTriggerSkill(2);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            playerTriggerSkill(3);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            playerTriggerSkill(4);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            playerTriggerSkill(5);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            playerTriggerSkill(6);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            playerTriggerSkill(7);
        }
    }