AddObserver() публичный Метод

public AddObserver ( IObserver, observer ) : void
observer IObserver,
Результат void
Пример #1
0
 private void Start()
 {
     subject.AddObserver(scoreCounter);
     subject.AddObserver(ball);
     subject.AddObserver(player);
     subject.AddObserver(ai);
 }
    // Start is called before the first frame update
    void Start()
    {
        Box box1 = new Box(box1Obj, new LittleJump());
        Box box2 = new Box(box2Obj, new MiddleJump());
        Box box3 = new Box(box3Obj, new HighJump());

        subject.AddObserver(box1);
        subject.AddObserver(box2);
        subject.AddObserver(box3);
    }
Пример #3
0
        static void Main(string[] args)
        {
            Subject         subject   = new Subject();
            SimpleObserverA observerA = new SimpleObserverA("A");
            SimpleObserverB observerB = new SimpleObserverB("B");

            subject.AddObserver(observerA);
            subject.AddObserver(observerB);

            subject.NotifyAll();
        }
Пример #4
0
    void Start()
    {
        //khởi tạo các đối tượng box và truyền hành vi tương ứng
        Box box1 = new Box(boxObj1, new JumpLittle());
        Box box2 = new Box(boxObj2, new JumpMedium());
        Box box3 = new Box(boxObj3, new JumpHigh());

        subject.AddObserver(box1);
        subject.AddObserver(box2);
        subject.AddObserver(box3);
    }
Пример #5
0
 // Start is called before the first frame update
 void Start()
 {
     for (int i = 0; i <= e.GetComponent <EnemyControl>().Enemies.Count - 1; i++)
     {
         enemy = e.Enemies[i];//assigns the prefab object to the list of enemies
     }
     health        = 3;
     testing       = new EnemyCube(enemy, new returnScore()); //assigns observer object to the function it needs
     healthTesting = new EnemyCube(enemy, new returnScore()); //assigns observer object to the function it needs
     subject.AddObserver(testing);
     subject.AddObserver(healthTesting);
 }
Пример #6
0
    void Start()
    {
        Observer yellow = new YellowCounterObserver(YellowCounter);
        Observer green  = new GreenCounterObserver(GreenCounter);
        Observer blue   = new BlueCounterObserver(BlueCounter);
        Observer total  = new TotalCounterObserver(TotalCounter);

        subject.AddObserver(yellow);
        subject.AddObserver(green);
        subject.AddObserver(blue);
        subject.AddObserver(total);
    }
Пример #7
0
    void Start()
    {
        //Create boxes that can observe events and give them an event to do
        Box box1 = new Box(box1Obj, new JumpLittle());
        Box box2 = new Box(box2Obj, new JumpMedium());
        Box box3 = new Box(box3Obj, new JumpHigh());

        //Add the boxes to the list of objects waiting for something to happen
        subject.AddObserver(box1);
        subject.AddObserver(box2);
        subject.AddObserver(box3);
    }
Пример #8
0
    void Start()
    {
        enemies.Add(new Alpha(enemy1.transform));
        enemies.Add(new Beta(enemy2.transform));

        Car car1 = new Car(objCar1, new MoveBack());
        Car car2 = new Car(objCar2, new MoveUp());
        Car car3 = new Car(objCar3, new MoveLeft());

        _subject.AddObserver(car1);
        _subject.AddObserver(car2);
        _subject.AddObserver(car3);
    }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            ISubject  subject   = new Subject();
            IObserver observer1 = new FirstObserver(subject);
            IObserver observer2 = new SecondObserver(subject);

            subject.AddObserver(observer1);
            subject.AddObserver(observer2);
            subject.HaveSomeTechLogic();
            subject.RemoveObserver(observer1);
            subject.HaveSomeTechLogic();
        }
Пример #10
0
    private void Start()
    {
        subject = new Subject();
        subject.AddObserver(canvas.GetComponent <IObserver>());
        subject.AddObserver(GameObject.FindWithTag("Player").GetComponent <IObserver>());

        accidentalBodilyHarm = 0;
        bodilyHarm           = 0;
        murder           = 0;
        accidentalMurder = 0;
        abhIds           = new List <int>();
        bhIds            = new List <int>();
        mIds             = new List <int>();
    }
Пример #11
0
 private void Init()
 {
     Subject.AddObserver(this);
     getPlayers();
     StartCoroutine(RepeatTrySearchPlayer());
     StartCoroutine(RepeatTrySearchPath());
 }
Пример #12
0
        //Змінити ім'я файлу або папки
        private void button7_Click(object sender, EventArgs e)
        {
            Subject test = new Subject("Change");

            test.AddObserver(MainObs);

            if (listView1.SelectedIndices.Count != 0)
            {
                int selectedIndex = listView1.SelectedIndices[0];

                string pathToObj = listView1.Items[selectedIndex].SubItems[0].Text,
                       extens    = listView1.Items[selectedIndex].SubItems[2].Text;

                bool isDisk = false;

                if (extens == @"Диск")
                {
                    isDisk = true;
                }

                if (isDisk)
                {
                    test.NotifyObservers("return message: Can't rename root-directory");
                }
                else
                {
                    RenameObject form = new RenameObject(pathToObj, extens);
                    form.Owner = this;
                    form.Show();

                    test.NotifyObservers("return message : Request processing by another form");
                    richTextBox1.Text = MainObs.GetLog();
                }
            }
        }
Пример #13
0
        public IShowFinishedRacesView CreateShowFinishedRacesView(Subject subject)
        {
            var newForm = new formViewFinishedRaces();

            subject.AddObserver(newForm);
            return(newForm);
        }
Пример #14
0
        public IShowTracksView CreateShowTracksView(Subject subject)
        {
            var newForm = new formViewTracks();

            subject.AddObserver(newForm);
            return(newForm);
        }
Пример #15
0
 void Start()
 {
     currentDirection = stepDirection.NEITHER;
     monster.AddObserver(this);
     garbageCollector.AddObserver(this);
     currentVelocity = Screen.height / 10;
 }
Пример #16
0
        // Перемістити файл/папку
        private void button9_Click(object sender, EventArgs e)
        {
            Subject test = new Subject("Move");

            test.AddObserver(MainObs);

            if (listView1.SelectedIndices.Count != 0)
            {
                int selectedIndex = listView1.SelectedIndices[0];

                string pathToObj = listView1.Items[selectedIndex].SubItems[0].Text,
                       name      = listView1.Items[selectedIndex].SubItems[1].Text,
                       extens    = listView1.Items[selectedIndex].SubItems[2].Text;

                if (name[1] != ':' && name[2] != '\\') // Неможливо перемістити диск
                {
                    EnterDestinationOf form = new EnterDestinationOf(pathToObj, name, extens);
                    form.Owner = this;
                    form.Show();
                    test.NotifyObservers("return message : Request processing by another form");
                    richTextBox1.Text = MainObs.GetLog();
                }
                else
                {
                    test.NotifyObservers("return message : You can't move disk");
                    MessageBox.Show("You can't move disk");
                }

                richTextBox1.Text = MainObs.GetLog();
            }
        }
Пример #17
0
 protected override void Init()
 {
     speed    = -75f;
     collided = false;
     subject  = new Subject();
     subject.AddObserver(GameObject.FindWithTag("GameController").GetComponent <IObserver>());
     Hp = 2;
 }
Пример #18
0
        public IShowStandingsView CreateShowStandingsView(Subject subject1, Subject subject2)
        {
            var newForm = new formViewStandings();

            subject1.AddObserver(newForm);
            subject2.AddObserver(newForm);
            return(newForm);
        }
 public void redo()
 {
     future.Peek().redo();
     if (future.Peek() is DeSpawnInteraction)
     {
         s.AddObserver(this.GetComponent <UIManager>()._createdObject);
     }
     history.Push(future.Pop());
 }
Пример #20
0
 private void Start()
 {
     foreach (var cubeObj in CubeList)
     {
         CubeEvent     cubeEvent     = Random.Range(0, 4) > 2 ? (CubeEvent) new LittleJumpEvent() : new BigJumpEvent();
         AObserverCube aObserverCube = new AObserverCube(cubeObj, cubeEvent);
         _cubeSubject.AddObserver(aObserverCube);
     }
 }
Пример #21
0
        public Subject GetInstance()
        {
            if (subject == null)
            {
                subject = new Subject();
                subject.AddObserver(new CacheObserver(CacheKey.ConsolidatedFinancialEntries));
            }

            return(subject);
        }
Пример #22
0
 protected override void Init()
 {
     kMgr       = new KeyManager();
     pcCollided = false;
     item       = Items.None;
     attackTime = 20;
     inBanana   = false;
     subject    = new Subject();
     subject.AddObserver(GameObject.Find("RoomManager").GetComponent <IObserver>());
 }
Пример #23
0
 // Use this for initialization
 void Start()
 {
     audio = GetComponent <AudioSource> ();
     lever.AddObserver(this);
     garbageCollector.AddObserver(this);
     running            = false;
     targetBubbleActive = false;
     targetVelocity     = Screen.height / 10;
     distanceTraveled   = Screen.height - Camera.main.WorldToScreenPoint(topOfFountain.transform.position).y;
 }
    // Start is called before the first frame update
    void Start()
    {
        //s_player = this.GetComponentInParent<PlayerMovement>();

        col_collider = this.GetComponent <BoxCollider>();

        obj_curritem = null;

        S_Notifier.AddObserver(achievmentobserver);
    }
Пример #25
0
        /// <summary>
        /// 初始化观察者
        /// </summary>
        public void InitObservers()
        {
            var subject = new Subject();

            foreach (var vm in PageNameAndVMDic.Values)
            {
                subject.AddObserver(vm.Receive);
                vm.Subject = subject;
            }
        }
Пример #26
0
 // Use this for initializing dependencies
 protected override void Start()
 {
     base.Start();
     isOnCoolDown     = cdManager.GetRangerCooldowns();
     animator         = GetComponent <Animator>();
     particles        = GetComponentInChildren <ParticleSystem>();
     particleSettings = particles.main;
     particles.Stop();
     Subject.AddObserver(this);
     Subject.AddCDObserver(this);
 }
Пример #27
0
 // Use this for initialization
 private void Awake()
 {
     Subject.AddObserver(this);
     hasFairy          = false;
     cameraControl     = GameObject.Find("CameraRig").GetComponent <CameraControl>();
     cdmanager         = GetComponent <CooldownManager>();
     uiManager         = GetComponent <UIManager>();
     currentClassIndex = 0;
     InitPlayerObject();
     SetAxis();
 }
Пример #28
0
    void Start()
    {
        // set up subject for observer
        subject = new Subject(this);

        // register observers
        var animOb = new AnimObserver();
        var audioOb = new AudioObserver();

        subject.AddObserver(animOb);
        subject.AddObserver(audioOb);

        // init command
        moveByXCommand = new MoveByXCommand();
        /*
        MoveByCommand command = new MoveByCommand(0.5f, 0);
        command.AddCommandExecutedCallback(CommandFinishCallback);
        command.execute(this);
        */

        //body2d.velocity = new Vector2(5, 0);
    }
Пример #29
0
    void Start()
    {
        if (chaseRange <= 0)
        {
            chaseRange = 8f;
        }

        WaitTime = startWaittime;
        randomWp = Random.Range(0, waypoint.Length);

        Enemy chase1 = new Enemy(enemy1);
        Enemy chase2 = new Enemy(enemy2);
        Enemy chase3 = new Enemy(enemy3);
        Enemy chase4 = new Enemy(enemy4);
        Enemy chase5 = new Enemy(enemy5);

        subject.AddObserver(chase1);
        subject.AddObserver(chase2);
        subject.AddObserver(chase3);
        subject.AddObserver(chase4);
        subject.AddObserver(chase5);
    }
Пример #30
0
 // use this for initializing dependencies
 protected override void Start()
 {
     base.Start();
     isOnCoolDown     = cdManager.GetWarriorCooldowns();
     attackColliders  = GetComponentsInChildren <BoxCollider2D>();
     sound            = GetComponent <AudioSource>();
     particles        = GetComponentInChildren <ParticleSystem>();
     particleSettings = particles.main;
     particles.Stop();
     DisableAttackColliders();
     Subject.AddObserver(this);
     Subject.AddCDObserver(this);
 }
Пример #31
0
 void IObserver.OnNotify(GameObject entity, EventMessage eventMsg, List <object> data)
 {
     if (eventMsg == EventMessage.ROOMMANAGER_WAKECANVAS)
     {
         //ActivateLawBook();
         gameObject.SetActive(true);
         if (!added)
         {
             subject.AddObserver(entity.GetComponent <IObserver>());
         }
         inLawbook = true;
     }
 }