Esempio n. 1
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();
        }
    }
Esempio 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);
 }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        initRoleAnimController();

        //获取播放器对象
        music = (GetComponent("MusicPlayer") as MusicPlayer);

        jumpSprict = this.GetComponent <Jump>();
        jumpAnim   = this.GetComponent <Animator> ();
        player     = this.GetComponent <Rigidbody2D> ();
        if (this.gameObject.name == "role")
        {
            MGNotificationCenter.defaultCenter().addObserver(this, upButtonClick, RoleButtonEvent.upFormerEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, downButtonClick, RoleButtonEvent.downFormerEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, roleDeadAnimController, RoleButtonEvent.deadFormerEventId);
        }
        //后面的角色动作
        else if (this.gameObject.name == "role1")
        {
            isKillRoadblock = false;
            MGNotificationCenter.defaultCenter().addObserver(this, upButtonClick, RoleButtonEvent.upLatterEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, downButtonClick, RoleButtonEvent.downLatterEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, roleDeadAnimController, RoleButtonEvent.deadLatterEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, roleKillAnimController, RoleButtonEvent.killLatterEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, roleKillRoadblockAnimController, RoleButtonEvent.killAnimLatterEventId);
        }
    }
Esempio n. 4
0
    public void OnMouseDown()
    {
        if (MGGlobalDataCenter.defaultCenter().isStop == true)
        {
            return;
        }
        int num = int.Parse(dartNum.text);

        if (!isCD && num > 0 && !MGGlobalDataCenter.defaultCenter().isBigSkilling)//如果不是GCD 且个数大于0 就可以放技能
        {
            print("update ********isPressDartButton : " + isPressDartButton);
            isPressDartButton = true;
            dartAnim.SetBool("pressDartButton", isPressDartButton);
            print("update ********isPressDartButton : " + isPressDartButton);
            if (num == MGSkillDartInfo.skillHoldLevel)//只有个数等于最大数量时才重置fillAmount
            {
                cdBack.fillAmount = addOrDec ? 0f : 1f;
            }
            --num;
            dartNum.text = num.ToString();
            isCD         = true;
            cdBackObject.transform.localScale = new Vector3((addOrDec ? 1 : -1) * (direction ? -1 : 1), 1, 1);
            MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.dart, null);
        }
    }
 void Update()
 {
     if (!isUseFirstSkill && blinkTimer > 0.5f)
     {
         Debug.Log("*************************************************");
         firstSkill();
     }
     blinkTimer  += Time.deltaTime;
     bonesTimer  += Time.deltaTime;
     sprintTimer += Time.deltaTime;
     if (MGGlobalDataCenter.defaultCenter().isGameOver)
     {
         return;
     }
     if (blinkTimer > 7f)
     {
         blinkTimer = 0f;
         MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.blink, null);
     }
     if (bonesTimer > 8f)
     {
         bonesTimer = 0f;
         MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.bones, null);
     }
     if (sprintTimer > 9f)
     {
         sprintTimer = 0f;
         MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.sprint, null);
     }
 }
 void firstSkill()
 {
     MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.blink, null);
     MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.bones, null);
     isUseFirstSkill = true;
     blinkTimer      = bonesTimer = sprintTimer = 0;
 }
 /// <summary>
 /// Get the signle instance
 /// </summary>
 /// <returns>MGNotificationCenter instance</returns>
 public static MGNotificationCenter defaultCenter()
 {
     if (instance == null)
     {
         instance = new MGNotificationCenter();
     }
     return(instance);
 }
Esempio n. 8
0
 void Start()
 {
     releaseSkillObjectName = "role";
     isBreak          = false;
     mgNetWorking     = GameObject.Find("NetWork").GetComponent <MGNetWorking>();
     gameObject.name += MGGlobalDataCenter.defaultCenter().dartIndex.ToString();
     MGGlobalDataCenter.defaultCenter().dartIndex = (MGGlobalDataCenter.defaultCenter().dartIndex + 1) % (MGSkillDartInfo.skillHoldLevel * MGSkillRoadblockInfo.skillHoldLevel);
     MGNotificationCenter.defaultCenter().addObserver(this, triggerFunc, SkillEnum.roadblock + gameObject.name);
 }
Esempio n. 9
0
 public void downToLine(MGNotification notification)
 {
     //角色会根据下按钮,翻转到线下
     MGNotificationCenter.defaultCenter().postNotification(buttonEventId(RoleButtonEvent.downFormerEventId), null);
     if (notification.objc == null)
     {
         mgNetWorking.sendMessageToPeer(objcToJson(RoleActEventEnum.downToLineFormerEventId));
     }
 }
Esempio n. 10
0
 public void onClick()
 {
     role1 = GameObject.Find("role1");
     MGNotificationCenter.defaultCenter().addObserver(this, observerSel, "testNotification");
     MGNotificationCenter.defaultCenter().addObserver(this, observerSel1, "testNotification");
     MGNotificationCenter.defaultCenter().addObserver(this, observerSel2, "testNotification");
     MGNotificationCenter.defaultCenter().addObserver(this, observerSel3, "testNotification");
     drat.createSkillSprite(new Vector3(role1.transform.position.x, role1.transform.position.y + role1.renderer.bounds.size.y / 2, role1.transform.position.z));
     roadblock.createSkillSprite(role1.transform.position);
 }
Esempio n. 11
0
 void roleLaterGuideDownToLine()
 {
     if ((guideEndMask & MGGuideManagerState.secondJump) != 0 && (guideMask & MGGuideManagerState.downToLine) == 0)
     {
         if (roleLaterJumpScript.isGround)
         {
             MGNotificationCenter.defaultCenter().postNotification(RoleActEventEnum.jumpFormerEventId, null);
             guideMask         |= MGGuideManagerState.downToLine;
             flag               = false;
             roadblockGCDTimer  = 0;
             roadblockHoldLevel = MGSkillRoadblockInfo.skillHoldLevel;
         }
     }
     if ((guideEndMask & MGGuideManagerState.downToLine) == 0 && (guideMask & MGGuideManagerState.downToLine) != 0)
     {
         if (flag == false && roleFront.rigidbody2D.velocity.y <= 0f && roleFrontJumpScript.isGround == false)
         {
             MGNotificationCenter.defaultCenter().postNotification(RoleActEventEnum.jumpFormerEventId, null);
             flag = true;
         }
         else if (flag && roleFrontJumpScript.isGround == false && roleFront.rigidbody2D.velocity.y <= 0f && roleFront.transform.position.y >= roleFront.GetComponent <SpriteRenderer>().bounds.size.y + MGGlobalDataCenter.defaultCenter().roadOrignY)
         {
             roadblockGCDTimer += Time.deltaTime;
             if (roadblockGCDTimer > 0.05f)
             {
                 roadblockGCDTimer = 0;
                 skillObjc         = roleFrontJumpScript.skillsDart();
             }
         }
         else if (skillObjc != null && roleFront.transform.position.y < roleFront.GetComponent <SpriteRenderer>().bounds.size.y + MGGlobalDataCenter.defaultCenter().roadOrignY)
         {
             if (roadblockHoldLevel > 0)
             {
                 if (roadblockHoldLevel == MGSkillRoadblockInfo.skillHoldLevel)
                 {
                     roadblockGCDTimer = 0;
                     --roadblockHoldLevel;
                     roleFrontJumpScript.skillsRoadblock();
                 }
                 roadblockGCDTimer += Time.deltaTime;
                 if (roadblockGCDTimer > MGSkillRoadblockInfo.skillGCD)
                 {
                     roadblockGCDTimer = 0;
                     --roadblockHoldLevel;
                     roleFrontJumpScript.skillsRoadblock();
                 }
             }
         }
         if (skillObjc != null && skillObjc.transform.position.x - roleLater.transform.position.x <= 3f)
         {
             skillObjc = null;
             showButtonAndLabel("downButton(Clone)", "明月放了好多技能,点击“下翻”来躲避障碍");
         }
     }
 }
Esempio n. 12
0
 void roleKillAnimController(MGNotification notification)
 {
     if (notification.objc.Equals("role1"))
     {
         Debug.Log("roleKillAnimController");
         setAllAnimStateToFalse();
         animStateToKill();
     }
     isKillRoadblock = false;
     MGNotificationCenter.defaultCenter().postNotification(uiEvent.enableAllUIButton, false);
 }
 void controlleOtherToDown()
 {
     if (MGGlobalDataCenter.defaultCenter().isLaterRoler)
     {
         MGNotificationCenter.defaultCenter().postNotification(RoleActEventEnum.downToLineFormerEventId, null);
     }
     else if (MGGlobalDataCenter.defaultCenter().isFrontRoler)
     {
         MGNotificationCenter.defaultCenter().postNotification(RoleActEventEnum.dowmToLineLatterEventId, null);
     }
 }
 void controlleOtherToJump()
 {
     if (MGGlobalDataCenter.defaultCenter().isLaterRoler)
     {
         MGNotificationCenter.defaultCenter().postNotification(RoleActEventEnum.jumpFormerEventId, null);
     }
     else if (MGGlobalDataCenter.defaultCenter().isFrontRoler)
     {
         MGNotificationCenter.defaultCenter().postNotification(RoleActEventEnum.jumpLatterEventId, null);
     }
 }
Esempio n. 15
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (MGGlobalDataCenter.defaultCenter().isFrontRoler == true || MGGlobalDataCenter.defaultCenter().isSingle)
     {
         MGMsgModel model = new MGMsgModel();
         model.eventId = SkillEnum.roadblock + gameObject.name;
         model.tag     = other.tag;
         model.name    = other.name;
         MGNotificationCenter.defaultCenter().postNotification(SkillEnum.roadblock + gameObject.name, other);
         mgNetWorking.sendMessageToPeer(JsonMapper.ToJson(model));
     }
 }
Esempio n. 16
0
    public void gameOver()
    {
        Vector3 roleLaterPos = Vector3.zero;
        Vector3 roleFrontPos = Vector3.zero;

        try
        {
            roleLaterPos = MGGlobalDataCenter.defaultCenter().roleLater.transform.position;
            roleFrontPos = MGGlobalDataCenter.defaultCenter().role.transform.position;
        }
        catch
        {
            return;
        }

        if (roleFrontPos.x - roleLaterPos.x < 1.0f || isCollisionOver)        //后者追上前者结束
        {
            GameObject.Find("MGSkillEffect").GetComponent <MGSkillEffect>().speedSwitch = 0;
            MGGlobalDataCenter.defaultCenter().roleLater.GetComponent <Jump>().stateMask |= roleState.wudi;

            //MGGlobalDataCenter.defaultCenter().isGameOver = true;
            MGGlobalDataCenter.defaultCenter().roleLater.rigidbody2D.velocity = Vector3.zero;
            MGGlobalDataCenter.defaultCenter().role.rigidbody2D.velocity = Vector3.zero;
            //强制roleLater出现在role的后面一点点。

            roleLaterPos.x = roleFrontPos.x - 0.95f;
            roleLaterPos.y = roleFrontPos.y = MGGlobalDataCenter.defaultCenter().roadOrignY;
            MGGlobalDataCenter.defaultCenter().roleLater.transform.position = roleLaterPos;
            MGGlobalDataCenter.defaultCenter().roleLater.transform.localScale = new Vector3(1, 1, 1);
            MGGlobalDataCenter.defaultCenter().roleLater.transform.rotation = Quaternion.Euler(0, 0, 0);
            MGGlobalDataCenter.defaultCenter().role.transform.position = roleFrontPos;
            MGGlobalDataCenter.defaultCenter().role.transform.localScale = new Vector3(1, 1, 1);
            MGGlobalDataCenter.defaultCenter().role.transform.rotation = Quaternion.Euler(0, 0, 0);

            if (this.gameObject.name == "role1")
            {
                MGNotificationCenter.defaultCenter().postNotification(RoleButtonEvent.killLatterEventId, this.gameObject.name);
            }
        }
        if (this.gameObject.name == "role1" && transform.position.x + 1.4f < MGGlobalDataCenter.defaultCenter().screenLiftX)        //后者出屏幕结束,还有一个后者死掉结束在RoleAnimController里
        {
            MGGlobalDataCenter.defaultCenter().isGameOver = true;
            //切换场景
            Debug.Log("role1 out of screen");
            MGGlobalDataCenter.defaultCenter().overSenceUIName = "victoryFrontGameUI";
            Application.LoadLevel("overSence");
            MGMsgModel gameoverModel = new MGMsgModel();
            gameoverModel.eventId        = RoleActEventEnum.gameoverEventId;
            gameoverModel.gameobjectName = MGGlobalDataCenter.defaultCenter().overSenceUIName;
            mgNetWorking.sendMessageToPeer(JsonMapper.ToJson(gameoverModel));
        }
    }
Esempio n. 17
0
 public void changeKillFlag()
 {
     if (this.gameObject.name == "role1")
     {
         Debug.Log("changeKillFlag");
         //GameObject.Find("log").GetComponent<UILabel>().text+="changeKillFlag";
         MGNotificationCenter.defaultCenter().postNotification(RoleButtonEvent.deadFormerEventId, "role");
         MGGlobalDataCenter.defaultCenter().isGameOver    = true;
         MGGlobalDataCenter.defaultCenter().isKillMingyue = true;
         toNomalRun();
         animStateToRun();
     }
 }
Esempio n. 18
0
 // Use this for initialization
 void Start()
 {
     gameObject.name += MGGlobalDataCenter.defaultCenter().dartIndex.ToString();
     MGGlobalDataCenter.defaultCenter().dartIndex = (MGGlobalDataCenter.defaultCenter().dartIndex + 1) % (MGSkillDartInfo.skillHoldLevel * MGSkillRoadblockInfo.skillHoldLevel);
     direction    = Vector3.left;
     timestamp    = MGGlobalDataCenter.timestamp();
     mgNetWorking = GameObject.Find("NetWork").GetComponent <MGNetWorking>();
     //获取播放器对象
     isPlayDart             = false;
     releaseSkillObjectName = "role";
     MGGlobalDataCenter.defaultCenter().isDartRelease = true;
     MGNotificationCenter.defaultCenter().addObserver(this, triggerFunc, SkillEnum.dart + gameObject.name);
 }
Esempio n. 19
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.DownArrow))
     {
         if (MGGlobalDataCenter.defaultCenter().isFrontRoler == true)
         {
             MGNotificationCenter.defaultCenter().postNotification("downToLine", null);
         }
         else
         {
             MGNotificationCenter.defaultCenter().postNotification("1downToLine", null);
         }
     }
     if (Input.GetKeyDown(KeyCode.UpArrow))
     {
         if (MGGlobalDataCenter.defaultCenter().isFrontRoler == true)
         {
             MGNotificationCenter.defaultCenter().postNotification("jump", null);
         }
         else
         {
             MGNotificationCenter.defaultCenter().postNotification("1jump", null);
         }
     }
     if (roleSpeed != 0)
     {
         float dis = MGGlobalDataCenter.defaultCenter().roleFrontPos.x - MGGlobalDataCenter.defaultCenter().roleLaterPos.x;
         transform.Translate(Vector3.right * dis * roleSpeed * Time.deltaTime);
     }
     if (!MGGlobalDataCenter.defaultCenter().isGameOver)
     {
         gameOver();
     }
     if (MGGlobalDataCenter.defaultCenter().isGameOver)
     {
         if (this.gameObject.name == "role")
         {
             if (collider2D.isTrigger && transform.position.x < MGGlobalDataCenter.defaultCenter().roleLater.transform.position.x - 2f)
             {
                 if (transform.position.y >= MGGlobalDataCenter.defaultCenter().roadOrignY)
                 {
                     transform.localScale     = new Vector3(1, 1, 1);
                     transform.rotation       = Quaternion.Euler(0, 0, 0);
                     rigidbody2D.gravityScale = 5;
                     collider2D.isTrigger     = false;
                 }
             }
         }
     }
 }
Esempio n. 20
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);
 }
Esempio n. 21
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));
         }
     }
 }
Esempio n. 22
0
 public void OnMouseDown()
 {
     if (MGGlobalDataCenter.defaultCenter().isStop == true)
     {
         return;
     }
     if (!isCD && !MGGlobalDataCenter.defaultCenter().isBigSkilling)
     {
         UILabel label = GameObject.Find("log").GetComponent <UIInput>().label;
         label.text       += "\r\n blink OnMouseDown";
         cdBack.fillAmount = addOrDec ? 0f : 1f;
         isCD = true;
         cdBackObject.transform.localScale = new Vector3((addOrDec ? 1 : -1) * (direction ? -1 : 1), 1, 1);
         MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.blink, null);
     }
 }
Esempio n. 23
0
    public void receiverMessageFromPeer(string msg)
    {
        //Debug.Log ("receiverMessageFromPeer:"+msg+";"+MGGlobalDataCenter.timestamp());
        MGMsgModel msgModel = JsonMapper.ToObject <MGMsgModel>(msg);

        if (msgModel.eventId == RoleActEventEnum.gameoverEventId)
        {
            MGGlobalDataCenter.defaultCenter().overSenceUIName = msgModel.gameobjectName;
            if (Application.loadedLevelName != "overSence")
            {
                Application.LoadLevel("overSence");
            }
            return;
        }
        MGNotificationCenter.defaultCenter().postNotification(msgModel.eventId, msgModel);
    }
Esempio n. 24
0
 public void OnMouseDown()
 {
     if (MGGlobalDataCenter.defaultCenter().isStop == true)
     {
         return;
     }
     if (!isCD && !holdCD && !MGGlobalDataCenter.defaultCenter().isBigSkilling)
     {
         addOrDec          = false;
         direction         = false;
         cdBack.fillAmount = addOrDec ? 0f : 1f;
         holdCD            = true;
         cdBackObject.transform.localScale = new Vector3((addOrDec ? 1 : -1) * (direction ? -1 : 1), 1, 1);
         MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.bones, null);
     }
 }
Esempio n. 25
0
 public void OnMouseDown()
 {
     if (MGGlobalDataCenter.defaultCenter().isStop == true)
     {
         return;
     }
     if (!isCD && !MGGlobalDataCenter.defaultCenter().isBigSkilling)
     {
         cdBack.fillAmount = addOrDec ? 0f : 1f;
         isCD = true;
         cdBackObject.transform.localScale = new Vector3((addOrDec ? 1 : -1) * (direction ? -1 : 1), 1, 1);
         roadblockGCDTimer = 0;
         holdLevel         = MGSkillRoadblockInfo.skillHoldLevel - 1;
         MGNotificationCenter.defaultCenter().postNotification(SkillActEventEnum.roadblock, null);
     }
 }
Esempio n. 26
0
    // Use this for initialization
    void Awake()
    {
        //获取角色的名字,role则是前面的角色,role1则是后面的角色
        //前面角色的动作
        if (this.gameObject.name == "role")
        {
            //print ("yes role");
            //注册动作事件
            //rolePlayer = GameObject.Find("roleFront");
            if (MGGlobalDataCenter.defaultCenter().isSingle&& MGGlobalDataCenter.defaultCenter().isLaterRoler)
            {
                this.gameObject.AddComponent <MGRoleActAIController>();
                this.gameObject.AddComponent <MGRoleFrontSkillAIController>();
            }

            roleSpeed = 0;
            MGGlobalDataCenter.defaultCenter().role = this.gameObject;
            MGNotificationCenter.defaultCenter().addObserver(this, jump, RoleActEventEnum.jumpFormerEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, downToLine, RoleActEventEnum.downToLineFormerEventId);
            //注册技能事件
            MGNotificationCenter.defaultCenter().addObserver(this, useSkillsDart, SkillActEventEnum.dart);
            MGNotificationCenter.defaultCenter().addObserver(this, useSkillsRoadblock, SkillActEventEnum.roadblock);
            MGNotificationCenter.defaultCenter().addObserver(this, useSkillsBeatback, SkillActEventEnum.beatback);
        }
        //后面的角色动作
        else if (this.gameObject.name == "role1")
        {
            //print ("yes role1");
            //注册动作事件
            //rolePlayer = GameObject.Find("roleLater");
            if (MGGlobalDataCenter.defaultCenter().isSingle&& MGGlobalDataCenter.defaultCenter().isFrontRoler)
            {
                this.gameObject.AddComponent <MGRoleActAIController>();
                this.gameObject.AddComponent <MGRoleLaterSkillAIController>();
            }
            roleSpeed = 1f / 25f;
            MGGlobalDataCenter.defaultCenter().roleLater = this.gameObject;
            MGNotificationCenter.defaultCenter().addObserver(this, jump, RoleActEventEnum.jumpLatterEventId);
            MGNotificationCenter.defaultCenter().addObserver(this, downToLine, RoleActEventEnum.dowmToLineLatterEventId);
            //注册技能事件
            MGNotificationCenter.defaultCenter().addObserver(this, useSkillsBlink, SkillActEventEnum.blink);
            MGNotificationCenter.defaultCenter().addObserver(this, useSkillsBones, SkillActEventEnum.bones);
            MGNotificationCenter.defaultCenter().addObserver(this, useSkillsSprint, SkillActEventEnum.sprint);
            //@test
            //useSkillsBones(new MGNotification("123", null, null));
        }
    }
Esempio n. 27
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag != "Player" || other.name == releaseSkillObjectName)
     {
         return;
     }
     if (MGGlobalDataCenter.defaultCenter().isFrontRoler == true || MGGlobalDataCenter.defaultCenter().isSingle)
     {
         Debug.Log("OnTriggerEnter2D dart");
         MGMsgModel model = new MGMsgModel();
         model.eventId = SkillEnum.dart + gameObject.name;
         model.tag     = other.tag;
         model.name    = other.name;
         MGNotificationCenter.defaultCenter().postNotification(SkillEnum.dart + gameObject.name, other);
         mgNetWorking.sendMessageToPeer(JsonMapper.ToJson(model));
     }
 }
Esempio n. 28
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "role1")
     {
         print("技能名:击退。被击中的是" + other.name + ",释放技能的是" + this.releaseSkillObjectName + ";gameobjc:" + other.gameObject);
         //MGGlobalDataCenter.defaultCenter().isBigSkilling = false;
         //被大招击中的声音和 金钟罩撞路障声音一致
         MGGlobalDataCenter.defaultCenter().isRoadBlockDefence = true;
         UILabel label = GameObject.Find("log").GetComponent <UIInput>().label;
         label.text += "\r\n Skill:" + other.name;
         //发送给自己
         MGMsgModel skillModel = new MGMsgModel();
         skillModel.eventId        = SkillEffectEnum.beatback;
         skillModel.gameobjectName = other.name;
         MGNotificationCenter.defaultCenter().postNotification(SkillEffectEnum.beatback, skillModel);
     }
 }
Esempio n. 29
0
 void Start()
 {
     NGUIRoot = GameObject.Find("UI Root");
     InvokeRepeating("gameTimer", 0, 0.01f);
     mgNetWorking = GameObject.Find("NetWork").GetComponent <MGNetWorking>();
     MGNotificationCenter.defaultCenter().addObserver(this, stopNotification, uiEvent.stopGame);
     MGNotificationCenter.defaultCenter().addObserver(this, continueNotification, uiEvent.continueGame);
     MGNotificationCenter.defaultCenter().addObserver(this, enableAllUIButton, uiEvent.enableAllUIButton);
     createCommonUI();
     if (MGGlobalDataCenter.defaultCenter().isFrontRoler == true)
     {
         createFrontRoleUI();
     }
     else if (MGGlobalDataCenter.defaultCenter().isLaterRoler == true)
     {
         createLaterRoleUI();
     }
 }
Esempio n. 30
0
 public override void playSkillAnimation()
 {
     base.playSkillAnimation();
     transform.Translate(Vector3.left * speed * Time.deltaTime);
     if (isBlinked == false)//通知技能效果类执行相应的效果
     {
         isBlinked = true;
         MGMsgModel skillModel = new MGMsgModel();
         skillModel.eventId        = SkillEffectEnum.blink;
         skillModel.gameobjectName = "role1";
         //发送给对面 产生技能效果
         if (MGGlobalDataCenter.defaultCenter().isFrontRoler == false || MGGlobalDataCenter.defaultCenter().isSingle)
         {
             Debug.Log("发送给对面 产生技能效果");
             MGNotificationCenter.defaultCenter().postNotification(SkillEffectEnum.blink, skillModel);
             mgNetWorking.sendMessageToPeer(JsonMapper.ToJson(skillModel));
         }
     }
 }