Example #1
0
    public void die()
    {
        PastMonsterCompent past = new PastMonsterCompent(this.gameObject, true, true);

        RunFacade.getInstance.SendNotification(NotificationConstant.MonsterMediator.ChangeMonsterCompent, past);

        PastAnimator pastA = new PastAnimator(this.gameObject, Tags.animator_type.Trigger, Tags.animator_monster.Die);

        RunFacade.getInstance.SendNotification(NotificationConstant.MonsterMediator.ChangeMonsterAnimation, pastA);

        Destroy(gameObject, 1f);
    }
Example #2
0
 void OnCollisionEnter(Collision collision)
 {
     switch (collision.collider.tag)
     {
     case Tags.tag.Player:
     {        //撞到主角
         PastMonsterCompent past = new PastMonsterCompent(this.gameObject, true, true);
         RunFacade.getInstance.sendNotificationCommand(NotificationConstant.MonsterMediator.ChangeMonsterCompent, past);
     }
     break;
     }
 }
Example #3
0
    public override void HandleNotification(PureMVC.Interfaces.INotification notification)
    {
        switch (notification.Name)
        {
        //执行和显示有关的命令
        case NotificationConstant.MonsterMediator.ChangeMonsterCompent:
        {
            PastMonsterCompent recive      = notification.Body as PastMonsterCompent;
            GameObject         MonsterItem = recive.monster;
            MonsterItem.GetComponent <Rigidbody>().isKinematic     = recive.isKinematic;
            MonsterItem.GetComponent <CapsuleCollider>().isTrigger = recive.isTrigger;
        }
        break;

        case NotificationConstant.MonsterMediator.ChangeMonsterAnimation:
        {
            PastAnimator recive      = notification.Body as PastAnimator;
            GameObject   MonsterItem = recive.monster;
            switch (recive.type)
            {
            case Tags.animator_type.Trigger: MonsterItem.GetComponent <Animator>().SetTrigger(recive.name); break;

            case Tags.animator_type.Bool: MonsterItem.GetComponent <Animator>().SetBool(recive.name, recive.boolState); break;
            }
        }
        break;


        case NotificationConstant.MonsterMediator.MonsterMove:
        {
            PastSingle recive = notification.Body as PastSingle;
            switch (recive.obj.name)
            {
            case Tags.monster_type.fly:
            {
                Vector3 fly_position = recive.obj.transform.position;
                fly_position.y = 2f + (float)Mathf.Sin(fly_x) * 0.5f;
                recive.obj.transform.position = fly_position;
                fly_x = 0;
            }
            break;

            case Tags.monster_type.water:
            {
                water_x += Time.deltaTime;
                if (water_x >= 2)
                {
                    Debug.Log("Jump");
                    recive.obj.GetComponent <Rigidbody>().velocity = new Vector3(0, 5, 0);
                    water_x = 0;
                }
            }
            break;

            case Tags.monster_type.Boss:
            {
                Vector3 pos = new Vector3(Player.transform.position.x + recive.f, recive.obj.transform.position.y, recive.obj.transform.position.z);
                recive.obj.transform.position = pos;
            }
            break;

            case Tags.monster_type.smallBoss:
            {
                recive.obj.GetComponent <Rigidbody>().AddForce(recive.vect);
            }
            break;
            }
        }
        break;

        case NotificationConstant.MonsterMediator.ChangeBossColor:
        {
            PastSingle recive = notification.Body as PastSingle;
            Renderer   rend   = recive.obj.GetComponent <Renderer>();
            rend.material.shader = Shader.Find("Specular");
            rend.material.SetColor("_SpecColor", recive.c);
        }
        break;

        case NotificationConstant.MonsterMediator.SpawnSmallBoss:
        {
            PastSingle recive = notification.Body as PastSingle;
        }
        break;
        }
    }