Exemplo n.º 1
0
            void CharacterUpdate(object source, CharacterEventArgs e) {
                //Unpack the event
                int[] oldPos = e.GetOldPosition();
                int[] newPos = e.GetNewPosition();
                char avatar = e.GetAvatar();

                //Update position, if necessary
                if (oldPos != newPos) {
                    if (GameboardLocationEmpty(newPos)) {
                        //Nothing's at the target destination. Go there
                        this.grid.SetValue(avatar, newPos);

                        //Set the old position to empty
                        //But first, check that 'oldPos' is within the current gridsize, as the grid may have been respawned at a lower size than the previous coordinates
                        if (oldPos[0] < gridSize && oldPos[1] < gridSize) {
                            this.grid.SetValue('-', oldPos);
                        }
                    }
                }

            }