Exemplo n.º 1
0
 public void useSkillsBlink(MGNotification notification)
 {
     if (notification.objc == null)
     {
         skillsBlink();
     }
 }
Exemplo n.º 2
0
 void roleDeadAnimController(MGNotification notification)
 {
     //if (GameObject.Find("role1").GetComponent<RoleAnimController>().isKillRoadblock) return;
     if (notification.objc.Equals("role"))
     {
         Debug.Log("roleDeadAnimController:" + notification.objc);
         setAllAnimStateToFalse();
         animStateToDead();
     }
     else if (notification.objc.Equals("role1"))
     {
         Debug.Log("roleDeadAnimController:" + notification.objc);
         setAllAnimStateToFalse();
         animStateToDead();
     }
     Debug.Log("set role trigger");
     if (downOrUp)
     {
         rigidbody2D.gravityScale = 0.5f;
     }
     else
     {
         rigidbody2D.gravityScale = 0f;
     }
     rigidbody2D.velocity = Vector3.zero;
     collider2D.isTrigger = true;
     isDead = true;
     MGNotificationCenter.defaultCenter().postNotification(uiEvent.enableAllUIButton, false);
 }
Exemplo n.º 3
0
 public void continueNotification(MGNotification notification)
 {
     if (notification.objc != null)
     {
         continueGame(null);
     }
 }
Exemplo n.º 4
0
 public void stopNotification(MGNotification notification)
 {
     if (notification.objc != null)
     {
         clickStop(null);
     }
 }
Exemplo n.º 5
0
 void loadLevelWay(MGNotification notification)
 {
     if (notification.objc != null && notification.objc is string)
     {
         Application.LoadLevel(notification.objc as string);
     }
 }
Exemplo n.º 6
0
 public void useSkillsRoadblock(MGNotification notification)
 {
     if (notification.objc == null)
     {
         skillsRoadblock();
     }
 }
Exemplo n.º 7
0
 public void useSkillsDart(MGNotification notification)
 {
     if (notification.objc == null)
     {
         skillsDart();
     }
 }
Exemplo n.º 8
0
    public void useSkillsBones(MGNotification notification)
    {
        Vector3      pos       = new Vector3(transform.position.x + 3 * renderer.bounds.size.x / 16, transform.position.y + (transform.localScale.y > 0 ? 1 : -1) * renderer.bounds.size.y / 2, transform.position.z);
        MGSkillBones skillObjc = bones as MGSkillBones;

        if (notification.objc == null)//需要在对方客户端同步的
        {
            if (Network.peerType != NetworkPeerType.Disconnected)
            {
                skillObjc = mgNetWorking.Instantiate(bones, pos, new Quaternion(), 0) as MGSkillBones;
            }
            else
            {
                skillObjc = bones.createSkillSprite(pos) as MGSkillBones;
            }
        }
        else//不需要再对方客户端同步的,短时间的bones
        {
            skillObjc      = bones.createSkillSprite(pos) as MGSkillBones;
            skillObjc.name = notification.objc as string;
        }
        if (skillObjc)
        {
            skillObjc.releaseSkillObjcName = this.gameObject.name;
            skillObjc.transform.parent     = this.transform;
        }
    }
Exemplo n.º 9
0
 public void downButtonClick(MGNotification notification)
 {
     if (!isRoll && !isPressDown && transform.localScale.y < 0)
     {
         return;
     }
     //Debug.Log(this.gameObject.name + " downButtonClick");
     collider2D.isTrigger = true;
     if (isFirstJump)//在空中
     {
         //Debug.Log("在空中");
         isPressDown              = true;
         isPressDownToGround      = false;
         downOrUp                 = true;
         rigidbody2D.gravityScale = 10f;
         rigidbody2D.velocity     = new Vector3(0, -10, 0);
         setAllAnimStateToFalse();
         animStateToRoll();
     }
     else//在绳子上
     {
         //Debug.Log("在绳子上");
         if (isRoll && !downOrUp)
         {
             isChangeDownOrUp = true;
         }
         isRoll   = true;
         downOrUp = true;
         rigidbody2D.gravityScale = 0f;
         music.play("Sound/updown_roll");
         setAllAnimStateToFalse();
         animStateToRoll();
     }
 }
Exemplo n.º 10
0
    void triggerFunc(MGNotification notification)
    {
        Debug.Log("triggerFunc");

        if (notification.objc is Collider2D)//自己要做的
        {
            Collider2D other = notification.objc as Collider2D;
            danDart();
            GameObject objc = GameObject.Find(other.name);
            if (objc)
            {
                int boneMask   = objc.GetComponent <Jump>().stateMask & roleState.bone;
                int sprintMask = objc.GetComponent <Jump>().stateMask & roleState.sprint;
                if (boneMask != 0 || sprintMask != 0)
                {
                    return;
                }
            }

            MGMsgModel skillModel = new MGMsgModel();
            skillModel.eventId        = SkillEffectEnum.dart;
            skillModel.gameobjectName = other.name;
            //发送给自己
            MGNotificationCenter.defaultCenter().postNotification(SkillEffectEnum.dart, skillModel);
        }
        else if (notification.objc is MGMsgModel)//对面要做的
        {
            //MGMsgModel other = notification.objc as MGMsgModel;
            danDart();
        }
    }
Exemplo n.º 11
0
 public void enableAllUIButton(MGNotification notification)
 {
     GameObject[] buttons = GameObject.FindGameObjectsWithTag("UIButton");
     for (int i = 0; i < buttons.Length; ++i)
     {
         buttons[i].GetComponent <UIButton>().enabled = (bool)notification.objc;
     }
 }
Exemplo n.º 12
0
 public void downToLine(MGNotification notification)
 {
     //角色会根据下按钮,翻转到线下
     MGNotificationCenter.defaultCenter().postNotification(buttonEventId(RoleButtonEvent.downFormerEventId), null);
     if (notification.objc == null)
     {
         mgNetWorking.sendMessageToPeer(objcToJson(RoleActEventEnum.downToLineFormerEventId));
     }
 }
Exemplo n.º 13
0
    void sprintEffect(MGNotification notification)
    {
        if (notification != null)
        {
            sprintSwitch = notification;
            MGMsgModel skillModel = (MGMsgModel)notification.objc;
            GameObject objc       = GameObject.Find(skillModel.gameobjectName);
            if (objc)
            {
                if (tempObjcet == null)
                {
                    tempObjcet = GameObject.Find("sprint(Clone)");
                }
                float dis = MGGlobalDataCenter.defaultCenter().roleFrontPos.x - MGGlobalDataCenter.defaultCenter().roleLaterPos.x;
                objc.transform.Translate(speedSwitch * Vector3.right * MGSkillSprintInfo.SkillEffectSpeed * dis * Time.deltaTime / MGSkillSprintInfo.durationTime);
                if (tempObjcet)
                {
                    int fx = objc.transform.localScale.y > 0?1:-1;
                    tempObjcet.transform.position = new Vector3(objc.transform.position.x + 0.25f, objc.transform.position.y + fx * objc.GetComponent <SpriteRenderer>().bounds.size.y / 2f, objc.transform.position.z);
                }
            }
            sprintTimer += Time.deltaTime;
            if (sprintTimer > MGSkillSprintInfo.durationTime)
            {
                //修改背景的移动速度
                GameObject[] backgroundList = GameObject.FindGameObjectsWithTag("Background");
                for (int i = 0; i < backgroundList.Length; ++i)
                {
                    backgroundList[i].GetComponent <bgnear>().speed -= 20;
                }
                backgroundList = GameObject.FindGameObjectsWithTag("Road");
                for (int i = 0; i < backgroundList.Length; ++i)
                {
                    backgroundList[i].GetComponent <bgnear>().speed -= 20;
                }

                objc.GetComponent <RoleAnimController>().isSprint = false;
                objc.GetComponent <Animator>().SetBool("sprint", false);
                objc.GetComponent <SpriteRenderer>().material = new Material(Shader.Find("Sprites/Default"));
                UILabel label = GameObject.Find("log").GetComponent <UIInput>().label;
                Vector3 pos1  = GameObject.Find("role1").transform.position;
                Vector3 pos   = GameObject.Find("role").transform.position;
                label.text  += "\r\nrole.x=" + pos.x + ";role1.x=" + pos1.x;
                sprintTimer  = 0;
                sprintSwitch = null;
                tempObjcet   = null;
                GameObject sprint = GameObject.Find("sprint(Clone)");
                if (sprint != null)
                {
                    Destroy(sprint);
                }
                objc.GetComponent <Jump>().stateMask &= ~roleState.sprint;
            }
        }
    }
Exemplo n.º 14
0
 void roleKillAnimController(MGNotification notification)
 {
     if (notification.objc.Equals("role1"))
     {
         Debug.Log("roleKillAnimController");
         setAllAnimStateToFalse();
         animStateToKill();
     }
     isKillRoadblock = false;
     MGNotificationCenter.defaultCenter().postNotification(uiEvent.enableAllUIButton, false);
 }
Exemplo n.º 15
0
 void dartEffect(MGNotification notification)
 {
     if (notification != null)
     {
         MGMsgModel skillModel = (MGMsgModel)notification.objc;
         GameObject objc       = GameObject.Find(skillModel.gameobjectName);
         float      dis        = MGGlobalDataCenter.defaultCenter().roleFrontPos.x - MGGlobalDataCenter.defaultCenter().roleLaterPos.x;
         if (objc && (objc.GetComponent <Jump>().stateMask & roleState.wudi) == 0)
         {
             objc.transform.Translate(Vector3.left * MGSkillDartInfo.SkillEffectSpeed * dis);
         }
     }
 }
Exemplo n.º 16
0
 void roleKillRoadblockAnimController(MGNotification notification)
 {
     if (isKillRoadblock)
     {
         return;
     }
     if (notification.objc.Equals("role1"))
     {
         Debug.Log("roleKillRoadblockAnimController");
         setAllAnimStateToFalse();
         animStateToKillRoadblock();
     }
     isKillRoadblock = true;
 }
Exemplo n.º 17
0
 // Use this for initialization
 void Start()
 {
     sprintTimer          = 0;
     beatbackTimer        = 0;
     blinkSkillBonesTimer = 1;
     sprintSwitch         = null;
     tempObjcet           = null;
     roadblockSwitch      = null;
     shortBonesName       = "bones_short";
     MGNotificationCenter.defaultCenter().addObserver(this, dartEffect, SkillEffectEnum.dart);
     MGNotificationCenter.defaultCenter().addObserver(this, blinkEffect, SkillEffectEnum.blink);
     MGNotificationCenter.defaultCenter().addObserver(this, sprintEffect, SkillEffectEnum.sprint);
     MGNotificationCenter.defaultCenter().addObserver(this, beatbackEffect, SkillEffectEnum.beatback);
     MGNotificationCenter.defaultCenter().addObserver(this, roadblockEffect, SkillEffectEnum.roadblock);
 }
Exemplo n.º 18
0
 public void jump(MGNotification notification)
 {
     MGNotificationCenter.defaultCenter().postNotification(buttonEventId(RoleButtonEvent.upFormerEventId), notification);
     //if (roleAnimaController.isRoll || roleAnimaController.isPressDown) return;
     if (transform.localScale.y < 0 || roleAnimaController.isRoll)
     {
         Debug.Log("jump");
         if (notification.objc == null)
         {
             mgNetWorking.sendMessageToPeer(objcToJson(RoleActEventEnum.jumpFormerEventId));
         }
         return;
     }
     if (roleAnimaController.isFirstJump && !roleAnimaController.isSecondJump && jumpCount == 0)
     {
         Debug.Log("一段跳");
         isGround = false;
         Vector3 velocity = rigidbody2D.velocity;
         velocity.y           = jumpVelocity;
         rigidbody2D.velocity = velocity;
         jumpCount            = 1;
         //如果没有发送给对方,则发送消息
         if (notification.objc == null)
         {
             mgNetWorking.sendMessageToPeer(objcToJson(RoleActEventEnum.jumpFormerEventId));
         }
     }
     //如果不在地面上,且一段跳了,则二段跳
     else if (roleAnimaController.isFirstJump && roleAnimaController.isSecondJump && jumpCount == 1)
     {
         Debug.Log("二段跳");
         Vector3 velocity = rigidbody2D.velocity;
         if (velocity.y < -1.0f)
         {
             velocity.y = jumpSecond + 3;
         }
         else
         {
             velocity.y = jumpSecond;
         }
         rigidbody2D.velocity = velocity;
         jumpCount            = 2;
         if (notification.objc == null)
         {
             mgNetWorking.sendMessageToPeer(objcToJson(RoleActEventEnum.jumpFormerEventId));
         }
     }
 }
Exemplo n.º 19
0
 public void upButtonClick(MGNotification notification)
 {
     //if (isPressDown && !isPressDownToGround) return;
     if (isSecondJump)
     {
         return;
     }
     Debug.Log(this.gameObject.name + " upButtonClick");
     if (transform.localScale.y < 0 || (isRoll && downOrUp))//上翻
     {
         //Debug.Log("上翻");
         if (isRoll && downOrUp == true)
         {
             isChangeDownOrUp = true;
         }
         isRoll   = true;
         downOrUp = false;
         rigidbody2D.gravityScale = 0f;
         collider2D.isTrigger     = true;
         music.play("Sound/updown_roll");
         setAllAnimStateToFalse();
         animStateToRoll();
         return;
     }
     if (isRoll)
     {
         return;
     }
     //Debug.Log(this.gameObject.name + " jumpButtonClick");
     if (isFirstJump == false)//一段跳
     {
         isFirstJump = true;
         setAllAnimStateToFalse();
         animStateToFirstJump();
         music.play("Sound/updown_roll");
     }
     else if (isSecondJump == false)//二段跳
     {
         isSecondJump = true;
         setAllAnimStateToFalse();
         animStateToRoll();
         music.play("Sound/updown_roll");
     }
 }
Exemplo n.º 20
0
 void roadblockEffect(MGNotification notification)
 {
     if (notification != null)
     {
         roadblockSwitch = notification;
         MGMsgModel skillModel = (MGMsgModel)notification.objc;
         GameObject objc       = GameObject.Find(skillModel.gameobjectName);
         float      dis        = MGGlobalDataCenter.defaultCenter().roleFrontPos.x - MGGlobalDataCenter.defaultCenter().roleLaterPos.x;
         if (objc && (objc.GetComponent <Jump>().stateMask & roleState.wudi) == 0)
         {
             objc.transform.Translate(Vector3.left * MGSkillRoadblockInfo.SkillEffectSpeed * dis * Time.deltaTime / MGSkillRoadblockInfo.durationTime);
         }
         roadblockTimer += Time.deltaTime;
         if (roadblockTimer > MGSkillRoadblockInfo.durationTime * Time.timeScale)
         {
             roadblockTimer  = 0;
             roadblockSwitch = null;
         }
     }
 }
Exemplo n.º 21
0
    void blinkEffect(MGNotification notification)
    {
        if (notification != null)
        {
            blinkSkillBonesTimer = 0;
            if (MGGlobalDataCenter.defaultCenter().isFrontRoler == false && MGGlobalDataCenter.defaultCenter().isSingle == false)
            {
                MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.bones, shortBonesName);//发送bones技能的事件
                return;
            }

            MGMsgModel skillModel = (MGMsgModel)notification.objc;
            Debug.Log("skillModel:" + skillModel + ",eventId:" + skillModel.eventId + ",gameobjectName:" + skillModel.gameobjectName);
            GameObject objc = GameObject.Find(skillModel.gameobjectName);
            if (objc)
            {
                Debug.Log("blinkObjc:" + objc + "name:" + objc.name);
                float   dis          = MGGlobalDataCenter.defaultCenter().roleFrontPos.x - MGGlobalDataCenter.defaultCenter().roleLaterPos.x;
                Vector3 roleLaterPos = MGGlobalDataCenter.defaultCenter().roleLater.transform.position;
                Vector3 roleFrontPos = MGGlobalDataCenter.defaultCenter().role.transform.position;
                if (roleFrontPos.x - roleLaterPos.x < MGSkillBlinkInfo.SkillEffectSpeed * dis)
                {
                    objc.transform.Translate(Vector3.right * (roleFrontPos.x - roleLaterPos.x - 1f));
                }
                else
                {
                    objc.transform.Translate(Vector3.right * MGSkillBlinkInfo.SkillEffectSpeed * dis);
                }
            }

            MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.bones, shortBonesName);//发送bones技能的事件

            UILabel label = GameObject.Find("log").GetComponent <UIInput> ().label;
            Vector3 pos1  = GameObject.Find("role1").transform.position;
            Vector3 pos   = GameObject.Find("role").transform.position;
            label.text += "\r\nrole.x=" + pos.x + ";role1.x=" + pos1.x + ";shortBonesName:" + shortBonesName;
        }
    }
Exemplo n.º 22
0
 void observerSel3(MGNotification notification)
 {
     print("收到通知:" + notification.name + notification);
 }
Exemplo n.º 23
0
    public void triggerFunc(MGNotification notification)
    {
        string tag = null, name = null;

        if (notification.objc is Collider2D)//自己要做的
        {
            tag  = (notification.objc as Collider2D).tag;
            name = (notification.objc as Collider2D).name;
        }
        else if (notification.objc is MGMsgModel)//对面要做的
        {
            tag  = (notification.objc as MGMsgModel).tag;
            name = (notification.objc as MGMsgModel).name;
        }
        //Debug.Log(tag + ";" + name);
        if (isBreak)
        {
            return;
        }
        if (name == "bones(Clone)" || name == "sprint(Clone)")
        {
            //Debug.Log("roadblock break");
            isBreak = true;
            try
            {
                this.GetComponent <Animator>().SetBool("isBreak", true);
            }
            catch { }
        }
        if (tag != "Player")
        {
            return;
        }
        if (name != releaseSkillObjectName)
        {
            string strrole = "role";
            int    irole   = strrole.Length;
            if (name.Length >= irole && name.Substring(0, irole) == strrole)
            {
                MGGlobalDataCenter.defaultCenter().isRoadBlockHit = true;
            }
            else
            {
                MGGlobalDataCenter.defaultCenter().isRoadBlockDefence = true;
            }
            //print("技能名:路障。被打中的是" + name + ",释放技能的是" + releaseSkillObjectName);
            isBreak = true;
            try{
                this.GetComponent <Animator>().SetBool("isBreak", true);
            }catch {}

            MGNotificationCenter.defaultCenter().postNotification(RoleButtonEvent.killAnimLatterEventId, name);

            GameObject objc = GameObject.Find(name);
            if (objc)
            {
                int boneMask   = objc.GetComponent <Jump>().stateMask & roleState.bone;
                int sprintMask = objc.GetComponent <Jump>().stateMask & roleState.sprint;
                if (boneMask != 0 || sprintMask != 0)
                {
                    return;
                }
            }

            if (notification.objc is Collider2D)
            {
                MGMsgModel skillModel = new MGMsgModel();
                skillModel.eventId        = SkillEffectEnum.roadblock;
                skillModel.gameobjectName = name;
                //发送给自己
                MGNotificationCenter.defaultCenter().postNotification(SkillEffectEnum.roadblock, skillModel);
            }
        }
    }