Exemplo n.º 1
0
    public static bool AttackJudge(humanBody targetBody, humanBody sourceBody)
    {
        //先判断是否已经死亡
        //分为多种情况
        //1.回放时,则如果是同纬度的人则不判断,非同纬度则倒退
        //2.正常情况,正常死亡
        //3.正常情况下,但是打到的不是同一纬度的人,则倒退
        if (targetBody == null || sourceBody == null)
        {
            Debug.Log("body为null");
        }

        //用于攻击后是否命中的判断
        if (Master.status == 2 && targetBody.tenetDirection == sourceBody.tenetDirection)
        {
            Debug.Log("1");
        }
        else if (Master.currentDirection != sourceBody.tenetDirection &&
                 targetBody.tenetDirection == sourceBody.tenetDirection)
        {
            //表示攻击者不在当前纬度且攻击到的目标和其一样不在当前纬度,则不进行判断
            Debug.Log("2");
        }
        else if (targetBody.tenetDirection != sourceBody.tenetDirection) //伤害判断前先判断是否在同一纬度,如果不在同一纬度则发生事件
        {
            //此时为发生错误,需要让玩家自己进行倒退

            Master.mistakeTimer = 40;  //进行强制倒退
        }
        else
        {
            Debug.Log("有死");
            targetBody.Dead(0);

            return(true);
        }



        return(false);
    }
Exemplo n.º 2
0
    //awdqwfqwwad
    private Vector2 Replay(Egg egg, int direction)
    {
        Vector2 position = transform.position;

        //direction决定是否和egg原有的direction一致,如果direction都为1则一致,为-1则相反

        //根据参数来进行各自的动作
        switch (egg.movement)
        {
        case ActionEnum.movement.walk:
            position = body.Walk(direction * -egg.parm1, egg.position);
            break;

        case ActionEnum.movement.attack:
            position = body.Attack(body.direction, true, egg.position);
            //Debug.Log("Attack");
            break;

        case ActionEnum.movement.jump:
            position = body.Jumping(1, (int)egg.parm2, egg.position);      //实现跳一百帧就是插入一百次即可
            //Debug.Log(egg.parm1 + "   " + egg.parm2);
            break;

        case ActionEnum.movement.dead:
            //Debug.Log("复活");
            body.Dead(1);
            position = egg.position;      //可能也要赋予位置
            break;

        case ActionEnum.movement.gravity:
            position = body.Gravity(egg.position);
            //Debug.Log("gravity");
            break;

        case ActionEnum.movement.bulletMove:
            position = egg.position;
            //Debug.Log("gravity");
            break;

        case ActionEnum.movement.bulletBack:

            transform.GetComponent <bullet>().speed = direction * -egg.parm1;

            //gameObject.SetActive(true);
            //Debug.Log(egg.parm1);
            GetComponent <BoxCollider2D>().enabled = true;

            //修改子弹的z坐标为-3
            transform.position = new Vector3(egg.position.x, egg.position.y, 3);

            position = transform.position;
            //Debug.Log(transform.position);
            //Debug.Log("gravity");
            break;

        case ActionEnum.movement.bulletGone:
            position = egg.position;
            //当frame还可以计入事件帧时才会销毁
            if (direction == Master.currentDirection)
            {
                Debug.Log("bullet销毁");
                Destroy(gameObject, 0);        //去除子弹
            }

            break;

        case ActionEnum.movement.targetConfirm:
            position = egg.position;
            body.GetAnimator().SetFloat("Speed", 1f);
            //body.SetFloat("Speed", 1f);
            body.transform.Find("CursorCollider").GetComponent <SpriteRenderer>().color = Color.white;

            body.tenetDirection = 1;         //将其状态改回原来的
            break;

        case ActionEnum.movement.findMainguy:
            position = egg.position;

            if (body.tenetDirection == Master.currentDirection)
            {
                body.target = null;
            }

            break;

        default:
            break;
        }

        return(position);

        //123
    }