Esempio n. 1
0
    public override void OnEnter()
    {
        mHurtBuffConfigInfo = mBuffConfig as HurtBuffConfig;

        base.OnEnter();
        if (!mReceRole.mStateMachine.SwitchState(IState.StateType.Buff, mHurtBuffConfigInfo.mStateName, 0.0f))
        {
            //mReceRole.mStateMachine.SetNextState(IState.StateType.Buff, mHurtBuffConfigInfo.mStateName, 0.0f);
        }

        mReceRole.mRoleData.SetTargetRole(mSendRole.mRoleData.mInstId);

        for (int i = 0; i < mReceRole.mRenderers.Length; ++i)
        {
            for (int ii = 0; ii < mReceRole.mRenderers[i].materials.Length; ++ii)
            {
                mReceRole.mRenderers[i].materials[ii].EnableKeyword("RIM");
            }
        }

        // 死亡应该服务器通知.单机暂时写在这里
        int hurt = mSendRole.mRoleData.mAtk - mReceRole.mRoleData.mDef;

        if (hurt > 0)
        {
            mReceRole.mRoleData.mHp -= hurt;
            if (mReceRole.mRoleData.mHp <= 0)
            {
                mReceRole.mRoleData.mHp = 0;
                mReceRole.mAnimator.SetBool("Death", true);
            }
        }
    }
Esempio n. 2
0
    public IEnumerator load(string filePath)
    {
        string url = filePath + "/config/buff.xml";
        WWW    www = new WWW(url);

        yield return(www);

        XmlDocument xmldoc = new XmlDocument();

        xmldoc.LoadXml(www.text);
        XmlNode root = xmldoc.SelectSingleNode("root");

        XmlNode     behaviorNode   = root.SelectSingleNode("behavior");
        XmlNodeList behaviorChilds = behaviorNode.SelectNodes("buff");

        foreach (XmlNode buffNode in behaviorChilds)
        {
            BehaviorBuffConfig info    = new BehaviorBuffConfig();
            XmlElement         buffxml = (XmlElement)buffNode;
            info.mType     = IBuff.BuffType.Behavior;
            info.mTypeId   = int.Parse(buffxml.GetAttribute("id"));
            info.mName     = buffxml.GetAttribute("Name");
            info.mDuration = float.Parse(buffxml.GetAttribute("Duration"));
            info.mCanAtk   = int.Parse(buffxml.GetAttribute("CanAtk")) == 1 ? true : false;
            info.mCanMove  = int.Parse(buffxml.GetAttribute("CanMove")) == 1 ? true : false;

            mBehaviorBuffConfigDict.Add(info.mTypeId, info);
        }

        XmlNode     moveNode   = root.SelectSingleNode("move");
        XmlNodeList moveChilds = moveNode.SelectNodes("buff");

        foreach (XmlNode buffNode in moveChilds)
        {
            MoveBuffConfig info    = new MoveBuffConfig();
            XmlElement     buffxml = (XmlElement)buffNode;
            info.mType     = IBuff.BuffType.Move;
            info.mTypeId   = int.Parse(buffxml.GetAttribute("id"));
            info.mName     = buffxml.GetAttribute("Name");
            info.mDir      = (MoveBuff.MoveDir) int.Parse(buffxml.GetAttribute("Dir"));
            info.mDuration = float.Parse(buffxml.GetAttribute("Duration"));
            info.mDistance = float.Parse(buffxml.GetAttribute("Distance"));
            mMoveBuffConfigDict.Add(info.mTypeId, info);
        }

        XmlNode     hurtNode   = root.SelectSingleNode("hurt");
        XmlNodeList hurtChilds = hurtNode.SelectNodes("buff");

        foreach (XmlNode buffNode in hurtChilds)
        {
            HurtBuffConfig info    = new HurtBuffConfig();
            XmlElement     buffxml = (XmlElement)buffNode;
            info.mType      = IBuff.BuffType.Hurt;
            info.mTypeId    = int.Parse(buffxml.GetAttribute("id"));
            info.mName      = buffxml.GetAttribute("Name");
            info.mDuration  = float.Parse(buffxml.GetAttribute("Duration"));
            info.mStateName = buffxml.GetAttribute("StateName");
            mHurtBuffConfigDict.Add(info.mTypeId, info);
        }

        XmlNode     controlNode   = root.SelectSingleNode("control");
        XmlNodeList controlChilds = controlNode.SelectNodes("buff");

        foreach (XmlNode buffNode in controlChilds)
        {
            ControlBuffConfig info    = new ControlBuffConfig();
            XmlElement        buffxml = (XmlElement)buffNode;
            info.mType           = IBuff.BuffType.Control;
            info.mTypeId         = int.Parse(buffxml.GetAttribute("id"));
            info.mName           = buffxml.GetAttribute("Name");
            info.mDuration       = float.Parse(buffxml.GetAttribute("Duration"));
            info.mClearBuff      = int.Parse(buffxml.GetAttribute("ClearBuff")) == 1 ? true : false;
            info.mEnableBehavior = int.Parse(buffxml.GetAttribute("EnableBehavior")) == 1 ? true : false;
            info.mEnableMove     = int.Parse(buffxml.GetAttribute("EnableMove")) == 1 ? true : false;
            info.mEnableHurt     = int.Parse(buffxml.GetAttribute("EnableHurt")) == 1 ? true : false;
            info.mEnableSelect   = int.Parse(buffxml.GetAttribute("EnableSelect")) == 1 ? true : false;
            mControlBuffConfigDict.Add(info.mTypeId, info);
        }
    }