コード例 #1
0
ファイル: Skills.cs プロジェクト: ybbbby/Client_IDG_YISHI
    public virtual void Deserialize(ByteProtocol protocol)
    {
        trigger = (SkillTrigger)protocol.getInt32();
        type    = (SkillNodeType)protocol.getInt32();
        //  UnityEngine.Debug.LogError("get type" +(Int32)type);
        var len = protocol.getInt32();

        //  UnityEngine.Debug.LogError("get nextNode Count" +len);
        nextNodes.Clear();
        for (int i = 0; i < len; i++)
        {
            var node = new SkillNode();
            node.Deserialize(protocol);
            nextNodes.Add(node);
        }
        len = protocol.getInt32();
        boolParams.Clear();
        for (int i = 0; i < len; i++)
        {
            boolParams.Add(protocol.getBoolean());
        }
        len = protocol.getInt32();
        fixedParams.Clear();
        for (int i = 0; i < len; i++)
        {
            fixedParams.Add(protocol.getRatio());
        }
    }
コード例 #2
0
ファイル: Skills.cs プロジェクト: ybbbby/Client_IDG_YISHI
    public List <SkillNode> GetNodes(SkillTrigger trigger)
    {
        List <SkillNode> nodes = new List <SkillNode>();

        foreach (var node in nextNodes)
        {
            if (node.trigger == trigger)
            {
                nodes.Add(node);
            }
        }
        return(nodes);
    }
コード例 #3
0
    private void AttackAction()
    {
        if (!canAttack)
        {
            return;
        }
        canAttack = false;
        StartCoroutine(WaitAndRun(1,
                                  new Action(() =>
        {
            canAttack = true;
        })));
        this.transform.eulerAngles = new Vector3(transform.localEulerAngles.x, Camera.main.transform.localEulerAngles.y, transform.localEulerAngles.z);
        this.playerAnimator.SetTrigger("Attack");
        Vector3 pos       = this.transform.position + this.transform.up + this.transform.forward * 3.5f;
        var     bulletObj = Instantiate(bolt, pos, this.bolt.transform.rotation);

        bulletObj.transform.rotation = Quaternion.AngleAxis(90, this.transform.right) * this.transform.rotation;
        var bc = bulletObj.GetComponent <BoltContoller>();

        bc.BornPos  = pos;
        bc.PlayerId = this.Pid;
        bc.BulletId = BoltId++;
        bc.SkillId  = 1;
        var rgbody = bulletObj.GetComponent <Rigidbody>();

        rgbody.velocity = this.transform.forward * this.boltSpeed;

        SkillTrigger fire = new SkillTrigger();

        fire.Pid     = this.Pid;
        fire.SkillId = 1;
        Position p = new Position();

        fire.BulletId = bc.BulletId;
        p.X           = bulletObj.transform.position.x;
        p.Y           = bulletObj.transform.position.y;
        p.Z           = bulletObj.transform.position.z;
        p.V           = bulletObj.transform.localEulerAngles.y;

        Velocity v = new Velocity();

        v.X    = rgbody.velocity.x;
        v.Y    = rgbody.velocity.y;
        v.Z    = rgbody.velocity.z;
        fire.P = p;
        fire.V = v;
        NetworkController.Instance.SendMessage(NetworkController.Protocol.GAME_MSG_SKILL_TRIGGER, fire);
    }
コード例 #4
0
    private void OnSkillTrigger(SkillTrigger trigger)
    {
        if (trigger.Pid != this.Pid)
        {
            return;
        }
        this.animator.SetTrigger("Attack");
        Vector3 pos       = this.transform.position + this.transform.up + this.transform.forward * 3.5f;
        var     bulletObj = Instantiate(bolt, pos, this.bolt.transform.rotation);

        bulletObj.transform.rotation = Quaternion.AngleAxis(90, this.transform.right) * this.transform.rotation;
        var bc = bulletObj.GetComponent <BoltContoller>();

        bc.BornPos  = pos;
        bc.PlayerId = this.Pid;
        bc.BulletId = trigger.BulletId;
        bc.SkillId  = trigger.SkillId;
        var rgbody = bulletObj.GetComponent <Rigidbody>();

        rgbody.velocity = new Vector3(trigger.V.X, trigger.V.Y, trigger.V.Z);
    }
コード例 #5
0
    public void Attack()
    {
        atackDeltatime += Time.deltaTime;
        if (atackDeltatime > attackInterval)
        {
            if (Input.GetButton("Fire1"))
            {
                _animator.SetTrigger("Attack");
                Vector3 position = this.transform.position + this.transform.up * GameConfig._bulletAdjust + this.transform.forward * GameConfig._bulletOffset;
                Vector3 velocity = this.transform.forward * GameConfig._bulletSpeed;

                BulletController bullet = Instantiate(_bullet, position, Quaternion.AngleAxis(90.0f, this.transform.right)).GetComponent <BulletController>();
                bullet._playerID = _heroID;
                bullet._skillID  = 1;
                bullet._origin   = position;
                bullet._velocity = velocity;

                Pb.SkillTrigger trigger = new SkillTrigger();
                trigger.Pid      = _heroID;
                trigger.BulletId = bullet._bulletID;
                trigger.SkillId  = 1;
                trigger.P        = new Pb.Position();
                trigger.P.X      = position.x;
                trigger.P.Y      = position.y;
                trigger.P.Z      = position.z;
                trigger.V        = new Pb.Velocity();
                trigger.V.X      = velocity.x;
                trigger.V.Y      = velocity.y;
                trigger.V.Z      = velocity.z;

                byte[] message = trigger.ToByteArray();
                NetworkHandler.Instance.SendMessage(Protocol.GAME_MSG_SKILL_TRIGGER, message);

                atackDeltatime = 0.0f;
                _state         = State.Attack;
            }
        }
    }
コード例 #6
0
 public static void SetTrigger(this SkillNode node, SkillTrigger trigger, ISkillNodeRun run)
 {
     RunNodes(run, node.GetNodes(trigger));
 }