Exemplo n.º 1
0
    void Update()
    {
        // loses interest
        if (inCombat && (targetActor.getDeathState() || Time.time >= timer))
        {
            interestLost();
        }

        if (inCombat && (rand.Next(1000) == 0 || targetActor.getDeathState() || targetActor == null))
        {
            // this should use an observable to trigger getDeathState. only uses n cycles during combat.
            // where n = number of combat motivators involved.
            getRandomTarget();
        }

        if (inCombat && actorSelf.queueCount() < planning)
        {
            actorSelf.skillEnqueue(rand.Next(skillCount - 1), targetActor);
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        // loses interest
        if (inCombat && (Time.time >= timer))
        {
            interestLost();
        }


        if (inCombat)
        {
            if (targetActor == null || targetActor.getDeathState() || rand.Next(1000) == 0)
            {
                changeTarget();
            }
            if (actorSelf.queueCount() < planning)
            {
                actorSelf.skillEnqueue(rand.Next(skillCount - 1), targetActor);
            }
        }
    }
Exemplo n.º 3
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);
        }
    }