Ejemplo n.º 1
0
    //其实很烂的动画转折方法
    public void PlayAnimation(playerAction theAction)
    {
        switch (theAction)
        {
        case playerAction.attack:
        {
            theAnimator.Play("attack");
            break;
        }

        case playerAction.move:
        {
            theAnimator.Play("move");
            break;
        }

        case playerAction.idle:
        {
            theAnimator.Play("idle");
            break;
        }

        case playerAction.jump:
        {
            theAnimator.Play("jump");
            break;
        }
        }
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     action = playerAction.normal;
     anim = GetComponent<Animator>();
     attackColl = GameObject.Find(PathHelper.playerAttackColliderPath).GetComponent<SphereCollider>();
     stateInfo = anim.GetCurrentAnimatorStateInfo(0);
     characterController = GetComponent<CharacterController>();
 }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     boardTransform    = GetComponent <Transform>();
     initBoardRotation = boardTransform.rotation;
     pScript           = boardTransform.parent.Find("Player").GetComponent <playerAction>();
     bgScript          = boardTransform.parent.Find("bg").GetComponent <bgAction>();
     target            = GetComponent <Renderer>().bounds.center;
 }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Awake()
 {
     boardTransform    = GetComponent <Transform>();
     initBoardRotation = boardTransform.rotation;
     escapeGateScript  = boardTransform.Find("escapeGate").GetComponent <escapeGateAction>();
     speedGatesScript  = boardTransform.Find("speedGates").GetComponent <speedGateController>();
     pScript           = boardTransform.parent.Find("Player").GetComponent <playerAction>();
     keysScripts       = boardTransform.Find("Keys").GetComponent <keyController>();
     bgScript          = boardTransform.parent.Find("bg").GetComponent <bgAction>();
     cameraScript      = Camera.main.GetComponent <levelSwitch>();
     target            = GetComponent <Renderer>().bounds.center;
 }
Ejemplo n.º 5
0
 public void UseItem(RaycastHit hitInfo)
 {
     if (hasReachedDestination)
     {
         if (itemUsed.UseItem(hitInfo))
         {
             currentAction = playerAction.idle;
             inventory.RemoveItem(itemUsed);
             itemUsed = null;
         }
     }
 }
Ejemplo n.º 6
0
 void Round()
 {
     playerAction p1_action = playerAction.noAction;
     playerAction p2_action = playerAction.noAction;
     //Check Ready Heroes
     //Mana refresh
     //Players Draw
     //Start of Round Effects
     // While not Pass:
     //      P1 Turn
     //      P2 Turn
     //End of Round effects trigger
 }
Ejemplo n.º 7
0
 public Action(playerAction pa, int amount)
 {
     log.Debug("Action(playerAction" + pa.ToString() + ", int" + amount + ") - Begin");
     action      = pa;
     this.amount = amount;
 }
Ejemplo n.º 8
0
 public Action(playerAction pa, int amount)
 {
     log.Debug("Action(playerAction" + pa.ToString() + ", int" + amount + ") - Begin");
     action = pa;
     this.amount = amount;
 }
Ejemplo n.º 9
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !gameManager.onPause)
        {
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hitInfo, Mathf.Infinity))
            {
                clickedTransform = hitInfo.transform;
                followTransform  = false;
                //register target
                target = new Vector3(hitInfo.point.x, 1, hitInfo.point.z);


                if (currentAction == playerAction.prepareItem)
                {
                    destination = target;
                    WalkToDestination();
                    agent.stoppingDistance = 2f;
                    currentAction          = playerAction.useItem;
                    hasReachedDestination  = false;
                    UseItem(hitInfo);
                    return;
                }
                switch (hitInfo.transform.tag)
                {
                case "Floor":
                    currentAction          = playerAction.walk;
                    agent.stoppingDistance = 0.1f;
                    destination            = target;
                    WalkToDestination();
                    break;

                case "NPC":
                    currentAction          = playerAction.talk;
                    agent.stoppingDistance = 1f;
                    followTransform        = true;
                    // follow NPC and talk;
                    break;

                case "Item":
                    currentAction          = playerAction.pick;
                    agent.stoppingDistance = 3f;
                    followTransform        = true;
                    break;

                case "Door":
                    currentAction          = playerAction.interact;
                    agent.stoppingDistance = 0.1f;
                    followTransform        = false;
                    break;

                default:
                    break;
                }
            }
        }

        if (followTransform)
        {
            destination = new Vector3(clickedTransform.position.x, 1, clickedTransform.position.z);
            WalkToDestination();
        }



        CheckDestination();

        if (hasReachedDestination)
        {
            switch (currentAction)
            {
            case playerAction.walk:
                currentAction = playerAction.idle;
                break;

            case playerAction.talk:
                clickedTransform.GetComponent <DialogueTrigger>().TriggerDialogue();
                currentAction   = playerAction.idle;
                followTransform = false;
                break;

            case playerAction.pick:
                clickedTransform.GetComponent <ClickableObject>().PickItem(inventory);
                followTransform = false;
                currentAction   = playerAction.idle;
                break;

            case playerAction.interact:
                clickedTransform.GetComponent <InteractableObject>().Interact(this);
                followTransform = false;
                currentAction   = playerAction.idle;
                break;

            case playerAction.prepareItem:
                break;

            case playerAction.idle:
                hasReachedDestination = true;
                break;

            case playerAction.useItem:
                UseItem(hitInfo);
                break;

            default:
                break;
            }
        }
    }